def gen_service_config(self): utilities.print_split_info() utilities.print_badage("generate service config") ret = self.service_controller.gen_all_service_config() if ret is True: utilities.print_badage("generate service config success") else: utilities.log_error("generate service config failed") utilities.print_split_info() return ret
def execute_command(self, function, notice_info): utilities.print_split_info() utilities.print_badage(notice_info) ret = getattr(self.node_controller, function)() if ret is True: utilities.print_badage("%s success" % notice_info) else: utilities.log_error("%s failed" % notice_info) utilities.print_split_info() return ret
def stop_service(self): utilities.print_split_info() utilities.print_badage("stop service, type: %s" % self.service_type) ret = self.service_controller.stop_all() if ret is True: utilities.print_badage("stop service success, type: %s" % self.service_type) else: utilities.log_error("stop service failed, type: %s" % self.service_type) utilities.print_split_info() return ret
def upload_service(self): # upload the generated_config utilities.print_split_info() utilities.print_badage("upload service, type: %s" % self.service_type) ret = self.service_controller.deploy_all() if ret is True: utilities.print_badage("upload service success, type: %s" % self.service_type) else: utilities.log_error("upload service failed, type: %s" % self.service_type) utilities.print_split_info() return ret
def create_subnet_operation(args): if parser_handler.is_create_subnet_command(args) is False: return docker_network_name = args.name if docker_network_name is None or len(docker_network_name) == 0: utilities.log_error( "Must set the docker network name! e.g. tars-network") sys.exit(-1) subnet_ip_segment = args.subnet if subnet_ip_segment is None or len(subnet_ip_segment) == 0: utilities.log_error("Must set the subnet! e.g. 172.25.0.0.1") sys.exist(-1) NetworkManager.create_sub_net(subnet_ip_segment, docker_network_name) utilities.print_split_info()
def deploy_service(self): # generate_config utilities.print_split_info() utilities.print_badage("deploy service, type: %s" % self.service_type) ret = self.gen_service_config() if ret is False: utilities.log_error( "deploy service failed for generate config failed, type: %s" % self.service_type) return False ret = self.service_controller.deploy_all() if ret is True: utilities.print_badage("deploy service success, type: %s" % self.service_type) else: utilities.log_error("deploy service failed, type: %s" % self.service_type) utilities.print_split_info() return ret
def download_binary_operation(args): if parser_handler.is_download_binary_command(args) is False: return utilities.print_split_info() binary_path = args.path version = args.version if version.startswith("v") is False: version = "v" + version if args.type not in CommandInfo.download_type: utilities.log_error( "Unsupported download type %s, only support %s now" % (args.type, ', '.join(CommandInfo.download_type))) return use_cdn = True if args.type == "git": use_cdn = False binary_controller = BinaryController(version, binary_path, use_cdn) binary_controller.download_all_binary() utilities.print_split_info()
def add_vxlan_operation(args): if parser_handler.is_add_vxlan_command(args) is False: return utilities.print_split_info() network = args.network if network is None or len(network) == 0: utilities.log_error( "Must set a valid non-empty network name, e.g. tars-network") return dstip = args.dstip if dstip is None or len(dstip) == 0: utilities.log_error("Must set a valid non-empty dst ip") return vxlan_name = args.vxlan if vxlan_name is None or len(vxlan_name) == 0: utilities.log_error("Must set a valid non-empty vxlan name") return NetworkManager.create_bridge(network, vxlan_name, dstip) utilities.print_split_info()
def expand_service(self): utilities.print_split_info() utilities.print_badage("expand service, type: %s" % self.service_type) # generate config ret = self.gen_service_config() if ret is False: utilities.log_error( "expand service failed for generate config failed, type: %s" % self.service_type) return False # expand service utilities.print_badage("begin expand service") ret = self.service_controller.expand_all() if ret is True: utilities.print_badage("expand service success, type: %s" % self.service_type) else: utilities.log_error("expand service failed, type: %s" % self.service_type) utilities.print_split_info() return ret