Browse Source

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>
tags/2.4.8
Cédric Ollivier 11 months ago
parent
commit
9c016e3f96
2 changed files with 10 additions and 22 deletions
  1. 7
    20
      vmtp/instance.py
  2. 3
    2
      vmtp/network.py

+ 7
- 20
vmtp/instance.py View File

@@ -18,9 +18,7 @@ import re
18 18
 from log import LOG
19 19
 import monitor
20 20
 import netaddr
21
-from novaclient.exceptions import BadRequest
22 21
 import sshutils
23
-import time
24 22
 
25 23
 
26 24
 # a dictionary of sequence number indexed by a name prefix
@@ -175,32 +173,21 @@ class Instance(object):
175 173
         else:
176 174
             # Set the internal ip to the correct ip for v4 and v6
177 175
             for ip_address in self.instance.networks[internal_network_name]:
178
-                ip = netaddr.IPAddress(ip_address)
179
-                if self.config.ipv6_mode:
180
-                    if ip.version == 6:
181
-                        self.internal_ip = ip_address
182
-                    else:
183
-                        ipv4_fixed_address = ip_address
184
-                else:
185
-                    if ip.version == 4:
186
-                        self.internal_ip = ip_address
187
-                        ipv4_fixed_address = ip_address
176
+                self.internal_ip = ip_address
188 177
             if self.no_floatingip:
189 178
                 self.ssh_access.host = self.internal_ip
190 179
             else:
191
-                fip = self.net.create_floating_ip()
180
+                interface_list = self.instance.interface_list()
181
+                if not interface_list:
182
+                    self.display('Cannot find port id for %s.', self.name)
183
+                    return False
184
+                port_id = interface_list[0].id
185
+                fip = self.net.create_floating_ip(port_id)
192 186
                 if not fip:
193 187
                     self.display('Floating ip creation failed.')
194 188
                     return False
195 189
                 self.ssh_access.host = fip['floatingip']['floating_ip_address']
196 190
                 self.ssh_ip_id = fip['floatingip']['id']
197
-                self.display('Associating floating IP %s', self.ssh_access.host)
198
-                for _ in range(1, 5):
199
-                    try:
200
-                        self.instance.add_floating_ip(self.ssh_access.host, ipv4_fixed_address)
201
-                        break
202
-                    except BadRequest:
203
-                        time.sleep(1)
204 191
 
205 192
         # extract the IP for the data network
206 193
         self.display('Internal network IP: %s', self.internal_ip)

+ 3
- 2
vmtp/network.py View File

@@ -331,10 +331,11 @@ class Network(object):
331 331
 
332 332
 
333 333
     # Create a floating ip on the external network and return it
334
-    def create_floating_ip(self):
334
+    def create_floating_ip(self, port_id):
335 335
         body = {
336 336
             "floatingip": {
337
-                "floating_network_id": self.ext_net['id']
337
+                "floating_network_id": self.ext_net['id'],
338
+                "port_id": port_id
338 339
             }
339 340
         }
340 341
         fip = self.neutron_client.create_floatingip(body)

Loading…
Cancel
Save