]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
openstack: there may be more than one IPv4 subnet
authorLoic Dachary <ldachary@redhat.com>
Sun, 27 Mar 2016 11:50:01 +0000 (13:50 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@suse.com>
Mon, 14 Oct 2019 14:47:01 +0000 (16:47 +0200)
Signed-off-by: Loic Dachary <loic@dachary.org>
teuthology/openstack/__init__.py

index d5e2cc0130307fca21a1ae4f2785c913cfeb3cf8..89179fdc4d92de14c23f4119ee6adf36ae83b6b7 100644 (file)
@@ -112,12 +112,11 @@ class OpenStackInstance(object):
 
     def get_ip_neutron(self):
         subnets = json.loads(misc.sh("neutron subnet-list -f json -c id -c ip_version"))
-        subnet_id = None
+        subnet_ids = []
         for subnet in subnets:
             if subnet['ip_version'] == 4:
-                subnet_id = subnet['id']
-                break
-        if not subnet_id:
+                subnet_ids.append(subnet['id'])
+        if not subnet_ids:
             raise Exception("no subnet with ip_version == 4")
         ports = json.loads(misc.sh("neutron port-list -f json -c fixed_ips -c device_id"))
         fixed_ips = None
@@ -130,7 +129,7 @@ class OpenStackInstance(object):
         ip = None
         for fixed_ip in fixed_ips:
             record = json.loads(fixed_ip)
-            if record['subnet_id'] == subnet_id:
+            if record['subnet_id'] in subnet_ids:
                 ip = record['ip_address']
                 break
         if not ip: