[PATCH] - more save to bugzilla error checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Used to be that "ppc" was not a valid platform in bugzilla but "powerpc"
was.  Of course, rpmUtils.arch.getBaseArch returned the former.  Well
that's been corrected in our bugzilla now, but this patch is still valid
as far as I'm concerned.

This checks the platform and sets it to All if rpmUtils returns
something that bugzilal doesn't understand, and checks that
product.productName also exists in bugzilla.  It's up to the install
class to give us a useful backup there, just like it is with the
version.

- Chris


diff --git a/exception.py b/exception.py
index 70b61c0..e4e7c08 100644
--- a/exception.py
+++ b/exception.py
@@ -408,9 +408,8 @@ def saveToBugzilla(anaconda, exn, dest):
     if buglist is None:
         return False
 
-    # FIXME:  need to handle all kinds of errors here
     if len(buglist) == 0:
-        bug = withBugzillaDo(filer, lambda b: b.createbug(product=product.productName,
+        bug = withBugzillaDo(filer, lambda b: b.createbug(product=filer.getproduct(product.productName),
                                        component="anaconda",
                                        version=filer.getversion(product.productVersion,
                                                                 product.productName),
diff --git a/filer.py b/filer.py
index e8431ea..74e8461 100644
--- a/filer.py
+++ b/filer.py
@@ -66,7 +66,7 @@ class AbstractFiler(object):
        ValueError         -- For all other operations where the client
                              supplied values are not correct.
     """
-    def __init__(self, bugUrl=None, develVersion=None):
+    def __init__(self, bugUrl=None, develVersion=None, defaultProduct=None):
         """Create a new AbstractFiler instance.  This method need not be
            overridden by subclasses.
 
@@ -75,6 +75,9 @@ class AbstractFiler(object):
                            the development version.  This is used in case
                            anaconda attempts to file bugs against invalid
                            versions.  It need not be set.
+           defaultProduct -- The product bugs should be filed against, should
+                             anaconda get an invalid product name from the
+                             boot media.  This must be set.
         """
         self.bugUrl = bugUrl
         self.develVersion = develVersion
@@ -109,6 +112,14 @@ class AbstractFiler(object):
         """
         raise NotImplementedError
 
+    def getproduct(self, prod):
+        """Verify that prod is a valid product name.  If it is, return that
+           same product name.  If not, return self.defaultProduct.  This method
+           queries the bug filing system for a list of valid products.  It must
+           be provided by all subclasses.
+       """
+       raise NotImplementedError
+
     def getversion(self, ver, prod):
         """Verify that ver is a valid version number for the product name prod.
            If it is, return that same version number.  If not, return
@@ -286,8 +297,9 @@ class BugzillaFiler(AbstractFiler):
         except socket.error, e:
             raise CommunicationError(str(e))
 
-    def __init__(self, bugUrl=None, develVersion=None):
-        AbstractFiler.__init__(self, bugUrl=bugUrl, develVersion=develVersion)
+    def __init__(self, bugUrl=None, develVersion=None, defaultProduct=None):
+        AbstractFiler.__init__(self, bugUrl=bugUrl, develVersion=develVersion,
+                               defaultProduct=defaultProduct)
         self._bz = None
 
     def login(self, username, password):
@@ -310,6 +322,11 @@ class BugzillaFiler(AbstractFiler):
                 whiteboards.append((wb, val))
                 kwargs.pop(key)
 
+            if key == "platform":
+                platformLst = self.__withBugzillaDo(lambda b: b._proxy.Bug.legal_values({'field': 'platform'}))
+                if not val in platformLst:
+                    kwargs[key] = "All"
+
         bug = self.__withBugzillaDo(lambda b: b.createbug(**kwargs))
         for (wb, val) in whiteboards:
             bug.setwhiteboard(val, which=wb)
@@ -323,6 +340,16 @@ class BugzillaFiler(AbstractFiler):
         lst = self.__withBugzillaDo(lambda b: b.getbugs(idlist))
         return map(lambda b: BugzillaBug(self, bug=b), lst)
 
+    def getproduct(self, prod):
+        details = self.__withBugzillaDo(lambda b: b.getproducts())
+        if prod not in details.keys():
+            if self.defaultProduct:
+                return self.defaultProduct
+            else:
+                raise ValueError, "The product %s is not valid and no defaultProduct is set." % prod
+        else:
+            return prod
+
     def getversion(self, ver, prod):
         details = self.__withBugzillaDo(lambda b: b._proxy.bugzilla.getProductDetails(prod))
         bugzillaVers = details[1]
diff --git a/installclasses/fedora.py b/installclasses/fedora.py
index bf26459..3554043 100644
--- a/installclasses/fedora.py
+++ b/installclasses/fedora.py
@@ -50,7 +50,7 @@ class InstallClass(BaseInstallClass):
              (N_("Web Server"), ["web-server"])]
 
     bugFiler = BugzillaFiler(bugUrl="https://bugzilla.redhat.com/xmlrpc.cgi";,
-                             develVersion="rawhide")
+                             develVersion="rawhide", defaultProduct="Fedora")
 
     def getPackagePaths(self, uri):
         if not type(uri) == types.ListType:

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux