xuzhang
Committed by Gerrit Code Review

[ONOS-2112]Create an application used to manage virtual network subnet and

virtualPort resource. Change the same of onos app as vtnrsc meaning that
the virtual resource.

Change-Id: Ia6057acdb39a6f51c1e67c0b143df8320dbcb224
......@@ -53,6 +53,7 @@
<module>pcep-api</module>
<module>olt</module>
<module>flowanalyzer</module>
<module>vtnrsc</module>
</modules>
<properties>
......
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
<version>1.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-vtnrsc</artifactId>
<packaging>bundle</packaging>
<properties>
<onos.app.name>org.onosproject.vtnrsc</onos.app.name>
<web.context>/onos/vtn</web.context>
</properties>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-api</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-cli</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<_wab>src/main/webapp/</_wab>
<Bundle-SymbolicName>
${project.groupId}.${project.artifactId}
</Bundle-SymbolicName>
<Import-Package>
org.slf4j,
org.osgi.framework,
javax.ws.rs,
javax.ws.rs.core,
com.sun.jersey.api.core,
com.sun.jersey.spi.container.servlet,
com.sun.jersey.server.impl.container.servlet,
com.fasterxml.jackson.databind,
com.fasterxml.jackson.databind.node,
com.fasterxml.jackson.core,
org.apache.karaf.shell.commands,
org.apache.commons.lang.math.*,
com.google.common.*,
org.onlab.packet.*,
org.onlab.rest.*,
org.onosproject.*,
org.onlab.util.*,
org.jboss.netty.util.*
</Import-Package>
<Web-ContextPath>${web.context}</Web-ContextPath>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
/*
* 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.app.vtnrsc;
import org.onlab.packet.IpAddress;
/**
* The continuous IP address range between the start address and the end address for the allocation pools.
*/
public interface AllocationPool {
/**
* The start address for the allocation pool.
*
* @return startIp
*/
IpAddress startIP();
/**
* The end address for the allocation pool.
*
* @return endIp
*/
IpAddress endIP();
}
/*
* 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.app.vtnrsc;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
/**
* Immutable representation of a allowed address pair.
*/
public final class AllowedAddressPair {
private final IpAddress ip;
private final MacAddress mac;
// Public construction is prohibited
private AllowedAddressPair(IpAddress ip, MacAddress mac) {
checkNotNull(ip, "IpAddress cannot be null");
checkNotNull(mac, "MacAddress cannot be null");
this.ip = ip;
this.mac = mac;
}
/**
* Returns the AllowedAddressPair ip address.
*
* @return ip address
*/
public IpAddress ip() {
return ip;
}
/**
* Returns the AllowedAddressPair MAC address.
*
* @return MAC address
*/
public MacAddress mac() {
return mac;
}
/**
* Creates a allowedAddressPair using the supplied ipAddress &amp;
* macAddress.
*
* @param ip IP address
* @param mac MAC address
* @return AllowedAddressPair
*/
public static AllowedAddressPair allowedAddressPair(IpAddress ip,
MacAddress mac) {
return new AllowedAddressPair(ip, mac);
}
@Override
public int hashCode() {
return Objects.hash(ip, mac);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof AllowedAddressPair) {
final AllowedAddressPair that = (AllowedAddressPair) obj;
return Objects.equals(this.ip, that.ip)
&& Objects.equals(this.mac, that.mac);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this).add("ip", ip).add("mac", mac).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.app.vtnrsc;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
import org.onlab.packet.IpAddress;
/**
* Immutable representation of a IP address for the port, Include the IP address
* and subnet identity.
*/
public final class FixedIp {
private final SubnetId subnetId;
private final IpAddress ip;
// Public construction is prohibited
private FixedIp(SubnetId subnetId, IpAddress ip) {
checkNotNull(subnetId, "SubnetId cannot be null");
checkNotNull(ip, "IpAddress cannot be null");
this.subnetId = subnetId;
this.ip = ip;
}
/**
* Returns the FixedIp subnet identifier.
*
* @return subnet identifier
*/
public SubnetId subnetId() {
return subnetId;
}
/**
* Returns the FixedIp IP address.
*
* @return IP address
*/
public IpAddress ip() {
return ip;
}
/**
* Creates a fixed ip using the supplied fixedIp.
*
* @param subnetId subnet identity
* @param ip IP address
* @return FixedIp
*/
public static FixedIp fixedIp(SubnetId subnetId, IpAddress ip) {
return new FixedIp(subnetId, ip);
}
@Override
public int hashCode() {
return Objects.hash(subnetId, ip);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof FixedIp) {
final FixedIp that = (FixedIp) obj;
return Objects.equals(this.subnetId, that.subnetId)
&& Objects.equals(this.ip, that.ip);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this).add("subnetId", subnetId).add("ip", ip)
.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.app.vtnrsc;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
/**
* Host route dictionaries for the subnet.
*/
public interface HostRoute {
/**
* Returns the next hop address.
*
* @return next hop address
*/
IpAddress nexthop();
/**
* Returns the destination address.
*
* @return destination address
*/
IpPrefix destination();
}
/*
* 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.app.vtnrsc;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Immutable representation of a physicalnetwork identity.
*/
public final class PhysicalNetwork {
private final String physicalnetwork;
// Public construction is prohibited
private PhysicalNetwork(String physicalnetwork) {
checkNotNull(physicalnetwork, "Physicalnetwork cannot be null");
this.physicalnetwork = physicalnetwork;
}
/**
* Creates a network id using the physicalnetwork.
*
* @param physicalnetwork network String
* @return physicalnetwork
*/
public static PhysicalNetwork physicalNetwork(String physicalnetwork) {
return new PhysicalNetwork(physicalnetwork);
}
/**
*
* @return physicalnetwork
*/
public String physicalnetwork() {
return physicalnetwork;
}
@Override
public int hashCode() {
return Objects.hash(physicalnetwork);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof PhysicalNetwork) {
final PhysicalNetwork that = (PhysicalNetwork) obj;
return this.getClass() == that.getClass()
&& Objects.equals(this.physicalnetwork,
that.physicalnetwork);
}
return false;
}
@Override
public String toString() {
return physicalnetwork;
}
}
/*
* 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.app.vtnrsc;
import java.util.Objects;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Immutable representation of a security group.
*/
public final class SecurityGroup {
private final String securityGroup;
/**
* Returns the securityGroup.
*
* @return securityGroup
*/
public String securityGroup() {
return securityGroup;
}
// Public construction is prohibited
private SecurityGroup(String securityGroup) {
checkNotNull(securityGroup, "SecurityGroup cannot be null");
this.securityGroup = securityGroup;
}
/**
* Creates a securityGroup using the supplied securityGroup.
*
* @param securityGroup security group
* @return securityGroup
*/
public static SecurityGroup securityGroup(String securityGroup) {
return new SecurityGroup(securityGroup);
}
@Override
public int hashCode() {
return Objects.hash(securityGroup);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof SecurityGroup) {
final SecurityGroup that = (SecurityGroup) obj;
return this.getClass() == that.getClass()
&& Objects.equals(this.securityGroup, that.securityGroup);
}
return false;
}
@Override
public String toString() {
return toStringHelper(this).add("securityGroup", securityGroup)
.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.app.vtnrsc;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Immutable representation of a Segmentation identity.
*/
public final class SegmentationId {
private final String segmentationid;
// Public construction is prohibited
private SegmentationId(String segmentationid) {
checkNotNull(segmentationid, "Segmentationid cannot be null");
this.segmentationid = segmentationid;
}
/**
* Creates a network id using the segmentationid.
*
* @param segmentationid network String
* @return SegmentationId
*/
public static SegmentationId segmentationID(String segmentationid) {
return new SegmentationId(segmentationid);
}
/**
*
* @return segmentationid
*/
public String segmentationid() {
return segmentationid;
}
@Override
public int hashCode() {
return Objects.hash(segmentationid);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof SegmentationId) {
final SegmentationId that = (SegmentationId) obj;
return this.getClass() == that.getClass()
&& Objects.equals(this.segmentationid, that.segmentationid);
}
return false;
}
@Override
public String toString() {
return segmentationid;
}
}
/*
*Copyright 2014 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.app.vtnrsc;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpAddress.Version;
import org.onlab.packet.IpPrefix;
/**
* Representation of a subnet.
*/
public interface Subnet {
/**
* Coarse classification of the type of the ipV6Mode.
*/
public enum Mode {
DHCPV6_STATEFUL, DHCPV6_STATELESS, SLAAC
}
/**
* Returns the ID of the subnet.
*
* @return id
*/
SubnetId id();
/**
* Returns the name of the subnet.
*
* @return subnetName
*/
String subnetName();
/**
* Returns the ID of the attached network.
*
* @return networkID
*/
TenantNetworkId networkId();
/**
* Returns the The ID of the tenant who owns the network. Only
* administrative users can specify a tenant ID other than their own. You
* cannot change this value through authorization policies.
*
* @return tenantID
*/
TenantId tenantId();
/**
* Returns the IP version, which is 4 or 6.
*
* @return ipVersion
*/
Version ipVersion();
/**
* Returns the cidr.
*
* @return cidr
*/
IpPrefix cidr();
/**
* Returns the gateway IP address..
*
* @return gatewayIP
*/
IpAddress gatewayIp();
/**
* Returns true if DHCP is enabled and return false if DHCP is disabled.
*
* @return dhcpEnabled
*/
boolean dhcpEnabled();
/**
* Indicates whether this tenantNetwork is shared across all tenants. By
* default,only administrative user can change this value.
*
* @return shared
*/
boolean shared();
/**
* Returns an iterable collections of hostRoutes.
*
* @return hostRoutes collection
*/
Iterable<HostRoute> hostRoutes();
/**
* Returns the ipV6AddressMode. A valid value is dhcpv6-stateful,
* dhcpv6-stateless, or slaac.
*
* @return ipV6AddressMode
*/
Mode ipV6AddressMode();
/**
* Returns the ipV6RaMode.A valid value is dhcpv6-stateful,
* dhcpv6-stateless, or slaac.
*
* @return ipV6RaMode
*/
Mode ipV6RaMode();
/**
* Returns an iterable collection of allocation_pools.
*
* @return allocationPools collection
*/
Iterable<AllocationPool> allocationPools();
}
/*
* 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.app.vtnrsc;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
/**
* Immutable representation of a subnet identity.
*/
public final class SubnetId {
private final String subnetId;
// Public construction is prohibited
private SubnetId(String subnetId) {
checkNotNull(subnetId, "SubnetId cannot be null");
this.subnetId = subnetId;
}
/**
* Creates a subnet identifier.
*
* @param subnetId subnet identifier
* @return SubnetId SubnetId
*/
public static SubnetId subnetId(String subnetId) {
return new SubnetId(subnetId);
}
@Override
public int hashCode() {
return Objects.hash(subnetId);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof SubnetId) {
final SubnetId that = (SubnetId) obj;
return this.getClass() == that.getClass()
&& Objects.equals(this.subnetId, that.subnetId);
}
return false;
}
@Override
public String toString() {
return subnetId;
}
}
/*
* 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.app.vtnrsc;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Immutable representation of a network identity.
*/
public final class TenantId {
private final String tenantid;
// Public construction is prohibited
private TenantId(String tenantid) {
this.tenantid = tenantid;
}
/**
* Creates a network id using the tenantid.
*
* @param tenantid network String
* @return TenantId
*/
public static TenantId tenantId(String tenantid) {
checkNotNull(tenantid, "Tenantid can not be null");
return new TenantId(tenantid);
}
/**
*
* @return tenantid
*/
public String tenantid() {
return tenantid;
}
@Override
public int hashCode() {
return Objects.hash(tenantid);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof TenantId) {
final TenantId that = (TenantId) obj;
return this.getClass() == that.getClass()
&& Objects.equals(this.tenantid, that.tenantid);
}
return false;
}
@Override
public String toString() {
return tenantid;
}
}
/*
* 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.app.vtnrsc;
/**
* Representation of the tenantNetwork.
*/
public interface TenantNetwork {
/**
* Coarse classification of the state of the tenantNetwork.
*/
public enum State {
/**
* Signifies that a tenantNetwork is currently active.This state means
* that this network is available.
*/
ACTIVE,
/**
* Signifies that a tenantNetwork is currently built.
*/
BUILD,
/**
* Signifies that a tenantNetwork is currently unavailable.
*/
DOWN,
/**
* Signifies that a tenantNetwork is currently error.
*/
ERROR
}
/**
* Coarse classification of the type of the tenantNetwork.
*/
public enum Type {
/**
* Signifies that a tenantNetwork is local.
*/
LOCAL
}
/**
* Returns the tenantNetwork identifier.
*
* @return tenantNetwork identifier
*/
TenantNetworkId id();
/**
* Returns the tenantNetwork name.
*
* @return tenantNetwork name
*/
String name();
/**
* Returns the administrative state of the tenantNetwork,which is up(true)
* or down(false).
*
* @return network admin state up
*/
boolean adminStateUp();
/**
* Returns the tenantNetwork state.
*
* @return tenantNetwork state
*/
State state();
/**
* Indicates whether this tenantNetwork is shared across all tenants. By
* default,only administrative user can change this value.
*
* @return tenantNetwork shared
*/
boolean shared();
/**
* Returns the UUID of the tenant that will own the tenantNetwork. This
* tenant can be different from the tenant that makes the create
* tenantNetwork request.
*
* @return tenantNetwork tenant identifier
*/
TenantId tenantId();
/**
* Returns the routerExternal.Indicates whether this network is externally
* accessible.
*
* @return true if tenantNetwork router external
*/
boolean routerExternal();
/**
* Returns the tenantNetwork Type.
*
* @return tenantNetwork Type
*/
Type type();
/**
* Returns the tenantNetwork physical network.
*
* @return tenantNetwork physical network
*/
PhysicalNetwork physicalNetwork();
/**
* Returns the tenantNetwork segmentation id.
*
* @return tenantNetwork segmentation id
*/
SegmentationId segmentationId();
}
/*
* 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.app.vtnrsc;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Immutable representation of a tenantNetwork identity.
*/
public final class TenantNetworkId {
private final String networkid;
// Public construction is prohibited
private TenantNetworkId(String networkid) {
this.networkid = networkid;
}
/**
* Creates a tenantNetwork id using the networkid.
*
* @param networkid tenantnetwork String
* @return NetworkId
*/
public static TenantNetworkId networkId(String networkid) {
checkNotNull(networkid, "Networkid cannot be null");
return new TenantNetworkId(networkid);
}
/**
*
* @return tenantNetworkid
*/
public String networkid() {
return networkid;
}
@Override
public int hashCode() {
return Objects.hash(networkid);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof TenantNetworkId) {
final TenantNetworkId that = (TenantNetworkId) obj;
return this.getClass() == that.getClass()
&& Objects.equals(this.networkid, that.networkid);
}
return false;
}
@Override
public String toString() {
return networkid;
}
}
/*
* 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.app.vtnrsc;
import java.util.Collection;
import org.onlab.packet.MacAddress;
import org.onosproject.net.DeviceId;
import org.onosproject.net.HostId;
/**
* Representation of a virtual port.
*/
public interface VirtualPort {
/**
* Coarse classification of the type of the virtual port.
*/
public enum State {
/**
* Signifies that a virtualPort is currently active,This state mean that
* this virtualPort is available.
*/
ACTIVE,
/**
* Signifies that a virtualPort is currently unavailable.
*/
DOWN;
}
/**
* Returns the virtualPort identifier.
*
* @return virtualPort identifier
*/
VirtualPortId portId();
/**
* Returns the network identifier.
*
* @return tenantNetwork ID
*/
TenantNetworkId networkId();
/**
* Returns the symbolic name for the virtualPort.
*
* @return virtualPort name
*/
String name();
/**
* Returns the administrative status of the port,which is up(true) or
* down(false).
*
* @return true or false
*/
Boolean adminStateUp();
/**
* Returns the state.
*
* @return state
*/
State state();
/**
* Returns the MAC address.
*
* @return MAC Address
*/
MacAddress macAddress();
/**
* Returns the port tenantId.
*
* @return port tenantId
*/
TenantId tenantId();
/**
* Returns the device identifier.
*
* @return deviceId
*/
DeviceId deviceId();
/**
* Returns the identifier of the entity that uses this port.
*
* @return deviceOwner
*/
String deviceOwner();
/**
* Returns the virtualPort allowedAddressPairs.
*
* @return virtualPort allowedAddressPairs
*/
Collection<AllowedAddressPair> allowedAddressPairs();
/**
* Returns the IP address for the port, Include the IP address and subnet
* identity.
*
* @return port fixedIps
*/
FixedIp fixedIps();
/**
* Returns the virtualPort bindinghostId.
*
* @return virtualPort bindinghostId
*/
HostId bindingHostId();
/**
* Returns the virtualPort bindingVnicType.
*
* @return virtualPort bindingVnicType
*/
String bindingVnicType();
/**
* Returns the virtualPort bindingVifType.
*
* @return virtualPort bindingVifType
*/
String bindingVifType();
/**
* Returns the virtualPort bindingvifDetail.
*
* @return virtualPort bindingvifDetail
*/
String bindingvifDetails();
/**
* Returns the security groups.
*
* @return port security groups
*/
Iterable<SecurityGroup> securityGroups();
}
/*
* 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.app.vtnrsc;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
/**
* Immutable representation of a virtual port identifier.
*/
public final class VirtualPortId {
private final String portId;
// Public construction is prohibited
private VirtualPortId(String virtualPortId) {
checkNotNull(virtualPortId, "VirtualPortId cannot be null");
this.portId = virtualPortId;
}
public String portId() {
return portId;
}
/**
* Creates a virtualPort id using the supplied portId.
*
* @param portId virtualport identifier
* @return VirtualPortId
*/
public static VirtualPortId portId(String portId) {
return new VirtualPortId(portId);
}
@Override
public int hashCode() {
return Objects.hash(portId);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof VirtualPortId) {
final VirtualPortId that = (VirtualPortId) obj;
return this.getClass() == that.getClass()
&& Objects.equals(this.portId, that.portId);
}
return false;
}
@Override
public String toString() {
return portId;
}
}
/*
* 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.app.vtnrsc.subnet;
import org.onosproject.app.vtnrsc.Subnet;
import org.onosproject.app.vtnrsc.SubnetId;
/**
* Service for interacting with the inventory of subnets.
*/
public interface SubnetService {
/**
* Returns the subnet with the specified identifier.
*
* @param subnetId subnet identifier
* @return true or false
*/
boolean exists(SubnetId subnetId);
/**
* Returns a collection of the currently known subnets.
*
* @return iterable collection of subnets
*/
Iterable<Subnet> getSubnets();
/**
* Returns the subnet with the specified identifier.
*
* @param subnetId subnet identifier
* @return subnet or null if one with the given identifier is not known
*/
Subnet getSubnet(SubnetId subnetId);
/**
* Creates new subnets.
*
* @param subnets the iterable collection of subnets
* @return true if the identifier subnet has been created right
*/
boolean createSubnets(Iterable<Subnet> subnets);
/**
* Updates existing subnets.
*
* @param subnets the iterable collection of subnets
* @return true if all subnets were updated successfully
*/
boolean updateSubnets(Iterable<Subnet> subnets);
/**
* Administratively removes the specified subnets from the store.
*
* @param subnetIds the iterable collection of subnets identifier
* @return true if remove identifier subnets successfully
*/
boolean removeSubnets(Iterable<SubnetId> subnetIds);
}
/*
* 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.app.vtnrsc.tenantnetwork;
import org.onosproject.app.vtnrsc.TenantNetwork;
import org.onosproject.app.vtnrsc.TenantNetworkId;
/**
* Service for interacting with the inventory of tenantNetwork.
*/
public interface TenantNetworkService {
/**
* Returns if the tenantNetwork is existed.
*
* @param networkId tenantNetwork identifier
* @return true or false if one with the given identifier exists.
*/
boolean exists(TenantNetworkId networkId);
/**
* Returns the number of tenantNetwork known to the system.
*
* @return number of tenantNetwork.
*/
int getNetworkCount();
/**
* Returns an iterable collection of the currently known tenantNetwork.
*
* @return collection of tenantNetwork.
*/
Iterable<TenantNetwork> getNetworks();
/**
* Returns the tenantNetwork with the identifier.
*
* @param networkId TenantNetwork identifier
* @return TenantNetwork or null if one with the given identifier is not
* known.
*/
TenantNetwork getNetwork(TenantNetworkId networkId);
/**
* Creates tenantNetworks by networks.
*
* @param networks the collection of tenantNetworks
* @return true if all given identifiers created successfully.
*/
boolean createNetworks(Iterable<TenantNetwork> networks);
/**
* Updates tenantNetworks by tenantNetworks.
*
* @param networks the collection of tenantNetworks
* @return true if all given identifiers updated successfully.
*/
boolean updateNetworks(Iterable<TenantNetwork> networks);
/**
* Deletes tenantNetwork by tenantNetworkIds.
*
* @param networksId the collection of tenantNetworkIds
* @return true if the specified tenantNetwork deleted successfully.
*/
boolean removeNetworks(Iterable<TenantNetworkId> networksId);
}
/*
* Copyright 2015 Open Porting 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.app.vtnrsc.virtualport;
import java.util.Collection;
import org.onosproject.app.vtnrsc.TenantNetworkId;
import org.onosproject.app.vtnrsc.TenantId;
import org.onosproject.app.vtnrsc.VirtualPort;
import org.onosproject.app.vtnrsc.VirtualPortId;
import org.onosproject.net.DeviceId;
/**
* Service for interacting with the inventory of virtualPort.
*/
public interface VirtualPortService {
/**
* Returns if the virtualPort is existed.
*
* @param virtualPortId virtualPort identifier
* @return true or false if one with the given identifier is not existed.
*/
boolean exists(VirtualPortId virtualPortId);
/**
* Returns the virtualPort with the identifier.
*
* @param virtualPortId virtualPort ID
* @return VirtualPort or null if one with the given ID is not know.
*/
VirtualPort getPort(VirtualPortId virtualPortId);
/**
* Returns the collection of the currently known virtualPort.
*
* @return virtualPort.
*/
Collection<VirtualPort> getPorts();
/**
* Returns the collection of the virtualPorts associated with the networkId.
*
* @param networkId
* @return collection of virtualPort.
*/
Collection<VirtualPort> getPorts(TenantNetworkId networkId);
/**
* Returns the collection of the virtualPorts associated with the tenantId.
*
* @param tenantId
* @return collection of virtualPort.
*/
Collection<VirtualPort> getPorts(TenantId tenantId);
/**
* Returns the collection of the virtualPorts associated with the deviceId.
*
* @param deviceId
* @return collection of virtualPort.
*/
Collection<VirtualPort> getPorts(DeviceId deviceId);
/**
* Creates virtualPorts by virtualPorts.
*
* @param virtualPorts the iterable collection of virtualPorts
* @return true if all given identifiers created successfully.
*/
boolean createPorts(Iterable<VirtualPort> virtualPorts);
/**
* Updates virtualPorts by virtualPorts.
*
* @param virtualPorts the iterable collection of virtualPorts
* @return true if all given identifiers updated successfully.
*/
boolean updatePorts(Iterable<VirtualPort> virtualPorts);
/**
* Deletes virtualPortIds by virtualPortIds.
*
* @param virtualPortIds the iterable collection of virtualPort identifiers
* @return true or false if one with the given identifier to delete is
* successfully.
*/
boolean removePorts(Iterable<VirtualPortId> virtualPortIds);
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="ONOS" version="2.5">
<display-name>Vtnrsc Routing REST API v1.0</display-name>
<servlet>
<servlet-name>JAX-RS Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.classnames</param-name>
<param-value>
org.onosproject.app.vtnrsc.web.SubnetWebResource,
org.onosproject.app.vtnrsc.web.NeutronNetworkWebResource,
org.onosproject.app.vtnrsc.web.VirtualPortWebResource
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Service</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>