[Falcon][WIP] CORD-368 Added APIs for service dependency
- Added create/remove service dependency to CordVtn
- Added new type for service ID
Change-Id: If836ab6bcc5e60c1707b2dbf0a244a204529b007
diff --git a/pom.xml b/pom.xml
index 3f3ec23..45fef52 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,6 +70,33 @@
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
+ <artifactId>onos-rest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-rest</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-servlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
<artifactId>onos-app-openstackswitching-api</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/src/main/java/org/onosproject/cordvtn/CordVtn.java b/src/main/java/org/onosproject/cordvtn/CordVtn.java
index 6729774..a31917a 100644
--- a/src/main/java/org/onosproject/cordvtn/CordVtn.java
+++ b/src/main/java/org/onosproject/cordvtn/CordVtn.java
@@ -282,6 +282,14 @@
return state != null && state.equals(NodeState.COMPLETE);
}
+ @Override
+ public void createServiceDependency(ServiceId tenantServiceId, ServiceId providerServiceId) {
+ }
+
+ @Override
+ public void removeServiceDependency(ServiceId tenantServiceId, ServiceId providerServiceId) {
+ }
+
/**
* Returns state of a given cordvtn node.
*
diff --git a/src/main/java/org/onosproject/cordvtn/CordVtnService.java b/src/main/java/org/onosproject/cordvtn/CordVtnService.java
index 5ab7baf..7bbc1e3 100644
--- a/src/main/java/org/onosproject/cordvtn/CordVtnService.java
+++ b/src/main/java/org/onosproject/cordvtn/CordVtnService.java
@@ -65,4 +65,20 @@
* @return list of nodes
*/
List<CordVtnNode> getNodes();
+
+ /**
+ * Creates a dependency between two services.
+ *
+ * @param tenantServiceId id of the service which has a dependency
+ * @param providerServiceId id of the service which provides dependency
+ */
+ void createServiceDependency(ServiceId tenantServiceId, ServiceId providerServiceId);
+
+ /**
+ * Removes a dependency between two services.
+ *
+ * @param tenantServiceId id of the service which has a dependency
+ * @param providerServiceId id of the service which provides dependency
+ */
+ void removeServiceDependency(ServiceId tenantServiceId, ServiceId providerServiceId);
}
diff --git a/src/main/java/org/onosproject/cordvtn/Service.java b/src/main/java/org/onosproject/cordvtn/Service.java
new file mode 100644
index 0000000..2c31ccc
--- /dev/null
+++ b/src/main/java/org/onosproject/cordvtn/Service.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cordvtn;
+
+import com.google.common.base.MoreObjects;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+
+import java.util.Objects;
+
+public final class Service {
+
+ enum ServiceType {
+ PRIVATE,
+ PRIVATE_DIRECT,
+ PRIVATE_INDIRECT,
+ PUBLIC_DIRECT,
+ PUBLIC_INDIRECT
+ }
+
+ private final ServiceId serviceId;
+ private final String networkId;
+ private final ServiceType serviceType;
+ private final IpPrefix serviceIpRange;
+ private final IpAddress serviceIp;
+
+ /**
+ * Default constructor.
+ *
+ * @param serviceId service id
+ * @param networkId OpenStack Neutron network id
+ * @param serviceType service type
+ * @param serviceIpRange service ip range
+ * @param serviceIp service ip
+ */
+ public Service(ServiceId serviceId, String networkId, ServiceType serviceType,
+ IpPrefix serviceIpRange, IpAddress serviceIp) {
+ this.serviceId = serviceId;
+ this.networkId = networkId;
+ this.serviceType = serviceType;
+ this.serviceIpRange = serviceIpRange;
+ this.serviceIp = serviceIp;
+ }
+
+ /**
+ * Returns service ID.
+ *
+ * @return service id
+ */
+ public ServiceId serviceId() {
+ return serviceId;
+ }
+
+ /**
+ * Returns OpenStack Neutron network ID of this service.
+ *
+ * @return network id
+ */
+ public String networkId() {
+ return networkId;
+ }
+
+ /**
+ * Returns service type.
+ *
+ * @return service type
+ */
+ public ServiceType serviceType() {
+ return serviceType;
+ }
+
+ /**
+ * Returns service IP range.
+ *
+ * @return CIDR
+ */
+ public IpPrefix serviceIpRange() {
+ return serviceIpRange;
+ }
+
+ /**
+ * Returns service IP address.
+ *
+ * @return ip address
+ */
+ public IpAddress serviceIp() {
+ return serviceIp;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(serviceId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof Service)) {
+ return false;
+ }
+ final Service other = (Service) obj;
+ return Objects.equals(this.serviceId, other.serviceId);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("serviceId", serviceId)
+ .add("networkId", networkId)
+ .add("serviceType", serviceType)
+ .add("serviceIpRange", serviceIpRange)
+ .add("serviceIp", serviceIp)
+ .toString();
+ }
+}
diff --git a/src/main/java/org/onosproject/cordvtn/ServiceId.java b/src/main/java/org/onosproject/cordvtn/ServiceId.java
new file mode 100644
index 0000000..0971692
--- /dev/null
+++ b/src/main/java/org/onosproject/cordvtn/ServiceId.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cordvtn;
+
+import com.google.common.base.MoreObjects;
+
+import java.util.Objects;
+
+/**
+ * Representation of service identifier.
+ */
+public final class ServiceId {
+
+ private final long serviceId;
+
+ /**
+ * Default constructor.
+ *
+ * @param serviceId service identifier
+ */
+ private ServiceId(long serviceId) {
+ this.serviceId = serviceId;
+ }
+
+ /**
+ * Returns the ServiceId with value.
+ *
+ * @param serviceId service id
+ * @return ServiceId
+ */
+ public static ServiceId of(long serviceId) {
+ return new ServiceId(serviceId);
+ }
+
+ /**
+ * Returns service identifier.
+ *
+ * @return service id
+ */
+ public long serviceId() {
+ return serviceId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(serviceId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof ServiceId)) {
+ return false;
+ }
+ final ServiceId other = (ServiceId) obj;
+ return Objects.equals(this.serviceId, other.serviceId);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("serviceId", serviceId)
+ .toString();
+ }
+}
diff --git a/src/main/java/org/onosproject/cordvtn/rest/ApiDocRegistrator.java b/src/main/java/org/onosproject/cordvtn/rest/ApiDocRegistrator.java
new file mode 100644
index 0000000..b6e876f
--- /dev/null
+++ b/src/main/java/org/onosproject/cordvtn/rest/ApiDocRegistrator.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cordvtn.rest;
+
+import org.apache.felix.scr.annotations.Component;
+import org.onosproject.rest.AbstractApiDocRegistrator;
+import org.onosproject.rest.ApiDocProvider;
+
+@Component(immediate = true)
+public class ApiDocRegistrator extends AbstractApiDocRegistrator {
+ public ApiDocRegistrator() {
+ super(new ApiDocProvider("/onos/cordvtn",
+ "CORD VTN Service REST API",
+ ApiDocRegistrator.class.getClassLoader()));
+ }
+}
diff --git a/src/main/java/org/onosproject/cordvtn/rest/ServiceDependencyWebResource.java b/src/main/java/org/onosproject/cordvtn/rest/ServiceDependencyWebResource.java
new file mode 100644
index 0000000..77822f2
--- /dev/null
+++ b/src/main/java/org/onosproject/cordvtn/rest/ServiceDependencyWebResource.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cordvtn.rest;
+
+import org.onosproject.rest.AbstractWebResource;
+
+import javax.ws.rs.Path;
+
+/**
+ * Manages service dependency.
+ */
+@Path("service-dependency")
+public class ServiceDependencyWebResource extends AbstractWebResource {
+}
diff --git a/src/main/java/org/onosproject/cordvtn/rest/package-info.java b/src/main/java/org/onosproject/cordvtn/rest/package-info.java
new file mode 100644
index 0000000..797a83f
--- /dev/null
+++ b/src/main/java/org/onosproject/cordvtn/rest/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * REST APIs for CORD VTN.
+ */
+package org.onosproject.cordvtn.rest;
\ No newline at end of file