From: Yury Kylulin Date: Thu, 10 Dec 2020 08:40:29 +0000 (+0300) Subject: Moving to python 3 for kubernetes scripts X-Git-Tag: 0.0.1~9 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F22%2F71722%2F1;p=samplevnf.git Moving to python 3 for kubernetes scripts Move to python version 3 in all scripts for kubernetes environment. Streamline file names to match existing libraries. Signed-off-by: Yury Kylulin Change-Id: Id875f4240a87ab600b445cb9a7fd97ec1335f88a --- diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/createrapidk8s.py b/VNFs/DPPD-PROX/helper-scripts/rapid/createrapidk8s.py index 4285584d..c4667f1f 100755 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/createrapidk8s.py +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/createrapidk8s.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 ## ## Copyright (c) 2019 Intel Corporation @@ -17,7 +17,7 @@ ## import argparse -from k8sdeployment import K8sDeployment +from rapid_k8s_deployment import K8sDeployment # Config file name for deployment creation CREATE_CONFIG_FILE_NAME = "rapid.pods" diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/k8sdeployment.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_k8s_deployment.py similarity index 96% rename from VNFs/DPPD-PROX/helper-scripts/rapid/k8sdeployment.py rename to VNFs/DPPD-PROX/helper-scripts/rapid/rapid_k8s_deployment.py index 5e921d46..822ead51 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/k8sdeployment.py +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_k8s_deployment.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python2.7 - ## ## Copyright (c) 2019-2020 Intel Corporation ## @@ -18,11 +16,15 @@ import sys from kubernetes import client, config -import ConfigParser +try: + import configparser +except ImportError: + # Python 2.x fallback + import ConfigParser as configparser import logging from logging import handlers -from pod import Pod +from rapid_k8s_pod import Pod class K8sDeployment: """Deployment class to create containers for test execution in Kubernetes @@ -69,7 +71,7 @@ class K8sDeployment: """Read and parse configuration file for the test environment. """ self._log.info("Loading configuration file %s", config_file_name) - self._create_config = ConfigParser.RawConfigParser() + self._create_config = configparser.RawConfigParser() try: self._create_config.read(config_file_name) except Exception as e: @@ -146,7 +148,7 @@ class K8sDeployment: def save_runtime_config(self, config_file_name): self._log.info("Saving config %s for runrapid script...", config_file_name) - self._runtime_config = ConfigParser.RawConfigParser() + self._runtime_config = configparser.RawConfigParser() # Section [DEFAULT] # self._runtime_config.set("DEFAULT", diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/pod.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_k8s_pod.py similarity index 99% rename from VNFs/DPPD-PROX/helper-scripts/rapid/pod.py rename to VNFs/DPPD-PROX/helper-scripts/rapid/rapid_k8s_pod.py index f663c9df..b5fc8158 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/pod.py +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_k8s_pod.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python2.7 - ## ## Copyright (c) 2019 Intel Corporation ## @@ -21,7 +19,7 @@ import time, yaml import logging from kubernetes import client, config -from sshclient import SSHClient +from rapid_sshclient import SSHClient class Pod: """Class which represents test pods. diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/sshclient.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_sshclient.py similarity index 99% rename from VNFs/DPPD-PROX/helper-scripts/rapid/sshclient.py rename to VNFs/DPPD-PROX/helper-scripts/rapid/rapid_sshclient.py index c781271e..e9fe134c 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/sshclient.py +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_sshclient.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python2.7 - ## ## Copyright (c) 2019 Intel Corporation ##