summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/Ohai.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-03-26 23:12:51 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-03-26 23:12:51 -0400
commit4a364848c6d0e64a38d5d481ff978c519389814c (patch)
treeba1412679c9998632d47ef7b3a766c4509f2c5bc /src/lib/Bcfg2/Server/Plugins/Ohai.py
parentbc35aa70ab8794b73019d90a41eb252fbb80ff52 (diff)
downloadbcfg2-4a364848c6d0e64a38d5d481ff978c519389814c.tar.gz
bcfg2-4a364848c6d0e64a38d5d481ff978c519389814c.tar.bz2
bcfg2-4a364848c6d0e64a38d5d481ff978c519389814c.zip
testsuite: more text fixes
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Ohai.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Ohai.py16
1 files changed, 9 insertions, 7 deletions
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())