def create_l2_gw_service(cluster, tenant_id, display_name, devices):
 tags = [{'tag': tenant_id, 'scope': 'os_tid'}]
 gateways = [{'transport_node_uuid': device['id'], 'device_id': device['interface_name'], 'type': 'L2Gateway'} for device in devices]
 gwservice_obj = {'display_name': _check_and_truncate_name(display_name), 'tags': tags, 'gateways': gateways, 'type': 'L2GatewayServiceConfig'}
 try:
  return json.loads(do_single_request('POST', _build_uri_path(GWSERVICE_RESOURCE), json.dumps(gwservice_obj), cluster=cluster))
 except NvpApiClient.NvpApiException:
  LOG.exception(_('An exception occured while communicating with the NVP controller for cluster:%s'), cluster.name)
  raise

def create_l2_gw_service ( cluster , tenant_id , display_name , devices ) : tags = [ { 'tag' : tenant_id , 'scope' : 'os_tid' } ] gateways = [ { 'transport_node_uuid' : device [ 'id' ] , 'device_id' : device [ 'interface_name' ] , 'type' : 'L2Gateway' } for device in devices ] gwservice_obj = { 'display_name' : _check_and_truncate_name ( display_name ) , 'tags' : tags , 'gateways' : gateways , 'type' : 'L2GatewayServiceConfig' } try : return json . loads ( do_single_request ( 'POST' , _build_uri_path ( GWSERVICE_RESOURCE ) , json . dumps ( gwservice_obj ) , cluster = cluster ) ) except NvpApiClient . NvpApiException : LOG . exception ( _ ( 'An exception occured while communicating with the NVP controller for cluster:%s' ) , cluster . name ) raise
create a nvp layer-2 network gateway service .