def execute(self, **kwargs): try: inputs = self.verify_args(**kwargs) hippo_id = inputs.get(CliBeanColumn.ID.value) force = inputs.get(CliBeanColumn.FORCE.value) del_service = inputs.get(CliBeanColumn.DEL_SERVICE.value) request_entity = HippoInstanceRequest(id=hippo_id) # stop service if force: stop_success, stop_resp = self.hippoServingService.stop_service( request_entity) if stop_success: print('stop {} success'.format(hippo_id)) if del_service: is_success, status_resp = self.hippoServingService.get_service_status( request_entity) # unregister service is_success, resp = self.hippoServingService.remove_service( request_entity) if not is_success: raise Exception('message: {}\n reason: {}'.format( resp.get('message'), resp.get('reason'))) self.output(resp) # delete service plugin from project if del_service: self._execute(status_resp) except Exception as e: self.logger.error('Remove {} service failed'.format(hippo_id)) self.logger.error(e.message) self.logger.debug(traceback.format_exc())
def execute(self, **kwargs): inputs = self.verify_args(**kwargs) project_home = inputs.get(CliBeanColumn.PROJECT_HOME.value) service_name = inputs.get(CliBeanColumn.SERVICE_NAME.value) client_ip = inputs.get(CliBeanColumn.CLIENT_IP.value) run_cmd = inputs.get(CliBeanColumn.RUN_CMD.value) user = inputs.get(CliBeanColumn.USER.value) api_url = inputs.get(CliBeanColumn.API_URL.value) try: check_service = self.hippoBuildService.check_service( service_name=service_name, project_home=project_home) # 若 Project 未裝 plugin ,則先進行安裝 if check_service.status != 0: create_service = self.hippoBuildService.create_service( service_name=service_name, project_home=project_home, cmd=run_cmd) print("Install {0} Hippo Plugin to {1}:{2} ".format( service_name, client_ip, project_home)) self.logger.info('==== create service ====') self.logger.info(create_service.stdout) double_check_service = self.hippoBuildService.check_service( service_name=service_name, project_home=project_home) if double_check_service.status != 0: raise Exception("Service plugin not found : {}".format( double_check_service.stderr)) conf_name = '{}-env.conf'.format(service_name) conf_path = os.path.join( project_home, 'hippo', 'etc', service_name, conf_name) cprint('Please confirm that the {} file is filled in correctly'.format( conf_path), 'green') cprint('================{} Header ====================='.format( conf_name), 'blue') common_util.print_by_file(conf_path, 'blue') cprint('================{} Footer =====================\n'.format( conf_name), 'blue') # TODO self.set_authkey(api_url) # call http register_request = HippoInstanceRequest( clientIP=client_ip, path=project_home, serviceName=service_name, user=user) is_success, resp = self.hippoServingService.register_service( register_request) if not is_success: raise Exception('message: {}\n reason: {}'.format(resp.get('message'),resp.get('reason'))) self.output(resp) except Exception as e: self.logger.error( 'Register {} service failed'.format(service_name)) self.logger.error(e.message) self.logger.debug(traceback.format_exc())
def execute(self, **kwargs): try: inputs = self.verify_args(**kwargs) hippo_id = inputs.get(CliBeanColumn.ID.value) # call http request_entity = HippoInstanceRequest(id=hippo_id) is_success, resp = self.hippoServingService.stop_service( request_entity) if not is_success: raise Exception('message: {}\n reason: {}'.format(resp.get('message'),resp.get('reason'))) output_dict = self.refactor_result(resp) self.output(output_dict) except Exception as e: self.logger.error('Stop {} service failed'.format(hippo_id)) self.logger.error(e.message) self.logger.debug(traceback.format_exc())
def execute_cluster(self, **kwargs): try: inputs = self.verify_args(**kwargs) user = inputs.get(CliBeanColumn.USER.value) client_ip = inputs.get(CliBeanColumn.CLIENT_IP.value) request_entity = HippoInstanceRequest( user=user, clientIP=client_ip) # call http is_success, resp = self.hippoServingService.get_cluster_status( request_entity) if not is_success: raise Exception(resp.get('message')) output_dict = self.refactor_cluster_result(resp) oeder_dict = self.output(output_dict) except Exception as e: self.logger.error('Get Node status failed') self.logger.error(e.message) self.logger.debug(traceback.format_exc())