From d922822bbe23387577e9e8c9f60131ac00a24c9f Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Sat, 10 Jan 2009 15:17:59 +0000 Subject: Rework bcfg2-info/showclient to use new metadata interface git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5006 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Plugins/Metadata.py | 11 +++++++---- src/sbin/bcfg2-info | 21 ++++++++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py index 355624ccc..eacc53f4b 100644 --- a/src/lib/Server/Plugins/Metadata.py +++ b/src/lib/Server/Plugins/Metadata.py @@ -14,9 +14,10 @@ class MetadataRuntimeError(Exception): class ClientMetadata(object): '''This object contains client metadata''' - def __init__(self, client, groups, bundles, categories, uuid, + def __init__(self, client, profile, groups, bundles, categories, uuid, password, overall): self.hostname = client + self.profile = profile self.bundles = bundles self.groups = groups self.categories = categories @@ -358,7 +359,8 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, if client in self.aliases: client = self.aliases[client] if client in self.clients: - (bundles, groups, categories) = self.groups[self.clients[client]] + profile = self.clients[client] + (bundles, groups, categories) = self.groups[profile] else: if self.default == None: self.logger.error("Cannot set group for client %s; no default group set" % (client)) @@ -388,8 +390,9 @@ class Metadata(Bcfg2.Server.Plugin.Plugin, newcategories.update(ncategories) groupscopy = copy.deepcopy(self.groups) clientscopy = copy.deepcopy(self.clients) - return ClientMetadata(client, newgroups, newbundles, newcategories, - uuid, password, (groupscopy, clientscopy)) + return ClientMetadata(client, profile, newgroups, newbundles, + newcategories, uuid, password, + (groupscopy, clientscopy)) def merge_additional_metadata(self, imd, source, groups, data): for group in groups: diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 5c689489b..cd868ef0d 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -211,29 +211,28 @@ Usage: [quit|exit]""" print "Usage:\nshowclient ... " return for client in args.split(): - if client not in self.metadata.clients: + try: + client_meta = self.build_metadata(client) + except: print "Client %s not defined" % client continue - profile = self.metadata.clients[client] - bds, gps, cgs = \ - copy.deepcopy(self.metadata.groups[profile]) - gps.remove(profile) - numbundles = len(bds) - numgroups = len(gps) + + numbundles = len(client_meta.bundles) + numgroups = len(client_meta.groups) num = max((numbundles, numgroups)) for i in range(0, num): if i == 0: - c = client - p = profile + c = client_meta.hostname + p = client_meta.profile else: c = "" p = "" if i < numbundles: - b = bds[i] + b = client_meta.bundles[i] else: b = "" if i < numgroups: - g = gps[i] + g = client_meta.groups[i] else: g = "" data.append((c, p, g, b)) -- cgit v1.2.3-1-g7c22