summaryrefslogtreecommitdiffstats
path: root/testcases/functest_utils.py
diff options
context:
space:
mode:
authormei mei <meimei@huawei.com>2016-01-20 01:16:03 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-01-20 01:16:03 +0000
commit4f0ed6bee0ec6ec3d55da5684f96ea9741b14b57 (patch)
treeb3fe8b2bb0ac525ed059eb97a401239676d49c69 /testcases/functest_utils.py
parent16e9bf66c5737e725a09064783599eb94e215095 (diff)
parent625dde8e972f2586e986a46225ce87ebd3823b79 (diff)
Merge "Added vPing2 using SCP and SSH instead of nova userdata"
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,