diff options
Diffstat (limited to 'testcases/functest_utils.py')
-rw-r--r-- | testcases/functest_utils.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py index baab415d..d9f43a79 100644 --- a/testcases/functest_utils.py +++ b/testcases/functest_utils.py @@ -116,6 +116,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: @@ -124,6 +133,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: @@ -226,6 +242,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: @@ -322,6 +347,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, |