def checkHash(self, path): # Same as real object, except we load from a saved # dictionary instead of a json file oldConfig = {} for key in self.savedYamlData.keys(): if key in path: oldConfig = self.savedYamlData[key] break newConfig = mini_utility.hash_dictionary(self.data) oldConfig = mini_utility.hash_dictionary(oldConfig) return mini_utility.diff_dicts(oldConfig, newConfig, checkValues=True)
def _check_configuration(self, pkg): """ Check to see if we have sufficient configuration data to mess around with a given package pkg -- a package object that we need to do something with """ if pkg.get_configuration(): required_configs = pkg.get_configuration() diff = diff_dicts(required_configs, self.config.data) if diff != {}: self.operation_status = FAIL errmsg = "This machine does not have sufficient " "configuration data to install %s " % pkg.name diff_txt = "" for key in diff: diff_txt += "key: %s; value: %s" % (key, diff[key]) Logger.warning(errmsg) Logger.warning(diff_txt) raise Exceptions.BadPackage(pkg.name, "Bad Config")
def cmd(self, command_line): """ command_line -- all of the keywords passed in the command string, parsed """ machine_name = check_machine_name(command_line) if len(command_line) != 4: msg = "Incomplete command; need to include package name." raise CommandError(msg) package_name = command_line[3] pkg_data = self.pkg_field.get_specific_data(command_line, 3) pkg_config_data = pkg_data.get("configuration", {}) merged_field = ConfigField.ConfigField(data_type=ConfigField.MERGED) merged_data = merged_field.get_specific_data(command_line, 1) missing_stuff = mini_utility.diff_dicts(pkg_config_data, merged_data) if package_name in merged_data.get("packages", []) and not missing_stuff: msg = "Package %s is already assigned and properly configured." return OK, [msg % package_name] return self.assign_package(machine_name, package_name, missing_stuff)