summaryrefslogtreecommitdiffstats
path: root/src/lib/Server
diff options
context:
space:
mode:
authorFabian Affolter <fabian@bernewireless.net>2010-12-05 22:46:05 +0100
committerFabian Affolter <fabian@bernewireless.net>2010-12-05 22:46:05 +0100
commit1c54f4d5c8c324ce6869b6d98f60e78f9b01bbb0 (patch)
tree261cf19cc8072ce751db1fcac0d0d157972a42d8 /src/lib/Server
parent94e4f622b4dee6b33983a17313c0ef5a71c93f2e (diff)
parent0cff753190c235a9ce65a920730d715a5e4a8ed4 (diff)
downloadbcfg2-1c54f4d5c8c324ce6869b6d98f60e78f9b01bbb0.tar.gz
bcfg2-1c54f4d5c8c324ce6869b6d98f60e78f9b01bbb0.tar.bz2
bcfg2-1c54f4d5c8c324ce6869b6d98f60e78f9b01bbb0.zip
Merge remote branch 'upstream/master'
Diffstat (limited to 'src/lib/Server')
-rw-r--r--src/lib/Server/Plugins/Packages.py25
-rw-r--r--src/lib/Server/Plugins/SSLCA.py28
2 files changed, 28 insertions, 25 deletions
diff --git a/src/lib/Server/Plugins/Packages.py b/src/lib/Server/Plugins/Packages.py
index 194330723..ee21fb622 100644
--- a/src/lib/Server/Plugins/Packages.py
+++ b/src/lib/Server/Plugins/Packages.py
@@ -76,8 +76,8 @@ def _fetch_url(url):
class Source(object):
basegroups = []
- def __init__(self, basepath, url, version, arches, components, groups, rawurl,
- blacklist, whitelist, recommended):
+ def __init__(self, basepath, url, version, arches, components, groups,
+ rawurl, blacklist, whitelist, recommended):
self.basepath = basepath
self.version = version
self.components = components
@@ -112,7 +112,8 @@ class Source(object):
try:
self.read_files()
except:
- logger.error("Packages: File read failed; falling back to file download")
+ logger.error("Packages: File read failed; "
+ "falling back to file download")
should_download = True
if should_download or force_update:
@@ -389,7 +390,7 @@ class APTSource(Source):
if self.recommended:
depfnames = ['Depends', 'Pre-Depends', 'Recommends']
else:
- depfnames = ['Depends', 'Pre-Depends']
+ depfnames = ['Depends', 'Pre-Depends']
for fname in self.files:
if not self.rawurl:
barch = [x for x in fname.split('@') if x.startswith('binary-')][0][7:]
@@ -504,7 +505,6 @@ class PACSource(Source):
raise Exception("PACSource : RAWUrl not supported (yet)")
urls = property(get_urls)
-
def read_files(self):
bdeps = dict()
bprov = dict()
@@ -512,7 +512,7 @@ class PACSource(Source):
if self.recommended:
depfnames = ['Depends', 'Pre-Depends', 'Recommends']
else:
- depfnames = ['Depends', 'Pre-Depends']
+ depfnames = ['Depends', 'Pre-Depends']
for fname in self.files:
if not self.rawurl:
@@ -535,8 +535,8 @@ class PACSource(Source):
for tarinfo in tar:
if tarinfo.isdir():
- self.pkgnames.add(tarinfo.name.rsplit("-",2)[0])
- print "added : " + tarinfo.name.rsplit("-",2)[0]
+ self.pkgnames.add(tarinfo.name.rsplit("-", 2)[0])
+ print "added : " + tarinfo.name.rsplit("-", 2)[0]
tar.close()
self.deps['global'] = dict()
@@ -676,7 +676,7 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
# do while unclassified or vpkgs or both or pkgs
while unclassified or pkgs or both or final_pass:
#print len(unclassified), len(pkgs), len(both), len(vpkgs), final_pass
- if really_done:
+ if really_done:
break
if len(unclassified) + len(pkgs) + len(both) == 0:
# one more pass then exit
@@ -760,7 +760,9 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
meta - client metadata instance
structures - a list of structure-stage entry combinations
'''
- if self.disableResolver: return # Config requests no resolver
+ if self.disableResolver:
+ # Config requests no resolver
+ return
initial = set([pkg.get('name') for struct in structures \
for pkg in struct.findall('Package') +
@@ -857,7 +859,8 @@ class Packages(Bcfg2.Server.Plugin.Plugin,
cachefiles = []
for source in self.sources:
cachefiles.append(source.cachefile)
- if not self.disableMetaData: source.setup_data(force_update)
+ if not self.disableMetaData:
+ source.setup_data(force_update)
self.sentinels.update(source.basegroups)
for cfile in glob.glob("%s/cache-*" % self.cachepath):
if cfile not in cachefiles:
diff --git a/src/lib/Server/Plugins/SSLCA.py b/src/lib/Server/Plugins/SSLCA.py
index 0dc448e69..4125cd498 100644
--- a/src/lib/Server/Plugins/SSLCA.py
+++ b/src/lib/Server/Plugins/SSLCA.py
@@ -7,6 +7,7 @@ import os
from subprocess import Popen, PIPE, STDOUT
from ConfigParser import ConfigParser
+
class SSLCA(Bcfg2.Server.Plugin.GroupSpool):
"""
The SSLCA generator handles the creation and
@@ -34,9 +35,9 @@ class SSLCA(Bcfg2.Server.Plugin.GroupSpool):
ident = self.handles[event.requestID] + event.filename
else:
ident = self.handles[event.requestID][:-1]
-
+
fname = "".join([ident, '/', event.filename])
-
+
if event.filename.endswith('.xml'):
if action in ['exists', 'created', 'changed']:
if event.filename.endswith('key.xml'):
@@ -89,12 +90,12 @@ class SSLCA(Bcfg2.Server.Plugin.GroupSpool):
of a new key if one doesn't exist.
"""
# set path type and permissions, otherwise bcfg2 won't bind the file
- permdata = {'owner':'root',
- 'group':'root',
- 'type':'file',
- 'perms':'644'}
+ permdata = {'owner': 'root',
+ 'group': 'root',
+ 'type': 'file',
+ 'perms': '644'}
[entry.attrib.__setitem__(key, permdata[key]) for key in permdata]
-
+
# check if we already have a hostfile, or need to generate a new key
# TODO: verify key fits the specs
path = entry.get('name')
@@ -125,10 +126,10 @@ class SSLCA(Bcfg2.Server.Plugin.GroupSpool):
of a new cert if one doesn't exist.
"""
# set path type and permissions, otherwise bcfg2 won't bind the file
- permdata = {'owner':'root',
- 'group':'root',
- 'type':'file',
- 'perms':'644'}
+ permdata = {'owner': 'root',
+ 'group': 'root',
+ 'type': 'file',
+ 'perms': '644'}
[entry.attrib.__setitem__(key, permdata[key]) for key in permdata]
path = entry.get('name')
@@ -157,7 +158,7 @@ class SSLCA(Bcfg2.Server.Plugin.GroupSpool):
"""
chaincert = self.CAs[self.cert_specs[entry.get('name')]['ca']].get('chaincert')
cert = self.data + filename
- cmd = "openssl verify -CAfile %s %s" % (chaincert, cert)
+ cmd = "openssl verify -CAfile %s %s" % (chaincert, cert)
res = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT).stdout.read()
if res == cert + ": OK\n":
return True
@@ -225,7 +226,7 @@ class SSLCA(Bcfg2.Server.Plugin.GroupSpool):
cp.write(conffile)
conffile.close()
return conffile.name
-
+
def build_request(self, key_filename, req_config, entry):
"""
creates the certificate request
@@ -236,4 +237,3 @@ class SSLCA(Bcfg2.Server.Plugin.GroupSpool):
cmd = "openssl req -new -config %s -days %s -key %s -text -out %s" % (req_config, days, key, req)
res = Popen(cmd, shell=True, stdout=PIPE).stdout.read()
return req
-