From: Suchismita Jena Date: Tue, 16 Nov 2021 08:08:23 +0000 (+0000) Subject: DMS_CLI removes local xApp folder while xapp deployment X-Git-Tag: 0.5.4^0 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=67d5a74c069b29cf0bd5b5cb7018e3ef2328368d;p=ric-plt%2Fappmgr.git DMS_CLI removes local xApp folder while xapp deployment Change-Id: I8e836324a27f57a5614ade76dfc6dc32f70f1ab3 Signed-off-by: Suchismita Jena --- diff --git a/xapp_orchestrater/dev/xapp_onboarder/xapp_onboarder/helm_controller/xApp_builder.py b/xapp_orchestrater/dev/xapp_onboarder/xapp_onboarder/helm_controller/xApp_builder.py index 8ef252e..ace97ae 100644 --- a/xapp_orchestrater/dev/xapp_onboarder/xapp_onboarder/helm_controller/xApp_builder.py +++ b/xapp_orchestrater/dev/xapp_onboarder/xapp_onboarder/helm_controller/xApp_builder.py @@ -235,6 +235,7 @@ class xApp(): raise xAppError( "xApp " + self.chart_name + '-' + self.chart_version + " distribution failed. (Caused by: " + str(err) + ")" , err.status_code) def install_chart_package(xapp_chart_name, version, namespace, overridefile): + dirTomove = "/tmp/helm_template" try: tar = tarfile.open(xapp_chart_name + "-" + version + ".tgz") tar.extractall() @@ -250,13 +251,19 @@ class xApp(): except Exception as err: print(err) status = 0 - subprocess.run(["rm", "-rf", xapp_chart_name ]) - subprocess.run(["rm", "-rf", xapp_chart_name + "-" + version + ".tgz" ]) + if (os.getcwd() != dirTomove): + subprocess.run(["mv", xapp_chart_name, dirTomove]) + PATH=xapp_chart_name + "-" + version + ".tgz" + if os.path.isfile(PATH): + subprocess.run(["mv", xapp_chart_name + "-" + version + ".tgz", dirTomove ]) return status - def uninstall_chart_package(xapp_chart_name, namespace): - + def uninstall_chart_package(xapp_chart_name, namespace, version): + dirTomove = "/tmp/helm_template/" try: + subprocess.run(["rm", "-rf", dirTomove + xapp_chart_name]) + if version != "" : + subprocess.run(["rm", "-rf", dirTomove+xapp_chart_name + "-" + version + ".tgz"]) process = subprocess.run(["helm", "delete", xapp_chart_name, "--namespace=" + namespace], stdout=PIPE, stderr=PIPE, check=True) status = 1 diff --git a/xapp_orchestrater/dev/xapp_onboarder/xapp_onboarder/server/cli.py b/xapp_orchestrater/dev/xapp_onboarder/xapp_onboarder/server/cli.py index 03d0827..aa58267 100755 --- a/xapp_orchestrater/dev/xapp_onboarder/xapp_onboarder/server/cli.py +++ b/xapp_orchestrater/dev/xapp_onboarder/xapp_onboarder/server/cli.py @@ -46,8 +46,8 @@ class cli(): content, status = download_chart_package(xapp_chart_name=xapp_chart_name, version=version) if status != 200: - return json.dumps(content, indent=4, sort_keys=True) - + #return json.dumps(content, indent=4, sort_keys=True) + return {"status": "NOT_OK"} try: if os.path.isabs(output_path): path = output_path + '/' + xapp_chart_name + '-' + version + '.tgz' @@ -95,15 +95,17 @@ class cli(): """Installing the xapp using the charts name and version,optionally can provide the yaml file to override""" resp = self.download_helm_chart(xapp_chart_name, version) + if resp['status'] == "NOT_OK": + return {"status": "Not OK"} status = xApp.install_chart_package(xapp_chart_name=xapp_chart_name, version=version, namespace=namespace,overridefile=overridefile) if status == 1: return {"status": "OK"} else: return {"status": "NOT_OK"} - def uninstall(self, xapp_chart_name ,namespace): - """Uninstalling the xapp using the charts name""" - status = xApp.uninstall_chart_package(xapp_chart_name=xapp_chart_name, namespace=namespace) + def uninstall(self, xapp_chart_name, namespace, version=""): + """Uninstalling the xapp using the charts name, --version can be provided optionally""" + status = xApp.uninstall_chart_package(xapp_chart_name=xapp_chart_name, namespace=namespace, version=version) if status == 1: return {"status": "OK"} else: @@ -112,13 +114,13 @@ class cli(): def upgrade(self, xapp_chart_name, old_version , new_version, namespace): """Upgrading the xapp to the new version specified""" - resp = self.uninstall(xapp_chart_name, namespace) + resp = self.uninstall(xapp_chart_name, namespace,old_version) if resp["status"] == "OK": status = self.install(xapp_chart_name, new_version, namespace) if status["status"] == "OK": return {"status": "OK"} else: - self.uninstall(xapp_chart_name, namespace) + self.uninstall(xapp_chart_name, namespace,new_version) self.install(xapp_chart_name, old_version, namespace) return {"status": "NOT_OK"} else: