def _extractMetadataInfos(manifestRootElement): manifestElements = manifestRootElement.findall('{http://www.w3.org/1999/02/22-rdf-syntax-ns#}RDF') manifests = [] infos = [] for e in manifestElements: manifest = ManifestInfo() manifest.parseManifestFromXmlTree(e) print manifest if len(manifest.locations)>0: info = {'md5': manifest.md5, 'os': manifest.os, 'os-version':manifest.osversion,'os-arch':manifest.arch, 'location':manifest.locations[0], 'creator':manifest.creator, 'valid':manifest.valid.replace("T"," "), 'description':manifest.comment, 'publisher':manifest.publisher, 'identifier':manifest.identifier} #parse extra attributes requires = getattr(e.find('.//{%s}requires' % NS_DCTERMS), 'text','') if requires: info['requires'] = requires # now is assumed that if network and storage info is the same, so system # is openstack else is opennebula, this is done only for demo in Technical Forum # for future this info should be taked from LDAP info if manifest.locations[0] == requires: # if is a OpenStack machine identifier is not more used, because it doesn't publish it # so we use to identify it from another possible machines running in site # i use the template name https://site:port/template pat = re.compile(r'http[s]{0,1}://[a-z].[a-z][a-z\.\-0-9]*:[0-9]+[a-z.0-9/\-]') domain = re.findall(pat,manifest.locations[0]) info['identifier'] = manifest.locations[0].replace(domain[0],"").replace("/","") info['cloud'] = "openstack" else: info['cloud'] = "opennebula" infos.append(info) return infos
def _extractManifestInfos(self, manifestRootElement): manifestElements = manifestRootElement.findall('{http://www.w3.org/1999/02/22-rdf-syntax-ns#}RDF') manifests = [] for e in manifestElements: manifest = ManifestInfo() manifest.parseManifestFromXmlTree(e) manifests.append(manifest) return manifests
def __getManifest(self, url): errorMessage = 'Failed to find metadata entry: %s' % url try: manifest = self._download(url) except urllib2.HTTPError: raise InputException(errorMessage) if manifest is not None: manifestInfo = ManifestInfo(self.configHolder) else: raise InputException(errorMessage) try: manifestInfo.parseManifestFromXmlTree(manifest) except ExecutionException, ex: raise InputException('Error parsing the metadata corresponding to url %s, with detail %s' % (url, ex))