def get_blank_config(self): """Get a blank configuration which can be used to create a new configuration from scratch. Returns: dict : A dictionary containing all the details of a blank configuration """ temp_config = InactiveConfigHolder(MACROS, self._vc, ConfigurationFileManager()) return temp_config.get_config_details()
def _get_inactive_history(self, name, is_component=False): # If it already exists load it try: inactive = InactiveConfigHolder(MACROS, self._vc, ConfigurationFileManager()) inactive.load_inactive(name, is_component) # Get previous history history = inactive.get_history() except IOError as err: # Config doesn't exist therefore start new history history = list() return history
def load_config(self, name, is_component=False): """Loads an inactive configuration or component. Args: name (string): The name of the configuration to load is_component (bool): Whether it is a component or not Returns: InactiveConfigHolder : The holder for the requested configuration """ config = InactiveConfigHolder(MACROS, self._vc, self.file_manager) config.load_inactive(name, is_component) return config
def save_inactive_config(self, json_data, as_comp=False): """Save an inactive configuration. Args: json_data (string): The JSON data containing the configuration/component as_comp (bool): Whether it is a component or not """ new_details = convert_from_json(json_data) inactive = InactiveConfigHolder(MACROS, self._vc, ConfigurationFileManager()) history = self._get_inactive_history(new_details["name"], as_comp) inactive.set_config_details(new_details) # Set updated history history.append(self._get_timestamp()) inactive.set_history(history) config_name = inactive.get_config_name() self._check_config_inactive(config_name, as_comp) try: if not as_comp: print_and_log("Saving configuration: %s" % config_name) inactive.save_inactive() self._config_list.update_a_config_in_list(inactive) else: print_and_log("Saving component: %s" % config_name) inactive.save_inactive(as_comp=True) self._config_list.update_a_config_in_list(inactive, True) print_and_log("Saved") except Exception as err: print_and_log("Problem occurred saving configuration: %s" % err) # Reload configuration if a component has changed if as_comp and new_details["name"] in self._active_configserver.get_component_names(): self.load_last_config()