Automate curl installation in sdnc container (vCPE) 71/96671/1
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>
Mon, 7 Oct 2019 12:25:30 +0000 (14:25 +0200)
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>
Mon, 7 Oct 2019 12:25:30 +0000 (14:25 +0200)
Curl package will be automatically installed be the
healthcheck-k8s.py script.

Change-Id: I7fc5579524c7519f6153b02d0de0000dc0138992
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Issue-ID: INT-1313

docs/docs_vCPE.rst
test/vcpe/healthcheck-k8s.py

index 48b56c2..25c4647 100644 (file)
@@ -136,33 +136,27 @@ Here are the main steps to run the use case in Integration lab environment, wher
 
     vcpe.py infra
 
-13. Install curl command on sdnc container inside sdnc-sdnc-0 pod
-
-::
-
-    sudo apk add curl
-
-14. From Rancher node run vcpe healthcheck command to check connectivity from sdnc to brg and gmux, and vpp configuration of brg and gmux. Write down BRG MAC address printed out at the last line
+13. From Rancher node run vcpe healthcheck command to check connectivity from sdnc to brg and gmux, and vpp configuration of brg and gmux. Write down BRG MAC address printed out at the last line
 
 ::
 
     healthcheck-k8s.py --namespace <namespace name> --environment <env name>
 
-15. Instantiate vCPE customer service. Input the BRG MAC when prompt
+14. Instantiate vCPE customer service. Input the BRG MAC when prompt
 
 ::
 
     vcpe.py customer
 
-16. Update libevel.so in vGMUX VM and restart the VM. This allows vGMUX to send events to VES collector in close loop test. See tutorial wiki for details
+15. Update libevel.so in vGMUX VM and restart the VM. This allows vGMUX to send events to VES collector in close loop test. See tutorial wiki for details
 
-17. Run heatbridge. The heatbridge command usage: demo-k8s.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>, please refer to vCPE tutorial page on how to fill in those paraemters. See an example as following:
+16. Run heatbridge. The heatbridge command usage: demo-k8s.sh <namespace> heatbridge <stack_name> <service_instance_id> <service> <oam-ip-address>, please refer to vCPE tutorial page on how to fill in those paraemters. See an example as following:
 
 ::
 
     ~/integration/test/vcpe# ~/oom/kubernetes/robot/demo-k8s.sh onap heatbridge vcpe_vfmodule_e2744f48729e4072b20b_201811262136 d8914ef3-3fdb-4401-adfe-823ee75dc604 vCPEvGMUX 10.0.101.21
 
-18. Start closed loop test by triggering packet drop VES event, and monitor if vGMUX is restarting. You may need to run the command twice if the first run fails
+17. Start closed loop test by triggering packet drop VES event, and monitor if vGMUX is restarting. You may need to run the command twice if the first run fails
 
 :: 
 
index 2416031..ae33e25 100755 (executable)
@@ -3,7 +3,7 @@
 import argparse
 import json
 import logging
-from subprocess import Popen,PIPE
+from subprocess import Popen,PIPE,STDOUT,check_output,CalledProcessError
 import sys
 
 def parse_args():
@@ -28,7 +28,9 @@ namespace = args.namespace
 environment = args.environment
 
 # config section
-kube_cmd = 'kubectl -n {0} exec {1}-sdnc-sdnc-0 -- bash -c '.format(namespace, environment)
+kube_cmd = 'kubectl -n {0} exec {1}-sdnc-sdnc-0 -c sdnc -- bash -c '.format(namespace, environment)
+curl_check_cmd = 'apk info -e curl'
+curl_install_cmd = 'sudo apk add curl'
 curl_cmd = 'curl -s -u admin:admin -X GET http://{0}:8183/restconf/config/ietf-interfaces:interfaces'
 endpoints = {
     "vGMUX": '10.0.101.21',
@@ -36,6 +38,18 @@ endpoints = {
 }
 # end of config section
 
+# Install curl command in SDNC container
+try:
+    check_output(kube_cmd.split() + [curl_check_cmd], stderr=STDOUT)
+except CalledProcessError:
+    try:
+        check_output(kube_cmd.split() + [curl_install_cmd], stderr=STDOUT)
+    except CalledProcessError:
+        print('Curl package installation failed, exiting.')
+        sys.exit(1)
+    else:
+        print("Curl package was installed in SDNC container")
+
 for ename,eip in endpoints.items():
     print('Checking {0} REST API from SDNC'.format(ename))
     p = Popen(kube_cmd.split() + [curl_cmd.format(eip)], stdout=PIPE, stderr=PIPE)