diff options
-rw-r--r-- | sdnvpn/lib/openstack_utils.py | 12 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_3.py | 13 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_7.py | 11 | ||||
-rw-r--r-- | sdnvpn/test/functest/testcase_8.py | 12 |
4 files changed, 32 insertions, 16 deletions
diff --git a/sdnvpn/lib/openstack_utils.py b/sdnvpn/lib/openstack_utils.py index a7ac80b..29843f0 100644 --- a/sdnvpn/lib/openstack_utils.py +++ b/sdnvpn/lib/openstack_utils.py @@ -539,6 +539,18 @@ def create_floating_ip(neutron_client): return {'fip_addr': fip_addr, 'fip_id': fip_id} +def attach_floating_ip(neutron_client, port_id): + extnet_id = get_external_net_id(neutron_client) + props = {'floating_network_id': extnet_id, + 'port_id': port_id} + try: + return neutron_client.create_floatingip({'floatingip': props}) + except Exception as e: + logger.error("Error [Attach_floating_ip(neutron_client), %s]: %s" + % (port_id, e)) + return None + + def add_floating_ip(nova_client, server_id, floatingip_addr): try: nova_client.servers.add_floating_ip(server_id, floatingip_addr) diff --git a/sdnvpn/test/functest/testcase_3.py b/sdnvpn/test/functest/testcase_3.py index b7fe642..7f70043 100644 --- a/sdnvpn/test/functest/testcase_3.py +++ b/sdnvpn/test/functest/testcase_3.py @@ -234,13 +234,11 @@ def main(): # this to work. # We also create the FIP first because it is used in the # cloud-init script. - fip = os_utils.create_floating_ip(neutron_client) # fake_fip is needed to bypass NAT # see below for the reason why. fake_fip = os_utils.create_floating_ip(neutron_client) - - floatingip_ids.extend([fip['fip_id'], fake_fip['fip_id']]) # pin quagga to some compute + floatingip_ids.append(fake_fip['fip_id']) compute_node = nova_client.hypervisors.list()[0] quagga_compute_node = "nova:" + compute_node.hypervisor_hostname # Map the hypervisor used above to a compute handle @@ -267,16 +265,19 @@ def main(): instance_ids.append(quagga_vm) - fip_added = os_utils.add_floating_ip(nova_client, - quagga_vm.id, - fip['fip_addr']) + quagga_vm_port = test_utils.get_port(neutron_client, + quagga_vm.id) + fip_added = os_utils.attach_floating_ip(neutron_client, + quagga_vm_port['id']) msg = ("Assign a Floating IP to %s " % TESTCASE_CONFIG.quagga_instance_name) if fip_added: results.add_success(msg) + floatingip_ids.append(fip_added['floatingip']['id']) else: results.add_failure(msg) + test_utils.attach_instance_to_ext_br(quagga_vm, compute) try: diff --git a/sdnvpn/test/functest/testcase_7.py b/sdnvpn/test/functest/testcase_7.py index ada45a5..1ad0538 100644 --- a/sdnvpn/test/functest/testcase_7.py +++ b/sdnvpn/test/functest/testcase_7.py @@ -151,17 +151,18 @@ def main(): results.record_action(msg) results.add_to_summary(0, '-') - fip = os_utils.create_floating_ip(neutron_client) - fip_added = os_utils.add_floating_ip(nova_client, vm_2.id, - fip['fip_addr']) + vm2_port = test_utils.get_port(neutron_client, + vm_2.id) + fip_added = os_utils.attach_floating_ip(neutron_client, + vm2_port['id']) if fip_added: results.add_success(msg) else: results.add_failure(msg) - results.ping_ip_test(fip['fip_addr']) + results.ping_ip_test(fip_added['floatingip']['floating_ip_address']) - floatingip_ids.append(fip['fip_id']) + floatingip_ids.append(fip_added['floatingip']['id']) except Exception as e: logger.error("exception occurred while executing testcase_7: %s", e) diff --git a/sdnvpn/test/functest/testcase_8.py b/sdnvpn/test/functest/testcase_8.py index e667dba..6336f46 100644 --- a/sdnvpn/test/functest/testcase_8.py +++ b/sdnvpn/test/functest/testcase_8.py @@ -154,21 +154,23 @@ def main(): msg = "Assign a Floating IP to %s" % vm_1.name results.record_action(msg) - fip = os_utils.create_floating_ip(neutron_client) + vm1_port = test_utils.get_port(neutron_client, vm_1.id) + fip_added = os_utils.attach_floating_ip(neutron_client, + vm1_port['id']) - fip_added = os_utils.add_floating_ip(nova_client, - vm_1.id, fip['fip_addr']) if fip_added: results.add_success(msg) else: results.add_failure(msg) + fip = fip_added['floatingip']['floating_ip_address'] + results.add_to_summary(0, "=") results.record_action("Ping %s via Floating IP" % vm_1.name) results.add_to_summary(0, "-") - results.ping_ip_test(fip['fip_addr']) + results.ping_ip_test(fip) - floatingip_ids.append(fip['fip_id']) + floatingip_ids.append(fip_added['floatingip']['id']) except Exception as e: logger.error("exception occurred while executing testcase_8: %s", e) |