From 79fe8f55f0c559f2e72fa0b7400b7294d3f9f04d Mon Sep 17 00:00:00 2001 From: longstaff Date: Tue, 5 Jun 2018 14:24:38 -0600 Subject: [PATCH] device_id exception raised when creating Neutron network port (v10.3, HPB) Issues: Fixes #930 Problem: create_port_on_network() fails to set a device_id in port data unless one is passed into the function. Because the agent calls this method without a device_id it will always fail. Analysis: Code was recently changed so that the passed in device_id is always used, but failed to account for situations when device_id is not given. Added additional code to set device_id to a uuid ID when no device_id is given. Tests: --- f5lbaasdriver/v2/bigip/plugin_rpc.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/f5lbaasdriver/v2/bigip/plugin_rpc.py b/f5lbaasdriver/v2/bigip/plugin_rpc.py index 279942f35..3f988236a 100644 --- a/f5lbaasdriver/v2/bigip/plugin_rpc.py +++ b/f5lbaasdriver/v2/bigip/plugin_rpc.py @@ -15,6 +15,8 @@ # limitations under the License. # +import uuid + from oslo_log import helpers as log_helpers from oslo_log import log as logging @@ -536,6 +538,9 @@ def create_port_on_subnet(self, context, subnet_id=None, if device_id: port_data['device_id'] = device_id + else: + port_data['device_id'] = str(uuid.uuid5( + uuid.NAMESPACE_DNS, str(host))) port_data[portbindings.HOST_ID] = host port_data[portbindings.VNIC_TYPE] = vnic_type port_data[portbindings.PROFILE] = binding_profile @@ -700,6 +705,9 @@ def create_port_on_network(self, context, network_id=None, } if device_id: port_data['device_id'] = device_id + else: + port_data['device_id'] = str(uuid.uuid5( + uuid.NAMESPACE_DNS, str(host))) port_data[portbindings.HOST_ID] = host port_data[portbindings.VNIC_TYPE] = vnic_type port_data[portbindings.PROFILE] = binding_profile