aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Ptacek <m.ptacek@partner.samsung.com>2019-08-20 11:37:43 +0000
committerMichal Ptacek <m.ptacek@partner.samsung.com>2019-08-20 11:40:21 +0000
commit995fd6e9bb0368ebbf87f38bd207c4a818443991 (patch)
treeb20b9bbe6c74f250b81a8bdfd3db4b3e9fdfb318
parent1d313be98083464b7674a54d5e1f93cad44d4417 (diff)
Making environment name configurable in vcpe healthcheck
Improving handling of arguments in healthcheck-k8s.py, making environment name configurable. Issue-ID: INT-1213 Change-Id: Ib6e2875f351f095bd64acd706a6060e169c54e79 Signed-off-by: Michal Ptacek <m.ptacek@partner.samsung.com>
-rwxr-xr-xtest/vcpe/healthcheck-k8s.py37
1 files changed, 26 insertions, 11 deletions
diff --git a/test/vcpe/healthcheck-k8s.py b/test/vcpe/healthcheck-k8s.py
index 04c6f158e..d16128510 100755
--- a/test/vcpe/healthcheck-k8s.py
+++ b/test/vcpe/healthcheck-k8s.py
@@ -1,34 +1,49 @@
#! /usr/bin/python
-import logging
-import json
+import argparse
import commands
-import sys
+import json
+import logging
import subprocess
+import sys
+
+def parse_args():
+ """
+ Parse command line arguments
+ :return: arguments
+ """
+ parser = argparse.ArgumentParser(description='Processing arguments for vCPE healthcheck')
+ parser.add_argument('--namespace', default="onap",
+ metavar=('<namespace_name>'),
+ help='Namespace name for existing ONAP deployment')
+ parser.add_argument('--environment', default="dev",
+ metavar=('<environment_name>'),
+ help='Environment name for existing ONAP deployment visible in <environment_name>-sdnc-sdnc-0 pod name')
+ args = parser.parse_args()
+ return args
+
-if len(sys.argv) <2:
- print('namespace not provided')
- print('Usage: healthcheck-k8s.py onap')
- sys.exit()
+args = parse_args()
-namespace=sys.argv[1]
+namespace = args.namespace
+environment = args.environment
print('Checking vGMUX REST API from SDNC')
cmd = 'curl -s -u admin:admin -X GET http://10.0.101.21:8183/restconf/config/ietf-interfaces:interfaces'
-ret = commands.getstatusoutput("kubectl -n {0} exec dev-sdnc-sdnc-0 -- bash -c '{1}'".format(namespace,cmd))
+ret = commands.getstatusoutput("kubectl -n {0} exec {1}-sdnc-sdnc-0 -- bash -c '{2}'".format(args.namespace, args.environment, cmd))
sz = ret[-1].split('\n')[-1]
print(json.dumps(json.loads(sz), indent=4))
print('\n')
print('Checking vBRG REST API from SDNC')
cmd = 'curl -s -u admin:admin -X GET http://10.3.0.2:8183/restconf/config/ietf-interfaces:interfaces'
-ret = commands.getstatusoutput("kubectl -n {0} exec dev-sdnc-sdnc-0 -- bash -c '{1}'".format(namespace,cmd))
+ret = commands.getstatusoutput("kubectl -n {0} exec {1}-sdnc-sdnc-0 -- bash -c '{2}'".format(args.namespace, args.environment, cmd))
sz = ret[-1].split('\n')[-1]
print(json.dumps(json.loads(sz), indent=4))
print('\n')
print('Checking SDNC DB for vBRG MAC address')
-cmd = "kubectl exec dev-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword sdnctl -e 'select * from DHCP_MAP'"
+cmd = "kubectl -n {0} exec {1}-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword sdnctl -e 'select * from DHCP_MAP'".format(args.namespace, args.environment)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
(output, error) = p.communicate()
print(output)