blob: d16128510dfb045b93874b2909d33bd3afa9839f [file] [log] [blame]
Brian Freeman81f6e9e2018-11-11 22:36:20 -05001#! /usr/bin/python
2
Michal Ptacek995fd6e2019-08-20 11:37:43 +00003import argparse
Brian Freeman81f6e9e2018-11-11 22:36:20 -05004import commands
Michal Ptacek995fd6e2019-08-20 11:37:43 +00005import json
6import logging
Yang Xuaa8c5842019-01-02 12:05:40 -05007import subprocess
Michal Ptacek995fd6e2019-08-20 11:37:43 +00008import sys
Brian Freeman81f6e9e2018-11-11 22:36:20 -05009
Michal Ptacek995fd6e2019-08-20 11:37:43 +000010def parse_args():
11 """
12 Parse command line arguments
13 :return: arguments
14 """
15 parser = argparse.ArgumentParser(description='Processing arguments for vCPE healthcheck')
16 parser.add_argument('--namespace', default="onap",
17 metavar=('<namespace_name>'),
18 help='Namespace name for existing ONAP deployment')
19 parser.add_argument('--environment', default="dev",
20 metavar=('<environment_name>'),
21 help='Environment name for existing ONAP deployment visible in <environment_name>-sdnc-sdnc-0 pod name')
22 args = parser.parse_args()
23 return args
Brian Freeman81f6e9e2018-11-11 22:36:20 -050024
Michal Ptacek995fd6e2019-08-20 11:37:43 +000025
26args = parse_args()
27
28namespace = args.namespace
29environment = args.environment
Brian Freeman81f6e9e2018-11-11 22:36:20 -050030
Brian Freeman81f6e9e2018-11-11 22:36:20 -050031print('Checking vGMUX REST API from SDNC')
Yang Xuaa8c5842019-01-02 12:05:40 -050032cmd = 'curl -s -u admin:admin -X GET http://10.0.101.21:8183/restconf/config/ietf-interfaces:interfaces'
Michal Ptacek995fd6e2019-08-20 11:37:43 +000033ret = commands.getstatusoutput("kubectl -n {0} exec {1}-sdnc-sdnc-0 -- bash -c '{2}'".format(args.namespace, args.environment, cmd))
Brian Freeman81f6e9e2018-11-11 22:36:20 -050034sz = ret[-1].split('\n')[-1]
Yang Xuaa8c5842019-01-02 12:05:40 -050035print(json.dumps(json.loads(sz), indent=4))
Brian Freeman81f6e9e2018-11-11 22:36:20 -050036
Yang Xuaa8c5842019-01-02 12:05:40 -050037print('\n')
Brian Freeman81f6e9e2018-11-11 22:36:20 -050038print('Checking vBRG REST API from SDNC')
Yang Xuaa8c5842019-01-02 12:05:40 -050039cmd = 'curl -s -u admin:admin -X GET http://10.3.0.2:8183/restconf/config/ietf-interfaces:interfaces'
Michal Ptacek995fd6e2019-08-20 11:37:43 +000040ret = commands.getstatusoutput("kubectl -n {0} exec {1}-sdnc-sdnc-0 -- bash -c '{2}'".format(args.namespace, args.environment, cmd))
Brian Freeman81f6e9e2018-11-11 22:36:20 -050041sz = ret[-1].split('\n')[-1]
Yang Xuaa8c5842019-01-02 12:05:40 -050042print(json.dumps(json.loads(sz), indent=4))
Brian Freeman81f6e9e2018-11-11 22:36:20 -050043
Yang Xuaa8c5842019-01-02 12:05:40 -050044print('\n')
Brian Freeman81f6e9e2018-11-11 22:36:20 -050045print('Checking SDNC DB for vBRG MAC address')
Michal Ptacek995fd6e2019-08-20 11:37:43 +000046cmd = "kubectl -n {0} exec {1}-mariadb-galera-mariadb-galera-0 -- mysql -uroot -psecretpassword sdnctl -e 'select * from DHCP_MAP'".format(args.namespace, args.environment)
Yang Xuaa8c5842019-01-02 12:05:40 -050047p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
48(output, error) = p.communicate()
49print(output)
Brian Freeman81f6e9e2018-11-11 22:36:20 -050050