From 8bff8d27a04a6556155195dadc97952eb36f5104 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Thu, 15 Mar 2007 22:08:17 +0000 Subject: Implement client profile remapping (May resolve Ticket #392) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2943 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Client/Tools/Chkconfig.py | 5 +++-- src/lib/Server/Plugins/Metadata.py | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lib/Client/Tools/Chkconfig.py b/src/lib/Client/Tools/Chkconfig.py index a1c1160c9..8e30cccc9 100644 --- a/src/lib/Client/Tools/Chkconfig.py +++ b/src/lib/Client/Tools/Chkconfig.py @@ -30,11 +30,12 @@ class Chkconfig(Bcfg2.Client.Tools.SvcTool): except IndexError: onlevels = [] + pstatus = self.cmd.run('/sbin/service %s status')[0] # chkconfig/init.d service if entry.get('status') == 'on': - status = len(onlevels) > 0 + status = (len(onlevels) > 0 ) and pstatus else: - status = len(onlevels) == 0 + status = (len(onlevels) == 0) and not pstatus if not status: if entry.get('status') == 'on': diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py index 6f4581daa..81fcba223 100644 --- a/src/lib/Server/Plugins/Metadata.py +++ b/src/lib/Server/Plugins/Metadata.py @@ -47,6 +47,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin): self.profiles = [] self.toolsets = {} self.categories = {} + self.bad_clients = {} self.clientdata = None self.default = None try: @@ -90,6 +91,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin): if dest == 'clients.xml': self.clients = {} self.aliases = {} + self.bad_clients = {} self.clientdata = xdata for client in xdata.findall('.//Client'): if 'address' in client.attrib: @@ -145,11 +147,17 @@ class Metadata(Bcfg2.Server.Plugin.Plugin): # check that all client groups are real and complete real = self.groups.keys() for client in self.clients.keys(): - if self.clients[client] not in real or self.clients[client] not in self.profiles: + if self.clients[client] not in self.profiles: self.logger.error("Client %s set as nonexistant or incomplete group %s" \ % (client, self.clients[client])) self.logger.error("Removing client mapping for %s" % (client)) + self.bad_clients[client] = self.clients[client] del self.clients[client] + for bclient in self.bad_clients.keys(): + if self.bad_clients[bclient] in self.profiles: + self.logger.info("Restored profile mapping for client %s" % bclient) + self.clients[bclient] = self.bad_clients[bclient] + del self.bad_clients[bclient] def set_profile(self, client, profile): '''Set group parameter for provided client''' -- cgit v1.2.3-1-g7c22