summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Server/Generators/Account.py10
-rw-r--r--src/lib/Server/Generators/Pkgmgr.py28
-rw-r--r--src/lib/Server/Generators/SSHbase.py10
3 files changed, 26 insertions, 22 deletions
diff --git a/src/lib/Server/Generators/Account.py b/src/lib/Server/Generators/Account.py
index 8797fe08a..afbefd29c 100644
--- a/src/lib/Server/Generators/Account.py
+++ b/src/lib/Server/Generators/Account.py
@@ -38,7 +38,7 @@ class Account(Generator):
static = self.repository.entries["static.limits.conf"].data
superusers = self.repository.entries["superusers"].data.split()
useraccess = self.repository.entries["useraccess"].data
- users = [x[0] for x in useraccess if x[1] == metadata.hostname]
+ users = [user for (user, host) in useraccess if host == metadata.hostname]
entry.attrib.upate({'owner':'root', 'group':'root', 'perms':'0600'})
entry.text = static + "".join(["%s hard maxlogins 1024\n" % x for x in superusers + users])
if "*" not in users:
@@ -47,11 +47,11 @@ class Account(Generator):
def gen_root_keys(self, entry, metadata):
'''Build root authorized keys file based on current ACLs'''
data = ''
- su = self.repository.entries['superusers'].data.split()
- rl = self.repository.entries['rootlike'].data.split()
- su += [x.split(':')[0] for x in rl if x.split(':')[1] == metadata.hostname]
+ superusers = self.repository.entries['superusers'].data.split()
+ rootlike = self.repository.entries['rootlike'].data.split()
+ superusers += [x.split(':')[0] for x in rootlike if x.split(':')[1] == metadata.hostname]
data = ''
- for user in su:
+ for user in superusers:
if self.ssh.entries.has_key(user):
data += self.ssh.entries[user].data
entry.attrib.update({'owner':'root', 'group':'root', 'perms':'0600'})
diff --git a/src/lib/Server/Generators/Pkgmgr.py b/src/lib/Server/Generators/Pkgmgr.py
index d8165bcea..63e65970d 100644
--- a/src/lib/Server/Generators/Pkgmgr.py
+++ b/src/lib/Server/Generators/Pkgmgr.py
@@ -11,23 +11,26 @@ class PackageEntry(XMLFileBacked):
rpm = regcompile('^(?P<name>[\w\+\d\.]+(-[\w\+\d\.]+)*)-(?P<version>[\w\d\.]+-([\w\d\.]+))\.(?P<arch>\w+)\.rpm$')
def Index(self):
+ '''Build internal data structures'''
XMLFileBacked.Index(self)
self.packages = {}
for location in self.entries:
for pkg in location.getchildren():
if pkg.attrib.has_key("file"):
- m = self.rpm.match(pkg.get('file'))
- if not m:
+ mdata = self.rpm.match(pkg.get('file'))
+ if not mdata:
print "failed to rpm match %s" % (pkg.get('file'))
continue
- self.packages[m.group('name')] = m.groupdict()
- self.packages[m.group('name')]['file'] = pkg.attrib['file']
- self.packages[m.group('name')]['uri'] = location.attrib['uri']
- self.packages[m.group('name')]['type'] = 'rpm'
+ pkgname = mdata.group('name')
+ self.packages[pkgname] = mdata.groupdict()
+ self.packages[pkgname]['file'] = pkg.attrib['file']
+ self.packages[pkgname]['uri'] = location.attrib['uri']
+ self.packages[pkgname]['type'] = 'rpm'
else:
self.packages[pkg.get('name')] = pkg.attrib
class PackageDir(DirectoryBacked):
+ '''A directory of package files'''
__child__ = PackageEntry
class Pkgmgr(Generator):
@@ -41,6 +44,7 @@ class Pkgmgr(Generator):
self.pkgdir = PackageDir(self.data, self.core.fam)
def FindHandler(self, entry):
+ '''Non static mechanism of determining entry provisioning'''
if entry.tag != 'Package':
raise KeyError, (entry.tag, entry.get('name'))
return self.LocatePackage
@@ -48,12 +52,12 @@ class Pkgmgr(Generator):
def LocatePackage(self, entry, metadata):
'''Locates a package entry for particular metadata'''
pkgname = entry.get('name')
- pl = self.pkgdir["%s.xml" % (metadata.image)]
- if pl.packages.has_key(pkgname):
- p = pl.packages[pkgname]
- if p.get('type', None) == 'rpm':
- entry.attrib.update({'url':"%s/%s" % (p['uri'], p['file']), 'version':p['version']})
+ pkglist = self.pkgdir["%s.xml" % (metadata.image)]
+ if pkglist.packages.has_key(pkgname):
+ pkg = pkglist.packages[pkgname]
+ if pkg.get('type', None) == 'rpm':
+ entry.attrib.update({'url':"%s/%s" % (pkg['uri'], pkg['file']), 'version':pkg['version']})
else:
- entry.attrib.update(p)
+ entry.attrib.update(pkg)
else:
raise KeyError, ("Package", pkgname)
diff --git a/src/lib/Server/Generators/SSHbase.py b/src/lib/Server/Generators/SSHbase.py
index 5a23fdbca..eab268ec0 100644
--- a/src/lib/Server/Generators/SSHbase.py
+++ b/src/lib/Server/Generators/SSHbase.py
@@ -51,7 +51,7 @@ class SSHbase(Generator):
client = metadata.hostname
filedata = self.repository.entries['ssh_known_hosts'].data
ipaddr = gethostbyname(client)
- keylist = [x % client for x in self.pubkeys]
+ keylist = [keytmpl % client for keytmpl in self.pubkeys]
for hostkey in keylist:
filedata += "%s,%s,%s %s" % (client, "%s.mcs.anl.gov"%(client),
ipaddr, self.repository.entries[hostkey].data)
@@ -80,17 +80,17 @@ class SSHbase(Generator):
output = ''
for filename, entry in self.repository.entries.iteritems():
if ".pub.H_" in filename:
- h = filename.split('_')[-1]
+ hname = filename.split('_')[-1]
try:
- ipaddr = gethostbyname(h)
- output += "%s,%s.mcs.anl.gov,%s %s" % (h, h, ipaddr, entry.data)
+ ipaddr = gethostbyname(hname)
+ output += "%s,%s.mcs.anl.gov,%s %s" % (hname, hname, ipaddr, entry.data)
except gaierror:
continue
self.repository.entries['ssh_known_hosts'].data = output
def GenerateHostKeys(self, client):
'''Generate new host keys for client'''
- keylist = [x % client for x in self.hostkeys]
+ keylist = [keytmpl % client for keytmpl in self.hostkeys]
for hostkey in keylist:
if 'ssh_host_rsa_key.H_' in hostkey:
keytype = 'rsa'