aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sfc/lib/cleanup.py8
-rw-r--r--sfc/lib/utils.py28
2 files changed, 36 insertions, 0 deletions
diff --git a/sfc/lib/cleanup.py b/sfc/lib/cleanup.py
index 34ace201..ebcb9aa9 100644
--- a/sfc/lib/cleanup.py
+++ b/sfc/lib/cleanup.py
@@ -18,6 +18,13 @@ def delete_odl_resources(odl_ip, odl_port, resource):
utils.delete_odl_resource_elem(odl_ip, odl_port, resource, elem)
+def delete_odl_ietf_access_lists(odl_ip, odl_port):
+ acl_list = utils.get_odl_acl_list(odl_ip, odl_port)
+ acl_types_names = utils.odl_acl_types_names(acl_list)
+ for acl_type, acl_name in acl_types_names:
+ utils.delete_odl_acl(odl_ip, odl_port, acl_type, acl_name)
+
+
def delete_vnfds():
t = os_tacker.get_tacker_client()
vnfds = os_tacker.list_vnfds(t)
@@ -92,6 +99,7 @@ def cleanup_odl(odl_ip, odl_port):
delete_odl_resources(odl_ip, odl_port, 'service-function-chain')
delete_odl_resources(odl_ip, odl_port, 'service-function-path')
delete_odl_resources(odl_ip, odl_port, 'service-function')
+ delete_odl_ietf_access_lists(odl_ip, odl_port)
def cleanup(odl_ip=None, odl_port=None):
diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py
index 99f0bb75..f0f24338 100644
--- a/sfc/lib/utils.py
+++ b/sfc/lib/utils.py
@@ -522,3 +522,31 @@ def get_odl_resource_list(odl_ip, odl_port, resource):
def delete_odl_resource_elem(odl_ip, odl_port, resource, elem_name):
url = format_odl_resource_elem_url(odl_ip, odl_port, resource, elem_name)
requests.delete(url)
+
+
+def odl_acl_types_names(acl_json):
+ if len(acl_json['access-lists'].items()) == 0:
+ return []
+ return [(acl['acl-type'], acl['acl-name'])
+ for acl in acl_json['access-lists']['acl']]
+
+
+def format_odl_acl_list_url(odl_ip, odl_port,
+ odl_user='admin', odl_pwd='admin'):
+ acl_list_url = ('http://{usr}:{pwd}@{ip}:{port}/restconf/config/'
+ 'ietf-access-control-list:access-lists'
+ .format(usr=odl_user, pwd=odl_pwd,
+ ip=odl_ip, port=odl_port))
+ return acl_list_url
+
+
+def get_odl_acl_list(odl_ip, odl_port):
+ acl_list_url = format_odl_acl_list_url(odl_ip, odl_port)
+ r = requests.get(acl_list_url)
+ return r.json()
+
+
+def delete_odl_acl(odl_ip, odl_port, acl_type, acl_name):
+ acl_list_url = format_odl_acl_list_url(odl_ip, odl_port)
+ acl_url = '{0}/acl/{1}/{2}'.format(acl_list_url, acl_type, acl_name)
+ requests.delete(acl_url)