def plug_router_port_attachment(cluster, router_id, port_id, attachment_uuid, nvp_attachment_type, attachment_vlan=None):
 uri = _build_uri_path(LROUTERPORT_RESOURCE, port_id, router_id, is_attachment=True)
 attach_obj = {}
 attach_obj['type'] = nvp_attachment_type
 if (nvp_attachment_type == 'PatchAttachment'):
  attach_obj['peer_port_uuid'] = attachment_uuid
 elif (nvp_attachment_type == 'L3GatewayAttachment'):
  attach_obj['l3_gateway_service_uuid'] = attachment_uuid
  if attachment_vlan:
   attach_obj['vlan_id'] = attachment_vlan
 else:
  raise Exception(_("Invalid NVP attachment type '%s'"), nvp_attachment_type)
 try:
  resp_obj = do_single_request(HTTP_PUT, uri, json.dumps(attach_obj), cluster=cluster)
 except NvpApiClient.ResourceNotFound as e:
  LOG.exception(_('Router Port not found, Error: %s'), str(e))
  raise
 except NvpApiClient.Conflict as e:
  LOG.exception(_('Conflict while setting router port attachment'))
  raise
 except NvpApiClient.NvpApiException as e:
  LOG.exception(_('Unable to plug attachment into logical router port'))
  raise
 result = json.loads(resp_obj)
 return result

def plug_router_port_attachment ( cluster , router_id , port_id , attachment_uuid , nvp_attachment_type , attachment_vlan = None ) : uri = _build_uri_path ( LROUTERPORT_RESOURCE , port_id , router_id , is_attachment = True ) attach_obj = { } attach_obj [ 'type' ] = nvp_attachment_type if ( nvp_attachment_type == 'PatchAttachment' ) : attach_obj [ 'peer_port_uuid' ] = attachment_uuid elif ( nvp_attachment_type == 'L3GatewayAttachment' ) : attach_obj [ 'l3_gateway_service_uuid' ] = attachment_uuid if attachment_vlan : attach_obj [ 'vlan_id' ] = attachment_vlan else : raise Exception ( _ ( "Invalid NVP attachment type '%s'" ) , nvp_attachment_type ) try : resp_obj = do_single_request ( HTTP_PUT , uri , json . dumps ( attach_obj ) , cluster = cluster ) except NvpApiClient . ResourceNotFound as e : LOG . exception ( _ ( 'Router Port not found, Error: %s' ) , str ( e ) ) raise except NvpApiClient . Conflict as e : LOG . exception ( _ ( 'Conflict while setting router port attachment' ) ) raise except NvpApiClient . NvpApiException as e : LOG . exception ( _ ( 'Unable to plug attachment into logical router port' ) ) raise result = json . loads ( resp_obj ) return result
attach a router port to the given attachment .