summaryrefslogtreecommitdiffstats
path: root/testcases/functest_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'testcases/functest_utils.py')
-rw-r--r--testcases/functest_utils.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py
index ef0b8afd2..e76ef991b 100644
--- a/testcases/functest_utils.py
+++ b/testcases/functest_utils.py
@@ -117,6 +117,15 @@ def delete_instance(nova_client, instance_id):
print "Error:", sys.exc_info()[0]
return False
+def create_floating_ip(neutron_client):
+ extnet_id = get_external_net_id(neutron_client)
+ props = {'floating_network_id': extnet_id}
+ try:
+ ip_json = neutron_client.create_floatingip({'floatingip': props})
+ floating_ip = ip_json['floatingip']['floating_ip_address']
+ except:
+ return None
+ return floating_ip
def get_floating_ips(nova_client):
try:
@@ -125,6 +134,13 @@ def get_floating_ips(nova_client):
except:
return None
+def add_floating_ip(nova_client, server_id, floatingip_id):
+ try:
+ nova_client.servers.add_floating_ip(server_id,floatingip_id)
+ return True
+ except:
+ print "Error:", sys.exc_info()[0]
+ return None
def delete_floating_ip(nova_client, floatingip_id):
try:
@@ -227,6 +243,15 @@ def remove_interface_router(neutron_client, router_id, subnet_id):
print "Error:", sys.exc_info()[0]
return False
+def add_gateway_router(neutron_client, router_id):
+ ext_net_id = get_external_net_id(neutron_client)
+ router_dict = {'network_id': ext_net_id}
+ try:
+ neutron_client.add_gateway_router(router_id,router_dict)
+ return True
+ except:
+ print "Error:", sys.exc_info()[0]
+ return False
def remove_gateway_router(neutron_client, router_id):
try:
@@ -323,6 +348,13 @@ def get_external_net(neutron_client):
return False
+def get_external_net_id(neutron_client):
+ for network in neutron_client.list_networks()['networks']:
+ if network['router:external']:
+ return network['id']
+ return False
+
+
def update_sg_quota(neutron_client, tenant_id, sg_quota, sg_rule_quota):
json_body = {"quota": {
"security_group": sg_quota,