def main(argv): role = get_role() # 只在一个master controller节点执行此命令 cluster_info = get_cluster_info() if role != ROLE_CONTROLLER or \ int(cluster_info["sid"]) != MASTER_CONTROLLER_SID: logger.info("queue action[%s] not handler on non-master [%s|%s].", argv, role, cluster_info["sid"]) return parser = ArgsParser() ret = parser.parse(argv) if not ret: sys.exit(40) if parser.action in ACTION_MAP: if parser.directive: queue = parser.directive["queue"] if isinstance(queue, str): queue = json_loads(queue) if queue is None: logger.error("Failed to load queue[%s] to json!", parser.directive) sys.exit(40) ret = ACTION_MAP[parser.action](queue) else: ret = ACTION_MAP[parser.action]() sys.exit(ret) else: logger.error("can not handle the action[%s].", parser.action) sys.exit(40)
def main(argv): try: # 只在一个master controller节点执行此命令 role = get_role() cluster_info = get_cluster_info() if role != ROLE_CONTROLLER or \ int(cluster_info["sid"]) != MASTER_CONTROLLER_SID: return parser = ArgsParser() ret = parser.parse(argv) if not ret: sys.exit(40) if parser.action in ACTION_MAP: if parser.directive: software = parser.directive["software"] if isinstance(software, str): software = json_loads(software) if software is None: logger.error("Failed to load software[%s] to json!", parser.directive) sys.exit(40) ret = ACTION_MAP[parser.action](software) else: ret = ACTION_MAP[parser.action]() sys.exit(ret) else: logger.error("can not handle the action[%s].", parser.action) sys.exit(40) except Exception: logger.error("Failed to update software: [%s]", traceback.format_exc()) sys.exit(1)
def main(argv): try: parser = ArgsParser() ret = parser.parse(argv) if not ret: sys.exit(40) if parser.action in ACTION_MAP: if parser.directive: software = parser.directive["software"] if isinstance(software, str): software = json_loads(software) if software is None: logger.error("Failed to load software[%s] to json!", parser.directive) sys.exit(40) ret = ACTION_MAP[parser.action](software) else: ret = ACTION_MAP[parser.action]() sys.exit(ret) else: logger.error("can not handle the action[%s].", parser.action) sys.exit(40) except Exception: logger.error("Failed to update software: [%s]", traceback.format_exc()) sys.exit(1)
def main(argv): parser = ArgsParser() ret = parser.parse(argv) if not ret: sys.exit(40) if parser.action in ACTION_MAP: ACTION_MAP[parser.action](parser.directive) if parser.directive \ else ACTION_MAP[parser.action]() else: logger.error("can not handle the action[%s].", parser.action) sys.exit(40)
def main(argv): parser = ArgsParser() ret = parser.parse(argv) if not ret: sys.exit(40) if parser.action in ACTION_MAP: ret = ACTION_MAP[parser.action]() sys.exit(ret) else: logger.error("Un-support action:[%s], exit!", parser.action) sys.exit(40)
def init_software(): # install software software = json_load(SOFTWARE_INFO) if software is None: logger.error("The software info is invalid format!") return 40 logger.info("init: install software[%s]..", software) if software: p_conf = ACTION_PARAM_CONF[ACTION_SOFTWARE_INSTALL]["children"]["software"] if not ArgsParser.check("software", software, p_conf): logger.error("The software[%s] valid failed!", software) return 40 return install(software, ignore_exist=True) return 0