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)
def main(): from cortx.utils.ha.hac.compile import Compiler from cortx.utils.ha.hac import generate from cortx.utils.ha.hac import const provider = { "pcs": generate.PCSGeneratorResource, "k8s": generate.KubernetesGenerator } try: Conf.init() argParser = argparse.ArgumentParser( usage = "%(prog)s\n\n" + usage(), formatter_class = argparse.RawDescriptionHelpFormatter) argParser.add_argument("-v", "--validate", help="Check input files for syntax errors") argParser.add_argument("-t", "--target", default="pcs", help="HA target to use. Example: pcs") argParser.add_argument("-c", "--compile", help="Path of ha_spec files.") argParser.add_argument("-o", "--output", help="Final spec/rule file for generator/compiler") argParser.add_argument("-g", "--generate", help="Ganerate script/rule for targeted HA tool. Eg: pcs") argParser.add_argument("-a", "--args_file", help="Args file for generator for dynamic input values") argParser.add_argument("-r", "--resources", help="Enter resorce list") args = argParser.parse_args() if args.generate is None: c = Compiler(args.compile, args.output, args.validate) if args.validate is None: c.parse_files() c.compile_graph() c.verify_schema() c.create_schema() c.draw_graph() else: com = provider[args.target](args.generate, args.output, args.args_file, args.resources) com.create_script() except Exception as e: #TODO: print traceback error properly with open(const.HAC_LOG, "w") as log: current_time = str(datetime.now().strftime("%d/%m/%Y %H:%M:%S")) log.writelines(current_time + ":"+ str(traceback.format_exc())) print('Error: ' + str(e), file=sys.stderr) sys.exit(1)
def __init__(self): if ConfInit.__instance == None: ConfInit.__instance = self Conf.init() Conf.load(const.CONFIG_INDEX, Json(const.MESSAGE_BUS_CONF))