From 3bc113551f654449777fd946f9991eefa92119c3 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Thu, 17 Aug 2017 15:05:55 +0300 Subject: [PATCH] NSX|v3: add network/port description to backend objects Setting the nsx logical switch and port description according to the neutron networ/port description Depends-on: If81f8eed647f69d88c299bfdcf83e88a5f3fa662 Change-Id: I1c3136563bb44c5cf96fcd12ba1eaaaf200537b9 --- vmware_nsx/plugins/nsx_v3/plugin.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index c6984f6362..d70abed350 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -758,7 +758,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, nsx_result = self.nsxlib.logical_switch.create( net_name, physical_net, tags, admin_state=admin_state, - vlan_id=vlan_id) + vlan_id=vlan_id, + description=net_data.get('description')) return (is_provider_net, net_type, @@ -1005,15 +1006,18 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, self._extend_network_dict_provider(context, updated_net) if (not extern_net and - 'name' in net_data or 'admin_state_up' in net_data): + ('name' in net_data or 'admin_state_up' in net_data or + 'description' in net_data)): try: # get the nsx switch id from the DB mapping nsx_id = self._get_network_nsx_id(context, id) + net_name = net_data.get('name', + original_net.get('name')) or 'network' self.nsxlib.logical_switch.update( nsx_id, - name=utils.get_name_and_uuid(net_data['name'] or 'network', - id), - admin_state=net_data.get('admin_state_up')) + name=utils.get_name_and_uuid(net_name, id), + admin_state=net_data.get('admin_state_up'), + description=net_data.get('description')) # Backend does not update the admin state of the ports on # the switch when the switch's admin state changes. Do not # update the admin state of the ports in neutron either. @@ -1683,7 +1687,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, admin_state=port_data['admin_state_up'], address_bindings=address_bindings, attachment_type=attachment_type, - switch_profile_ids=profiles) + switch_profile_ids=profiles, + description=port_data.get('description')) except nsx_lib_exc.ManagerError as inst: # we may fail if the QoS is not supported for this port # (for example - transport zone with KVM) @@ -2482,7 +2487,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, admin_state=updated_port.get('admin_state_up'), address_bindings=address_bindings, switch_profile_ids=switch_profile_ids, - tags_update=tags_update) + tags_update=tags_update, + description=updated_port.get('description')) except nsx_lib_exc.ManagerError as inst: # we may fail if the QoS is not supported for this port # (for example - transport zone with KVM)