summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/Metadata.py
diff options
context:
space:
mode:
authorMichael Fenn <fennm@deshawresearch.com>2013-08-06 16:01:12 -0400
committerMichael Fenn <fennm@deshawresearch.com>2013-08-06 16:01:12 -0400
commit4bf1c82868357e5c357e0b656419af37a99a8545 (patch)
treef6936718d151e65ac1b113cbdd692869218e8fdf /src/lib/Bcfg2/Server/Plugins/Metadata.py
parent936b8aa2b6329ddf45c1032171c16d0eaea99b37 (diff)
downloadbcfg2-4bf1c82868357e5c357e0b656419af37a99a8545.tar.gz
bcfg2-4bf1c82868357e5c357e0b656419af37a99a8545.tar.bz2
bcfg2-4bf1c82868357e5c357e0b656419af37a99a8545.zip
Get profile by building metadata instead of guessing
Rather than doing some ad-hoc lookups of internal data structures stpierre suggested that it'd be better to use the normal metadata build procedures. This implements that and adjusts the tests.
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Metadata.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Metadata.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py
index e62b3f77f..cc0456334 100644
--- a/src/lib/Bcfg2/Server/Plugins/Metadata.py
+++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py
@@ -978,18 +978,21 @@ class Metadata(Bcfg2.Server.Plugin.Metadata,
self.logger.error(msg)
raise Bcfg2.Server.Plugin.PluginExecutionError(msg)
- profiles = [g for g in self.clientgroups[client]
- if g in self.groups and self.groups[g].is_profile]
- if profiles != [profile]:
+ metadata = self.core.build_metadata(client)
+ if metadata.profile != profile:
self.logger.info("Changing %s profile from %s to %s" %
- (client, profiles, profile))
+ (client, metadata.profile, profile))
self.update_client(client, dict(profile=profile))
if client in self.clientgroups:
- for prof in profiles:
- self.clientgroups[client].remove(prof)
+ if metadata.profile in self.clientgroups[client]:
+ self.clientgroups[client].remove(metadata.profile)
self.clientgroups[client].append(profile)
else:
self.clientgroups[client] = [profile]
+ else:
+ self.logger.debug(
+ "Ignoring %s request to change profile from %s to %s"
+ % (client, metadata.profile, profile))
else:
self.logger.info("Creating new client: %s, profile %s" %
(client, profile))