From de38fad9969934794fd68acb77811d51f581ccd8 Mon Sep 17 00:00:00 2001 From: Yichen Wang Date: Thu, 9 May 2019 15:11:32 -0700 Subject: [PATCH] Fix compability issue for adding floating ip to VM Change-Id: I4dd7603f044499185c5d870f4dc7771c8fdf6769 --- kloudbuster/base_network.py | 7 ++++--- kloudbuster/cfg.scale.yaml | 2 +- kloudbuster/kloudbuster.py | 14 +++++--------- kloudbuster/users.py | 2 +- test-requirements.txt | 2 +- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/kloudbuster/base_network.py b/kloudbuster/base_network.py index 645875f..73b3c38 100644 --- a/kloudbuster/base_network.py +++ b/kloudbuster/base_network.py @@ -35,17 +35,18 @@ class KBGetExtNetException(Exception): class KBGetProvNetException(Exception): pass -def create_floating_ip(neutron_client, ext_net): +def create_floating_ip(neutron_client, ext_net, port_id): """ Function that creates a floating ip and returns it - Accepts the neutron client and ext_net + Accepts the neutron client, ext_net, and port_id Module level function since this is not associated with a specific network instance """ body = { "floatingip": { - "floating_network_id": ext_net['id'] + "floating_network_id": ext_net['id'], + "port_id": port_id } } fip = neutron_client.create_floatingip(body) diff --git a/kloudbuster/cfg.scale.yaml b/kloudbuster/cfg.scale.yaml index 67edbb5..018d6dd 100644 --- a/kloudbuster/cfg.scale.yaml +++ b/kloudbuster/cfg.scale.yaml @@ -62,7 +62,7 @@ vm_creation_concurrency: 5 public_key_file: # Name of Provider network used for multicast tests or storage tests. -provider_network_name: +provider_network: # TSDB connectors are optional and can be used to retrieve CPU usage information and attach them # to the results. diff --git a/kloudbuster/kloudbuster.py b/kloudbuster/kloudbuster.py index 1b26b65..035cbd5 100755 --- a/kloudbuster/kloudbuster.py +++ b/kloudbuster/kloudbuster.py @@ -255,20 +255,16 @@ class Kloud(object): instance.fip = None elif instance.vm_name == "KB-PROXY" and not u_fip and not self.multicast_mode: neutron_client = instance.network.router.user.neutron_client - external_network = base_network.find_external_network(neutron_client) - instance.fip = base_network.create_floating_ip(neutron_client, external_network) + ext_net = base_network.find_external_network(neutron_client) + port_id = instance.instance.interface_list()[0].id + # Associate the floating ip with this instance + instance.fip = base_network.create_floating_ip(neutron_client, ext_net, port_id) instance.fip_ip = instance.fip['floatingip']['floating_ip_address'] self.res_logger.log('floating_ips', instance.fip['floatingip']['floating_ip_address'], instance.fip['floatingip']['id']) - if instance.fip: - # Associate the floating ip with this instance - instance.instance.add_floating_ip(instance.fip_ip) - instance.ssh_ip = instance.fip_ip - else: - # Store the fixed ip as ssh ip since there is no floating ip - instance.ssh_ip = instance.fixed_ip + instance.ssh_ip = instance.fip_ip if instance.fip else instance.fixed_ip if not instance.vm_name == "KB-PROXY" and self.multicast_mode: nc = instance.network.router.user.neutron_client diff --git a/kloudbuster/users.py b/kloudbuster/users.py index 3cb3d90..f7b4dc1 100644 --- a/kloudbuster/users.py +++ b/kloudbuster/users.py @@ -146,7 +146,7 @@ class User(object): if self.tenant.kloud.multicast_mode or ( self.tenant.kloud.storage_mode and config_scale.provider_network): router_instance = base_network.Router( - self, provider_network=config_scale.provider_network_name) + self, provider_network=config_scale.provider_network) self.router_list.append(router_instance) router_instance.create_network_resources(config_scale) else: diff --git a/test-requirements.txt b/test-requirements.txt index cfa963c..e01e7d7 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,7 +7,7 @@ hacking<0.11,>=0.10.0 coverage>=3.6 discover python-subunit>=0.0.18 -sphinx>=1.4.0 +sphinx>=1.4.0,<2.0 sphinx_rtd_theme>=0.1.9 oslosphinx>=2.5.0 # Apache-2.0 oslotest>=1.10.0 # Apache-2.0