diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-08-07 05:44:56 -0700 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2013-08-07 05:44:56 -0700 |
commit | 3b58eed6508606bab752aa84829b26a7eabc1ac1 (patch) | |
tree | 39431ae13bf0907dc76f837dab9fd7ad94b7266a /src/lib/Bcfg2/Server/Plugins/Metadata.py | |
parent | 99c680e94132d5bf3110bd14bfabc9e407b1dae9 (diff) | |
parent | 4bf1c82868357e5c357e0b656419af37a99a8545 (diff) | |
download | bcfg2-3b58eed6508606bab752aa84829b26a7eabc1ac1.tar.gz bcfg2-3b58eed6508606bab752aa84829b26a7eabc1ac1.tar.bz2 bcfg2-3b58eed6508606bab752aa84829b26a7eabc1ac1.zip |
Merge pull request #130 from fennm/metadata-dont-update-xml-on-gratuitous-profile-update
Metadata: Don't update XML on gratuitous profile update
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Metadata.py')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Metadata.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Metadata.py b/src/lib/Bcfg2/Server/Plugins/Metadata.py index e8962d707..cc0456334 100644 --- a/src/lib/Bcfg2/Server/Plugins/Metadata.py +++ b/src/lib/Bcfg2/Server/Plugins/Metadata.py @@ -978,17 +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] - self.logger.info("Changing %s profile from %s to %s" % - (client, profiles, profile)) - self.update_client(client, dict(profile=profile)) - if client in self.clientgroups: - for prof in profiles: - self.clientgroups[client].remove(prof) - self.clientgroups[client].append(profile) + metadata = self.core.build_metadata(client) + if metadata.profile != profile: + self.logger.info("Changing %s profile from %s to %s" % + (client, metadata.profile, profile)) + self.update_client(client, dict(profile=profile)) + if client in self.clientgroups: + 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.clientgroups[client] = [profile] + 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)) @@ -1004,8 +1008,8 @@ class Metadata(Bcfg2.Server.Plugin.Metadata, self.add_client(client, dict(profile=profile)) self.clients.append(client) self.clientgroups[client] = [profile] - if not self._use_db: - self.clients_xml.write() + if not self._use_db: + self.clients_xml.write() def set_version(self, client, version): """Set version for provided client.""" |