summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2006-09-14 13:07:38 +0000
committerNarayan Desai <desai@mcs.anl.gov>2006-09-14 13:07:38 +0000
commit572d9a12556ce916704293e12e36b3b3e3c4c5e4 (patch)
tree85233778823f66b8c45ec19cd9d1669a91f1fed3 /src
parent5d4849dc21d7aae7e861033ab5aa3bdeb17847c1 (diff)
downloadbcfg2-572d9a12556ce916704293e12e36b3b3e3c4c5e4.tar.gz
bcfg2-572d9a12556ce916704293e12e36b3b3e3c4c5e4.tar.bz2
bcfg2-572d9a12556ce916704293e12e36b3b3e3c4c5e4.zip
Add ClientMetadata.categories, for direct, by-name access to category instances
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2249 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Metadata.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/lib/Server/Metadata.py b/src/lib/Server/Metadata.py
index 8eeb1d400..9f4c3cde0 100644
--- a/src/lib/Server/Metadata.py
+++ b/src/lib/Server/Metadata.py
@@ -13,11 +13,12 @@ class MetadataRuntimeError(Exception):
class ClientMetadata(object):
'''This object contains client metadata'''
- def __init__(self, client, groups, bundles, toolset):
+ def __init__(self, client, groups, bundles, toolset, categories):
self.hostname = client
self.bundles = bundles
self.groups = groups
self.toolset = toolset
+ self.categories = categories
class Metadata:
'''This class contains data for bcfg2 server metadata'''
@@ -66,7 +67,7 @@ class Metadata:
self.clients.update({client.get('name'): client.get('profile')})
[self.aliases.update({alias.get('name'): client.get('name')}) for alias in client.findall('Alias')]
- else:
+ elif filename == 'groups.xml':
self.public = []
self.profiles = []
self.toolsets = {}
@@ -88,8 +89,8 @@ class Metadata:
if group.attrib.has_key('category'):
self.categories[group.get('name')] = group.get('category')
for group in grouptmp:
- self.groups[group] = ([], [])
- gcategories = []
+ # self.groups[group] => (bundles, groups, categories)
+ self.groups[group] = ([], [], {})
tocheck = [group]
while tocheck:
now = tocheck.pop()
@@ -98,11 +99,11 @@ class Metadata:
if grouptmp.has_key(now):
(bundles, groups) = grouptmp[now]
for ggg in [ggg for ggg in groups if ggg not in self.groups[group][1]]:
- if not self.categories.has_key(ggg) or (self.categories[ggg] not in gcategories):
+ if not self.categories.has_key(ggg) or not self.groups[group][2].has_key(self.categories[ggg]):
self.groups[group][1].append(ggg)
tocheck.append(ggg)
if self.categories.has_key(ggg):
- gcategories.append(self.categories[ggg])
+ self.groups[group][2][self.categories[ggg]] = ggg
[self.groups[group][0].append(bund) for bund in bundles
if bund not in self.groups[group][0]]
self.states[filename] = True
@@ -175,7 +176,7 @@ class Metadata:
if self.aliases.has_key(client):
client = self.aliases[client]
if self.clients.has_key(client):
- [bundles, groups] = self.groups[self.clients[client]]
+ (bundles, groups, categories) = self.groups[self.clients[client]]
else:
if self.default == None:
self.logger.error("Cannot set group for client %s; no default group set" % (client))
@@ -188,7 +189,7 @@ class Metadata:
self.logger.error("Cannot determine toolset for client %s" % (client))
raise MetadataConsistencyError
toolset = toolinfo[0]
- return ClientMetadata(client, groups, bundles, toolset)
+ return ClientMetadata(client, groups, bundles, toolset, categories)
def ping_sweep_clients(self):
'''Find live and dead clients'''