Committed by
Gerrit Code Review
[ONOS-2158]The implementation of TenantNetwork.
Change-Id: I13715bcc7687bffe878eb6f4c5f7ec1b2489e944
Showing
10 changed files
with
506 additions
and
34 deletions
| ... | @@ -55,6 +55,7 @@ | ... | @@ -55,6 +55,7 @@ |
| 55 | <module>flowanalyzer</module> | 55 | <module>flowanalyzer</module> |
| 56 | <module>vtnrsc</module> | 56 | <module>vtnrsc</module> |
| 57 | <module>vtn</module> | 57 | <module>vtn</module> |
| 58 | + <module>vtnweb</module> | ||
| 58 | </modules> | 59 | </modules> |
| 59 | 60 | ||
| 60 | <properties> | 61 | <properties> | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.app.vtnrsc; | ||
| 17 | + | ||
| 18 | +import static com.google.common.base.MoreObjects.toStringHelper; | ||
| 19 | + | ||
| 20 | +import java.util.Objects; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * Default implementation of TenantNetwork interface. | ||
| 24 | + */ | ||
| 25 | +public final class DefaultTenantNetwork implements TenantNetwork { | ||
| 26 | + private final TenantNetworkId id; | ||
| 27 | + private final String name; | ||
| 28 | + private final boolean adminStateUp; | ||
| 29 | + private final State state; | ||
| 30 | + private final boolean shared; | ||
| 31 | + private final Type type; | ||
| 32 | + private final TenantId tenantId; | ||
| 33 | + private final boolean routerExternal; | ||
| 34 | + private final PhysicalNetwork physicalNetwork; | ||
| 35 | + private final SegmentationId segmentationId; | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * Creates a neutronNetwork element attributed to the specified provider. | ||
| 39 | + * | ||
| 40 | + * @param id network identifier | ||
| 41 | + * @param name the network name | ||
| 42 | + * @param adminStateUp administrative state of the network | ||
| 43 | + * @param state the network state | ||
| 44 | + * @param shared indicates whether this network is shared across all | ||
| 45 | + * tenants, By default, only administrative user can change this | ||
| 46 | + * value | ||
| 47 | + * @param tenantId tenant identifier | ||
| 48 | + * @param routerExternal network routerExternal | ||
| 49 | + * @param type the network type | ||
| 50 | + * @param physicalNetwork physicalNetwork identifier | ||
| 51 | + * @param segmentationId segmentation identifier | ||
| 52 | + */ | ||
| 53 | + public DefaultTenantNetwork(TenantNetworkId id, String name, | ||
| 54 | + boolean adminStateUp, State state, | ||
| 55 | + boolean shared, TenantId tenantId, | ||
| 56 | + boolean routerExternal, Type type, | ||
| 57 | + PhysicalNetwork physicalNetwork, | ||
| 58 | + SegmentationId segmentationId) { | ||
| 59 | + this.id = id; | ||
| 60 | + this.name = name; | ||
| 61 | + this.adminStateUp = adminStateUp; | ||
| 62 | + this.state = state; | ||
| 63 | + this.shared = shared; | ||
| 64 | + this.type = type; | ||
| 65 | + this.tenantId = tenantId; | ||
| 66 | + this.routerExternal = routerExternal; | ||
| 67 | + this.physicalNetwork = physicalNetwork; | ||
| 68 | + this.segmentationId = segmentationId; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + @Override | ||
| 72 | + public TenantNetworkId id() { | ||
| 73 | + return id; | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Override | ||
| 77 | + public String name() { | ||
| 78 | + return name; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @Override | ||
| 82 | + public boolean adminStateUp() { | ||
| 83 | + return adminStateUp; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + @Override | ||
| 87 | + public State state() { | ||
| 88 | + return state; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + @Override | ||
| 92 | + public boolean shared() { | ||
| 93 | + return shared; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + @Override | ||
| 97 | + public TenantId tenantId() { | ||
| 98 | + return tenantId; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + @Override | ||
| 102 | + public boolean routerExternal() { | ||
| 103 | + return routerExternal; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + @Override | ||
| 107 | + public Type type() { | ||
| 108 | + return type; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + @Override | ||
| 112 | + public PhysicalNetwork physicalNetwork() { | ||
| 113 | + return physicalNetwork; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + @Override | ||
| 117 | + public SegmentationId segmentationId() { | ||
| 118 | + return segmentationId; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + @Override | ||
| 122 | + public int hashCode() { | ||
| 123 | + return Objects.hash(id, name, adminStateUp, state, shared, tenantId, | ||
| 124 | + routerExternal, type, physicalNetwork, | ||
| 125 | + segmentationId); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + @Override | ||
| 129 | + public boolean equals(Object obj) { | ||
| 130 | + if (this == obj) { | ||
| 131 | + return true; | ||
| 132 | + } | ||
| 133 | + if (obj instanceof DefaultTenantNetwork) { | ||
| 134 | + final DefaultTenantNetwork that = (DefaultTenantNetwork) obj; | ||
| 135 | + return Objects.equals(this.id, that.id) | ||
| 136 | + && Objects.equals(this.name, that.name) | ||
| 137 | + && Objects.equals(this.adminStateUp, that.adminStateUp) | ||
| 138 | + && Objects.equals(this.state, that.state) | ||
| 139 | + && Objects.equals(this.shared, that.shared) | ||
| 140 | + && Objects.equals(this.tenantId, that.tenantId) | ||
| 141 | + && Objects.equals(this.routerExternal, that.routerExternal) | ||
| 142 | + && Objects.equals(this.type, that.type) | ||
| 143 | + && Objects.equals(this.physicalNetwork, | ||
| 144 | + that.physicalNetwork) | ||
| 145 | + && Objects.equals(this.segmentationId, that.segmentationId); | ||
| 146 | + } | ||
| 147 | + return false; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + @Override | ||
| 151 | + public String toString() { | ||
| 152 | + return toStringHelper(this).add("id", id).add("name", name) | ||
| 153 | + .add("adminStateUp", adminStateUp).add("state", state) | ||
| 154 | + .add("shared", shared).add("tenantId", tenantId) | ||
| 155 | + .add("routeExternal", routerExternal).add("type", type) | ||
| 156 | + .add("physicalNetwork", physicalNetwork) | ||
| 157 | + .add("segmentationId", segmentationId).toString(); | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | +} |
| ... | @@ -20,39 +20,40 @@ import java.util.Objects; | ... | @@ -20,39 +20,40 @@ import java.util.Objects; |
| 20 | import static com.google.common.base.Preconditions.checkNotNull; | 20 | import static com.google.common.base.Preconditions.checkNotNull; |
| 21 | 21 | ||
| 22 | /** | 22 | /** |
| 23 | - * Immutable representation of a Segmentation identity. | 23 | + * Immutable representation of a Segmentation identifier. |
| 24 | */ | 24 | */ |
| 25 | public final class SegmentationId { | 25 | public final class SegmentationId { |
| 26 | 26 | ||
| 27 | - private final String segmentationid; | 27 | + private final String segmentationId; |
| 28 | 28 | ||
| 29 | // Public construction is prohibited | 29 | // Public construction is prohibited |
| 30 | - private SegmentationId(String segmentationid) { | 30 | + private SegmentationId(String segmentationId) { |
| 31 | - checkNotNull(segmentationid, "Segmentationid cannot be null"); | 31 | + checkNotNull(segmentationId, "SegmentationId cannot be null"); |
| 32 | - this.segmentationid = segmentationid; | 32 | + this.segmentationId = segmentationId; |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | /** | 35 | /** |
| 36 | - * Creates a network id using the segmentationid. | 36 | + * Creates a SegmentationId object. |
| 37 | * | 37 | * |
| 38 | - * @param segmentationid network String | 38 | + * @param segmentationId segmentation identifier |
| 39 | * @return SegmentationId | 39 | * @return SegmentationId |
| 40 | */ | 40 | */ |
| 41 | - public static SegmentationId segmentationID(String segmentationid) { | 41 | + public static SegmentationId segmentationId(String segmentationId) { |
| 42 | - return new SegmentationId(segmentationid); | 42 | + return new SegmentationId(segmentationId); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| 46 | + * Returns the segmentation identifier. | ||
| 46 | * | 47 | * |
| 47 | - * @return segmentationid | 48 | + * @return segmentationId |
| 48 | */ | 49 | */ |
| 49 | - public String segmentationid() { | 50 | + public String segmentationId() { |
| 50 | - return segmentationid; | 51 | + return segmentationId; |
| 51 | } | 52 | } |
| 52 | 53 | ||
| 53 | @Override | 54 | @Override |
| 54 | public int hashCode() { | 55 | public int hashCode() { |
| 55 | - return Objects.hash(segmentationid); | 56 | + return Objects.hash(segmentationId); |
| 56 | } | 57 | } |
| 57 | 58 | ||
| 58 | @Override | 59 | @Override |
| ... | @@ -63,14 +64,14 @@ public final class SegmentationId { | ... | @@ -63,14 +64,14 @@ public final class SegmentationId { |
| 63 | if (obj instanceof SegmentationId) { | 64 | if (obj instanceof SegmentationId) { |
| 64 | final SegmentationId that = (SegmentationId) obj; | 65 | final SegmentationId that = (SegmentationId) obj; |
| 65 | return this.getClass() == that.getClass() | 66 | return this.getClass() == that.getClass() |
| 66 | - && Objects.equals(this.segmentationid, that.segmentationid); | 67 | + && Objects.equals(this.segmentationId, that.segmentationId); |
| 67 | } | 68 | } |
| 68 | return false; | 69 | return false; |
| 69 | } | 70 | } |
| 70 | 71 | ||
| 71 | @Override | 72 | @Override |
| 72 | public String toString() { | 73 | public String toString() { |
| 73 | - return segmentationid; | 74 | + return segmentationId; |
| 74 | } | 75 | } |
| 75 | 76 | ||
| 76 | } | 77 | } | ... | ... |
| ... | @@ -71,14 +71,14 @@ public interface TenantNetwork { | ... | @@ -71,14 +71,14 @@ public interface TenantNetwork { |
| 71 | * Returns the administrative state of the tenantNetwork,which is up(true) | 71 | * Returns the administrative state of the tenantNetwork,which is up(true) |
| 72 | * or down(false). | 72 | * or down(false). |
| 73 | * | 73 | * |
| 74 | - * @return network admin state up | 74 | + * @return true or false |
| 75 | */ | 75 | */ |
| 76 | boolean adminStateUp(); | 76 | boolean adminStateUp(); |
| 77 | 77 | ||
| 78 | /** | 78 | /** |
| 79 | * Returns the tenantNetwork state. | 79 | * Returns the tenantNetwork state. |
| 80 | * | 80 | * |
| 81 | - * @return tenantNetwork state | 81 | + * @return tenant network state |
| 82 | */ | 82 | */ |
| 83 | State state(); | 83 | State state(); |
| 84 | 84 | ||
| ... | @@ -86,7 +86,7 @@ public interface TenantNetwork { | ... | @@ -86,7 +86,7 @@ public interface TenantNetwork { |
| 86 | * Indicates whether this tenantNetwork is shared across all tenants. By | 86 | * Indicates whether this tenantNetwork is shared across all tenants. By |
| 87 | * default,only administrative user can change this value. | 87 | * default,only administrative user can change this value. |
| 88 | * | 88 | * |
| 89 | - * @return tenantNetwork shared | 89 | + * @return true or false |
| 90 | */ | 90 | */ |
| 91 | boolean shared(); | 91 | boolean shared(); |
| 92 | 92 | ||
| ... | @@ -103,7 +103,7 @@ public interface TenantNetwork { | ... | @@ -103,7 +103,7 @@ public interface TenantNetwork { |
| 103 | * Returns the routerExternal.Indicates whether this network is externally | 103 | * Returns the routerExternal.Indicates whether this network is externally |
| 104 | * accessible. | 104 | * accessible. |
| 105 | * | 105 | * |
| 106 | - * @return true if tenantNetwork router external | 106 | + * @return true or false |
| 107 | */ | 107 | */ |
| 108 | boolean routerExternal(); | 108 | boolean routerExternal(); |
| 109 | 109 | ... | ... |
| ... | @@ -23,35 +23,36 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -23,35 +23,36 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 23 | */ | 23 | */ |
| 24 | public final class TenantNetworkId { | 24 | public final class TenantNetworkId { |
| 25 | 25 | ||
| 26 | - private final String networkid; | 26 | + private final String networkId; |
| 27 | 27 | ||
| 28 | // Public construction is prohibited | 28 | // Public construction is prohibited |
| 29 | - private TenantNetworkId(String networkid) { | 29 | + private TenantNetworkId(String networkId) { |
| 30 | - this.networkid = networkid; | 30 | + this.networkId = networkId; |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | /** | 33 | /** |
| 34 | - * Creates a tenantNetwork id using the networkid. | 34 | + * Creates a TenantNetwork identifier. |
| 35 | * | 35 | * |
| 36 | - * @param networkid tenantnetwork String | 36 | + * @param networkId tenantNetwork identify string |
| 37 | - * @return NetworkId | 37 | + * @return the attached tenantNetwork identifier |
| 38 | */ | 38 | */ |
| 39 | - public static TenantNetworkId networkId(String networkid) { | 39 | + public static TenantNetworkId networkId(String networkId) { |
| 40 | - checkNotNull(networkid, "Networkid cannot be null"); | 40 | + checkNotNull(networkId, "Networkid cannot be null"); |
| 41 | - return new TenantNetworkId(networkid); | 41 | + return new TenantNetworkId(networkId); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | /** | 44 | /** |
| 45 | + * Returns tenantNetwork identifier. | ||
| 45 | * | 46 | * |
| 46 | - * @return tenantNetworkid | 47 | + * @return the tenantNetwork identifier |
| 47 | */ | 48 | */ |
| 48 | - public String networkid() { | 49 | + public String networkId() { |
| 49 | - return networkid; | 50 | + return networkId; |
| 50 | } | 51 | } |
| 51 | 52 | ||
| 52 | @Override | 53 | @Override |
| 53 | public int hashCode() { | 54 | public int hashCode() { |
| 54 | - return Objects.hash(networkid); | 55 | + return Objects.hash(networkId); |
| 55 | } | 56 | } |
| 56 | 57 | ||
| 57 | @Override | 58 | @Override |
| ... | @@ -62,14 +63,14 @@ public final class TenantNetworkId { | ... | @@ -62,14 +63,14 @@ public final class TenantNetworkId { |
| 62 | if (obj instanceof TenantNetworkId) { | 63 | if (obj instanceof TenantNetworkId) { |
| 63 | final TenantNetworkId that = (TenantNetworkId) obj; | 64 | final TenantNetworkId that = (TenantNetworkId) obj; |
| 64 | return this.getClass() == that.getClass() | 65 | return this.getClass() == that.getClass() |
| 65 | - && Objects.equals(this.networkid, that.networkid); | 66 | + && Objects.equals(this.networkId, that.networkId); |
| 66 | } | 67 | } |
| 67 | return false; | 68 | return false; |
| 68 | } | 69 | } |
| 69 | 70 | ||
| 70 | @Override | 71 | @Override |
| 71 | public String toString() { | 72 | public String toString() { |
| 72 | - return networkid; | 73 | + return networkId; |
| 73 | } | 74 | } |
| 74 | 75 | ||
| 75 | } | 76 | } | ... | ... |
apps/vtnrsc/src/main/java/org/onosproject/app/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.app.vtnrsc.tenantnetwork.impl; | ||
| 17 | + | ||
| 18 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 19 | +import static org.slf4j.LoggerFactory.getLogger; | ||
| 20 | + | ||
| 21 | +import java.util.Collections; | ||
| 22 | + | ||
| 23 | +import org.apache.felix.scr.annotations.Activate; | ||
| 24 | +import org.apache.felix.scr.annotations.Component; | ||
| 25 | +import org.apache.felix.scr.annotations.Deactivate; | ||
| 26 | +import org.apache.felix.scr.annotations.Reference; | ||
| 27 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
| 28 | +import org.apache.felix.scr.annotations.Service; | ||
| 29 | +import org.onlab.util.KryoNamespace; | ||
| 30 | +import org.onosproject.app.vtnrsc.TenantNetwork; | ||
| 31 | +import org.onosproject.app.vtnrsc.TenantNetworkId; | ||
| 32 | +import org.onosproject.app.vtnrsc.tenantnetwork.TenantNetworkService; | ||
| 33 | +import org.onosproject.store.service.EventuallyConsistentMap; | ||
| 34 | +import org.onosproject.store.service.MultiValuedTimestamp; | ||
| 35 | +import org.onosproject.store.service.StorageService; | ||
| 36 | +import org.onosproject.store.service.WallClockTimestamp; | ||
| 37 | +import org.slf4j.Logger; | ||
| 38 | + | ||
| 39 | +/** | ||
| 40 | + * Provides implementation of the tenantNetworkService. | ||
| 41 | + */ | ||
| 42 | +@Component(immediate = true) | ||
| 43 | +@Service | ||
| 44 | +public class TenantNetworkManager implements TenantNetworkService { | ||
| 45 | + | ||
| 46 | + private static final String NETWORK_ID_NULL = "Network ID cannot be null"; | ||
| 47 | + private static final String NETWORK_NOT_NULL = "Network ID cannot be null"; | ||
| 48 | + | ||
| 49 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 50 | + protected StorageService storageService; | ||
| 51 | + private EventuallyConsistentMap<TenantNetworkId, TenantNetwork> networkIdAsKeyStore; | ||
| 52 | + private final Logger log = getLogger(getClass()); | ||
| 53 | + | ||
| 54 | + @Activate | ||
| 55 | + public void activate() { | ||
| 56 | + KryoNamespace.Builder serializer = KryoNamespace.newBuilder() | ||
| 57 | + .register(MultiValuedTimestamp.class); | ||
| 58 | + networkIdAsKeyStore = storageService | ||
| 59 | + .<TenantNetworkId, TenantNetwork>eventuallyConsistentMapBuilder() | ||
| 60 | + .withName("all_network").withSerializer(serializer) | ||
| 61 | + .withTimestampProvider((k, v) -> new WallClockTimestamp()) | ||
| 62 | + .build(); | ||
| 63 | + log.info("Started"); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @Deactivate | ||
| 67 | + public void deactivate() { | ||
| 68 | + networkIdAsKeyStore.destroy(); | ||
| 69 | + log.info("Stopped"); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Override | ||
| 73 | + public boolean exists(TenantNetworkId networkId) { | ||
| 74 | + checkNotNull(networkId, NETWORK_ID_NULL); | ||
| 75 | + return networkIdAsKeyStore.containsKey(networkId); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @Override | ||
| 79 | + public int getNetworkCount() { | ||
| 80 | + return networkIdAsKeyStore.size(); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @Override | ||
| 84 | + public Iterable<TenantNetwork> getNetworks() { | ||
| 85 | + return Collections.unmodifiableCollection(networkIdAsKeyStore.values()); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + @Override | ||
| 89 | + public TenantNetwork getNetwork(TenantNetworkId networkId) { | ||
| 90 | + checkNotNull(networkId, NETWORK_ID_NULL); | ||
| 91 | + return networkIdAsKeyStore.get(networkId); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + @Override | ||
| 95 | + public boolean createNetworks(Iterable<TenantNetwork> networks) { | ||
| 96 | + checkNotNull(networks, NETWORK_NOT_NULL); | ||
| 97 | + for (TenantNetwork network : networks) { | ||
| 98 | + networkIdAsKeyStore.put(network.id(), network); | ||
| 99 | + if (!networkIdAsKeyStore.containsKey(network.id())) { | ||
| 100 | + log.debug("the network created failed which identifier was {}", network.id() | ||
| 101 | + .toString()); | ||
| 102 | + return false; | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + return true; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @Override | ||
| 109 | + public boolean updateNetworks(Iterable<TenantNetwork> networks) { | ||
| 110 | + checkNotNull(networks, NETWORK_NOT_NULL); | ||
| 111 | + for (TenantNetwork network : networks) { | ||
| 112 | + if (!networkIdAsKeyStore.containsKey(network.id())) { | ||
| 113 | + log.debug("the tenantNetwork did not exist whose identifier was {} ", | ||
| 114 | + network.id().toString()); | ||
| 115 | + return false; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + networkIdAsKeyStore.put(network.id(), network); | ||
| 119 | + | ||
| 120 | + if (network.equals(networkIdAsKeyStore.get(network.id()))) { | ||
| 121 | + log.debug("the network updated failed whose identifier was {} ", | ||
| 122 | + network.id().toString()); | ||
| 123 | + return false; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + } | ||
| 127 | + return true; | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + @Override | ||
| 131 | + public boolean removeNetworks(Iterable<TenantNetworkId> networkIds) { | ||
| 132 | + checkNotNull(networkIds, NETWORK_NOT_NULL); | ||
| 133 | + for (TenantNetworkId networkId : networkIds) { | ||
| 134 | + networkIdAsKeyStore.remove(networkId); | ||
| 135 | + if (networkIdAsKeyStore.containsKey(networkId)) { | ||
| 136 | + log.debug("the network removed failed whose identifier was {}", | ||
| 137 | + networkId.toString()); | ||
| 138 | + return false; | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + return true; | ||
| 142 | + } | ||
| 143 | +} |
| 1 | +/* | ||
| 2 | + * Copyright 2015 Open Networking Laboratory | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | +package org.onosproject.app.vtnrsc.web; | ||
| 17 | + | ||
| 18 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
| 19 | + | ||
| 20 | +import org.onosproject.codec.CodecContext; | ||
| 21 | +import org.onosproject.codec.JsonCodec; | ||
| 22 | +import org.onosproject.app.vtnrsc.TenantNetwork; | ||
| 23 | + | ||
| 24 | +import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * TenantNetwork JSON codec. | ||
| 28 | + */ | ||
| 29 | +public final class TenantNetworkCodec extends JsonCodec<TenantNetwork> { | ||
| 30 | + | ||
| 31 | + @Override | ||
| 32 | + public ObjectNode encode(TenantNetwork network, CodecContext context) { | ||
| 33 | + checkNotNull(network, "Network cannot be null"); | ||
| 34 | + ObjectNode result = context.mapper().createObjectNode() | ||
| 35 | + .put("id", network.id().toString()) | ||
| 36 | + .put("name", network.name().toString()) | ||
| 37 | + .put("admin_state_up", network.adminStateUp()) | ||
| 38 | + .put("status", "" + network.state()) | ||
| 39 | + .put("shared", network.shared()) | ||
| 40 | + .put("tenant_id", network.tenantId().toString()) | ||
| 41 | + .put("router:external", network.routerExternal()) | ||
| 42 | + .put("provider:network_type", "" + network.type()) | ||
| 43 | + .put("provider:physical_network", network.physicalNetwork().toString()) | ||
| 44 | + .put("provider:segmentation_id", network.segmentationId().toString()); | ||
| 45 | + return result; | ||
| 46 | + } | ||
| 47 | +} |
apps/vtnweb/pom.xml
0 → 100644
| 1 | +<?xml version="1.0"?> | ||
| 2 | +<project | ||
| 3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
| 4 | + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
| 5 | + <modelVersion>4.0.0</modelVersion> | ||
| 6 | + <parent> | ||
| 7 | + <groupId>org.onosproject</groupId> | ||
| 8 | + <artifactId>onos-apps</artifactId> | ||
| 9 | + <version>1.3.0-SNAPSHOT</version> | ||
| 10 | + <relativePath>../pom.xml</relativePath> | ||
| 11 | + </parent> | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + <artifactId>onos-app-vtnweb</artifactId> | ||
| 15 | + <packaging>bundle</packaging> | ||
| 16 | + <properties> | ||
| 17 | + <onos.app.name>org.onosproject.vtnweb</onos.app.name> | ||
| 18 | + <web.context>/onos/vtn</web.context> | ||
| 19 | + </properties> | ||
| 20 | + | ||
| 21 | + <dependencies> | ||
| 22 | + <dependency> | ||
| 23 | + <groupId>javax.ws.rs</groupId> | ||
| 24 | + <artifactId>jsr311-api</artifactId> | ||
| 25 | + <version>1.1.1</version> | ||
| 26 | + </dependency> | ||
| 27 | + <dependency> | ||
| 28 | + <groupId>org.onosproject</groupId> | ||
| 29 | + <artifactId>onos-api</artifactId> | ||
| 30 | + </dependency> | ||
| 31 | + <dependency> | ||
| 32 | + <groupId>org.onosproject</groupId> | ||
| 33 | + <artifactId>onos-app-vtnrsc</artifactId> | ||
| 34 | + <version>${project.version}</version> | ||
| 35 | + </dependency> | ||
| 36 | + </dependencies> | ||
| 37 | + <build> | ||
| 38 | + <plugins> | ||
| 39 | + <plugin> | ||
| 40 | + <groupId>org.apache.felix</groupId> | ||
| 41 | + <artifactId>maven-bundle-plugin</artifactId> | ||
| 42 | + <extensions>true</extensions> | ||
| 43 | + <configuration> | ||
| 44 | + <instructions> | ||
| 45 | + <_wab>src/main/webapp/</_wab> | ||
| 46 | + <Bundle-SymbolicName> | ||
| 47 | + ${project.groupId}.${project.artifactId} | ||
| 48 | + </Bundle-SymbolicName> | ||
| 49 | + <Import-Package> | ||
| 50 | + org.slf4j, | ||
| 51 | + org.osgi.framework, | ||
| 52 | + javax.ws.rs, | ||
| 53 | + javax.ws.rs.core, | ||
| 54 | + com.sun.jersey.api.core, | ||
| 55 | + com.sun.jersey.spi.container.servlet, | ||
| 56 | + com.sun.jersey.server.impl.container.servlet, | ||
| 57 | + com.fasterxml.jackson.databind, | ||
| 58 | + com.fasterxml.jackson.databind.node, | ||
| 59 | + com.fasterxml.jackson.core, | ||
| 60 | + org.apache.karaf.shell.commands, | ||
| 61 | + org.apache.commons.lang.math.*, | ||
| 62 | + com.google.common.*, | ||
| 63 | + org.onlab.packet.*, | ||
| 64 | + org.onlab.rest.*, | ||
| 65 | + org.onosproject.*, | ||
| 66 | + org.onlab.util.*, | ||
| 67 | + org.jboss.netty.util.* | ||
| 68 | + </Import-Package> | ||
| 69 | + <Web-ContextPath>${web.context}</Web-ContextPath> | ||
| 70 | + </instructions> | ||
| 71 | + </configuration> | ||
| 72 | + </plugin> | ||
| 73 | + </plugins> | ||
| 74 | + </build> | ||
| 75 | + | ||
| 76 | +</project> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed. Click to expand it.
apps/vtnweb/src/main/webapp/WEB-INF/web.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!-- | ||
| 3 | + ~ Copyright 2015 Open Networking Laboratory | ||
| 4 | + ~ | ||
| 5 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 6 | + ~ you may not use this file except in compliance with the License. | ||
| 7 | + ~ You may obtain a copy of the License at | ||
| 8 | + ~ | ||
| 9 | + ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| 10 | + ~ | ||
| 11 | + ~ Unless required by applicable law or agreed to in writing, software | ||
| 12 | + ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
| 13 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 14 | + ~ See the License for the specific language governing permissions and | ||
| 15 | + ~ limitations under the License. | ||
| 16 | + --> | ||
| 17 | +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" | ||
| 18 | + xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
| 19 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
| 20 | + id="ONOS" version="2.5"> | ||
| 21 | + <display-name>VTNRSC REST API v1.0</display-name> | ||
| 22 | + | ||
| 23 | + <servlet> | ||
| 24 | + <servlet-name>JAX-RS Service</servlet-name> | ||
| 25 | + <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> | ||
| 26 | + <init-param> | ||
| 27 | + <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name> | ||
| 28 | + <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value> | ||
| 29 | + </init-param> | ||
| 30 | + <init-param> | ||
| 31 | + <param-name>com.sun.jersey.config.property.classnames</param-name> | ||
| 32 | + <param-value> | ||
| 33 | + org.onosproject.vtnweb.resources.TenantNetworkWebResource | ||
| 34 | + </param-value> | ||
| 35 | + </init-param> | ||
| 36 | + <load-on-startup>1</load-on-startup> | ||
| 37 | + </servlet> | ||
| 38 | + | ||
| 39 | + <servlet-mapping> | ||
| 40 | + <servlet-name>JAX-RS Service</servlet-name> | ||
| 41 | + <url-pattern>/*</url-pattern> | ||
| 42 | + </servlet-mapping> | ||
| 43 | +</web-app> |
-
Please register or login to post a comment