summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX
diff options
context:
space:
mode:
authorYury Kylulin <yury.kylulin@intel.com>2020-06-05 16:05:28 +0000
committerYury Kylulin <yury.kylulin@intel.com>2020-06-05 16:05:28 +0000
commit7c3217fc16020c36c5a7c9c4f4542f99cbcad57f (patch)
treec63b22cfa3345606fc5d4589a88a2d213df43d1f /VNFs/DPPD-PROX
parent5efcdda3cc2d4e0333cce4a872ae3de4d3e3710b (diff)
Clean up for the test pods
Option for Kubernetes environment clean up (createrapidk8s.py -c) from the test pods added. Signed-off-by: Yury Kylulin <yury.kylulin@intel.com> Change-Id: I1c6c7090462b55fbadd1d8f1a277470a6eeb2dee
Diffstat (limited to 'VNFs/DPPD-PROX')
-rwxr-xr-xVNFs/DPPD-PROX/helper-scripts/rapid/createrapidk8s.py32
-rw-r--r--VNFs/DPPD-PROX/helper-scripts/rapid/pod.py9
2 files changed, 31 insertions, 10 deletions
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/createrapidk8s.py b/VNFs/DPPD-PROX/helper-scripts/rapid/createrapidk8s.py
index e096c82e..4285584d 100755
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/createrapidk8s.py
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/createrapidk8s.py
@@ -16,6 +16,7 @@
## limitations under the License.
##
+import argparse
from k8sdeployment import K8sDeployment
# Config file name for deployment creation
@@ -24,14 +25,29 @@ CREATE_CONFIG_FILE_NAME = "rapid.pods"
# Config file name for runrapid script
RUN_CONFIG_FILE_NAME = "rapid.env"
-# Create a new deployment
-deployment = K8sDeployment()
+def main():
+ # Parse command line arguments
+ argparser = argparse.ArgumentParser()
+ argparser.add_argument("-c", "--clean", action = "store_true",
+ help = "Terminate pod-rapid-* PODs. "
+ "Clean up cluster before or after the testing.")
+ args = argparser.parse_args()
-# Load config file with test environment description
-deployment.load_create_config(CREATE_CONFIG_FILE_NAME)
+ # Create a new deployment
+ deployment = K8sDeployment()
-# Create PODs for test
-deployment.create_pods()
+ # Load config file with test environment description
+ deployment.load_create_config(CREATE_CONFIG_FILE_NAME)
-# Save config file for runrapid script
-deployment.save_runtime_config(RUN_CONFIG_FILE_NAME)
+ if args.clean:
+ deployment.delete_pods()
+ return
+
+ # Create PODs for test
+ deployment.create_pods()
+
+ # Save config file for runrapid script
+ deployment.save_runtime_config(RUN_CONFIG_FILE_NAME)
+
+if __name__ == "__main__":
+ main()
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/pod.py b/VNFs/DPPD-PROX/helper-scripts/rapid/pod.py
index fdcb6a4b..61af9371 100644
--- a/VNFs/DPPD-PROX/helper-scripts/rapid/pod.py
+++ b/VNFs/DPPD-PROX/helper-scripts/rapid/pod.py
@@ -82,8 +82,13 @@ class Pod:
"""
if self._ssh_client is not None:
self._ssh_client.disconnect()
- self.k8s_CoreV1Api.delete_namespaced_pod(name = self._name,
- namespace = self._namespace)
+
+ try:
+ self.k8s_CoreV1Api.delete_namespaced_pod(name = self._name,
+ namespace = self._namespace)
+ except client.rest.ApiException as e:
+ if e.reason != "Not Found":
+ self._log.error("Couldn't delete POD %s!\n%s\n" % (self._name, e.reason))
def update_admin_ip(self):
"""Check for admin IP address assigned by k8s.