aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2018-11-22 04:44:06 +0000
committerGerrit Code Review <gerrit@onap.org>2018-11-22 04:44:06 +0000
commit098b666ab5018ac75535ab0809a02825f5dfd9c6 (patch)
tree95c7b6e7bda9c8eb29c4c466410f800ff19ce7d7 /test
parent0c2002628c129e648c63772d1784f217de5d2f1a (diff)
parent78f01f5ddf7035c7c88319cd03684e299ec27d9a (diff)
Merge "Add a script to clean up VPP vxlan interfaces" into casablanca
Diffstat (limited to 'test')
-rw-r--r--test/vcpe/cleanvGMUX.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/test/vcpe/cleanvGMUX.py b/test/vcpe/cleanvGMUX.py
new file mode 100644
index 000000000..fe586fe53
--- /dev/null
+++ b/test/vcpe/cleanvGMUX.py
@@ -0,0 +1,64 @@
+#! /usr/bin/python
+
+import sys
+import logging
+import requests
+import json
+from datetime import datetime
+import time
+
+gmux_ip = '10.12.6.115'
+logging.basicConfig(level=logging.DEBUG, format='%(message)s')
+logger = logging.getLogger('')
+headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
+auth = 'admin', 'admin'
+base_url = 'http://{0}:8183/restconf/config/ietf-interfaces:interfaces'.format(gmux_ip)
+
+def list_interface():
+ url = base_url
+ logger.info(url)
+ r = requests.get(url, headers=headers, auth=auth)
+ logger.debug(r)
+ response = r.json()
+
+ logger.debug('---------------------------------------------------------------')
+ logger.debug(json.dumps(response, indent=4, sort_keys=True))
+ logger.debug('---------------------------------------------------------------')
+
+def clean_gmux():
+ url = base_url
+ r = requests.get(url, headers=headers, auth=auth)
+ response = r.json()
+
+ interfaces = response.get('interfaces').get('interface')
+ for inf in interfaces:
+ name = inf.get('name')
+ if name.startswith('vxlanTun10'):
+ logger.debug('name = {0}'.format(name))
+ delete_interface_v3po_l2(name)
+
+ for inf in interfaces:
+ name = inf.get('name')
+ if name.startswith('vxlanTun10'):
+ logger.debug('name = {0}'.format(name))
+ delete_interface(name)
+
+def delete_interface_v3po_l2(interface_name):
+ url = '{0}/interface/{1}/v3po:l2'.format(base_url, interface_name)
+ r = requests.delete(url, headers=headers, auth=auth)
+ logger.debug(r)
+
+def delete_interface(interface_name):
+ url = '{0}/interface/{1}'.format(base_url, interface_name)
+ r = requests.delete(url, headers=headers, auth=auth)
+ logger.debug(r)
+
+if __name__ == '__main__':
+ logger.debug('---------------------------------------------------------------')
+ logger.debug('list interfaces before cleaning gmux')
+ list_interface()
+ clean_gmux()
+ logger.debug('---------------------------------------------------------------')
+ logger.debug('list interfaces after cleaning gmux')
+ list_interface()
+