def read_config_store(self): try: self.config_store = config_store.ConfigStore( CS_NAME, log_com=self.log, access_mode=config_store.AccessModeEnum.LOCAL) except config_store.ConfigStoreError: self.log( "configstore is not valid: {}".format( process_tools.get_except_info()), logging_tools.LOG_LEVEL_ERROR) # remove store config_store.ConfigStore.remove_store(CS_NAME) # create self.config_store = config_store.ConfigStore( CS_NAME, log_com=self.log, access_mode=config_store.AccessModeEnum.LOCAL) for _key, _default in DEFAULT_PROC_DICT.items(): self.config_store[_key] = self.config_store.get(_key, _default) global_config.add_config_entries([ ("MON_TARGET_STATE", configfile.BoolConfigVar(self.config_store["start_process"])), # just a guess ("MON_CURRENT_STATE", configfile.BoolConfigVar(False)), ]) self.config_store.write() self.log(self._get_flag_info())
def main(): global_config.add_config_entries([ ("MEMCACHE_ADDRESS", configfile.StringConfigVar("127.0.0.1", help_string="memcache address")), ]) # enable connection debugging run_code() # exit os._exit(0)
def read_config_store(self): self.config_store = config_store.ConfigStore( CS_NAME, log_com=self.log, access_mode=config_store.AccessModeEnum.LOCAL) for _key, _default in DEFAULT_PROC_DICT.iteritems(): self.config_store[_key] = self.config_store.get(_key, _default) global_config.add_config_entries([ ("MON_TARGET_STATE", configfile.bool_c_var(self.config_store["start_process"])), # just a guess ("MON_CURRENT_STATE", configfile.bool_c_var(False)), ]) self.config_store.write() self.log(self._get_flag_info())
def main(): global_config.add_config_entries([ ("DEBUG", configfile.bool_c_var(False, help_string="enable debug mode [%(default)s]", short_options="d", only_commandline=True)), ("VERBOSE", configfile.int_c_var(0, help_string="set verbose level [%(default)d]", short_options="v", only_commandline=True)), ("MEMCACHE_ADDRESS", configfile.str_c_var("127.0.0.1", help_string="memcache address")), ]) # enable connection debugging run_code() # exit os._exit(0)
def VCM_check_md_version(self): start_time = time.time() _info_file = MON_DAEMON_INFO_FILE self.log( "checking type and version of installed monitoring daemon via file {}" .format(_info_file)) if os.path.isfile(_info_file): try: _content = { _key.strip(): _value.strip().replace("\"", "") for _key, _value in [ _line.split("=") for _line in file(_info_file, "r").read().split("\n") if _line.count("=") ] } except: self.log( "error reading from {}: {}".format( _info_file, process_tools.get_except_info()), logging_tools.LOG_LEVEL_ERROR) else: md_type = _content["MON_TYPE"].lower() md_versrel = _content["MON_VERSION"].lower() md_version, md_release = md_versrel.split("-", 1) global_config.add_config_entries([ ("MD_TYPE", configfile.str_c_var(md_type)), ("MD_VERSION_STRING", configfile.str_c_var(md_versrel)), ("MD_VERSION", configfile.str_c_var(md_version)), ("MD_RELEASE", configfile.str_c_var(md_release)), ("MD_BASEDIR", configfile.str_c_var( os.path.join("/opt", "cluster", md_type))), ("MAIN_CONFIG_NAME", configfile.str_c_var(md_type)), ("MD_LOCK_FILE", configfile.str_c_var("{}.lock".format(md_type))), ]) self.log("Discovered installed monitor-daemon {}, version {}". format(md_type, md_version)) end_time = time.time() self.log("monitor-daemon version discovery took {}".format( logging_tools.get_diff_time_str(end_time - start_time)))