diff options
author | Chris Lumens <clumens@redhat.com> | 2008-10-31 16:31:35 -0400 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2008-10-31 16:32:29 -0400 |
commit | 934a10a9b09ae7b4630c7c21c8c23cf9592990f8 (patch) | |
tree | f25713244f3d6f557cc893d156ca727fd4eb0940 | |
parent | 90b3dd722756333adf5a3f934bc3ffe26272ba41 (diff) | |
download | anaconda-934a10a9b09ae7b4630c7c21c8c23cf9592990f8.tar.gz anaconda-934a10a9b09ae7b4630c7c21c8c23cf9592990f8.tar.xz anaconda-934a10a9b09ae7b4630c7c21c8c23cf9592990f8.zip |
Check that the platform and product are also correct (#469367).
-rw-r--r-- | exception.py | 3 | ||||
-rw-r--r-- | filer.py | 33 | ||||
-rw-r--r-- | installclasses/fedora.py | 2 |
3 files changed, 32 insertions, 6 deletions
diff --git a/exception.py b/exception.py index 70b61c0f4..e4e7c08ae 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), @@ -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] = platformList[0] + 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 bf264591f..355404340 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: |