Hyunsun Moon
Committed by Gerrit Code Review

[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
......@@ -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>
......
......@@ -282,6 +282,14 @@ public class CordVtn implements CordVtnService {
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.
*
......
......@@ -65,4 +65,20 @@ public interface CordVtnService {
* @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);
}
......
/*
* 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();
}
}
/*
* 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();
}
}
/*
* 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()));
}
}
/*
* 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 {
}
/*
* 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