Skip to content
Snippets Groups Projects
Commit 50e34dc9 authored by Shrinithi R's avatar Shrinithi R
Browse files

Cluster Integration: Adding the clusters to old collection


Change-Id: I625b027427c982d13400db454fb1fc1bd6619b47
Signed-off-by: default avatarrshri <shrinithi.r@tataelxsi.co.in>
parent becc7051
No related branches found
No related tags found
No related merge requests found
......@@ -1022,3 +1022,56 @@ class BaseTopic:
privkey = str(ident)
# return both public and private key
return pubkey, privkey
def add_to_old_collection(self, content, session):
self.logger.info(f"content is : {content}")
item = {}
item["name"] = content["name"]
item["credentials"] = {}
# item["k8s_version"] = content["k8s_version"]
if "k8s_version" in content:
item["k8s_version"] = content["k8s_version"]
else:
item["k8s_version"] = None
vim_account_details = self.db.get_one(
"vim_accounts", {"name": content["vim_account"]}
)
item["vim_account"] = vim_account_details["_id"]
item["nets"] = {"k8s_net1": None}
item["deployment_methods"] = {"juju-bundle": False, "helm-chart-v3": True}
# item["description"] = content["description"]
if "description" in content:
item["description"] = content["description"]
else:
item["description"] = None
item["namespace"] = "kube-system"
item["osm_acm"] = True
item["schema_version"] = "1.11"
self.logger.info(f"item is : {item}")
self.format_on_new(item, session["project_id"], make_public=session["public"])
_id = self.db.create("k8sclusters", item)
self.logger.info(f"_id is : {_id}")
item_1 = self.db.get_one("k8sclusters", {"name": item["name"]})
item_1["_admin"]["operationalState"] = "PROCESSING"
self.logger.info(f"content is : {item_1}")
# Create operation data
now = time()
operation_data = {
"lcmOperationType": "create", # Assuming 'create' operation here
"operationState": "PROCESSING",
"startTime": now,
"statusEnteredTime": now,
"detailed-status": "",
"operationParams": None, # Add parameters as needed
}
# create operation
item_1["_admin"]["operations"] = [operation_data]
item_1["_admin"]["current_operation"] = None
self.logger.info(f"content is : {item_1}")
self.db.set_one("k8sclusters", {"_id": item_1["_id"]}, item_1)
return
......@@ -192,6 +192,7 @@ class K8sTopic(BaseTopic):
@staticmethod
def format_on_new(content, project_id=None, make_public=False):
# logger.info("it is getting into format on new in new fon")
BaseTopic.format_on_new(content, project_id=project_id, make_public=make_public)
content["current_operation"] = None
......@@ -245,6 +246,9 @@ class K8sTopic(BaseTopic):
self.db.set_one("clusters", {"_id": _id}, cls_create)
self._send_msg("create", {"cluster_id": _id, "operation_id": op_id})
# To add the content in old collection "k8sclusters"
self.add_to_old_collection(cls_create, session)
return _id, None
except (
ValidationError,
......@@ -376,7 +380,7 @@ class K8sTopic(BaseTopic):
)
def edit(self, session, _id, item, indata=None, kwargs=None):
if item != (
if item not in (
"infra_controller_profiles",
"infra_config_profiles",
"app_profiles",
......@@ -611,6 +615,10 @@ class K8saddTopic(BaseTopic):
self.db.set_one(self.topic, {"_id": _id}, cls_add_request)
rollback.append({"topic": self.topic, "_id": _id})
self._send_msg("register", {"cluster_id": _id, "operation_id": op_id})
# To add the content in old collection "k8sclusters"
self.add_to_old_collection(cls_add_request, session)
return _id, None
except (
ValidationError,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment