Minor Fixes. 16/73016/1
authorSridhar K. N. Rao <sridhar.rao@spirent.com>
Wed, 10 Nov 2021 15:56:14 +0000 (21:26 +0530)
committerSridhar K. N. Rao <sridhar.rao@spirent.com>
Wed, 10 Nov 2021 15:57:45 +0000 (21:27 +0530)
This patch add multiple minor changes.

Signed-off-by: Sridhar K. N. Rao <sridhar.rao@spirent.com>
Change-Id: Ieda8af0b8145c1ffde6bfdb7a7394776b42df988

19 files changed:
pods/papi/k8scmdrun.py
pods/papi/papi.py
tools/docker/test-containers/dpdk-forwarding-pods/Dockerfile [moved from tools/k8s/test-containers/dpdk-forwarding-pods/Dockerfile with 100% similarity]
tools/docker/test-containers/trafficgen-pods/pktgen/Dockerfile [moved from tools/k8s/test-containers/trafficgen-pods/pktgen/Dockerfile with 100% similarity]
tools/docker/test-containers/trafficgen-pods/prox/Dockerfile [moved from tools/k8s/test-containers/trafficgen-pods/prox/Dockerfile with 100% similarity]
tools/docker/test-containers/trafficgen-pods/prox/deploycentostools.sh [moved from tools/k8s/test-containers/trafficgen-pods/prox/deploycentostools.sh with 100% similarity]
tools/docker/test-containers/trafficgen-pods/prox/port_info/Makefile [moved from tools/k8s/test-containers/trafficgen-pods/prox/port_info/Makefile with 100% similarity]
tools/docker/test-containers/trafficgen-pods/prox/port_info/port_info.c [moved from tools/k8s/test-containers/trafficgen-pods/prox/port_info/port_info.c with 100% similarity]
tools/docker/test-containers/trafficgen-pods/prox/rapid_rsa_key [moved from tools/k8s/test-containers/trafficgen-pods/prox/rapid_rsa_key with 100% similarity]
tools/docker/test-containers/trafficgen-pods/prox/rapid_rsa_key.pub [moved from tools/k8s/test-containers/trafficgen-pods/prox/rapid_rsa_key.pub with 100% similarity]
tools/docker/test-containers/trafficgen-pods/prox/start.sh [moved from tools/k8s/test-containers/trafficgen-pods/prox/start.sh with 100% similarity]
tools/docker/test-containers/trafficgen-pods/prox/vhost_substitute.sh [moved from tools/k8s/test-containers/trafficgen-pods/prox/vhost_substitute.sh with 100% similarity]
tools/docker/test-containers/trafficgen-pods/trex/Dockerfile [moved from tools/k8s/test-containers/trafficgen-pods/trex/Dockerfile with 100% similarity]
tools/docker/test-containers/trafficgen-pods/trex/deploycentostools.sh [moved from tools/k8s/test-containers/trafficgen-pods/trex/deploycentostools.sh with 100% similarity]
tools/docker/test-containers/trafficgen-pods/trex/rapid_rsa_key [moved from tools/k8s/test-containers/trafficgen-pods/trex/rapid_rsa_key with 100% similarity]
tools/docker/test-containers/trafficgen-pods/trex/rapid_rsa_key.pub [moved from tools/k8s/test-containers/trafficgen-pods/trex/rapid_rsa_key.pub with 100% similarity]
tools/docker/test-containers/trafficgen-pods/trex/trex_cfg.yaml [moved from tools/k8s/test-containers/trafficgen-pods/trex/trex_cfg.yaml with 100% similarity]
tools/docker/test-containers/trafficgen-pods/trex/trex_cfg.yaml.j2 [moved from tools/k8s/test-containers/trafficgen-pods/trex/trex_cfg.yaml.j2 with 100% similarity]
tools/docker/test-containers/trafficgen-pods/trex/vppconf.py [moved from tools/k8s/test-containers/trafficgen-pods/trex/vppconf.py with 100% similarity]

index 2fb1a62..d9c9502 100644 (file)
@@ -16,8 +16,7 @@ Run commands inside the pod for post-deployment configuration
 """
 
 import re
-import os
-from kubernetes import client, config
+import sys
 from kubernetes.client.rest import ApiException
 from kubernetes.stream import stream
 
@@ -31,10 +30,10 @@ def execute_command(api_instance, pod_info, exec_command):
     try:
         resp = api_instance.read_namespaced_pod(name=name,
                                                 namespace='default')
-    except ApiException as e:
-        if e.status != 404:
-            print("Unknown error: %s" % e)
-            exit(1)
+    except ApiException as excep:
+        if excep.status != 404:
+            print("Unknown error: %s" % excep)
+            sys.exit(0)
     if not resp:
         print("Pod %s does not exist. Creating it..." % name)
         return -1
@@ -100,6 +99,7 @@ def get_sriov_interfaces(api_instance, podname, namespace):
                 elif 'name' in rout:
                     names.append(rout[5:])
     res = {names[i]: ifs[i] for i in range(len(names))}
+    return res
 
 def start_fowarding_app(api_instance, podname, namespace, appname):
     """
@@ -110,3 +110,4 @@ def start_fowarding_app(api_instance, podname, namespace, appname):
              'namespace': namespace}
     cmd = [appname, '&']
     response = execute_command(api_instance, pinfo, cmd)
+    return response
index 67cc3bc..bd93589 100644 (file)
@@ -27,6 +27,7 @@ from kubernetes.client.rest import ApiException
 
 from conf import settings as S
 from pods.pod.pod import IPod
+from pods.papi import k8scmdrun as util
 
 class Papi(IPod):
     """
@@ -73,7 +74,7 @@ class Papi(IPod):
         group = 'k8s.cni.cncf.io'
         version = 'v1'
         kind_plural = 'network-attachment-definitions'
-        api = client.CustomObjectsApi() 
+        api = client.CustomObjectsApi()
         assert pod_count <= len(pod_manifests)
 
         for nad_filepath in S.getValue('NETWORK_ATTACHMENT_FILEPATH'):
@@ -113,13 +114,10 @@ class Papi(IPod):
                     status = response.status.phase
                 except ApiException as err:
                     raise Exception from err
-                if (status == "Running"
-                        or status == "Failed"
-                        or status == "Unknown"):
+                if status in ("Running", "Failed", "Unknown"):
                     break
-                else:
-                    time.sleep(5)
-                    count = count + 1
+                time.sleep(5)
+                count = count + 1
             # Now Get the Pod-IP
             try:
                 response = api.read_namespaced_pod_status(dep_pod_info['name'],
@@ -128,10 +126,11 @@ class Papi(IPod):
             except ApiException as err:
                 raise Exception from err
             dep_pod_info['namespace'] = namespace
-            dep_pod_list.append(dep_pod_info)
             cmd = ['cat', '/etc/podnetinfo/annotations']
-            execute_command(api, dep_pod_info, cmd)
-        
+            output = util.execute_command(api, dep_pod_info, cmd)
+            dep_pod_info['annotations'] = output
+            dep_pod_list.append(dep_pod_info)
+
         S.setValue('POD_LIST',dep_pod_list)
         return dep_pod_list