summaryrefslogtreecommitdiffstats
path: root/sdnvpn/lib/utils.py
diff options
context:
space:
mode:
authorpanageo2 <panageo@intracom-telecom.com>2017-06-28 12:34:55 +0000
committerpanageo2 <panageo@intracom-telecom.com>2017-06-28 13:05:53 +0000
commit916e904bea22193e8160894f8eea999bf965cde2 (patch)
tree496210ba7aaf5880a6a520ff55cf819f2fef4672 /sdnvpn/lib/utils.py
parent4a6bb979b45c3b7f00f9dcc9519f439b3d405189 (diff)
Transfer utils functions from functest
Transfer functions: - create_bgpvpn - create_network_association - create_router_association - update_bgpvpn - delete_bgpvpn - get_bgpvpn - get_bgpvpn_routers - get_bgpvpn_networks from functest/utils/openstack_utils.py to sdnvpn/lib/utils.py JIRA: SDNVPN-164 JIRA: FUNCTEST-840 Change-Id: Ic64d8ee85e74601b0fe51e1c452cf83fa6b0203b Signed-off-by: panageo2 <panageo@intracom-telecom.com>
Diffstat (limited to 'sdnvpn/lib/utils.py')
-rw-r--r--sdnvpn/lib/utils.py44
1 files changed, 41 insertions, 3 deletions
diff --git a/sdnvpn/lib/utils.py b/sdnvpn/lib/utils.py
index 7e41d41..78bd09e 100644
--- a/sdnvpn/lib/utils.py
+++ b/sdnvpn/lib/utils.py
@@ -279,7 +279,7 @@ def wait_for_bgp_net_assoc(neutron_client, bgpvpn_id, net_id):
% (bgpvpn_id, net_id))
while tries > 0 and net_id not in nets:
- nets = os_utils.get_bgpvpn_networks(neutron_client, bgpvpn_id)
+ nets = get_bgpvpn_networks(neutron_client, bgpvpn_id)
time.sleep(sleep_time)
tries -= 1
if net_id not in nets:
@@ -303,7 +303,7 @@ def wait_for_bgp_router_assoc(neutron_client, bgpvpn_id, router_id):
logger.debug("Waiting for router %s to associate with BGPVPN %s "
% (bgpvpn_id, router_id))
while tries > 0 and router_id not in routers:
- routers = os_utils.get_bgpvpn_routers(neutron_client, bgpvpn_id)
+ routers = get_bgpvpn_routers(neutron_client, bgpvpn_id)
time.sleep(sleep_time)
tries -= 1
if router_id not in routers:
@@ -543,7 +543,7 @@ def cleanup_neutron(neutron_client, bgpvpn_ids, interfaces, subnet_ids,
if len(bgpvpn_ids) != 0:
for bgpvpn_id in bgpvpn_ids:
- os_utils.delete_bgpvpn(neutron_client, bgpvpn_id)
+ delete_bgpvpn(neutron_client, bgpvpn_id)
if len(interfaces) != 0:
for router_id, subnet_id in interfaces:
@@ -612,3 +612,41 @@ def cleanup_nova(nova_client, floatingip_ids, instance_ids, image_ids):
format(image_id))
return False
return True
+
+
+def create_bgpvpn(neutron_client, **kwargs):
+ # route_distinguishers
+ # route_targets
+ json_body = {"bgpvpn": kwargs}
+ return neutron_client.create_bgpvpn(json_body)
+
+
+def update_bgpvpn(neutron_client, bgpvpn_id, **kwargs):
+ json_body = {"bgpvpn": kwargs}
+ return neutron_client.update_bgpvpn(bgpvpn_id, json_body)
+
+
+def delete_bgpvpn(neutron_client, bgpvpn_id):
+ return neutron_client.delete_bgpvpn(bgpvpn_id)
+
+
+def get_bgpvpn(neutron_client, bgpvpn_id):
+ return neutron_client.show_bgpvpn(bgpvpn_id)
+
+
+def get_bgpvpn_routers(neutron_client, bgpvpn_id):
+ return get_bgpvpn(neutron_client, bgpvpn_id)['bgpvpn']['routers']
+
+
+def get_bgpvpn_networks(neutron_client, bgpvpn_id):
+ return get_bgpvpn(neutron_client, bgpvpn_id)['bgpvpn']['networks']
+
+
+def create_router_association(neutron_client, bgpvpn_id, router_id):
+ json_body = {"router_association": {"router_id": router_id}}
+ return neutron_client.create_router_association(bgpvpn_id, json_body)
+
+
+def create_network_association(neutron_client, bgpvpn_id, neutron_network_id):
+ json_body = {"network_association": {"network_id": neutron_network_id}}
+ return neutron_client.create_network_association(bgpvpn_id, json_body)