コード例 #1
0
def main(resource, action=''):
    try:
        if action == 'meta-data':
            return resource.metadata()
        Conf.load(const.HA_GLOBAL_INDEX, Yaml(const.HA_CONFIG_FILE))
        log_path = Conf.get(const.HA_GLOBAL_INDEX, f"LOG{_DELIM}path")
        log_level = Conf.get(const.HA_GLOBAL_INDEX, f"LOG{_DELIM}level")
        Log.init(service_name='resource_agent', log_path=log_path, level=log_level)
        with open(const.RESOURCE_SCHEMA, 'r') as f:
            resource_schema = json.load(f)
        os.makedirs(const.RA_LOG_DIR, exist_ok=True)
        resource_agent = resource(DecisionMonitor(), resource_schema)
        Log.debug(f"{resource_agent} initialized for action {action}")
        if action == 'monitor':
            return resource_agent.monitor()
        elif action == 'start':
            return resource_agent.start()
        elif action == 'stop':
            return resource_agent.stop()
        else:
            print('Usage %s [monitor] [start] [stop] [meta-data]' % sys.argv[0])
            exit()
    except Exception as e:
        Log.error(f"{traceback.format_exc()}")
        return const.OCF_ERR_GENERIC
コード例 #2
0
 def __init__(self, compiled_file, output_file, args_file):
     """
     compiled_file   : Compiled file generate by hac compiler
     output_file     : Output file for target ha tool
     args_file       : Provision file for dynamic input
     """
     if compiled_file is None:
         raise Exception("compiled_file is missing")
     if output_file is None:
         raise Exception("output_file is missing")
     if args_file is None:
         raise Exception("args_file is missing")
     self._is_file(compiled_file)
     self._is_file(args_file)
     Conf.load(const.PROV_CONF_INDEX, Yaml(args_file))
     self._script = output_file
     with open(compiled_file, "r") as f:
         self.compiled_json = json.load(f)
         self._modify_schema()
         self._provision_compiled_schema(self.compiled_json)
     self._resource_set = self.compiled_json["resources"]
コード例 #3
0
 def __init__(self):
     """
     Initialization of HA CLI.
     """
     # TODO Check product env and load specific conf
     Conf.init()
     Conf.load(const.RESOURCE_GLOBAL_INDEX, Json(const.RESOURCE_SCHEMA))
     Conf.load(const.RULE_GLOBAL_INDEX, Json(const.RULE_ENGINE_SCHAMA))
     Conf.load(const.HA_GLOBAL_INDEX, Yaml(const.HA_CONFIG_FILE))
     log_path = Conf.get(const.HA_GLOBAL_INDEX, "LOG.path")
     log_level = Conf.get(const.HA_GLOBAL_INDEX, "LOG.level")
     Log.init(service_name='cortxha', log_path=log_path, level=log_level)
コード例 #4
0
ファイル: message.py プロジェクト: mssawant/cortx-utils
 def __init__(self):
     if ConfInit.__instance == None:
         ConfInit.__instance = self
         Conf.init()
         Conf.load(const.CONFIG_INDEX, Json(const.MESSAGE_BUS_CONF))