Patch Set 4: Removed I*Aware related code, Addressed review comments.
Patch Set 5: Aligned code with merged changes. Addressed review
comments.
Openstack Neutron API:
https://github.com/openstack/networking-l2gw/blob/master/specs/kilo/l2-gateway-api.rst
Patch Set 8: fixed the review comments
Patch Set 9: fixed the review comments
Change-Id: Icfc93bc39f56f6b103b13834359128f29df804b9
Signed-off-by: raveek <raveek@hp.com>
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+module neutron-l2gateways{
+ yang-version 1;
+ namespace "urn:opendaylight:neutron-l2gateways";
+ prefix neutron-l2gateways;
+
+ import ietf-yang-types { prefix "yang"; }
+ import ietf-inet-types { prefix "inet"; revision-date 2010-09-24; }
+ import neutron-attrs { prefix "attrs"; }
+
+ organization "OpenDaylight Neutron Group";
+
+ description "This YANG module defines l2gateway objects that are used by
+ Openstack kilo Neutron YANG modules.";
+
+ revision "2015-07-12" {
+ description
+ "Initial version of l2gateway group objects used by OpenStack
+ kilo Neutron models";
+ }
+
+ grouping l2gateway-connection-attributes {
+ leaf l2gateway-id {
+ type yang:uuid;
+ }
+ leaf network-id {
+ type yang:uuid;
+ }
+ leaf segment-id {
+ type int32;
+ }
+ leaf port-id {
+ type yang:uuid;
+ }
+ }
+
+ grouping l2gateway-attributes {
+ leaf l2gateway-name{
+ type string;
+ }
+ list devices {
+ description "Description of devices.";
+ leaf device-name{
+ type string;
+ }
+ list interfaces {
+ description "Description of interfaces";
+ leaf interface-name {
+ type string;
+ }
+ leaf-list segmentation-ids {
+ description "Description of segmentations";
+ type int32;
+ }
+ }
+ }
+ }
+
+ grouping l2gateways-attributes {
+ container l2gateways {
+ list l2gateway {
+ description "l2gateway description ";
+ key "uuid";
+ uses attrs:base-attributes;
+ uses l2gateway-attributes;
+ }
+ }
+ }
+
+ grouping l2gateway-connections-attributes{
+ container l2gatewayConnections {
+ list l2gatewayConnection {
+ description "l2gateway connection description ";
+ key "uuid";
+ uses attrs:base-attributes;
+ uses l2gateway-connection-attributes;
+ }
+ }
+ }
+
+}
\ No newline at end of file
import neutron-metering { prefix "metering"; }
import neutron-lbaasv2 { prefix "lbaasv2"; }
import neutron-provider { prefix "provider"; }
+ import neutron-l2gateways { prefix "l2gateways"; }
import neutron-vpnaas { prefix "vpnaas"; }
import neutron-fwaas { prefix "fwaas"; }
import neutron-bgpvpns { prefix "bgpvpns"; }
uses vpnaas:ipsecpolicies-attributes;
uses vpnaas:ipsecconnections-attributes;
uses bgpvpns:bgpvpns-attributes;
+ uses l2gateways:l2gateways-attributes;
+ uses l2gateways:l2gateway-connections-attributes;
}
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.spi;
+/**
+ * This interface defines the methods for CRUD of NB OpenStack L2gateway objects
+ */
+public interface INeutronL2gatewayCRUD extends INeutronCRUD<NeutronL2gateway>{
+ //Do nothing here.
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.spi;
+/**
+ * This interface defines the methods for CRUD of NB OpenStack L2gateway
+ * Connection objects.
+ */
+
+public interface INeutronL2gatewayConnectionCRUD extends INeutronCRUD<NeutronL2gatewayConnection> {
+ //Do nothing here.
+
+}
private INeutronVPNServiceCRUD vpnInterface;
private INeutronVPNIPSECSiteConnectionsCRUD ipsecScInterface;
private INeutronBgpvpnCRUD bgpvpnInterface;
+ private INeutronL2gatewayCRUD l2gatewayInterface;
+ private INeutronL2gatewayConnectionCRUD l2gatewayConnectionInterface;
public NeutronCRUDInterfaces() {
}
return ipsecpInterface;
}
+ public INeutronL2gatewayCRUD getL2gatewayInterface() {
+ return l2gatewayInterface;
+ }
+
+ public INeutronL2gatewayConnectionCRUD getL2gatewayConnectionInterface() {
+ return l2gatewayConnectionInterface;
+ }
+
public void setVPNServiceInterface(INeutronVPNServiceCRUD iface) {
vpnInterface = iface;
}
return this;
}
+ public NeutronCRUDInterfaces fetchINeutronL2gatewayCRUD(Object obj) {
+ l2gatewayInterface = (INeutronL2gatewayCRUD) getInstances(INeutronL2gatewayCRUD.class, obj);
+ return this;
+ }
+
+ public NeutronCRUDInterfaces fetchINeutronL2gatewayConnectionCRUD(Object obj) {
+ l2gatewayConnectionInterface = (INeutronL2gatewayConnectionCRUD) getInstances(INeutronL2gatewayConnectionCRUD.class, obj);
+ return this;
+ }
+
public Object getInstances(Class<?> clazz, Object bundle) {
try {
BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass()).getBundleContext();
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.spi;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "l2gateway")
+public class NeutronL2gateway extends NeutronObject implements Serializable, INeutronObject{
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "name")
+ String l2gatewayName;
+
+ @XmlElement(name = "devices")
+ List<NeutronL2gatewayDevice> neutronL2gatewayDevices;
+
+ public String getL2gatewayName() {
+ return l2gatewayName;
+ }
+
+ public void setL2gatewayName(String l2gatewayName) {
+ this.l2gatewayName = l2gatewayName;
+ }
+
+ public List<NeutronL2gatewayDevice> getNeutronL2gatewayDevices() {
+ return neutronL2gatewayDevices;
+ }
+
+ public void setNeutronL2gatewayDevices(List<NeutronL2gatewayDevice> neutronL2gatewayDevices) {
+ this.neutronL2gatewayDevices = neutronL2gatewayDevices;
+ }
+
+ public NeutronL2gateway extractFields(List<String> fields) {
+ NeutronL2gateway ans = new NeutronL2gateway();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("id")) {
+ ans.setID(this.getID());
+ }
+ if (s.equals("name")) {
+ ans.setL2gatewayName(this.getL2gatewayName());
+ }
+ if (s.equals("tenant_id")) {
+ ans.setTenantID(this.getTenantID());
+ }
+ if (s.equals("devices")) {
+ List<NeutronL2gatewayDevice> devices = new ArrayList<NeutronL2gatewayDevice>();
+ devices.addAll(this.getNeutronL2gatewayDevices());
+ ans.setNeutronL2gatewayDevices(devices);
+ }
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronL2Gateway [" +
+ "id = " + uuid +
+ ", name = " + l2gatewayName +
+ ", tenant_id = " + tenantID +
+ ", devices = " + neutronL2gatewayDevices +
+ "]";
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.spi;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "l2gatewayConnection")
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronL2gatewayConnection extends NeutronObject implements Serializable, INeutronObject {
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "gateway_id")
+ String l2gatewayID;
+
+ @XmlElement(name = "network_id")
+ String networkID;
+
+ @XmlElement(name = "segmentation_id")
+ Integer segmentID;
+
+ @XmlElement(name = "port_id")
+ String portID;
+
+ public String getL2gatewayID() {
+ return l2gatewayID;
+ }
+
+ public String getNetworkID() {
+ return networkID;
+ }
+
+ public Integer getSegmentID() {
+ return segmentID;
+ }
+
+ public void setL2gatewayID(String l2gatewayID) {
+ this.l2gatewayID = l2gatewayID;
+ }
+
+ public void setNetworkID(String networkID) {
+ this.networkID = networkID;
+ }
+
+ public void setSegmentID(Integer segmentID) {
+ this.segmentID = segmentID;
+ }
+
+ public String getPortID() {
+ return portID;
+ }
+
+ public void setPortID(String portID) {
+ this.portID = portID;
+ }
+
+ public NeutronL2gatewayConnection extractFields(List<String> fields) {
+ NeutronL2gatewayConnection ans = new NeutronL2gatewayConnection();
+ Iterator<String> i = fields.iterator();
+ while (i.hasNext()) {
+ String s = i.next();
+ if (s.equals("tenant_id")) {
+ ans.setTenantID(this.getTenantID());
+ }
+ if (s.equals("connection_id")) {
+ ans.setID(this.getID());
+ }
+ if (s.equals("gateway_id")) {
+ ans.setL2gatewayID(this.getL2gatewayID());
+ }
+ if (s.equals("network_id")) {
+ ans.setNetworkID(this.getNetworkID());
+ }
+ if (s.equals("segmentation_id")) {
+ ans.setSegmentID(this.getSegmentID());
+ }
+ if (s.equals("port_id")) {
+ ans.setPortID(this.getPortID());
+ }
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronL2GatewayConnection [" +
+ "tenant_id = " + tenantID +
+ ", connection_id = " + uuid +
+ ", gateway_id = " + l2gatewayID +
+ ", network_id = " + networkID +
+ ", segmentation_id = " + segmentID +
+ ", port_id = " + portID +
+ "]";
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.spi;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public class NeutronL2gatewayDevice implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "interfaces")
+ List<NeutronL2gatewayDeviceInterface> neutronL2gatewayDeviceInterfaces;
+
+ @XmlElement(name = "device_name")
+ String deviceName;
+
+ public String getDeviceName() {
+ return deviceName;
+ }
+
+ public void setDeviceName(String deviceName) {
+ this.deviceName = deviceName;
+ }
+
+ public List<NeutronL2gatewayDeviceInterface> getNeutronL2gatewayDeviceInterfaces() {
+ return neutronL2gatewayDeviceInterfaces;
+ }
+
+ public void setNeutronL2gatewayDeviceInterfaces(
+ List<NeutronL2gatewayDeviceInterface> neutronL2gatewayDeviceInterfaces) {
+ this.neutronL2gatewayDeviceInterfaces = neutronL2gatewayDeviceInterfaces;
+ }
+ @Override
+ public String toString() {
+ return "NeutronL2gatewayDevice [neutronL2gwDeviceInterfaces="
+ + neutronL2gatewayDeviceInterfaces + ", deviceName=" + deviceName
+ + "]";
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.spi;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public class NeutronL2gatewayDeviceInterface implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement(name = "name")
+ String interfaceName;
+
+ @XmlElement(name = "segmentation_id")
+ List<Integer> segmentationId;
+
+ public String getInterfaceName() {
+ return interfaceName;
+ }
+
+ public void setInterfaceName(String interfaceName) {
+ this.interfaceName = interfaceName;
+ }
+
+ public List<Integer> getSegmentationId() {
+ return segmentationId;
+ }
+
+ public void setSegmentationId(List<Integer> segmentationId) {
+ this.segmentationId = segmentationId;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronL2gatewayDeviceInterface [interfaceNames=" + interfaceName
+ + ", segmentationId=" + segmentationId + "]";
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.northbound.api;
+
+import java.net.HttpURLConnection;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.opendaylight.neutron.spi.INeutronL2gatewayConnectionCRUD;
+import org.opendaylight.neutron.spi.NeutronCRUDInterfaces;
+import org.opendaylight.neutron.spi.NeutronL2gatewayConnection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Neutron Northbound REST APIs for L2 gateway Connection.<br>
+ * This class provides REST APIs for managing L2 gateway Connection
+ * * *
+ * <br>
+ * <br>
+ * Authentication scheme : <b>HTTP Basic</b><br>
+ * Authentication realm : <b>opendaylight</b><br>
+ * Transport : <b>HTTP and HTTPS</b><br>
+ * <br>
+ * HTTPS Authentication is disabled by default. Administrator can enable it in
+ * tomcat-server.xml after adding a proper keystore / SSL certificate from a
+ * trusted authority.<br>
+ * More info :
+ * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ */
+
+@Path ("/l2gateway-connections")
+public class NeutronL2gatewayConnectionNorthbound
+ extends AbstractNeutronNorthbound<NeutronL2gatewayConnection, NeutronL2gatewayConnectionRequest, INeutronL2gatewayConnectionCRUD> {
+
+ static final Logger logger = LoggerFactory.getLogger(NeutronL2gatewayConnectionNorthbound.class);
+
+ @Context
+ UriInfo uriInfo;
+
+ private static final String RESOURCE_NAME = "L2gatewayConnection";
+ private static final String INTERFACE_NAME = "L2gatewayConnection CRUD Interface";
+
+ @Override
+ protected String getResourceName() {
+ return RESOURCE_NAME;
+ }
+
+ @Override
+ protected NeutronL2gatewayConnection extractFields(NeutronL2gatewayConnection o,
+ List<String> fields) {
+ return o.extractFields(fields);
+ }
+
+ @Override
+ protected NeutronL2gatewayConnectionRequest newNeutronRequest(NeutronL2gatewayConnection o) {
+ return new NeutronL2gatewayConnectionRequest(o);
+ }
+
+ @Override
+ protected INeutronL2gatewayConnectionCRUD getNeutronCRUD() {
+ NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronL2gatewayConnectionCRUD(this);
+ if (answer.getFirewallInterface() == null) {
+ throw new ServiceUnavailableException(serviceUnavailable());
+ }
+ return answer.getL2gatewayConnectionInterface();
+ }
+
+ /**
+ * Creates L2gateway Connection
+ * @param input contains connection details
+ * @return status
+ */
+ @POST
+ @Produces ({MediaType.APPLICATION_JSON})
+ @Consumes ({MediaType.APPLICATION_JSON})
+ @StatusCodes({
+ @ResponseCode(code = HttpURLConnection.HTTP_CREATED, condition = "Created"),
+ @ResponseCode(code = HttpURLConnection.HTTP_BAD_REQUEST, condition = "Bad Request"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"),
+ @ResponseCode(code = HttpURLConnection.HTTP_FORBIDDEN, condition = "Forbidden"),
+ @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"),
+ @ResponseCode(code = HttpURLConnection.HTTP_CONFLICT, condition = "Conflict"),
+ @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
+
+ public Response createL2gatewayConnection(final NeutronL2gatewayConnectionRequest input) {
+ logger.debug("createL2GatewayConnection NeutronL2GatewayConnectionRequest");
+ return create(input);
+ }
+
+ /**
+ * Returns a list of all L2gateway Connections.
+ *
+ */
+ @GET
+ @Produces({ MediaType.APPLICATION_JSON })
+ @StatusCodes({
+ @ResponseCode(code = HttpURLConnection.HTTP_OK,
+ condition = "Operation successful"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED,
+ condition = "Unauthorized"),
+ @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED,
+ condition = "Not Implemented"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE,
+ condition = "No providers available") })
+ public Response listL2gatewayConnections(
+ // return fields
+ @QueryParam("fields") List<String> fields,
+ @QueryParam("tenant_id") String queryTenantID,
+ @QueryParam("connection_id") String queryConnectionID,
+ @QueryParam("l2gateway_id") String queryL2gatewayID,
+ @QueryParam("network_id") String queryNetworkID,
+ @QueryParam("segment_id") String querySegmentID,
+ @QueryParam("port_id") String queryPortID,
+ @QueryParam ("limit") String limit,
+ @QueryParam ("marker") String marker,
+ @QueryParam ("page_reverse") String pageReverse
+ // sorting not supported
+ ) {
+ INeutronL2gatewayConnectionCRUD l2gatewayConnectionInterface = getNeutronInterfaces()
+ .getL2gatewayConnectionInterface();
+ if (l2gatewayConnectionInterface == null) {
+ throw new ServiceUnavailableException(INTERFACE_NAME
+ + RestMessages.SERVICEUNAVAILABLE.toString());
+ }
+ List<NeutronL2gatewayConnection> allL2gatewayConnections = l2gatewayConnectionInterface.getAll();
+ List<NeutronL2gatewayConnection> ans = new ArrayList<NeutronL2gatewayConnection>();
+ Iterator<NeutronL2gatewayConnection> i = allL2gatewayConnections
+ .iterator();
+ while (i.hasNext()) {
+ NeutronL2gatewayConnection oSS = i.next();
+ if ((queryTenantID == null || queryTenantID.equals(oSS
+ .getTenantID()))
+ && (queryConnectionID == null || queryConnectionID
+ .equals(oSS.getID()))
+ && (queryL2gatewayID == null || queryL2gatewayID.equals(oSS
+ .getL2gatewayID()))
+ && (queryNetworkID == null || queryNetworkID.equals(oSS
+ .getNetworkID()))
+ && (querySegmentID == null || querySegmentID.equals(oSS
+ .getSegmentID()))
+ && (queryPortID == null || queryPortID.equals(oSS
+ .getPortID()))) {
+ if (fields.size() > 0) {
+ ans.add(extractFields(oSS, fields));
+ } else {
+ ans.add(oSS);
+ }
+ }
+ }
+ // TODO: apply pagination to results
+ return Response.status(HttpURLConnection.HTTP_OK)
+ .entity(new NeutronL2gatewayConnectionRequest(ans)).build();
+ }
+
+ /**
+ * Returns a specific L2gateway Connection.
+ * @param l2gatewayConnectionID gateway connectID to fetch
+ * @param fields attributes used for querying
+ * @return status
+ */
+ @Path ("{l2gatewayConnectionID}")
+ @GET
+ @Produces ({MediaType.APPLICATION_JSON})
+ @StatusCodes ({
+ @ResponseCode (code = HttpURLConnection.HTTP_OK,
+ condition = "Operation successful"),
+ @ResponseCode (code = HttpURLConnection.HTTP_UNAUTHORIZED,
+ condition = "Unauthorized"),
+ @ResponseCode (code = HttpURLConnection.HTTP_NOT_FOUND,
+ condition = "Not Found"),
+ @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED,
+ condition = "Not Implemented"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE,
+ condition = "No providers available") })
+ public Response showL2gatewayID(@PathParam("l2gatewayConnectionID") String l2gatewayConnectionID,
+ // return fields
+ @QueryParam("fields") List<String> fields) {
+ return show(l2gatewayConnectionID, fields);
+ }
+
+ /**
+ * Deletes a L2gateway Connection
+ * @param l2gatewayConnectionID connection ID to delete
+ * @return status
+ */
+ @Path("{l2gatewayConnectionID}")
+ @DELETE
+ @StatusCodes({
+ @ResponseCode(code = HttpURLConnection.HTTP_NO_CONTENT,
+ condition = "No Content"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE,
+ condition = "No providers available") })
+ public Response deleteL2gatewayConnection(
+ @PathParam("l2gatewayConnectionID") String l2gatewayConnectionID) {
+ return delete(l2gatewayConnectionID);
+ }
+
+ private NeutronCRUDInterfaces getNeutronInterfaces() {
+ logger.debug("Get Neutron interface");
+ NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronL2gatewayConnectionCRUD(this);
+ if (answer.getL2gatewayConnectionInterface() == null) {
+ throw new ServiceUnavailableException(INTERFACE_NAME + RestMessages.SERVICEUNAVAILABLE.toString());
+ }
+ return answer;
+ }
+
+ // l2gwconnection API doesn't have update method
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.northbound.api;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.opendaylight.neutron.spi.NeutronL2gatewayConnection;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronL2gatewayConnectionRequest implements INeutronRequest<NeutronL2gatewayConnection> {
+ @XmlElement(name = "l2gateway_connection")
+ NeutronL2gatewayConnection singletonL2gatewayConnection;
+
+ @XmlElement(name = "l2gateway_connections")
+ List<NeutronL2gatewayConnection> bulkRequest;
+
+ NeutronL2gatewayConnectionRequest() {
+ }
+
+ NeutronL2gatewayConnectionRequest(NeutronL2gatewayConnection l2gatewayConnection) {
+ this.singletonL2gatewayConnection = l2gatewayConnection;
+ }
+
+ NeutronL2gatewayConnectionRequest(List<NeutronL2gatewayConnection> bulk) {
+ bulkRequest = bulk;
+ singletonL2gatewayConnection = null;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return (singletonL2gatewayConnection != null);
+ }
+
+ @Override
+ public NeutronL2gatewayConnection getSingleton() {
+ return singletonL2gatewayConnection;
+ }
+
+ @Override
+ public List<NeutronL2gatewayConnection> getBulk() {
+ return bulkRequest;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.neutron.northbound.api;
+
+import java.net.HttpURLConnection;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.opendaylight.neutron.spi.INeutronL2gatewayCRUD;
+import org.opendaylight.neutron.spi.NeutronCRUDInterfaces;
+import org.opendaylight.neutron.spi.NeutronL2gateway;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Neutron Northbound REST APIs for L2 gateway.<br>
+ * This class provides REST APIs for managing L2 gateway
+ * *
+ * <br>
+ * <br>
+ * Authentication scheme : <b>HTTP Basic</b><br>
+ * Authentication realm : <b>opendaylight</b><br>
+ * Transport : <b>HTTP and HTTPS</b><br>
+ * <br>
+ * HTTPS Authentication is disabled by default. Administrator can enable it in
+ * tomcat-server.xml after adding a proper keystore / SSL certificate from a
+ * trusted authority.<br>
+ * More info :
+ * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ */
+
+@Path ("/l2-gateways")
+public class NeutronL2gatewayNorthbound
+ extends AbstractNeutronNorthbound<NeutronL2gateway, NeutronL2gatewayRequest, INeutronL2gatewayCRUD> {
+ static final Logger logger = LoggerFactory.getLogger(NeutronL2gatewayNorthbound.class);
+
+ @Context
+ UriInfo uriInfo;
+
+ private static final String RESOURCE_NAME = "L2gateway";
+
+ @Override
+ protected String getResourceName() {
+ return RESOURCE_NAME;
+ }
+
+ @Override
+ protected NeutronL2gateway extractFields(NeutronL2gateway o, List<String> fields) {
+ return o.extractFields(fields);
+ }
+
+ @Override
+ protected NeutronL2gatewayRequest newNeutronRequest(NeutronL2gateway o) {
+ return new NeutronL2gatewayRequest(o);
+ }
+
+ @Override
+ protected INeutronL2gatewayCRUD getNeutronCRUD() {
+ NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronL2gatewayCRUD(this);
+ if (answer.getL2gatewayInterface() == null) {
+ throw new ServiceUnavailableException(serviceUnavailable());
+ }
+ return answer.getL2gatewayInterface();
+ }
+
+ /**
+ * Creates L2gateway
+ * @param input l2gateway attributes
+ * @return success or error code
+ */
+ @POST
+ @Produces ({MediaType.APPLICATION_JSON})
+ @Consumes ({MediaType.APPLICATION_JSON})
+ @StatusCodes({
+ @ResponseCode(code = HttpURLConnection.HTTP_CREATED, condition = "Created"),
+ @ResponseCode(code = HttpURLConnection.HTTP_BAD_REQUEST, condition = "Bad Request"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"),
+ @ResponseCode(code = HttpURLConnection.HTTP_FORBIDDEN, condition = "Forbidden"),
+ @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"),
+ @ResponseCode(code = HttpURLConnection.HTTP_CONFLICT, condition = "Conflict"),
+ @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
+
+ public Response createL2gateway(final NeutronL2gatewayRequest input) {
+ logger.debug("CreateL2gateway NeutronL2gatewayRequest");
+ return create(input);
+ }
+
+ /**
+ * Returns a list of all L2gateways
+ */
+ @GET
+ @Produces({ MediaType.APPLICATION_JSON })
+ @StatusCodes({
+ @ResponseCode(code = HttpURLConnection.HTTP_OK,
+ condition = "Operation successful"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED,
+ condition = "Unauthorized"),
+ @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED,
+ condition = "Not Implemented"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE,
+ condition = "No providers available") })
+ public Response listL2gateways(
+ // return fields
+ @QueryParam("fields") List<String> fields,
+ // OpenStack L2gateway attributes
+ @QueryParam("id") String queryID,
+ @QueryParam("name") String queryName,
+ @QueryParam("tenant_id") String queryTenantID,
+ @QueryParam("devices") String queryNeutronL2gatewayDevice,
+ // pagination
+ @QueryParam("limit") String limit,
+ @QueryParam("marker") String marker,
+ @QueryParam("page_reverse") String pageReverse
+ // sorting not supported
+ ){
+ INeutronL2gatewayCRUD l2gatewayInterface =
+ getNeutronInterfaces().getL2gatewayInterface();
+ List<NeutronL2gateway> allL2gateways =
+ l2gatewayInterface.getAll();
+ List<NeutronL2gateway> ans = new ArrayList<NeutronL2gateway>();
+ Iterator<NeutronL2gateway> i = allL2gateways.iterator();
+ while (i.hasNext()) {
+ NeutronL2gateway l2gateway = i.next();
+ if ((queryID == null || queryID.equals(l2gateway.getID()))
+ && (queryName == null || queryName.equals(l2gateway.getL2gatewayName()))
+ && (queryTenantID == null || queryTenantID.equals(l2gateway.getTenantID()))
+ && (queryNeutronL2gatewayDevice == null || queryNeutronL2gatewayDevice
+ .equals(l2gateway.getNeutronL2gatewayDevices()))) {
+ if (fields.size() > 0) {
+ ans.add(extractFields(l2gateway,fields));
+ } else {
+ ans.add(l2gateway);
+ }
+ }
+ }
+ //TODO: apply pagination to results
+ return Response.status(HttpURLConnection.HTTP_OK).entity(new NeutronL2gatewayRequest(ans)).build();
+ }
+
+ /**
+ * Returns a specific L2gateway.
+ * @param l2gatewayID requested l2gateway uuid
+ * @param fields l2gateway attributes
+ * @return l2gateway details or error.
+ */
+ @Path ("{l2gatewayID}")
+ @GET
+ @Produces ({MediaType.APPLICATION_JSON})
+ @StatusCodes ({
+ @ResponseCode (code = HttpURLConnection.HTTP_OK,
+ condition = "Operation successful"),
+ @ResponseCode (code = HttpURLConnection.HTTP_UNAUTHORIZED,
+ condition = "Unauthorized"),
+ @ResponseCode (code = HttpURLConnection.HTTP_NOT_FOUND,
+ condition = "Not Found"),
+ @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED,
+ condition = "Not Implemented"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE,
+ condition = "No providers available") })
+ public Response showL2gateway(@PathParam ("l2gatewayID") String l2gatewayID,
+ // return fields
+ @QueryParam ("fields") List<String> fields) {
+ return show(l2gatewayID, fields);
+ }
+
+ /**
+ * Deletes a L2gateway
+ * @param l2gatewayID l2gateway uuid which should be deleted
+ * @return success or error code
+ * */
+
+ @Path("{l2gatewayID}")
+ @DELETE
+ @StatusCodes({
+ @ResponseCode(code = HttpURLConnection.HTTP_NO_CONTENT,
+ condition = "No Content"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE,
+ condition = "No providers available") })
+ public Response deleteL2gateway(
+ @PathParam("l2gatewayID") String l2gatewayID) {
+ return delete(l2gatewayID);
+ }
+
+ /**
+ * Updates a L2gateway
+ * @param l2gatewayID gateway ID that needs to be modified
+ * @param input gateway attributes
+ * @return status
+ * */
+ @Path("{l2gatewayID}")
+ @PUT
+ @Produces({ MediaType.APPLICATION_JSON })
+ @Consumes({ MediaType.APPLICATION_JSON })
+ @StatusCodes({
+ @ResponseCode(code = HttpURLConnection.HTTP_OK,
+ condition = "Operation successful"),
+ @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE,
+ condition = "No providers available") })
+ public Response updateL2gateway(
+ @PathParam("l2gatewayID") String l2gatewayID,
+ NeutronL2gatewayRequest input) {
+ return update(l2gatewayID, input);
+ }
+
+ private NeutronCRUDInterfaces getNeutronInterfaces() {
+ NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronL2gatewayCRUD(this);
+ if (answer.getL2gatewayInterface() == null) {
+ throw new ServiceUnavailableException("Service is unavailable");
+ }
+ return answer;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.northbound.api;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+import org.opendaylight.neutron.spi.NeutronL2gateway;
+
+public class NeutronL2gatewayRequest implements INeutronRequest<NeutronL2gateway> {
+
+ @XmlElement(name = "l2_gateway")
+ NeutronL2gateway singletonL2gateway;
+
+ @XmlElement(name = "l2_gateways")
+ List<NeutronL2gateway> bulkRequest;
+
+ NeutronL2gatewayRequest() {
+ }
+
+ NeutronL2gatewayRequest(NeutronL2gateway l2gateway) {
+ this.singletonL2gateway = l2gateway;
+ }
+
+ NeutronL2gatewayRequest(List<NeutronL2gateway> bulk) {
+ bulkRequest = bulk;
+ singletonL2gateway = null;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return (singletonL2gateway != null);
+ }
+
+ @Override
+ public NeutronL2gateway getSingleton() {
+ return singletonL2gateway;
+ }
+
+ @Override
+ public List<NeutronL2gateway> getBulk() {
+ return bulkRequest;
+ }
+
+}
classes.add(NeutronVPNIPSECPoliciesNorthbound.class);
classes.add(NeutronVPNIPSECSiteConnectionsNorthbound.class);
classes.add(NeutronBgpvpnsNorthbound.class);
+ classes.add(NeutronL2gatewayNorthbound.class);
+ classes.add(NeutronL2gatewayConnectionNorthbound.class);
classes.add(MOXyJsonProvider.class);
return classes;
NeutronVPNIPSECSiteConnectionsInterface.registerNewInterface(context, providerContext, registrations);
NeutronFloatingIPInterface.registerNewInterface(context, providerContext, registrations);
NeutronBgpvpnInterface.registerNewInterface(context, providerContext, registrations);
+ NeutronL2gatewayInterface.registerNewInterface(context, providerContext, registrations);
+ NeutronL2gatewayConnectionInterface.registerNewInterface(context, providerContext, registrations);
}
@Override
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.transcriber;
+
+import java.util.List;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.neutron.spi.INeutronL2gatewayConnectionCRUD;
+import org.opendaylight.neutron.spi.NeutronL2gatewayConnection;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.L2gatewayConnections;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnection;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.connections.attributes.l2gatewayconnections.L2gatewayConnectionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronL2gatewayConnectionInterface extends
+AbstractNeutronInterface<L2gatewayConnection, L2gatewayConnections, NeutronL2gatewayConnection>
+implements INeutronL2gatewayConnectionCRUD {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronL2gatewayConnectionInterface.class);
+
+ NeutronL2gatewayConnectionInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ @Override
+ protected List<L2gatewayConnection> getDataObjectList(L2gatewayConnections l2gatewayConnections) {
+ return l2gatewayConnections.getL2gatewayConnection();
+ }
+
+ @Override
+ public boolean inUse(String l2gatewayConnectionID) {
+ return !exists(l2gatewayConnectionID);
+ }
+
+ @Override
+ protected InstanceIdentifier<L2gatewayConnection>
+ createInstanceIdentifier(L2gatewayConnection l2gatewayConnection) {
+ return InstanceIdentifier.create(Neutron.class).child(L2gatewayConnections.class)
+ .child(L2gatewayConnection.class,l2gatewayConnection.getKey());
+ }
+
+ @Override
+ protected InstanceIdentifier<L2gatewayConnections> createInstanceIdentifier(){
+ return InstanceIdentifier.create(Neutron.class).child(L2gatewayConnections.class);
+ }
+
+ @Override
+ protected NeutronL2gatewayConnection fromMd(L2gatewayConnection l2gatewayConnection){
+ NeutronL2gatewayConnection result = new NeutronL2gatewayConnection();
+ if (l2gatewayConnection.getUuid() != null){
+ result.setID(l2gatewayConnection.getUuid().getValue());
+ }
+ if (l2gatewayConnection.getKey().getUuid() != null){
+ result.setID(l2gatewayConnection.getKey().getUuid().getValue());
+ }
+ if (l2gatewayConnection.getL2gatewayId().getValue() != null){
+ result.setL2gatewayID(String.valueOf(l2gatewayConnection.getL2gatewayId().getValue()));
+ }
+ if (l2gatewayConnection.getTenantId().getValue() != null){
+ result.setTenantID(String.valueOf(l2gatewayConnection.getTenantId().getValue()));
+ }
+ if (l2gatewayConnection.getNetworkId().getValue() != null){
+ result.setNetworkID(String.valueOf(l2gatewayConnection.getNetworkId().getValue()));
+ }
+ if (l2gatewayConnection.getSegmentId() != null){
+ result.setSegmentID(Integer.valueOf(l2gatewayConnection.getSegmentId()));
+ }
+ if (l2gatewayConnection.getPortId().getValue() != null){
+ result.setPortID(String.valueOf(l2gatewayConnection.getPortId().getValue()));
+ }
+ return result;
+ }
+
+ @Override
+ protected L2gatewayConnection toMd(NeutronL2gatewayConnection neutronObject) {
+ L2gatewayConnectionBuilder l2gatewayConnectionBuilder =
+ new L2gatewayConnectionBuilder();
+ if (neutronObject.getID() != null){
+ l2gatewayConnectionBuilder.setUuid(toUuid(neutronObject.getID()));
+ }
+ if (neutronObject.getL2gatewayID() != null){
+ l2gatewayConnectionBuilder.setL2gatewayId(toUuid(neutronObject.getL2gatewayID()));
+ }
+ if (neutronObject.getNetworkID() != null){
+ l2gatewayConnectionBuilder.setNetworkId(toUuid(neutronObject.getNetworkID()));
+ }
+ if (neutronObject.getSegmentID() != null){
+ l2gatewayConnectionBuilder.setSegmentId((neutronObject.getSegmentID()));
+ }
+ if (neutronObject.getTenantID() != null){
+ l2gatewayConnectionBuilder.setTenantId(toUuid(neutronObject.getTenantID()));
+ }
+ if (neutronObject.getPortID() != null){
+ l2gatewayConnectionBuilder.setPortId(toUuid(neutronObject.getPortID()));
+ }
+ return l2gatewayConnectionBuilder.build();
+ }
+
+ @Override
+ protected L2gatewayConnection toMd(String uuid) {
+ L2gatewayConnectionBuilder l2gatewayConnectionBuilder = new L2gatewayConnectionBuilder();
+ l2gatewayConnectionBuilder.setUuid(toUuid(uuid));
+ return l2gatewayConnectionBuilder.build();
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronL2gatewayConnectionInterface neutronL2gatewayConnectionInterface =
+ new NeutronL2gatewayConnectionInterface(providerContext);
+ ServiceRegistration<INeutronL2gatewayConnectionCRUD> neutronL2gatewayConInterfaceRegistration = context
+ .registerService(INeutronL2gatewayConnectionCRUD.class, neutronL2gatewayConnectionInterface, null);
+ if (neutronL2gatewayConInterfaceRegistration != null) {
+ registrations.add(neutronL2gatewayConInterfaceRegistration);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Hewlett-Packard Development Company, L.P. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.neutron.transcriber;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.neutron.spi.INeutronL2gatewayCRUD;
+import org.opendaylight.neutron.spi.NeutronL2gatewayDevice;
+import org.opendaylight.neutron.spi.NeutronL2gatewayDeviceInterface;
+import org.opendaylight.neutron.spi.NeutronL2gateway;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.DevicesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.InterfacesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.L2gateways;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gatewayBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class NeutronL2gatewayInterface extends
+ AbstractNeutronInterface<L2gateway, L2gateways, NeutronL2gateway>
+ implements INeutronL2gatewayCRUD {
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronL2gatewayInterface.class);
+
+ NeutronL2gatewayInterface(ProviderContext providerContext) {
+ super(providerContext);
+ }
+
+ @Override
+ protected List<L2gateway> getDataObjectList(L2gateways l2gateways) {
+ return l2gateways.getL2gateway();
+ }
+
+ @Override
+ public boolean inUse(String l2gatewayID) {
+ return !exists(l2gatewayID);
+ }
+
+ @Override
+ protected InstanceIdentifier<L2gateway>
+ createInstanceIdentifier(L2gateway l2gateway) {
+ return InstanceIdentifier.create(Neutron.class).child(L2gateways.class)
+ .child(L2gateway.class,l2gateway.getKey());
+ }
+
+ @Override
+ protected InstanceIdentifier<L2gateways> createInstanceIdentifier() {
+ return InstanceIdentifier.create(Neutron.class).child(L2gateways.class);
+ }
+
+ @Override
+ protected NeutronL2gateway fromMd(L2gateway l2gateway){
+ NeutronL2gateway result = new NeutronL2gateway();
+ List<NeutronL2gatewayDevice> neutronL2gatewayDevices = new ArrayList<NeutronL2gatewayDevice>();
+
+ if (l2gateway.getUuid() != null){
+ result.setID(l2gateway.getUuid().getValue());
+ }
+ if (l2gateway.getUuid() != null){
+ result.setID(l2gateway.getUuid().getValue());
+ }
+ if (l2gateway.getL2gatewayName() != null){
+ result.setL2gatewayName(String.valueOf(l2gateway.getL2gatewayName()));
+ }
+ if (l2gateway.getTenantId().getValue() != null){
+ result.setTenantID(String.valueOf(l2gateway.getTenantId().getValue()));
+ }
+ if (l2gateway.getDevices() != null){
+ for (Devices device:l2gateway.getDevices()){
+ NeutronL2gatewayDevice neutronL2gatewayDevice = new NeutronL2gatewayDevice();
+ List<NeutronL2gatewayDeviceInterface> neutronL2gatewayDeviceInterfaces =
+ new ArrayList<NeutronL2gatewayDeviceInterface>();
+ if (device.getDeviceName() != null){
+ neutronL2gatewayDevice.setDeviceName(device.getDeviceName().toString());
+ }
+ if(device.getInterfaces() != null){
+ for(Interfaces deviceInterface:device.getInterfaces()){
+ NeutronL2gatewayDeviceInterface neutronL2gatewayDeviceInterface =
+ new NeutronL2gatewayDeviceInterface();
+ String interfaceName = null;
+ List<Integer> segmentationIds = new ArrayList<Integer>();
+ if (deviceInterface.getInterfaceName() != null){
+ interfaceName = deviceInterface
+ .getInterfaceName().toString();
+ }
+ if (deviceInterface.getSegmentationIds() != null){
+ for(Integer segmentId:deviceInterface.getSegmentationIds()){
+ segmentationIds.add(segmentId);
+ }
+ neutronL2gatewayDeviceInterface.setSegmentationId(segmentationIds);
+ }
+ neutronL2gatewayDeviceInterface.setInterfaceName(interfaceName);
+ neutronL2gatewayDeviceInterfaces.add(neutronL2gatewayDeviceInterface);
+ }
+ }
+ neutronL2gatewayDevice.setNeutronL2gatewayDeviceInterfaces(neutronL2gatewayDeviceInterfaces);
+ neutronL2gatewayDevices.add(neutronL2gatewayDevice);
+ }
+ }
+ result.setNeutronL2gatewayDevices(neutronL2gatewayDevices);
+ return result;
+ }
+
+ @Override
+ protected L2gateway toMd(NeutronL2gateway neutronObject) {
+ L2gatewayBuilder l2gatewayBuilder = new L2gatewayBuilder();
+ if (neutronObject.getL2gatewayName() != null){
+ l2gatewayBuilder.setL2gatewayName(neutronObject.getL2gatewayName());
+ }
+ if (neutronObject.getID() != null){
+ l2gatewayBuilder.setUuid(toUuid(neutronObject.getID()));
+ }
+ if (neutronObject.getTenantID() != null){
+ l2gatewayBuilder.setTenantId(toUuid(neutronObject.getTenantID()));
+ }
+
+ if (neutronObject.getNeutronL2gatewayDevices() != null){
+ List<Devices> devices = new ArrayList<>();
+ for(NeutronL2gatewayDevice neutronL2gatewayDevice:neutronObject.getNeutronL2gatewayDevices()){
+ DevicesBuilder deviceBuilder = new DevicesBuilder();
+ List<Interfaces> interfaces = new ArrayList<Interfaces>();
+ for(NeutronL2gatewayDeviceInterface neutronL2gatewayDeviceInterface:neutronL2gatewayDevice
+ .getNeutronL2gatewayDeviceInterfaces()){
+ InterfacesBuilder interfacesBuilder = new InterfacesBuilder();
+ List<Integer> segmentIds = new ArrayList<Integer>();
+ interfacesBuilder.setInterfaceName(neutronL2gatewayDeviceInterface.getInterfaceName());
+ if (neutronL2gatewayDeviceInterface.getSegmentationId() != null){
+ for(Integer segmentationId:neutronL2gatewayDeviceInterface
+ .getSegmentationId()){
+ segmentIds.add(segmentationId);
+ }
+ interfacesBuilder.setSegmentationIds(segmentIds);
+ }
+ interfaces.add(interfacesBuilder.build());
+ }
+ deviceBuilder.setDeviceName(neutronL2gatewayDevice.getDeviceName());
+ deviceBuilder.setInterfaces(interfaces);
+ devices.add(deviceBuilder.build());
+ }
+ l2gatewayBuilder.setDevices(devices);
+ }
+ return l2gatewayBuilder.build();
+ }
+
+ @Override
+ protected L2gateway toMd(String uuid) {
+ L2gatewayBuilder l2gatewayBuilder = new L2gatewayBuilder();
+ l2gatewayBuilder.setUuid(toUuid(uuid));
+ return l2gatewayBuilder.build();
+ }
+
+ public static void registerNewInterface(BundleContext context,
+ ProviderContext providerContext,
+ List<ServiceRegistration<?>> registrations) {
+ NeutronL2gatewayInterface neutronL2gatewayInterface = new NeutronL2gatewayInterface(providerContext);
+ ServiceRegistration<INeutronL2gatewayCRUD> neutronL2gatewayInterfaceRegistration = context
+ .registerService(INeutronL2gatewayCRUD.class, neutronL2gatewayInterface, null);
+ if (neutronL2gatewayInterfaceRegistration != null) {
+ registrations.add(neutronL2gatewayInterfaceRegistration);
+ }
+ }
+
+}