From ea377abf2fa96df00e7829ebe408a1ae7ac37a4e Mon Sep 17 00:00:00 2001 From: John Garbutt Date: Wed, 8 Jun 2016 15:20:35 +0100 Subject: [PATCH] Extract update_port call into method This is to allow the addition of error handling that matches the create_port call in a future patchset. blueprint prep-for-network-aware-scheduling Change-Id: I6327f6861cf4132d41624b544508cd1c3a5958f4 --- nova/network/neutronv2/api.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py index 014f77939a30..a12118bc13a1 100644 --- a/nova/network/neutronv2/api.py +++ b/nova/network/neutronv2/api.py @@ -243,6 +243,12 @@ class API(base_api.NetworkAPI): LOG.exception(_LE('Neutron error creating port on network %s'), network_id, instance=instance) + def _update_port(self, port_client, instance, port_id, + port_req_body): + port_client.update_port(port_id, port_req_body) + LOG.debug('Successfully updated port: %s', port_id, + instance=instance) + @staticmethod def _populate_mac_address(instance, port_req_body, available_macs): if available_macs is not None: @@ -629,10 +635,10 @@ class API(base_api.NetworkAPI): created_port_ids.append(created_port_id) ports_in_requested_order.append(created_port_id) else: - port = ports[request.port_id] - port_client.update_port(port['id'], port_req_body) - preexisting_port_ids.append(port['id']) - ports_in_requested_order.append(port['id']) + self._update_port( + port_client, instance, request.port_id, port_req_body) + preexisting_port_ids.append(request.port_id) + ports_in_requested_order.append(request.port_id) self._update_port_dns_name(context, instance, network, ports_in_requested_order[-1],