diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-03-26 23:12:51 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-03-26 23:12:51 -0400 |
commit | 4a364848c6d0e64a38d5d481ff978c519389814c (patch) | |
tree | ba1412679c9998632d47ef7b3a766c4509f2c5bc /src/lib/Bcfg2/Server | |
parent | bc35aa70ab8794b73019d90a41eb252fbb80ff52 (diff) | |
download | bcfg2-4a364848c6d0e64a38d5d481ff978c519389814c.tar.gz bcfg2-4a364848c6d0e64a38d5d481ff978c519389814c.tar.bz2 bcfg2-4a364848c6d0e64a38d5d481ff978c519389814c.zip |
testsuite: more text fixes
Diffstat (limited to 'src/lib/Bcfg2/Server')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Metadata.py | 1 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Ohai.py | 16 |
2 files changed, 10 insertions, 7 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py index b181c2237..7561aec1e 100644 --- a/src/lib/Bcfg2/Server/Plugins/Metadata.py +++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py @@ -75,6 +75,7 @@ if HAS_DJANGO: yield client.hostname def keys(self): + """ Get keys for the mapping """ return [c.hostname for c in MetadataClientModel.objects.all()] def __contains__(self, key): diff --git a/src/lib/Bcfg2/Server/Plugins/Ohai.py b/src/lib/Bcfg2/Server/Plugins/Ohai.py index 8a1b07ac8..1ec3cbd60 100644 --- a/src/lib/Bcfg2/Server/Plugins/Ohai.py +++ b/src/lib/Bcfg2/Server/Plugins/Ohai.py @@ -33,20 +33,22 @@ class OhaiCache(object): self.dirname = dirname self.cache = dict() - def itempath(self, item): - return os.path.join(self.dirname, "%s.json" % item) + def hostpath(self, host): + """ Get the path to the file that contains Ohai data for the + given host """ + return os.path.join(self.dirname, "%s.json" % host) def __setitem__(self, item, value): if value is None: # simply return if the client returned nothing return self.cache[item] = json.loads(value) - open(self.itempath(item), 'w').write(value) + open(self.hostpath(item), 'w').write(value) def __getitem__(self, item): if item not in self.cache: try: - data = open(self.itempath(item)).read() + data = open(self.hostpath(item)).read() except: raise KeyError(item) self.cache[item] = json.loads(data) @@ -56,13 +58,13 @@ class OhaiCache(object): if item in self.cache: del self.cache[item] try: - os.unlink(self.itempath(item)) + os.unlink(self.hostpath(item)) except: - raise IndexError("Could not unlink %s: %s" % (self.itempath(item), + raise IndexError("Could not unlink %s: %s" % (self.hostpath(item), sys.exc_info()[1])) def __len__(self): - return len(glob.glob(self.itempath('*'))) + return len(glob.glob(self.hostpath('*'))) def __iter__(self): data = list(self.cache.keys()) |