def update_node(access_token, project_id, node_id, status=None): if not status: status = models.CommonStatus.Scheduling resp = paas_cc.update_node( access_token, project_id, node_id, {"status": status} ) return resp
def delete_cluster_node(new_log): log_type, log_id = new_log if not (log_type and log_id): return log_type, log_id model = models.log_factory(log_type) log = model.objects.filter(id=log_id).last() params = json.loads(log.params) # 触发bcs任务 model.objects.filter(id=log.id) bcs_client = BCSClient( log.token, log.project_id, log.cluster_id, None ) resp = bcs_client.delete_cluster_node( params.get("kind_name"), log.operator, list(params.get("nodes", {}).keys()) ) if not resp.get("result"): log.is_finished = True log.is_polling = False log.status = models.CommonStatus.RemoveFailed log.log = json.dumps({ "state": "remove_failed", "node_tasks": [{ "state": "FAILURE", "name": resp.get("message") }] }) log.save() result = paas_cc.update_node( log.token, log.project_id, params["node_id"], {"status": models.CommonStatus.RemoveFailed} ) if result.get("code") != ErrorCode.NoError: return None, None return None, None data = resp.get("data") or {} taskid = data.get("taskID") log.task_id = taskid log.is_polling = True log.save() return log_type, log.id