Skip to content
Snippets Groups Projects
Commit 33b36e73 authored by garciadeblas's avatar garciadeblas
Browse files

Rename functions in k8s.py:GitOpsLcm to improve readability


Change-Id: I517565c8f27e6da3bfcfb0086d1ba95068408d97
Signed-off-by: default avatargarciadeblas <gerardo.garciadeblas@telefonica.com>
parent 995cbf3d
No related branches found
No related tags found
No related merge requests found
......@@ -156,7 +156,7 @@ class GitOpsLcm(LcmBase):
return content
async def check_workflow(self, op_id, workflow_name, db_content):
async def check_workflow_and_update_db(self, op_id, workflow_name, db_content):
workflow_status, workflow_msg = await self.odu.check_workflow_status(
workflow_name
)
......@@ -186,7 +186,9 @@ class GitOpsLcm(LcmBase):
self.db.set_one(self.db_collection, {"_id": db_content["_id"]}, db_content)
return workflow_status
async def check_resource(self, resource_name, op_id, op_params, db_content):
async def check_resource_and_update_db(
self, resource_name, op_id, op_params, db_content
):
workflow_status = True
resource_status, resource_msg = await self.check_resource_status(
......@@ -1311,10 +1313,12 @@ class K8sAppLcm(GitOpsLcm):
)
self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status = await self.check_workflow(op_id, workflow_name, content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, content
)
if workflow_status:
resource_status, content = await self.check_resource(
resource_status, content = await self.check_resource_and_update_db(
"create_profile", op_id, op_params, content
)
self.db.set_one(self.db_collection, {"_id": content["_id"]}, content)
......@@ -1338,10 +1342,12 @@ class K8sAppLcm(GitOpsLcm):
)
self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status = await self.check_workflow(op_id, workflow_name, content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, content
)
if workflow_status:
resource_status, content = await self.check_resource(
resource_status, content = await self.check_resource_and_update_db(
"delete_profile", op_id, op_params, content
)
......@@ -1383,10 +1389,12 @@ class K8sResourceLcm(GitOpsLcm):
)
self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status = await self.check_workflow(op_id, workflow_name, content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, content
)
if workflow_status:
resource_status, content = await self.check_resource(
resource_status, content = await self.check_resource_and_update_db(
"create_profile", op_id, op_params, content
)
self.db.set_one(self.db_collection, {"_id": content["_id"]}, content)
......@@ -1412,10 +1420,12 @@ class K8sResourceLcm(GitOpsLcm):
)
self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status = await self.check_workflow(op_id, workflow_name, content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, content
)
if workflow_status:
resource_status, content = await self.check_resource(
resource_status, content = await self.check_resource_and_update_db(
"delete_profile", op_id, op_params, content
)
......@@ -1459,10 +1469,12 @@ class K8sInfraControllerLcm(GitOpsLcm):
)
self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status = await self.check_workflow(op_id, workflow_name, content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, content
)
if workflow_status:
resource_status, content = await self.check_resource(
resource_status, content = await self.check_resource_and_update_db(
"create_profile", op_id, op_params, content
)
self.db.set_one(self.db_collection, {"_id": content["_id"]}, content)
......@@ -1488,10 +1500,12 @@ class K8sInfraControllerLcm(GitOpsLcm):
)
self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status = await self.check_workflow(op_id, workflow_name, content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, content
)
if workflow_status:
resource_status, content = await self.check_resource(
resource_status, content = await self.check_resource_and_update_db(
"delete_profile", op_id, op_params, content
)
......@@ -1535,10 +1549,12 @@ class K8sInfraConfigLcm(GitOpsLcm):
)
self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status = await self.check_workflow(op_id, workflow_name, content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, content
)
if workflow_status:
resource_status, content = await self.check_resource(
resource_status, content = await self.check_resource_and_update_db(
"create_profile", op_id, op_params, content
)
self.db.set_one(self.db_collection, {"_id": content["_id"]}, content)
......@@ -1564,10 +1580,12 @@ class K8sInfraConfigLcm(GitOpsLcm):
)
self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status = await self.check_workflow(op_id, workflow_name, content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, content
)
if workflow_status:
resource_status, content = await self.check_resource(
resource_status, content = await self.check_resource_and_update_db(
"delete_profile", op_id, op_params, content
)
......@@ -1605,10 +1623,12 @@ class OkaLcm(GitOpsLcm):
"create_oka", op_id, op_params, db_content
)
workflow_status = await self.check_workflow(op_id, workflow_name, db_content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, db_content
)
if workflow_status:
resource_status, db_content = await self.check_resource(
resource_status, db_content = await self.check_resource_and_update_db(
"create_oka", op_id, op_params, db_content
)
self.db.set_one(self.db_collection, {"_id": db_content["_id"]}, db_content)
......@@ -1626,10 +1646,12 @@ class OkaLcm(GitOpsLcm):
_, workflow_name = await self.odu.launch_workflow(
"update_oka", op_id, op_params, db_content
)
workflow_status = await self.check_workflow(op_id, workflow_name, db_content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, db_content
)
if workflow_status:
resource_status, db_content = await self.check_resource(
resource_status, db_content = await self.check_resource_and_update_db(
"update_oka", op_id, op_params, db_content
)
self.db.set_one(self.db_collection, {"_id": db_content["_id"]}, db_content)
......@@ -1647,10 +1669,12 @@ class OkaLcm(GitOpsLcm):
_, workflow_name = await self.odu.launch_workflow(
"delete_oka", op_id, op_params, db_content
)
workflow_status = await self.check_workflow(op_id, workflow_name, db_content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, db_content
)
if workflow_status:
resource_status, db_content = await self.check_resource(
resource_status, db_content = await self.check_resource_and_update_db(
"delete_oka", op_id, op_params, db_content
)
......@@ -1709,10 +1733,12 @@ class KsuLcm(GitOpsLcm):
"create_ksus", op_id, op_params, db_content
)
for db_ksu, ksu_params in zip(db_content, op_params):
workflow_status = await self.check_workflow(op_id, workflow_name, db_ksu)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, db_ksu
)
if workflow_status:
resource_status, db_ksu = await self.check_resource(
resource_status, db_ksu = await self.check_resource_and_update_db(
"create_ksus", op_id, ksu_params, db_ksu
)
......@@ -1762,10 +1788,12 @@ class KsuLcm(GitOpsLcm):
)
for db_ksu, ksu_params in zip(db_content, op_params):
workflow_status = await self.check_workflow(op_id, workflow_name, db_ksu)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, db_ksu
)
if workflow_status:
resource_status, db_ksu = await self.check_resource(
resource_status, db_ksu = await self.check_resource_and_update_db(
"update_ksus", op_id, ksu_params, db_ksu
)
db_ksu["name"] = ksu_params["name"]
......@@ -1814,10 +1842,12 @@ class KsuLcm(GitOpsLcm):
)
for db_ksu, ksu_params in zip(db_content, op_params):
workflow_status = await self.check_workflow(op_id, workflow_name, db_ksu)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, db_ksu
)
if workflow_status:
resource_status, db_ksu = await self.check_resource(
resource_status, db_ksu = await self.check_resource_and_update_db(
"delete_ksus", op_id, ksu_params, db_ksu
)
......@@ -1840,10 +1870,12 @@ class KsuLcm(GitOpsLcm):
"clone_ksus", op_id, op_params, db_content
)
workflow_status = await self.check_workflow(op_id, workflow_name, db_content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, db_content
)
if workflow_status:
resource_status, db_content = await self.check_resource(
resource_status, db_content = await self.check_resource_and_update_db(
"clone_ksus", op_id, op_params, db_content
)
self.db.set_one(self.db_collection, {"_id": db_content["_id"]}, db_content)
......@@ -1862,10 +1894,12 @@ class KsuLcm(GitOpsLcm):
"move_ksus", op_id, op_params, db_content
)
workflow_status = await self.check_workflow(op_id, workflow_name, db_content)
workflow_status = await self.check_workflow_and_update_db(
op_id, workflow_name, db_content
)
if workflow_status:
resource_status, db_content = await self.check_resource(
resource_status, db_content = await self.check_resource_and_update_db(
"move_ksus", op_id, op_params, db_content
)
self.db.set_one(self.db_collection, {"_id": db_content["_id"]}, db_content)
......
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