Merge "Set display_name for port on NSX if specified in Neutron"

This commit is contained in:
Jenkins 2015-06-10 09:22:22 +00:00 committed by Gerrit Code Review
commit a73dd23db1
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, def create_logical_port(lswitch_id,
vif_uuid, vif_uuid,
attachment_type=nsx_constants.ATTACHMENT_VIF, 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() controller, user, password = _get_controller_endpoint()
url = controller + "/api/v1/logical-ports" url = controller + "/api/v1/logical-ports"
@ -100,6 +101,8 @@ def create_logical_port(lswitch_id,
'attachment': {'attachment_type': attachment_type, 'attachment': {'attachment_type': attachment_type,
'id': vif_uuid}, 'id': vif_uuid},
'admin_state': admin_state} 'admin_state': admin_state}
if name:
body['display_name'] = name
result = requests.post(url, auth=auth.HTTPBasicAuth(user, password), result = requests.post(url, auth=auth.HTTPBasicAuth(user, password),
verify=False, headers=headers, verify=False, headers=headers,

View File

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