Set display_name for port on NSX if specified in Neutron

During port-creation, if user specifies a port name;
it wasn't getting set on NSX.

Change-Id: I2db8f14f2165392839a289a6b114c54e13858477
This commit is contained in:
Amey Bhide 2015-06-05 12:10:34 -07:00 committed by Kobi Samoray
parent 1d9015dfb0
commit 0092cf13d0
2 changed files with 7 additions and 4 deletions

View File

@ -91,7 +91,8 @@ def delete_logical_switch(lswitch_id):
def create_logical_port(lswitch_id,
vif_uuid,
attachment_type=nsx_constants.ATTACHMENT_VIF,
admin_state=nsx_constants.ADMIN_STATE_UP):
admin_state=nsx_constants.ADMIN_STATE_UP,
name=None):
controller, user, password = _get_controller_endpoint()
url = controller + "/api/v1/logical-ports"
@ -100,6 +101,8 @@ def create_logical_port(lswitch_id,
'attachment': {'attachment_type': attachment_type,
'id': vif_uuid},
'admin_state': admin_state}
if name:
body['display_name'] = name
result = requests.post(url, auth=auth.HTTPBasicAuth(user, password),
verify=False, headers=headers,

View File

@ -111,9 +111,9 @@ class NsxV3Plugin(db_base_plugin_v2.NeutronDbPluginV2,
nsxlib.delete_logical_switch(network_id)
return ret_val
def update_network(self, context, id, network):
def update_network(self, context, network_id, network):
# TODO(arosen) - call to backend
return super(NsxV3Plugin, self).update_network(context, id,
return super(NsxV3Plugin, self).update_network(context, network_id,
network)
def create_port(self, context, port):
@ -124,7 +124,7 @@ class NsxV3Plugin(db_base_plugin_v2.NeutronDbPluginV2,
port_id = uuidutils.generate_uuid()
result = nsxlib.create_logical_port(
lswitch_id=port['port']['network_id'],
vif_uuid=port_id)
vif_uuid=port_id, name=port['port']['name'])
port['port']['id'] = port_id
# TODO(salv-orlando): Undo logical switch creation on failure
with context.session.begin():