def check_hash(self, path): """ We saved off a hash of our configuration data the last time we did some package maintenance. Now we're going to load that saved value and compare it with our current config. That will tell us what values have changed. path -- the place to find the configuration hash that was used the last time this package was configured or installed """ old_config = {} difference = {} try: load_string = open(path, "r").read() old_config = yaml_load(load_string) new_config = hash_dictionary(self.data) difference = diff_dicts(old_config, new_config, check_values=True) except IOError: msg = "Could not load saved configuration data in %s" % path Logger.debug(msg) except IndexError: msg = "Could not compare configuration data in %s" % path Logger.debug(msg) except: Logger.warning("Bad json/yaml in file %s" % path) return difference
def load_current_progress(self): "Loads the status.yml file for this instance" try: raw_data = open(self.progress_path, 'r').read() data = yaml_load(raw_data) assert type(data) == type({}) except Exception: raise StatusException(self.progress_path) return data
def _read_local_config(self): """If there is a cleartext configuration file on the system, we will read that and ignore the configuration sent to us from the server.""" spkg_path = get_spkg_path() if not spkg_path: return FAIL config_path = make_path(get_spkg_path(), self.instance_name, CONFIG_FILE) if not os.path.isfile(config_path): return FAIL msg = "DETECTED A CLEARTEXT LOCAL CONFIGURATION FILE:" " IGNORING MANAGEMENT SERVER CONFIGURATION" Logger.warning(msg) file_handle = open(config_path, "r") try: config_data = file_handle.read() self.data = yaml_load(config_data) except: return FAIL return OK
def load_manifest( self ): """Initialize manifest_dictionary from the existing manifest_path""" load_string = open( self.manifest_path, 'r' ).read() self.manifest_dictionary = yaml_load(load_string)