return None
@staticmethod
- def format_on_operation(
- content, operation_type, operation_params=None, launch_workflow=True
- ):
- if content["current_operation"] is None:
- op_id = str(uuid4())
- content["current_operation"] = op_id
- else:
- op_id = content["current_operation"]
+ def format_on_operation(content, operation_type, operation_params=None):
+ op_id = str(uuid4())
now = time()
if "operationHistory" not in content:
content["operationHistory"] = []
operation["result"] = None
operation["creationDate"] = now
operation["endDate"] = None
- if launch_workflow:
- operation["workflowState"] = "PROCESSING"
- operation["resourceState"] = "NOT_READY"
- operation["operationState"] = "IN_PROGRESS"
- operation["gitOperationInfo"] = None
- operation["operationParams"] = operation_params
- else:
- operation["workflowState"] = operation["resourceState"] = operation[
- "operationState"
- ] = operation["gitOperationInfo"] = operation["operationParams"] = None
+ operation["workflowState"] = operation["resourceState"] = operation[
+ "operationState"
+ ] = operation["gitOperationInfo"] = None
+ operation["operationParams"] = operation_params
content["operationHistory"].append(operation)
return op_id
self.resource_topic = ResourceTopic(db, fs, msg, auth)
self.app_topic = AppTopic(db, fs, msg, auth)
+ @staticmethod
+ def format_on_new(content, project_id=None, make_public=False):
+ BaseTopic.format_on_new(content, project_id=project_id, make_public=make_public)
+ content["current_operation"] = None
+
def new(self, rollback, session, indata=None, kwargs=None, headers=None):
"""
Creates a new k8scluster into database.
self.format_on_new(
cls_create, session["project_id"], make_public=session["public"]
)
- cls_create["current_operation"] = None
op_id = self.format_on_operation(
cls_create,
"create",
if profile_id not in profile_list:
content["operatingState"] = "PROCESSING"
- content["current_operation"] = None
op_id = self.format_on_operation(
content,
"add",
"Cannot remove default profile", HTTPStatus.UNPROCESSABLE_ENTITY
)
if profile_id in profile_list:
- content["operatingState"] = "PROCESSING"
- content["current_operation"] = None
op_id = self.format_on_operation(
content,
"remove",
else:
filter_db = self._get_project_filter(session)
filter_db[BaseTopic.id_field(self.topic, _id)] = _id
- operation_params = {}
+ operation_params = None
data = self.db.get_one(self.topic, filter_db)
- op_id = self.format_on_operation(
- data, item, operation_params, launch_workflow=False
- )
+ op_id = self.format_on_operation(data, item, operation_params)
self.db.set_one(self.topic, {"_id": data["_id"]}, data)
self._send_msg("get_creds", {"cluster_id": _id, "operation_id": op_id})
return op_id
def __init__(self, db, fs, msg, auth):
BaseTopic.__init__(self, db, fs, msg, auth)
+ @staticmethod
+ def format_on_new(content, project_id=None, make_public=False):
+ BaseTopic.format_on_new(content, project_id=project_id, make_public=make_public)
+ content["current_operation"] = None
+
def add(self, rollback, session, indata, kwargs=None, headers=None):
step = "checking quotas"
try:
self.format_on_new(
cls_add_request, session["project_id"], make_public=session["public"]
)
- cls_add_request["current_operation"] = None
op_id = self.format_on_operation(
cls_add_request,
"register",
filter_q[self.id_field(self.topic, _id)] = _id
item_content = self.db.get_one(self.topic, filter_q)
- item_content["operatingState"] = "PROCESSING"
- item_content["current_operation"] = None
op_id = self.format_on_operation(
item_content,
"deregister",
@staticmethod
def format_on_new(content, project_id=None, make_public=False):
BaseTopic.format_on_new(content, project_id=project_id, make_public=make_public)
+ content["current_operation"] = None
content["state"] = "IN_CREATION"
content["operatingState"] = "PROCESSING"
content["resourceState"] = "IN_PROGRESS"
self.format_on_new(
content, project_id=session["project_id"], make_public=session["public"]
)
- content["current_operation"] = None
op_id = self.format_on_operation(
content,
operation_type="create",
_id = self.db.create(self.topic, content)
rollback.append({"topic": self.topic, "_id": _id})
-
- if not op_id:
- op_id = content["current_operation"]
_id_list.append(_id)
data = {"ksus_list": _id_list, "operation_id": op_id}
self._send_msg("create", data)
filter_db[BaseTopic.id_field(self.topic, _id)] = _id
data = self.db.get_one(self.topic, filter_db)
- data["current_operation"] = None
op_id = self.format_on_operation(
data,
"clone",
# To allow project addressing by name AS WELL AS _id. Get the _id, just in case the provided one is a name
_id = content.get("_id") or _id
- content["current_operation"] = None
op_id = self.format_on_operation(
content,
"move",
DescriptorTopic.format_on_new(
content, project_id=project_id, make_public=make_public
)
+ content["current_operation"] = None
content["state"] = "PENDING_CONTENT"
content["operatingState"] = "PROCESSING"
content["resourceState"] = "IN_PROGRESS"
self.format_on_new(
content, session["project_id"], make_public=session["public"]
)
- content["current_operation"] = None
op_id = self.format_on_operation(
content,
operation_type="create",
kwargs["package"] = filename
if headers["Method"] == "POST":
current_desc["state"] = "IN_CREATION"
- op_id = current_desc["current_operation"]
+ op_id = current_desc.get("operationHistory", [{"op_id": None}])[-1].get(
+ "op_id"
+ )
elif headers["Method"] in ("PUT", "PATCH"):
- current_desc["current_operation"] = None
op_id = self.format_on_operation(
current_desc,
"update",