diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-06-11 01:21:02 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-06-11 01:21:02 +0000 |
commit | c02d3575ab0241209e67c7052dcd3767173860db (patch) | |
tree | f6fb27cb65f93e33338445b07829ba900defee18 | |
parent | dd918eee28a022722d0d668b88b9397306abcabb (diff) | |
download | bcfg2-c02d3575ab0241209e67c7052dcd3767173860db.tar.gz bcfg2-c02d3575ab0241209e67c7052dcd3767173860db.tar.bz2 bcfg2-c02d3575ab0241209e67c7052dcd3767173860db.zip |
Implement RawURL support
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5271 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r-- | schemas/packages.xsd | 8 | ||||
-rw-r--r-- | src/lib/Server/Plugins/Packages.py | 23 |
2 files changed, 21 insertions, 10 deletions
diff --git a/schemas/packages.xsd b/schemas/packages.xsd index 843e5ee68..17f6aee02 100644 --- a/schemas/packages.xsd +++ b/schemas/packages.xsd @@ -2,7 +2,7 @@ <xsd:annotation> <xsd:documentation> - bundle schema for bcfg2 + packages config schema for bcfg2 Narayan Desai, Argonne National Laboratory </xsd:documentation> </xsd:annotation> @@ -11,8 +11,10 @@ <xsd:sequence> <xsd:element name="Group" type="xsd:string" minOccurs='1' maxOccurs='unbounded'/> - <xsd:element name="URL" type="xsd:string" minOccurs='1' - maxOccurs='unbounded'/> + <xsd:element name="URL" type="xsd:string" minOccurs='0' + maxOccurs='1'/> + <xsd:element name="RawURL" type="xsd:string" minOccurs='0' + maxOccurs='1'/> <xsd:element name="Version" type="xsd:string"/> <xsd:element name="Component" type="xsd:string" minOccurs='1' maxOccurs='unbounded'/> diff --git a/src/lib/Server/Plugins/Packages.py b/src/lib/Server/Plugins/Packages.py index 010283fe9..2e25eaf90 100644 --- a/src/lib/Server/Plugins/Packages.py +++ b/src/lib/Server/Plugins/Packages.py @@ -13,12 +13,15 @@ class NoData(Exception): logger = logging.getLogger('Packages') def source_from_xml(xsource): - ret = dict() + ret = dict([('rawurl', False), ('url', False)]) for key, tag in [('groups', 'Group'), ('components', 'Component'), ('arches', 'Arch')]: ret[key] = [item.text for item in xsource.findall(tag)] ret['version'] = xsource.find('Version').text - ret['url'] = xsource.find('URL').text + if xsource.find('RawURL') is not None: + ret['rawurl'] = xsource.find('RawURL').text + else: + ret['url'] = xsource.find('URL').text return ret class Source(object): @@ -120,10 +123,16 @@ class YUMSource(Source): basegroups = ['redhat', 'centos'] ptype = 'yum' - def __init__(self, basepath, url, version, arches, components, groups): - self.urls = ["%s/%s/%s/%s/repodata/%s.xml.gz" % \ - (url, version, part, arch, basename) for part in components \ - for arch in arches for basename in ['primary', 'filelists']] + def __init__(self, basepath, url, version, arches, components, groups, rawurl): + if not rawurl: + urlbase = url + '%%(version)s/%(component)s/%(arch)s/repodata/' % url + else: + urlbase = rawurl + usettings = [{'version': version, 'component':part, 'arch':arch} + for part in components for arch in arches] + fnames = ['primary.xml.gz', 'filelists.xml.gz'] + self.urls = [urlbase % item + fname \ + for item in usettings for fname in fnames] Source.__init__(self, basepath, url, version, arches, components, groups) self.packages = dict() self.deps = dict([('global', dict())]) @@ -212,7 +221,7 @@ class APTSource(Source): basegroups = ['debian', 'ubuntu', 'nexenta'] ptype = 'deb' - def __init__(self, basepath, url, version, arches, components, groups): + def __init__(self, basepath, url, version, arches, components, groups, rawurl): self.urls = ["%s/dists/%s/%s/binary-%s/Packages.gz" % \ (url, version, part, arch) for part in components \ for arch in arches] |