From 9c016e3f9683ae557e8271ef358d9c1b59126cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Ollivier?= Date: Mon, 9 Jul 2018 08:17:39 +0200 Subject: [PATCH] Levage on Neutron Floating IP support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Floating IP support was removed from Nova client. Else Vmtp cannot work vs OpenStack Queens. Closes-Bug: #1776082 Change-Id: I34d810aac537663fd638cd0a5dc950b7dafab92f Signed-off-by: Cédric Ollivier --- vmtp/instance.py | 27 +++++++-------------------- vmtp/network.py | 5 +++-- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/vmtp/instance.py b/vmtp/instance.py index 511600f..1f16a48 100644 --- a/vmtp/instance.py +++ b/vmtp/instance.py @@ -18,9 +18,7 @@ import re from log import LOG import monitor import netaddr -from novaclient.exceptions import BadRequest import sshutils -import time # a dictionary of sequence number indexed by a name prefix @@ -175,32 +173,21 @@ class Instance(object): else: # Set the internal ip to the correct ip for v4 and v6 for ip_address in self.instance.networks[internal_network_name]: - ip = netaddr.IPAddress(ip_address) - if self.config.ipv6_mode: - if ip.version == 6: - self.internal_ip = ip_address - else: - ipv4_fixed_address = ip_address - else: - if ip.version == 4: - self.internal_ip = ip_address - ipv4_fixed_address = ip_address + self.internal_ip = ip_address if self.no_floatingip: self.ssh_access.host = self.internal_ip else: - fip = self.net.create_floating_ip() + interface_list = self.instance.interface_list() + if not interface_list: + self.display('Cannot find port id for %s.', self.name) + return False + port_id = interface_list[0].id + fip = self.net.create_floating_ip(port_id) if not fip: self.display('Floating ip creation failed.') return False self.ssh_access.host = fip['floatingip']['floating_ip_address'] self.ssh_ip_id = fip['floatingip']['id'] - self.display('Associating floating IP %s', self.ssh_access.host) - for _ in range(1, 5): - try: - self.instance.add_floating_ip(self.ssh_access.host, ipv4_fixed_address) - break - except BadRequest: - time.sleep(1) # extract the IP for the data network self.display('Internal network IP: %s', self.internal_ip) diff --git a/vmtp/network.py b/vmtp/network.py index ea28f79..52b3b14 100644 --- a/vmtp/network.py +++ b/vmtp/network.py @@ -331,10 +331,11 @@ class Network(object): # Create a floating ip on the external network and return it - def create_floating_ip(self): + def create_floating_ip(self, port_id): body = { "floatingip": { - "floating_network_id": self.ext_net['id'] + "floating_network_id": self.ext_net['id'], + "port_id": port_id } } fip = self.neutron_client.create_floatingip(body)