Levage on Neutron Floating IP support

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 <ollivier.cedric@gmail.com>
This commit is contained in:
Cédric Ollivier 2018-07-09 08:17:39 +02:00
parent 3a3d8c8a65
commit 9c016e3f96
2 changed files with 10 additions and 22 deletions

View File

@ -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)

View File

@ -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)