Brian Freeman | 81f6e9e | 2018-11-11 22:36:20 -0500 | [diff] [blame] | 1 | #! /usr/bin/python |
| 2 | |
| 3 | import logging |
| 4 | import json |
Brian Freeman | 81f6e9e | 2018-11-11 22:36:20 -0500 | [diff] [blame] | 5 | import commands |
| 6 | import sys |
Yang Xu | aa8c584 | 2019-01-02 12:05:40 -0500 | [diff] [blame] | 7 | import subprocess |
Brian Freeman | 81f6e9e | 2018-11-11 22:36:20 -0500 | [diff] [blame] | 8 | |
| 9 | if len(sys.argv) <2: |
| 10 | print('namespace not provided') |
| 11 | print('Usage: healthcheck-k8s.py onap') |
| 12 | sys.exit() |
| 13 | |
| 14 | namespace=sys.argv[1] |
| 15 | |
Brian Freeman | 81f6e9e | 2018-11-11 22:36:20 -0500 | [diff] [blame] | 16 | print('Checking vGMUX REST API from SDNC') |
Yang Xu | aa8c584 | 2019-01-02 12:05:40 -0500 | [diff] [blame] | 17 | cmd = 'curl -s -u admin:admin -X GET http://10.0.101.21:8183/restconf/config/ietf-interfaces:interfaces' |
Brian Freeman | 81f6e9e | 2018-11-11 22:36:20 -0500 | [diff] [blame] | 18 | ret = commands.getstatusoutput("kubectl -n {0} exec dev-sdnc-sdnc-0 -- bash -c '{1}'".format(namespace,cmd)) |
| 19 | sz = ret[-1].split('\n')[-1] |
Yang Xu | aa8c584 | 2019-01-02 12:05:40 -0500 | [diff] [blame] | 20 | print(json.dumps(json.loads(sz), indent=4)) |
Brian Freeman | 81f6e9e | 2018-11-11 22:36:20 -0500 | [diff] [blame] | 21 | |
Yang Xu | aa8c584 | 2019-01-02 12:05:40 -0500 | [diff] [blame] | 22 | print('\n') |
Brian Freeman | 81f6e9e | 2018-11-11 22:36:20 -0500 | [diff] [blame] | 23 | print('Checking vBRG REST API from SDNC') |
Yang Xu | aa8c584 | 2019-01-02 12:05:40 -0500 | [diff] [blame] | 24 | cmd = 'curl -s -u admin:admin -X GET http://10.3.0.2:8183/restconf/config/ietf-interfaces:interfaces' |
Brian Freeman | 81f6e9e | 2018-11-11 22:36:20 -0500 | [diff] [blame] | 25 | ret = commands.getstatusoutput("kubectl -n {0} exec dev-sdnc-sdnc-0 -- bash -c '{1}'".format(namespace,cmd)) |
| 26 | sz = ret[-1].split('\n')[-1] |
Yang Xu | aa8c584 | 2019-01-02 12:05:40 -0500 | [diff] [blame] | 27 | print(json.dumps(json.loads(sz), indent=4)) |
Brian Freeman | 81f6e9e | 2018-11-11 22:36:20 -0500 | [diff] [blame] | 28 | |
Yang Xu | aa8c584 | 2019-01-02 12:05:40 -0500 | [diff] [blame] | 29 | print('\n') |
Brian Freeman | 81f6e9e | 2018-11-11 22:36:20 -0500 | [diff] [blame] | 30 | print('Checking SDNC DB for vBRG MAC address') |
Yang Xu | aa8c584 | 2019-01-02 12:05:40 -0500 | [diff] [blame] | 31 | cmd = "kubectl -n onap exec dev-sdnc-sdnc-db-0 -c sdnc-db -- mysql -usdnctl -pgamma sdnctl -e 'select * from DHCP_MAP;'" |
| 32 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) |
| 33 | (output, error) = p.communicate() |
| 34 | print(output) |
Brian Freeman | 81f6e9e | 2018-11-11 22:36:20 -0500 | [diff] [blame] | 35 | |