def exec_task(ref_task_inst, context): try: options = ref_task_inst.get_options() except Exception as e: logging.warn('get options failed, err=[%s], task_instance_id=[%s]', e, ref_task_inst.id()) return -1 if 'service_id' not in options: logging.warn('service_id not found, task_instance_id=[%s]', ref_task_inst.id()) return -1 helper = bs_scheduler_task.SchedulerTaskHelper(ref_task_inst.id(), context) app_id = None app_group_id = None if 'app_id' in options: app_id = options['app_id'] if 'app_group_id' in options: app_group_id = options['app_group_id'] task = bs_scheduler_task.BsSchedulerTask(context=context, service_id=options['service_id'], options=options, ref_task_inst=ref_task_inst, scheduler_task_helper=helper, run_mode='deploy', app_id=app_id, app_group_id=app_group_id) ret, err = task.run() return ret
def run(self): # app_id="bs_gfw-en-se_1922" helper = bs_scheduler_task.SchedulerTaskHelper("diaoyan_bs_deploy_task.test", self.task_context_) task = bs_deploy_task.BsDeployTask("diaoyan_bs_deploy_task.test", self.task_context_, service_id='bs', scheduler_task_helper=helper, options='{"media":"ssd", "storage_style":"single","action_file":"./test_action_file"}') #task = bs_deploy_task.BsDeployTask("bs_deploy_task.test", self.task_context_, service_id='bs', options='{"media":"ssd", "storage_style":"share"}') ret, msg = task.run() print "[FINISH] %d, %s" % (ret, msg)
def main(): if len(sys.argv) != 2: print "USAGE: python %s <dump-file>" % (sys.argv[0], ) return dump_file = sys.argv[1] mock_am_conf() service_mgr = SM.ServiceManager(g_zk_server, g_zk_root, g_zk_user, g_zk_pass) bh_mgr = BH.BHManager(g_bhcli_path, g_bhcli_cluster) task_context = AT.TaskContext(service_mgr, bh_mgr) tool = BST.SchedulerTaskHelper("task_debug", task_context) ret, err_msg, all_apps, all_machines, all_resource = tool.step_dump(g_service_id, dump_file) if ret != 0: print "FAIL:%s" % (err_msg, ) else: print "SUCC"
def exec_task(ref_task_inst, context): try: options = ref_task_inst.get_options() except Exception as e: logging.warn('get options failed, err=[%s], task_instance_id=[%s]', e, ref_task_inst.id()) return -1 if 'service_id' not in options: logging.warn('service_id not found, task_instance_id=[%s]', ref_task_inst.id()) return -1 if type(options['force_delete_unvisible']) is not bool: logging.warn('force_delete_unvisible should be bool(true/false), task_instance_id=[%s]', ref_task_inst.id()) return -1 ret, app_id_list = context.service_manager_.ListAppByService(options['service_id']) if ret != 0: logging.warn('get app list failed, service_id=[%s], task_instance_id=[%s]', options['service_id'], ref_task_inst.id()) return -1 helper = bs_scheduler_task.SchedulerTaskHelper(ref_task_inst.id(), context) ret = helper.step_commit_delete(app_id_list, service_id=options['service_id'], force_delete_unvisible=options['force_delete_unvisible']) return ret
"manual_connection":true, "manual_delete":true, "media":"ssd", "output_format":"bash", "output_index_distr":{}, "ratio_cross_real_idc":0.1, "service_id":"bs", "stable_index_types":{}, "storage_style":"share", "disable_empty_storage":true, "offline_mode":true, "reserve_mem_percent": 0.0, "skip_reconfig": {"cpu":0} }""" tool = bst.SchedulerTaskHelper("task_debug", None) dump_file_name = "./data_debug/dump-file-empty" app_from_file = "./data_debug/app_list" plan_file = "./data_debug/plan-file-empty" sim_file = "./data_debug/sim-file-empty" def build_options(op_type): try: options = json.loads(rebalance_default_options) return options except: print "build_options failed" print traceback.print_exc() exit(1)