summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/network/quantumv2/api.py25
-rw-r--r--nova/tests/network/test_quantumv2.py12
2 files changed, 24 insertions, 13 deletions
diff --git a/nova/network/quantumv2/api.py b/nova/network/quantumv2/api.py
index 420396ed4..58a27340c 100644
--- a/nova/network/quantumv2/api.py
+++ b/nova/network/quantumv2/api.py
@@ -260,19 +260,20 @@ class API(base.Base):
data = quantumv2.get_client(context).list_ports(**search_opts)
ports = data['ports']
for p in ports:
- fixed_ips = p['fixed_ips']
for subnet in ipam_subnets:
- fixed_ip = {'subnet_id': subnet['id']}
- fixed_ips.append(fixed_ip)
- port_req_body = {'port': {'fixed_ips': fixed_ips}}
- try:
- quantumv2.get_client(context).update_port(p['id'],
- port_req_body)
- except Exception as ex:
- msg = _("Unable to update port %(portid)s with"
- " failure: %(exception)s")
- LOG.debug(msg, {'portid': p['id'], 'exception': ex})
- return
+ fixed_ips = [{'subnet_id': subnet['id']}]
+ port_req_body = {'port': {'fixed_ips': fixed_ips}}
+ try:
+ quantumv2.get_client(context).update_port(p['id'],
+ port_req_body)
+ return
+ except Exception as ex:
+ msg = _("Unable to update port %(portid)s on subnet "
+ "%(subnet_id)s with failure: %(exception)s")
+ LOG.debug(msg, {'portid': p['id'],
+ 'subnet_id': subnet['id'],
+ 'exception': ex})
+
raise exception.NetworkNotFoundForInstance(
instance_id=instance['uuid'])
diff --git a/nova/tests/network/test_quantumv2.py b/nova/tests/network/test_quantumv2.py
index 1805044a1..f3f306694 100644
--- a/nova/tests/network/test_quantumv2.py
+++ b/nova/tests/network/test_quantumv2.py
@@ -189,6 +189,16 @@ class TestQuantumv2(test.TestCase):
'gateway_ip': '10.0.1.1',
'dns_nameservers': ['8.8.1.1', '8.8.1.2']}]
self.subnet_data2 = []
+ self.subnet_data_n = [{'id': 'my_subid1',
+ 'cidr': '10.0.1.0/24',
+ 'network_id': 'my_netid1',
+ 'gateway_ip': '10.0.1.1',
+ 'dns_nameservers': ['8.8.1.1', '8.8.1.2']},
+ {'id': 'my_subid2',
+ 'cidr': '20.0.1.0/24',
+ 'network_id': 'my_netid2',
+ 'gateway_ip': '20.0.1.1',
+ 'dns_nameservers': ['8.8.1.1', '8.8.1.2']}]
self.subnet_data2.append({'id': 'my_subid2',
'cidr': '10.0.2.0/24',
'network_id': 'my_netid2',
@@ -1010,7 +1020,7 @@ class TestQuantumv2(test.TestCase):
network_id = 'my_netid1'
search_opts = {'network_id': network_id}
self.moxed_client.list_subnets(
- **search_opts).AndReturn({'subnets': self.subnet_data1})
+ **search_opts).AndReturn({'subnets': self.subnet_data_n})
zone = 'compute:%s' % self.instance['availability_zone']
search_opts = {'device_id': self.instance['uuid'],