diff options
author | Ashlee Young <ashlee@wildernessvoice.com> | 2015-11-11 14:39:51 -0800 |
---|---|---|
committer | Ashlee Young <ashlee@wildernessvoice.com> | 2015-11-11 14:40:00 -0800 |
commit | baac58c7c50e6f89eb0520e3f5b0e83a69839bd3 (patch) | |
tree | 9c5a149ee6cdf345fed7dfe8c97fcaac8959a70d /framework/src/onos/apps/vtn | |
parent | 8f92448e4f2f5d9c98036097bdabd1c40166908a (diff) |
Updating onos src to commit id ec0425c18cbe49d368c600160f033acf9fe344ca
Change-Id: Iec2815bf7771080f25272842b852bd9d33f908ff
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/apps/vtn')
12 files changed, 442 insertions, 10 deletions
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/Router.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/Router.java new file mode 100644 index 00000000..e853ec2f --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/Router.java @@ -0,0 +1,102 @@ +/*
+ * 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.vtnrsc;
+
+import java.util.List;
+
+/**
+ * Representation of a Router.
+ */
+public interface Router {
+
+ /**
+ * Coarse classification of the type of the Router.
+ */
+ public enum Status {
+ /**
+ * Signifies that a router is currently active.
+ */
+ ACTIVE,
+ /**
+ * Signifies that a router is currently inactive.
+ */
+ INACTIVE
+ }
+
+ /**
+ * Returns the router identifier.
+ *
+ * @return identifier
+ */
+ RouterId id();
+
+ /**
+ * Returns the router Name.
+ *
+ * @return routerName
+ */
+ String name();
+
+ /**
+ * Returns the router admin state.
+ *
+ * @return true or false
+ */
+ boolean adminStateUp();
+
+ /**
+ * Returns the status of router.
+ *
+ * @return RouterStatus
+ */
+ Status status();
+
+ /**
+ * Returns the distributed status of this router.
+ * If true, indicates a distributed router.
+ *
+ * @return true or false
+ */
+ boolean distributed();
+
+ /**
+ * Returns the RouterGateway of router.
+ *
+ * @return routerGateway
+ */
+ RouterGateway externalGatewayInfo();
+
+ /**
+ * Returns the gatewayPortid of router.
+ *
+ * @return virtualPortId
+ */
+ VirtualPortId gatewayPortid();
+
+ /**
+ * Returns the owner(tenant) of this router.
+ *
+ * @return tenantId
+ */
+ TenantId tenantId();
+
+ /**
+ * Returns the router list of router.
+ *
+ * @return routes
+ */
+ List<String> routes();
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterGateway.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterGateway.java new file mode 100644 index 00000000..9a755561 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterGateway.java @@ -0,0 +1,108 @@ +/*
+ * 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.vtnrsc;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Collection;
+import java.util.Objects;
+
+/**
+ * Representation of a Router gateway.
+ */
+public final class RouterGateway {
+
+ private final TenantNetworkId networkId;
+ private final boolean enableSnat;
+ private final Collection<FixedIp> externalFixedIps;
+
+ // Public construction is prohibited
+ private RouterGateway(TenantNetworkId networkId, boolean enableSnat,
+ Collection<FixedIp> externalFixedIps) {
+ this.networkId = checkNotNull(networkId, "networkId cannot be null");
+ this.enableSnat = checkNotNull(enableSnat, "enableSnat cannot be null");
+ this.externalFixedIps = checkNotNull(externalFixedIps, "externalFixedIps cannot be null");
+ }
+
+ /**
+ * Creates router gateway object.
+ *
+ * @param networkId network identifier
+ * @param enableSnat SNAT enable or not
+ * @param externalFixedIps external fixed IP
+ * @return RouterGateway
+ */
+ public static RouterGateway routerGateway(TenantNetworkId networkId, boolean enableSnat,
+ Collection<FixedIp> externalFixedIps) {
+ return new RouterGateway(networkId, enableSnat, externalFixedIps);
+ }
+
+ /**
+ * Returns network identifier.
+ *
+ * @return networkId
+ */
+ public TenantNetworkId networkId() {
+ return networkId;
+ }
+
+ /**
+ * Return SNAT enable or not.
+ *
+ * @return enableSnat
+ */
+ public boolean enableSnat() {
+ return enableSnat;
+ }
+
+ /**
+ * Return external fixed Ip.
+ *
+ * @return externalFixedIps
+ */
+ public Collection<FixedIp> externalFixedIps() {
+ return externalFixedIps;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(networkId, enableSnat, externalFixedIps);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof RouterGateway) {
+ final RouterGateway that = (RouterGateway) obj;
+ return Objects.equals(this.networkId, that.networkId)
+ && Objects.equals(this.enableSnat, that.enableSnat)
+ && Objects.equals(this.externalFixedIps, that.externalFixedIps);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("networkId", networkId)
+ .add("enableSnat", enableSnat)
+ .add("externalFixedIps", externalFixedIps)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterId.java new file mode 100644 index 00000000..d396c0d1 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/RouterId.java @@ -0,0 +1,77 @@ +/* + * 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.vtnrsc; + +import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Objects; + +/** + * Immutable representation of a router identifier. + */ +public final class RouterId { + + private final String routerId; + + // Public construction is prohibited + private RouterId(String routerId) { + checkNotNull(routerId, "routerId cannot be null"); + this.routerId = routerId; + } + + /** + * Creates a router identifier. + * + * @param routerId the router identifier + * @return the router identifier + */ + public static RouterId valueOf(String routerId) { + return new RouterId(routerId); + } + + /** + * Returns the router identifier. + * + * @return the router identifier + */ + public String routerId() { + return routerId; + } + + @Override + public int hashCode() { + return routerId.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof RouterId) { + final RouterId that = (RouterId) obj; + return Objects.equals(this.routerId, that.routerId); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this).add("routerId", routerId).toString(); + } +} + diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/FlowClassifierService.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java index e379be81..c160d221 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/FlowClassifierService.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierService.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.onosproject.vtnrsc.flowClassifier; +package org.onosproject.vtnrsc.flowclassifier; import org.onosproject.vtnrsc.FlowClassifier; import org.onosproject.vtnrsc.FlowClassifierId; @@ -69,4 +69,4 @@ public interface FlowClassifierService { * @return true if Flow Classifier removal is success otherwise return false. */ boolean removeFlowClassifier(FlowClassifierId id); -}
\ No newline at end of file +} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/FlowClassifierManager.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java index ca01c434..ee5873d6 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/FlowClassifierManager.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/FlowClassifierManager.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.onosproject.vtnrsc.flowClassifier.impl; +package org.onosproject.vtnrsc.flowclassifier.impl; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; @@ -29,7 +29,7 @@ import org.onosproject.store.service.StorageService; import org.onosproject.store.service.WallClockTimestamp; import org.onosproject.vtnrsc.FlowClassifierId; import org.onosproject.vtnrsc.FlowClassifier; -import org.onosproject.vtnrsc.flowClassifier.FlowClassifierService; +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService; import org.slf4j.Logger; import static org.slf4j.LoggerFactory.getLogger; @@ -121,4 +121,4 @@ public class FlowClassifierManager implements FlowClassifierService { } return true; } -}
\ No newline at end of file +} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/package-info.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/package-info.java index 4ea050b3..62b5603d 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/package-info.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/impl/package-info.java @@ -17,4 +17,4 @@ /** * Provides implementation of the flow Classifier service. */ -package org.onosproject.vtnrsc.flowClassifier.impl; +package org.onosproject.vtnrsc.flowclassifier.impl; diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/package-info.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/package-info.java index 07584170..c8c75bf3 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/package-info.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowclassifier/package-info.java @@ -17,4 +17,4 @@ /** * Service for interacting with flow Classifier of SFC. */ -package org.onosproject.vtnrsc.flowClassifier; +package org.onosproject.vtnrsc.flowclassifier; diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java index 88fecf8d..a87bdb99 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.onosproject.vtnrsc.portpair; +package org.onosproject.vtnrsc.portchain; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java index 7da4c489..25db9d2e 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.onosproject.vtnrsc.portpair; +package org.onosproject.vtnrsc.portpairgroup; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterGatewayTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterGatewayTest.java new file mode 100644 index 00000000..ce6b6c00 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterGatewayTest.java @@ -0,0 +1,82 @@ +/* + * 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.vtnrsc.router; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.Test; +import org.onosproject.vtnrsc.RouterGateway; +import org.onosproject.vtnrsc.TenantNetworkId; +import org.onosproject.vtnrsc.FixedIp; + +import com.google.common.testing.EqualsTester; + +/** + * Unit tests for RouterGateway class. + */ +public class RouterGatewayTest { + final TenantNetworkId networkId1 = TenantNetworkId.networkId("1"); + final TenantNetworkId networkId2 = TenantNetworkId.networkId("2"); + final Set<FixedIp> fixedIpSet1 = new HashSet<>(); + final Set<FixedIp> fixedIpSet2 = new HashSet<>(); + + /** + * Checks that the RouterGateway class is immutable. + */ + @Test + public void testImmutability() { + assertThatClassIsImmutable(RouterGateway.class); + } + + /** + * Checks the operation of equals(). + */ + @Test + public void testEquals() { + RouterGateway routerGateway1 = RouterGateway.routerGateway(networkId1, + true, + fixedIpSet1); + RouterGateway routerGateway2 = RouterGateway.routerGateway(networkId1, + true, + fixedIpSet1); + RouterGateway routerGateway3 = RouterGateway.routerGateway(networkId2, + true, + fixedIpSet2); + new EqualsTester().addEqualityGroup(routerGateway1, routerGateway2) + .addEqualityGroup(routerGateway3).testEquals(); + } + + /** + * Checks the construction of a RouterGateway object. + */ + @Test + public void testConstruction() { + RouterGateway routerGateway = RouterGateway.routerGateway(networkId1, + true, + fixedIpSet1); + assertThat(fixedIpSet1, is(notNullValue())); + assertThat(fixedIpSet1, is(routerGateway.externalFixedIps())); + assertThat(networkId1, is(notNullValue())); + assertThat(networkId1, is(routerGateway.networkId())); + assertThat(routerGateway.enableSnat(), is(true)); + } +} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterIdTest.java new file mode 100644 index 00000000..3751c11a --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterIdTest.java @@ -0,0 +1,63 @@ +/* + * 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.vtnrsc.router; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; + +import org.junit.Test; +import org.onosproject.vtnrsc.RouterId; + +import com.google.common.testing.EqualsTester; + +/** + * Unit tests for RouterId class. + */ +public class RouterIdTest { + final RouterId routerId1 = RouterId.valueOf("1"); + final RouterId sameAsRouterId1 = RouterId.valueOf("1"); + final RouterId routerId2 = RouterId.valueOf("2"); + + /** + * Checks that the RouterId class is immutable. + */ + @Test + public void testImmutability() { + assertThatClassIsImmutable(RouterId.class); + } + + /** + * Checks the operation of equals() methods. + */ + @Test + public void testEquals() { + new EqualsTester().addEqualityGroup(routerId1, sameAsRouterId1).addEqualityGroup(routerId2) + .testEquals(); + } + + /** + * Checks the construction of a RouterId object. + */ + @Test + public void testConstruction() { + final String routerIdValue = "s"; + final RouterId routerId = RouterId.valueOf(routerIdValue); + assertThat(routerId, is(notNullValue())); + assertThat(routerId.routerId(), is(routerIdValue)); + } +} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java index b5b8252b..7a57c0ab 100644 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java @@ -39,7 +39,7 @@ import javax.ws.rs.core.Response; import org.onosproject.vtnrsc.FlowClassifier; import org.onosproject.vtnrsc.FlowClassifierId; import org.onosproject.rest.AbstractWebResource; -import org.onosproject.vtnrsc.flowClassifier.FlowClassifierService; +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService; import org.onosproject.vtnweb.web.FlowClassifierCodec; import com.fasterxml.jackson.databind.ObjectMapper; |