CNlucius
Committed by Gerrit Code Review

ONOS-2622

Fix error of north app and update onos-app-vtnrsc package

Change-Id: I375002ff26d2ab3ada879a92a1d47bcdb8980054
Showing 41 changed files with 4776 additions and 4677 deletions
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.vtn.impl; 16 +package org.onosproject.vtn.impl;
17 - 17 +
18 -import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor; 18 +import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
19 -import static org.onlab.util.Tools.groupedThreads; 19 +import static org.onlab.util.Tools.groupedThreads;
20 -import static org.slf4j.LoggerFactory.getLogger; 20 +import static org.slf4j.LoggerFactory.getLogger;
21 - 21 +
22 -import java.util.HashSet; 22 +import java.util.HashSet;
23 -import java.util.List; 23 +import java.util.List;
24 -import java.util.Set; 24 +import java.util.Set;
25 -import java.util.concurrent.ScheduledExecutorService; 25 +import java.util.concurrent.ScheduledExecutorService;
26 - 26 +
27 -import org.apache.felix.scr.annotations.Activate; 27 +import org.apache.felix.scr.annotations.Activate;
28 -import org.apache.felix.scr.annotations.Component; 28 +import org.apache.felix.scr.annotations.Component;
29 -import org.apache.felix.scr.annotations.Deactivate; 29 +import org.apache.felix.scr.annotations.Deactivate;
30 -import org.apache.felix.scr.annotations.Reference; 30 +import org.apache.felix.scr.annotations.Reference;
31 -import org.apache.felix.scr.annotations.ReferenceCardinality; 31 +import org.apache.felix.scr.annotations.ReferenceCardinality;
32 -import org.apache.felix.scr.annotations.Service; 32 +import org.apache.felix.scr.annotations.Service;
33 -import org.onlab.packet.IpAddress; 33 +import org.onlab.packet.IpAddress;
34 -import org.onlab.packet.MacAddress; 34 +import org.onlab.packet.MacAddress;
35 -import org.onlab.util.KryoNamespace; 35 +import org.onlab.util.KryoNamespace;
36 -import org.onosproject.app.vtnrsc.SegmentationId; 36 +import org.onosproject.core.ApplicationId;
37 -import org.onosproject.app.vtnrsc.TenantNetwork; 37 +import org.onosproject.core.CoreService;
38 -import org.onosproject.app.vtnrsc.VirtualPort; 38 +import org.onosproject.net.Device;
39 -import org.onosproject.app.vtnrsc.VirtualPortId; 39 +import org.onosproject.net.DeviceId;
40 -import org.onosproject.app.vtnrsc.tenantnetwork.TenantNetworkService; 40 +import org.onosproject.net.Host;
41 -import org.onosproject.app.vtnrsc.virtualport.VirtualPortService; 41 +import org.onosproject.net.HostId;
42 -import org.onosproject.core.ApplicationId; 42 +import org.onosproject.net.Port;
43 -import org.onosproject.core.CoreService; 43 +import org.onosproject.net.PortNumber;
44 -import org.onosproject.net.Device; 44 +import org.onosproject.net.behaviour.BridgeConfig;
45 -import org.onosproject.net.DeviceId; 45 +import org.onosproject.net.behaviour.BridgeName;
46 -import org.onosproject.net.Host; 46 +import org.onosproject.net.behaviour.DefaultTunnelDescription;
47 -import org.onosproject.net.HostId; 47 +import org.onosproject.net.behaviour.IpTunnelEndPoint;
48 -import org.onosproject.net.Port; 48 +import org.onosproject.net.behaviour.TunnelConfig;
49 -import org.onosproject.net.PortNumber; 49 +import org.onosproject.net.behaviour.TunnelDescription;
50 -import org.onosproject.net.behaviour.BridgeConfig; 50 +import org.onosproject.net.behaviour.TunnelEndPoint;
51 -import org.onosproject.net.behaviour.BridgeName; 51 +import org.onosproject.net.device.DeviceEvent;
52 -import org.onosproject.net.behaviour.DefaultTunnelDescription; 52 +import org.onosproject.net.device.DeviceListener;
53 -import org.onosproject.net.behaviour.IpTunnelEndPoint; 53 +import org.onosproject.net.device.DeviceService;
54 -import org.onosproject.net.behaviour.TunnelConfig; 54 +import org.onosproject.net.driver.DriverHandler;
55 -import org.onosproject.net.behaviour.TunnelDescription; 55 +import org.onosproject.net.driver.DriverService;
56 -import org.onosproject.net.behaviour.TunnelEndPoint; 56 +import org.onosproject.net.flow.DefaultTrafficSelector;
57 -import org.onosproject.net.device.DeviceEvent; 57 +import org.onosproject.net.flow.DefaultTrafficTreatment;
58 -import org.onosproject.net.device.DeviceListener; 58 +import org.onosproject.net.flow.FlowRuleService;
59 -import org.onosproject.net.device.DeviceService; 59 +import org.onosproject.net.flow.TrafficSelector;
60 -import org.onosproject.net.driver.DriverHandler; 60 +import org.onosproject.net.flow.TrafficTreatment;
61 -import org.onosproject.net.driver.DriverService; 61 +import org.onosproject.net.flow.criteria.Criteria;
62 -import org.onosproject.net.flow.DefaultTrafficSelector; 62 +import org.onosproject.net.flow.instructions.Instructions;
63 -import org.onosproject.net.flow.DefaultTrafficTreatment; 63 +import org.onosproject.net.flowobjective.DefaultForwardingObjective;
64 -import org.onosproject.net.flow.FlowRuleService; 64 +import org.onosproject.net.flowobjective.FlowObjectiveService;
65 -import org.onosproject.net.flow.TrafficSelector; 65 +import org.onosproject.net.flowobjective.ForwardingObjective;
66 -import org.onosproject.net.flow.TrafficTreatment; 66 +import org.onosproject.net.flowobjective.ForwardingObjective.Flag;
67 -import org.onosproject.net.flow.criteria.Criteria; 67 +import org.onosproject.net.flowobjective.Objective;
68 -import org.onosproject.net.flow.instructions.Instructions; 68 +import org.onosproject.net.host.HostEvent;
69 -import org.onosproject.net.flowobjective.DefaultForwardingObjective; 69 +import org.onosproject.net.host.HostListener;
70 -import org.onosproject.net.flowobjective.FlowObjectiveService; 70 +import org.onosproject.net.host.HostService;
71 -import org.onosproject.net.flowobjective.ForwardingObjective; 71 +import org.onosproject.store.serializers.KryoNamespaces;
72 -import org.onosproject.net.flowobjective.ForwardingObjective.Flag; 72 +import org.onosproject.store.service.EventuallyConsistentMap;
73 -import org.onosproject.net.flowobjective.Objective; 73 +import org.onosproject.store.service.StorageService;
74 -import org.onosproject.net.host.HostEvent; 74 +import org.onosproject.store.service.WallClockTimestamp;
75 -import org.onosproject.net.host.HostListener; 75 +import org.onosproject.vtn.VTNService;
76 -import org.onosproject.net.host.HostService; 76 +import org.onosproject.vtnrsc.SegmentationId;
77 -import org.onosproject.store.serializers.KryoNamespaces; 77 +import org.onosproject.vtnrsc.TenantNetwork;
78 -import org.onosproject.store.service.EventuallyConsistentMap; 78 +import org.onosproject.vtnrsc.VirtualPort;
79 -import org.onosproject.store.service.StorageService; 79 +import org.onosproject.vtnrsc.VirtualPortId;
80 -import org.onosproject.store.service.WallClockTimestamp; 80 +import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
81 -import org.onosproject.vtn.VTNService; 81 +import org.onosproject.vtnrsc.virtualport.VirtualPortService;
82 -import org.slf4j.Logger; 82 +import org.slf4j.Logger;
83 - 83 +
84 -import com.google.common.collect.Sets; 84 +import com.google.common.collect.Sets;
85 - 85 +
86 -/** 86 +/**
87 - * Provides implementation of VTNService. 87 + * Provides implementation of VTNService.
88 - */ 88 + */
89 -@Component(immediate = true) 89 +@Component(immediate = true)
90 -@Service 90 +@Service
91 -public class VTNManager implements VTNService { 91 +public class VTNManager implements VTNService {
92 - private final Logger log = getLogger(getClass()); 92 + private final Logger log = getLogger(getClass());
93 - 93 +
94 - private static final String APP_ID = "org.onosproject.app.vtn"; 94 + private static final String APP_ID = "org.onosproject.app.vtn";
95 - private ScheduledExecutorService backgroundService; 95 + private ScheduledExecutorService backgroundService;
96 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 96 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
97 - protected DeviceService deviceService; 97 + protected DeviceService deviceService;
98 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 98 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
99 - protected HostService hostService; 99 + protected HostService hostService;
100 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 100 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
101 - protected FlowRuleService flowRuleService; 101 + protected FlowRuleService flowRuleService;
102 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 102 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
103 - protected CoreService coreService; 103 + protected CoreService coreService;
104 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 104 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
105 - protected StorageService storageService; 105 + protected StorageService storageService;
106 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 106 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
107 - protected TenantNetworkService tenantNetworkService; 107 + protected TenantNetworkService tenantNetworkService;
108 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 108 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
109 - protected VirtualPortService virtualPortService; 109 + protected VirtualPortService virtualPortService;
110 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 110 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
111 - protected DriverService driverService; 111 + protected DriverService driverService;
112 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 112 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
113 - protected FlowObjectiveService flowObjectiveService; 113 + protected FlowObjectiveService flowObjectiveService;
114 - private EventuallyConsistentMap<HostId, SegmentationId> binding; 114 + private EventuallyConsistentMap<HostId, SegmentationId> binding;
115 - private ApplicationId appId; 115 + private ApplicationId appId;
116 - private HostListener hostListener = new InnerHostListener(); 116 + private HostListener hostListener = new InnerHostListener();
117 - private DeviceListener deviceListener = new InnerDeviceListener(); 117 + private DeviceListener deviceListener = new InnerDeviceListener();
118 - private static final String IFACEID = "ifaceid"; 118 + private static final String IFACEID = "ifaceid";
119 - private static final String PORT_HEAD = "vxlan"; 119 + private static final String PORT_HEAD = "vxlan";
120 - private static final String DEFAULT_BRIDGE_NAME = "br-int"; 120 + private static final String DEFAULT_BRIDGE_NAME = "br-int";
121 - private static final String CONTROLLER_IP_KEY = "ipaddress"; 121 + private static final String CONTROLLER_IP_KEY = "ipaddress";
122 - 122 +
123 - @Activate 123 + @Activate
124 - public void activate() { 124 + public void activate() {
125 - KryoNamespace.Builder serializer = KryoNamespace.newBuilder() 125 + KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
126 - .register(KryoNamespaces.API); 126 + .register(KryoNamespaces.API);
127 - appId = coreService.registerApplication(APP_ID); 127 + appId = coreService.registerApplication(APP_ID);
128 - deviceService.addListener(deviceListener); 128 + deviceService.addListener(deviceListener);
129 - hostService.addListener(hostListener); 129 + hostService.addListener(hostListener);
130 - backgroundService = newSingleThreadScheduledExecutor(groupedThreads("onos-apps/vtn", 130 + backgroundService = newSingleThreadScheduledExecutor(groupedThreads("onos-apps/vtn",
131 - "manager-background")); 131 + "manager-background"));
132 - binding = storageService 132 + binding = storageService
133 - .<HostId, SegmentationId>eventuallyConsistentMapBuilder() 133 + .<HostId, SegmentationId>eventuallyConsistentMapBuilder()
134 - .withName("all_tunnel").withSerializer(serializer) 134 + .withName("all_tunnel").withSerializer(serializer)
135 - .withTimestampProvider((k, v) -> new WallClockTimestamp()) 135 + .withTimestampProvider((k, v) -> new WallClockTimestamp())
136 - .build(); 136 + .build();
137 - log.info("Started"); 137 + log.info("Started");
138 - } 138 + }
139 - 139 +
140 - @Deactivate 140 + @Deactivate
141 - public void deactivate() { 141 + public void deactivate() {
142 - backgroundService.shutdown(); 142 + backgroundService.shutdown();
143 - binding.destroy(); 143 + binding.destroy();
144 - log.info("Stopped"); 144 + log.info("Stopped");
145 - } 145 + }
146 - 146 +
147 - @Override 147 + @Override
148 - public void onServerDetected(Device device) { 148 + public void onServerDetected(Device device) {
149 - Iterable<Device> devices = deviceService.getAvailableDevices(); 149 + Iterable<Device> devices = deviceService.getAvailableDevices();
150 - DriverHandler handler = driverService.createHandler(device.id()); 150 + DriverHandler handler = driverService.createHandler(device.id());
151 - BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class); 151 + BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
152 - bridgeConfig.addBridge(BridgeName.bridgeName(DEFAULT_BRIDGE_NAME)); 152 + bridgeConfig.addBridge(BridgeName.bridgeName(DEFAULT_BRIDGE_NAME));
153 - String ipAddress = device.annotations().value(CONTROLLER_IP_KEY); 153 + String ipAddress = device.annotations().value(CONTROLLER_IP_KEY);
154 - IpAddress ip = IpAddress.valueOf(ipAddress); 154 + IpAddress ip = IpAddress.valueOf(ipAddress);
155 - Sets.newHashSet(devices) 155 + Sets.newHashSet(devices)
156 - .stream() 156 + .stream()
157 - .filter(d -> d.type() == Device.Type.CONTROLLER) 157 + .filter(d -> d.type() == Device.Type.CONTROLLER)
158 - .filter(d -> !device.id().equals(d.id())) 158 + .filter(d -> !device.id().equals(d.id()))
159 - .forEach(d -> { 159 + .forEach(d -> {
160 - String ipAddress1 = d.annotations() 160 + String ipAddress1 = d.annotations()
161 - .value(CONTROLLER_IP_KEY); 161 + .value(CONTROLLER_IP_KEY);
162 - IpAddress ip1 = IpAddress.valueOf(ipAddress1); 162 + IpAddress ip1 = IpAddress.valueOf(ipAddress1);
163 - applyTunnelConfig(ip, ip1, handler); 163 + applyTunnelConfig(ip, ip1, handler);
164 - DriverHandler handler1 = driverService 164 + DriverHandler handler1 = driverService
165 - .createHandler(d.id()); 165 + .createHandler(d.id());
166 - applyTunnelConfig(ip1, ip, handler1); 166 + applyTunnelConfig(ip1, ip, handler1);
167 - }); 167 + });
168 - } 168 + }
169 - 169 +
170 - @Override 170 + @Override
171 - public void onServerVanished(Device device) { 171 + public void onServerVanished(Device device) {
172 - Iterable<Device> devices = deviceService.getAvailableDevices(); 172 + Iterable<Device> devices = deviceService.getAvailableDevices();
173 - String ipAddress = device.annotations().value(CONTROLLER_IP_KEY); 173 + String ipAddress = device.annotations().value(CONTROLLER_IP_KEY);
174 - IpAddress dst = IpAddress.valueOf(ipAddress); 174 + IpAddress dst = IpAddress.valueOf(ipAddress);
175 - Sets.newHashSet(devices) 175 + Sets.newHashSet(devices)
176 - .stream() 176 + .stream()
177 - .filter(d -> d.type() == Device.Type.CONTROLLER) 177 + .filter(d -> d.type() == Device.Type.CONTROLLER)
178 - .filter(d -> !device.id().equals(d.id())) 178 + .filter(d -> !device.id().equals(d.id()))
179 - .forEach(d -> { 179 + .forEach(d -> {
180 - String ipAddress1 = d.annotations() 180 + String ipAddress1 = d.annotations()
181 - .value(CONTROLLER_IP_KEY); 181 + .value(CONTROLLER_IP_KEY);
182 - DriverHandler handler = driverService 182 + DriverHandler handler = driverService
183 - .createHandler(d.id()); 183 + .createHandler(d.id());
184 - IpAddress src = IpAddress.valueOf(ipAddress1); 184 + IpAddress src = IpAddress.valueOf(ipAddress1);
185 - removeTunnelConfig(src, dst, handler); 185 + removeTunnelConfig(src, dst, handler);
186 - }); 186 + });
187 - } 187 + }
188 - 188 +
189 - private void applyTunnelConfig(IpAddress src, IpAddress dst, 189 + private void applyTunnelConfig(IpAddress src, IpAddress dst,
190 - DriverHandler handler) { 190 + DriverHandler handler) {
191 - TunnelEndPoint tunnelAsSrc = IpTunnelEndPoint.ipTunnelPoint(src); 191 + TunnelEndPoint tunnelAsSrc = IpTunnelEndPoint.ipTunnelPoint(src);
192 - TunnelEndPoint tunnelAsDst = IpTunnelEndPoint.ipTunnelPoint(dst); 192 + TunnelEndPoint tunnelAsDst = IpTunnelEndPoint.ipTunnelPoint(dst);
193 - TunnelDescription tunnel = new DefaultTunnelDescription( 193 + TunnelDescription tunnel = new DefaultTunnelDescription(
194 - tunnelAsSrc, 194 + tunnelAsSrc,
195 - tunnelAsDst, 195 + tunnelAsDst,
196 - TunnelDescription.Type.VXLAN, 196 + TunnelDescription.Type.VXLAN,
197 - null); 197 + null);
198 - TunnelConfig config = handler.behaviour(TunnelConfig.class); 198 + TunnelConfig config = handler.behaviour(TunnelConfig.class);
199 - config.createTunnel(tunnel); 199 + config.createTunnel(tunnel);
200 - } 200 + }
201 - 201 +
202 - private void removeTunnelConfig(IpAddress src, IpAddress dst, 202 + private void removeTunnelConfig(IpAddress src, IpAddress dst,
203 - DriverHandler handler) { 203 + DriverHandler handler) {
204 - TunnelEndPoint tunnelAsSrc = IpTunnelEndPoint.ipTunnelPoint(src); 204 + TunnelEndPoint tunnelAsSrc = IpTunnelEndPoint.ipTunnelPoint(src);
205 - TunnelEndPoint tunnelAsDst = IpTunnelEndPoint.ipTunnelPoint(dst); 205 + TunnelEndPoint tunnelAsDst = IpTunnelEndPoint.ipTunnelPoint(dst);
206 - TunnelDescription tunnel = new DefaultTunnelDescription( 206 + TunnelDescription tunnel = new DefaultTunnelDescription(
207 - tunnelAsSrc, 207 + tunnelAsSrc,
208 - tunnelAsDst, 208 + tunnelAsDst,
209 - TunnelDescription.Type.VXLAN, 209 + TunnelDescription.Type.VXLAN,
210 - null); 210 + null);
211 - TunnelConfig config = handler.behaviour(TunnelConfig.class); 211 + TunnelConfig config = handler.behaviour(TunnelConfig.class);
212 - config.removeTunnel(tunnel); 212 + config.removeTunnel(tunnel);
213 - } 213 + }
214 - 214 +
215 - @Override 215 + @Override
216 - public void onOvsDetected(Device device) { 216 + public void onOvsDetected(Device device) {
217 - programMacDefaultRules(device.id(), appId, Objective.Operation.ADD); 217 + programMacDefaultRules(device.id(), appId, Objective.Operation.ADD);
218 - programPortDefaultRules(device.id(), appId, Objective.Operation.ADD); 218 + programPortDefaultRules(device.id(), appId, Objective.Operation.ADD);
219 - } 219 + }
220 - 220 +
221 - @Override 221 + @Override
222 - public void onOvsVanished(Device device) { 222 + public void onOvsVanished(Device device) {
223 - programMacDefaultRules(device.id(), appId, Objective.Operation.REMOVE); 223 + programMacDefaultRules(device.id(), appId, Objective.Operation.REMOVE);
224 - programPortDefaultRules(device.id(), appId, Objective.Operation.REMOVE); 224 + programPortDefaultRules(device.id(), appId, Objective.Operation.REMOVE);
225 - } 225 + }
226 - 226 +
227 - @Override 227 + @Override
228 - public void onHostDetected(Host host) { 228 + public void onHostDetected(Host host) {
229 - String ifaceId = host.annotations().value(IFACEID); 229 + String ifaceId = host.annotations().value(IFACEID);
230 - VirtualPortId portId = VirtualPortId.portId(ifaceId); 230 + VirtualPortId portId = VirtualPortId.portId(ifaceId);
231 - VirtualPort port = virtualPortService.getPort(portId); 231 + VirtualPort port = virtualPortService.getPort(portId);
232 - TenantNetwork network = tenantNetworkService.getNetwork(port 232 + TenantNetwork network = tenantNetworkService.getNetwork(port
233 - .networkId()); 233 + .networkId());
234 - binding.put(host.id(), network.segmentationId()); 234 + binding.put(host.id(), network.segmentationId());
235 - DeviceId deviceId = host.location().deviceId(); 235 + DeviceId deviceId = host.location().deviceId();
236 - List<Port> allPorts = deviceService.getPorts(deviceId); 236 + List<Port> allPorts = deviceService.getPorts(deviceId);
237 - PortNumber inPort = host.location().port(); 237 + PortNumber inPort = host.location().port();
238 - Set<Port> localPorts = new HashSet<>(); 238 + Set<Port> localPorts = new HashSet<>();
239 - allPorts.forEach(p -> { 239 + allPorts.forEach(p -> {
240 - if (!p.number().name().startsWith(PORT_HEAD)) { 240 + if (!p.number().name().startsWith(PORT_HEAD)) {
241 - localPorts.add(p); 241 + localPorts.add(p);
242 - } 242 + }
243 - }); 243 + });
244 - programLocalBcastRules(deviceId, network.segmentationId(), inPort, 244 + programLocalBcastRules(deviceId, network.segmentationId(), inPort,
245 - allPorts, appId, Objective.Operation.ADD); 245 + allPorts, appId, Objective.Operation.ADD);
246 - programLocalOut(deviceId, network.segmentationId(), inPort, host.mac(), 246 + programLocalOut(deviceId, network.segmentationId(), inPort, host.mac(),
247 - appId, Objective.Operation.ADD); 247 + appId, Objective.Operation.ADD);
248 - programTunnelFloodOut(deviceId, network.segmentationId(), inPort, 248 + programTunnelFloodOut(deviceId, network.segmentationId(), inPort,
249 - localPorts, appId, Objective.Operation.ADD); 249 + localPorts, appId, Objective.Operation.ADD);
250 - programTunnelOut(deviceId, network.segmentationId(), inPort, 250 + programTunnelOut(deviceId, network.segmentationId(), inPort,
251 - host.mac(), appId, Objective.Operation.ADD); 251 + host.mac(), appId, Objective.Operation.ADD);
252 - programLocalIn(deviceId, network.segmentationId(), inPort, host.mac(), 252 + programLocalIn(deviceId, network.segmentationId(), inPort, host.mac(),
253 - appId, Objective.Operation.ADD); 253 + appId, Objective.Operation.ADD);
254 - programTunnelIn(deviceId, network.segmentationId(), inPort, host.mac(), 254 + programTunnelIn(deviceId, network.segmentationId(), inPort, host.mac(),
255 - appId, Objective.Operation.ADD); 255 + appId, Objective.Operation.ADD);
256 - } 256 + }
257 - 257 +
258 - @Override 258 + @Override
259 - public void onHostVanished(Host host) { 259 + public void onHostVanished(Host host) {
260 - SegmentationId segId = binding.remove(host.id()); 260 + SegmentationId segId = binding.remove(host.id());
261 - DeviceId deviceId = host.location().deviceId(); 261 + DeviceId deviceId = host.location().deviceId();
262 - List<Port> allPorts = deviceService.getPorts(deviceId); 262 + List<Port> allPorts = deviceService.getPorts(deviceId);
263 - PortNumber inPort = host.location().port(); 263 + PortNumber inPort = host.location().port();
264 - Set<Port> localPorts = new HashSet<>(); 264 + Set<Port> localPorts = new HashSet<>();
265 - allPorts.forEach(p -> { 265 + allPorts.forEach(p -> {
266 - if (!p.number().name().startsWith(PORT_HEAD)) { 266 + if (!p.number().name().startsWith(PORT_HEAD)) {
267 - localPorts.add(p); 267 + localPorts.add(p);
268 - } 268 + }
269 - }); 269 + });
270 - programLocalBcastRules(deviceId, segId, inPort, allPorts, appId, 270 + programLocalBcastRules(deviceId, segId, inPort, allPorts, appId,
271 - Objective.Operation.REMOVE); 271 + Objective.Operation.REMOVE);
272 - programLocalOut(deviceId, segId, inPort, host.mac(), appId, 272 + programLocalOut(deviceId, segId, inPort, host.mac(), appId,
273 - Objective.Operation.REMOVE); 273 + Objective.Operation.REMOVE);
274 - programTunnelFloodOut(deviceId, segId, inPort, localPorts, appId, 274 + programTunnelFloodOut(deviceId, segId, inPort, localPorts, appId,
275 - Objective.Operation.REMOVE); 275 + Objective.Operation.REMOVE);
276 - programTunnelOut(deviceId, segId, inPort, host.mac(), appId, 276 + programTunnelOut(deviceId, segId, inPort, host.mac(), appId,
277 - Objective.Operation.REMOVE); 277 + Objective.Operation.REMOVE);
278 - programLocalIn(deviceId, segId, inPort, host.mac(), appId, 278 + programLocalIn(deviceId, segId, inPort, host.mac(), appId,
279 - Objective.Operation.REMOVE); 279 + Objective.Operation.REMOVE);
280 - programTunnelIn(deviceId, segId, inPort, host.mac(), appId, 280 + programTunnelIn(deviceId, segId, inPort, host.mac(), appId,
281 - Objective.Operation.REMOVE); 281 + Objective.Operation.REMOVE);
282 - } 282 + }
283 - 283 +
284 - private class InnerDeviceListener implements DeviceListener { 284 + private class InnerDeviceListener implements DeviceListener {
285 - 285 +
286 - @Override 286 + @Override
287 - public void event(DeviceEvent event) { 287 + public void event(DeviceEvent event) {
288 - Device device = event.subject(); 288 + Device device = event.subject();
289 - if (Device.Type.CONTROLLER == device.type() 289 + if (Device.Type.CONTROLLER == device.type()
290 - && DeviceEvent.Type.DEVICE_ADDED == event.type()) { 290 + && DeviceEvent.Type.DEVICE_ADDED == event.type()) {
291 - backgroundService.execute(() -> { 291 + backgroundService.execute(() -> {
292 - onServerDetected(device); 292 + onServerDetected(device);
293 - }); 293 + });
294 - } else if (Device.Type.CONTROLLER == device.type() 294 + } else if (Device.Type.CONTROLLER == device.type()
295 - && DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event 295 + && DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event
296 - .type()) { 296 + .type()) {
297 - backgroundService.execute(() -> { 297 + backgroundService.execute(() -> {
298 - onServerVanished(device); 298 + onServerVanished(device);
299 - }); 299 + });
300 - } else if (Device.Type.SWITCH == device.type() 300 + } else if (Device.Type.SWITCH == device.type()
301 - && DeviceEvent.Type.DEVICE_ADDED == event.type()) { 301 + && DeviceEvent.Type.DEVICE_ADDED == event.type()) {
302 - backgroundService.execute(() -> { 302 + backgroundService.execute(() -> {
303 - onOvsDetected(device); 303 + onOvsDetected(device);
304 - }); 304 + });
305 - } else if (Device.Type.SWITCH == device.type() 305 + } else if (Device.Type.SWITCH == device.type()
306 - && DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event 306 + && DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event
307 - .type()) { 307 + .type()) {
308 - backgroundService.execute(() -> { 308 + backgroundService.execute(() -> {
309 - onOvsVanished(device); 309 + onOvsVanished(device);
310 - }); 310 + });
311 - } else { 311 + } else {
312 - log.info("do nothing for this device type"); 312 + log.info("do nothing for this device type");
313 - } 313 + }
314 - } 314 + }
315 - 315 +
316 - } 316 + }
317 - 317 +
318 - private class InnerHostListener implements HostListener { 318 + private class InnerHostListener implements HostListener {
319 - 319 +
320 - @Override 320 + @Override
321 - public void event(HostEvent event) { 321 + public void event(HostEvent event) {
322 - Host host = event.subject(); 322 + Host host = event.subject();
323 - if (HostEvent.Type.HOST_ADDED == event.type()) { 323 + if (HostEvent.Type.HOST_ADDED == event.type()) {
324 - backgroundService.execute(() -> { 324 + backgroundService.execute(() -> {
325 - onHostDetected(host); 325 + onHostDetected(host);
326 - }); 326 + });
327 - } else if (HostEvent.Type.HOST_REMOVED == event.type()) { 327 + } else if (HostEvent.Type.HOST_REMOVED == event.type()) {
328 - backgroundService.execute(() -> { 328 + backgroundService.execute(() -> {
329 - onHostVanished(host); 329 + onHostVanished(host);
330 - }); 330 + });
331 - } else { 331 + } else {
332 - log.info("unknow host"); 332 + log.info("unknow host");
333 - } 333 + }
334 - } 334 + }
335 - 335 +
336 - } 336 + }
337 - 337 +
338 - // Used to forward the flows to the local VM. 338 + // Used to forward the flows to the local VM.
339 - private void programLocalOut(DeviceId dpid, SegmentationId segmentationId, 339 + private void programLocalOut(DeviceId dpid, SegmentationId segmentationId,
340 - PortNumber outPort, MacAddress sourceMac, 340 + PortNumber outPort, MacAddress sourceMac,
341 - ApplicationId appid, Objective.Operation type) { 341 + ApplicationId appid, Objective.Operation type) {
342 - TrafficSelector selector = DefaultTrafficSelector.builder() 342 + TrafficSelector selector = DefaultTrafficSelector.builder()
343 - .matchEthDst(sourceMac).build(); 343 + .matchEthDst(sourceMac).build();
344 - TrafficTreatment treatment = DefaultTrafficTreatment 344 + TrafficTreatment treatment = DefaultTrafficTreatment
345 - .builder() 345 + .builder()
346 - .add(Instructions.modTunnelId(Long.parseLong(segmentationId 346 + .add(Instructions.modTunnelId(Long.parseLong(segmentationId
347 - .toString()))).setOutput(outPort).build(); 347 + .toString()))).setOutput(outPort).build();
348 - ForwardingObjective.Builder objective = DefaultForwardingObjective 348 + ForwardingObjective.Builder objective = DefaultForwardingObjective
349 - .builder().withTreatment(treatment).withSelector(selector) 349 + .builder().withTreatment(treatment).withSelector(selector)
350 - .fromApp(appId).withFlag(Flag.SPECIFIC); 350 + .fromApp(appId).withFlag(Flag.SPECIFIC);
351 - if (type.equals(Objective.Operation.ADD)) { 351 + if (type.equals(Objective.Operation.ADD)) {
352 - flowObjectiveService.forward(dpid, objective.add()); 352 + flowObjectiveService.forward(dpid, objective.add());
353 - } else { 353 + } else {
354 - flowObjectiveService.forward(dpid, objective.remove()); 354 + flowObjectiveService.forward(dpid, objective.remove());
355 - } 355 + }
356 - 356 +
357 - } 357 + }
358 - 358 +
359 - // Used to forward the flows to the remote VM via VXLAN tunnel. 359 + // Used to forward the flows to the remote VM via VXLAN tunnel.
360 - private void programTunnelOut(DeviceId dpid, SegmentationId segmentationId, 360 + private void programTunnelOut(DeviceId dpid, SegmentationId segmentationId,
361 - PortNumber outPort, MacAddress sourceMac, 361 + PortNumber outPort, MacAddress sourceMac,
362 - ApplicationId appid, Objective.Operation type) { 362 + ApplicationId appid, Objective.Operation type) {
363 - TrafficSelector selector = DefaultTrafficSelector.builder() 363 + TrafficSelector selector = DefaultTrafficSelector.builder()
364 - .matchEthDst(sourceMac).build(); 364 + .matchEthDst(sourceMac).build();
365 - TrafficTreatment treatment = DefaultTrafficTreatment 365 + TrafficTreatment treatment = DefaultTrafficTreatment
366 - .builder() 366 + .builder()
367 - .add(Instructions.modTunnelId(Long.parseLong(segmentationId 367 + .add(Instructions.modTunnelId(Long.parseLong(segmentationId
368 - .toString()))).setOutput(outPort).build(); 368 + .toString()))).setOutput(outPort).build();
369 - ForwardingObjective.Builder objective = DefaultForwardingObjective 369 + ForwardingObjective.Builder objective = DefaultForwardingObjective
370 - .builder().withTreatment(treatment).withSelector(selector) 370 + .builder().withTreatment(treatment).withSelector(selector)
371 - .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC); 371 + .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC);
372 - if (type.equals(Objective.Operation.ADD)) { 372 + if (type.equals(Objective.Operation.ADD)) {
373 - flowObjectiveService.forward(dpid, objective.add()); 373 + flowObjectiveService.forward(dpid, objective.add());
374 - } else { 374 + } else {
375 - flowObjectiveService.forward(dpid, objective.remove()); 375 + flowObjectiveService.forward(dpid, objective.remove());
376 - } 376 + }
377 - } 377 + }
378 - 378 +
379 - // Used to forward multicast flows to remote VMs of the same tenant via 379 + // Used to forward multicast flows to remote VMs of the same tenant via
380 - // VXLAN tunnel. 380 + // VXLAN tunnel.
381 - private void programTunnelFloodOut(DeviceId dpid, 381 + private void programTunnelFloodOut(DeviceId dpid,
382 - SegmentationId segmentationId, 382 + SegmentationId segmentationId,
383 - PortNumber ofPortOut, 383 + PortNumber ofPortOut,
384 - Iterable<Port> localports, 384 + Iterable<Port> localports,
385 - ApplicationId appid, 385 + ApplicationId appid,
386 - Objective.Operation type) { 386 + Objective.Operation type) {
387 - TrafficSelector selector = DefaultTrafficSelector 387 + TrafficSelector selector = DefaultTrafficSelector
388 - .builder() 388 + .builder()
389 - .matchInPort(ofPortOut) 389 + .matchInPort(ofPortOut)
390 - 390 +
391 - .add(Criteria.matchTunnelId(Long.parseLong(segmentationId 391 + .add(Criteria.matchTunnelId(Long.parseLong(segmentationId
392 - .toString()))).matchEthDst(MacAddress.BROADCAST) 392 + .toString()))).matchEthDst(MacAddress.BROADCAST)
393 - .build(); 393 + .build();
394 - TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); 394 + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
395 - for (Port outport : localports) { 395 + for (Port outport : localports) {
396 - treatment.setOutput(outport.number()); 396 + treatment.setOutput(outport.number());
397 - } 397 + }
398 - 398 +
399 - ForwardingObjective.Builder objective = DefaultForwardingObjective 399 + ForwardingObjective.Builder objective = DefaultForwardingObjective
400 - .builder().withTreatment(treatment.build()) 400 + .builder().withTreatment(treatment.build())
401 - .withSelector(selector).fromApp(appId).makePermanent() 401 + .withSelector(selector).fromApp(appId).makePermanent()
402 - .withFlag(Flag.SPECIFIC); 402 + .withFlag(Flag.SPECIFIC);
403 - if (type.equals(Objective.Operation.ADD)) { 403 + if (type.equals(Objective.Operation.ADD)) {
404 - flowObjectiveService.forward(dpid, objective.add()); 404 + flowObjectiveService.forward(dpid, objective.add());
405 - } else { 405 + } else {
406 - flowObjectiveService.forward(dpid, objective.remove()); 406 + flowObjectiveService.forward(dpid, objective.remove());
407 - } 407 + }
408 - } 408 + }
409 - 409 +
410 - // Applies default flows to mac table. 410 + // Applies default flows to mac table.
411 - private void programMacDefaultRules(DeviceId dpid, ApplicationId appid, 411 + private void programMacDefaultRules(DeviceId dpid, ApplicationId appid,
412 - Objective.Operation type) { 412 + Objective.Operation type) {
413 - TrafficSelector selector = DefaultTrafficSelector.builder().build(); 413 + TrafficSelector selector = DefaultTrafficSelector.builder().build();
414 - TrafficTreatment treatment = DefaultTrafficTreatment.builder().drop() 414 + TrafficTreatment treatment = DefaultTrafficTreatment.builder().drop()
415 - .build(); 415 + .build();
416 - ForwardingObjective.Builder objective = DefaultForwardingObjective 416 + ForwardingObjective.Builder objective = DefaultForwardingObjective
417 - .builder().withTreatment(treatment).withSelector(selector) 417 + .builder().withTreatment(treatment).withSelector(selector)
418 - .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC); 418 + .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC);
419 - if (type.equals(Objective.Operation.ADD)) { 419 + if (type.equals(Objective.Operation.ADD)) {
420 - flowObjectiveService.forward(dpid, objective.add()); 420 + flowObjectiveService.forward(dpid, objective.add());
421 - } else { 421 + } else {
422 - flowObjectiveService.forward(dpid, objective.remove()); 422 + flowObjectiveService.forward(dpid, objective.remove());
423 - } 423 + }
424 - } 424 + }
425 - 425 +
426 - // Used to forward the flows to the local VMs with the same tenant. 426 + // Used to forward the flows to the local VMs with the same tenant.
427 - private void programLocalBcastRules(DeviceId dpid, 427 + private void programLocalBcastRules(DeviceId dpid,
428 - SegmentationId segmentationId, 428 + SegmentationId segmentationId,
429 - PortNumber inPort, List<Port> allports, 429 + PortNumber inPort, List<Port> allports,
430 - ApplicationId appid, 430 + ApplicationId appid,
431 - Objective.Operation type) { 431 + Objective.Operation type) {
432 - TrafficSelector selector = DefaultTrafficSelector 432 + TrafficSelector selector = DefaultTrafficSelector
433 - .builder() 433 + .builder()
434 - .matchInPort(inPort) 434 + .matchInPort(inPort)
435 - .matchEthDst(MacAddress.BROADCAST) 435 + .matchEthDst(MacAddress.BROADCAST)
436 - .add(Criteria.matchTunnelId(Long.parseLong(segmentationId 436 + .add(Criteria.matchTunnelId(Long.parseLong(segmentationId
437 - .toString()))).build(); 437 + .toString()))).build();
438 - TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); 438 + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
439 - 439 +
440 - for (Port outport : allports) { 440 + for (Port outport : allports) {
441 - if (inPort != outport.number()) { 441 + if (inPort != outport.number()) {
442 - treatment.setOutput(outport.number()); 442 + treatment.setOutput(outport.number());
443 - } 443 + }
444 - } 444 + }
445 - ForwardingObjective.Builder objective = DefaultForwardingObjective 445 + ForwardingObjective.Builder objective = DefaultForwardingObjective
446 - .builder().withTreatment(treatment.build()) 446 + .builder().withTreatment(treatment.build())
447 - .withSelector(selector).fromApp(appId).makePermanent() 447 + .withSelector(selector).fromApp(appId).makePermanent()
448 - .withFlag(Flag.SPECIFIC); 448 + .withFlag(Flag.SPECIFIC);
449 - if (type.equals(Objective.Operation.ADD)) { 449 + if (type.equals(Objective.Operation.ADD)) {
450 - flowObjectiveService.forward(dpid, objective.add()); 450 + flowObjectiveService.forward(dpid, objective.add());
451 - } else { 451 + } else {
452 - flowObjectiveService.forward(dpid, objective.remove()); 452 + flowObjectiveService.forward(dpid, objective.remove());
453 - } 453 + }
454 - } 454 + }
455 - 455 +
456 - // Used to apply local entry flow. 456 + // Used to apply local entry flow.
457 - private void programLocalIn(DeviceId dpid, SegmentationId segmentationId, 457 + private void programLocalIn(DeviceId dpid, SegmentationId segmentationId,
458 - PortNumber inPort, MacAddress srcMac, 458 + PortNumber inPort, MacAddress srcMac,
459 - ApplicationId appid, Objective.Operation type) { 459 + ApplicationId appid, Objective.Operation type) {
460 - TrafficSelector selector = DefaultTrafficSelector.builder() 460 + TrafficSelector selector = DefaultTrafficSelector.builder()
461 - .matchInPort(inPort).matchEthSrc(srcMac).build(); 461 + .matchInPort(inPort).matchEthSrc(srcMac).build();
462 - TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); 462 + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
463 - treatment.add(Instructions.modTunnelId(Long.parseLong(segmentationId 463 + treatment.add(Instructions.modTunnelId(Long.parseLong(segmentationId
464 - .toString()))); 464 + .toString())));
465 - ForwardingObjective.Builder objective = DefaultForwardingObjective 465 + ForwardingObjective.Builder objective = DefaultForwardingObjective
466 - .builder().withTreatment(treatment.build()) 466 + .builder().withTreatment(treatment.build())
467 - .withSelector(selector).fromApp(appId).makePermanent() 467 + .withSelector(selector).fromApp(appId).makePermanent()
468 - .withFlag(Flag.SPECIFIC); 468 + .withFlag(Flag.SPECIFIC);
469 - if (type.equals(Objective.Operation.ADD)) { 469 + if (type.equals(Objective.Operation.ADD)) {
470 - flowObjectiveService.forward(dpid, objective.add()); 470 + flowObjectiveService.forward(dpid, objective.add());
471 - } else { 471 + } else {
472 - flowObjectiveService.forward(dpid, objective.remove()); 472 + flowObjectiveService.forward(dpid, objective.remove());
473 - } 473 + }
474 - } 474 + }
475 - 475 +
476 - // Used to forward the flows from the egress tunnel to the VM. 476 + // Used to forward the flows from the egress tunnel to the VM.
477 - private void programTunnelIn(DeviceId dpid, SegmentationId segmentationId, 477 + private void programTunnelIn(DeviceId dpid, SegmentationId segmentationId,
478 - PortNumber inPort, MacAddress sourceMac, 478 + PortNumber inPort, MacAddress sourceMac,
479 - ApplicationId appid, Objective.Operation type) { 479 + ApplicationId appid, Objective.Operation type) {
480 - TrafficSelector selector = DefaultTrafficSelector 480 + TrafficSelector selector = DefaultTrafficSelector
481 - .builder() 481 + .builder()
482 - .matchInPort(inPort) 482 + .matchInPort(inPort)
483 - .add(Criteria.matchTunnelId(Long.parseLong(segmentationId 483 + .add(Criteria.matchTunnelId(Long.parseLong(segmentationId
484 - .toString()))).build(); 484 + .toString()))).build();
485 - TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); 485 + TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
486 - 486 +
487 - ForwardingObjective.Builder objective = DefaultForwardingObjective 487 + ForwardingObjective.Builder objective = DefaultForwardingObjective
488 - .builder().withTreatment(treatment).withSelector(selector) 488 + .builder().withTreatment(treatment).withSelector(selector)
489 - .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC); 489 + .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC);
490 - if (type.equals(Objective.Operation.ADD)) { 490 + if (type.equals(Objective.Operation.ADD)) {
491 - flowObjectiveService.forward(dpid, objective.add()); 491 + flowObjectiveService.forward(dpid, objective.add());
492 - } else { 492 + } else {
493 - flowObjectiveService.forward(dpid, objective.remove()); 493 + flowObjectiveService.forward(dpid, objective.remove());
494 - } 494 + }
495 - } 495 + }
496 - 496 +
497 - // Applies the default flows to port table. 497 + // Applies the default flows to port table.
498 - private void programPortDefaultRules(DeviceId dpid, ApplicationId appid, 498 + private void programPortDefaultRules(DeviceId dpid, ApplicationId appid,
499 - Objective.Operation type) { 499 + Objective.Operation type) {
500 - TrafficSelector selector = DefaultTrafficSelector.builder().build(); 500 + TrafficSelector selector = DefaultTrafficSelector.builder().build();
501 - TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); 501 + TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
502 - ForwardingObjective.Builder objective = DefaultForwardingObjective 502 + ForwardingObjective.Builder objective = DefaultForwardingObjective
503 - .builder().withTreatment(treatment).withSelector(selector) 503 + .builder().withTreatment(treatment).withSelector(selector)
504 - .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC); 504 + .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC);
505 - if (type.equals(Objective.Operation.ADD)) { 505 + if (type.equals(Objective.Operation.ADD)) {
506 - flowObjectiveService.forward(dpid, objective.add()); 506 + flowObjectiveService.forward(dpid, objective.add());
507 - } else { 507 + } else {
508 - flowObjectiveService.forward(dpid, objective.remove()); 508 + flowObjectiveService.forward(dpid, objective.remove());
509 - } 509 + }
510 - } 510 + }
511 -} 511 +}
......
1 -<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
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 -<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
18 - <repository>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repository>
19 - <feature name="onos-app-vtnrsc" version="@FEATURE-VERSION"
20 - description="ONOS app vtnrsc components">
21 - <feature>onos-api</feature>
22 - <bundle>mvn:org.onosproject/onos-app-vtnrsc/@ONOS-VERSION
23 - </bundle>
24 - </feature>
25 -</features>
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import org.onlab.packet.IpAddress; 18 +import org.onlab.packet.IpAddress;
19 - 19 +
20 -/** 20 +/**
21 - * The continuous IP address range between the start address and the end address for the allocation pools. 21 + * The continuous IP address range between the start address and the end address for the allocation pools.
22 - */ 22 + */
23 -public interface AllocationPool { 23 +public interface AllocationPool {
24 - 24 +
25 - /** 25 + /**
26 - * The start address for the allocation pool. 26 + * The start address for the allocation pool.
27 - * 27 + *
28 - * @return startIp 28 + * @return startIp
29 - */ 29 + */
30 - IpAddress startIp(); 30 + IpAddress startIp();
31 - 31 +
32 - /** 32 + /**
33 - * The end address for the allocation pool. 33 + * The end address for the allocation pool.
34 - * 34 + *
35 - * @return endIp 35 + * @return endIp
36 - */ 36 + */
37 - IpAddress endIp(); 37 + IpAddress endIp();
38 -} 38 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 -import static com.google.common.base.Preconditions.checkNotNull; 19 +import static com.google.common.base.Preconditions.checkNotNull;
20 - 20 +
21 -import java.util.Objects; 21 +import java.util.Objects;
22 - 22 +
23 -import org.onlab.packet.IpAddress; 23 +import org.onlab.packet.IpAddress;
24 -import org.onlab.packet.MacAddress; 24 +import org.onlab.packet.MacAddress;
25 - 25 +
26 -/** 26 +/**
27 - * Immutable representation of a allowed address pair. 27 + * Immutable representation of a allowed address pair.
28 - */ 28 + */
29 -public final class AllowedAddressPair { 29 +public final class AllowedAddressPair {
30 - private final IpAddress ip; 30 + private final IpAddress ip;
31 - private final MacAddress mac; 31 + private final MacAddress mac;
32 - // Public construction is prohibited 32 + // Public construction is prohibited
33 - private AllowedAddressPair(IpAddress ip, MacAddress mac) { 33 + private AllowedAddressPair(IpAddress ip, MacAddress mac) {
34 - checkNotNull(ip, "IpAddress cannot be null"); 34 + checkNotNull(ip, "IpAddress cannot be null");
35 - checkNotNull(mac, "MacAddress cannot be null"); 35 + checkNotNull(mac, "MacAddress cannot be null");
36 - this.ip = ip; 36 + this.ip = ip;
37 - this.mac = mac; 37 + this.mac = mac;
38 - } 38 + }
39 - /** 39 + /**
40 - * Returns the AllowedAddressPair ip address. 40 + * Returns the AllowedAddressPair ip address.
41 - * 41 + *
42 - * @return ip address 42 + * @return ip address
43 - */ 43 + */
44 - public IpAddress ip() { 44 + public IpAddress ip() {
45 - return ip; 45 + return ip;
46 - } 46 + }
47 - 47 +
48 - /** 48 + /**
49 - * Returns the AllowedAddressPair MAC address. 49 + * Returns the AllowedAddressPair MAC address.
50 - * 50 + *
51 - * @return MAC address 51 + * @return MAC address
52 - */ 52 + */
53 - public MacAddress mac() { 53 + public MacAddress mac() {
54 - return mac; 54 + return mac;
55 - } 55 + }
56 - 56 +
57 - 57 +
58 - /** 58 + /**
59 - * Creates a allowedAddressPair using the supplied ipAddress &amp; 59 + * Creates a allowedAddressPair using the supplied ipAddress &amp;
60 - * macAddress. 60 + * macAddress.
61 - * 61 + *
62 - * @param ip IP address 62 + * @param ip IP address
63 - * @param mac MAC address 63 + * @param mac MAC address
64 - * @return AllowedAddressPair 64 + * @return AllowedAddressPair
65 - */ 65 + */
66 - public static AllowedAddressPair allowedAddressPair(IpAddress ip, 66 + public static AllowedAddressPair allowedAddressPair(IpAddress ip,
67 - MacAddress mac) { 67 + MacAddress mac) {
68 - return new AllowedAddressPair(ip, mac); 68 + return new AllowedAddressPair(ip, mac);
69 - } 69 + }
70 - 70 +
71 - @Override 71 + @Override
72 - public int hashCode() { 72 + public int hashCode() {
73 - return Objects.hash(ip, mac); 73 + return Objects.hash(ip, mac);
74 - } 74 + }
75 - 75 +
76 - @Override 76 + @Override
77 - public boolean equals(Object obj) { 77 + public boolean equals(Object obj) {
78 - if (this == obj) { 78 + if (this == obj) {
79 - return true; 79 + return true;
80 - } 80 + }
81 - if (obj instanceof AllowedAddressPair) { 81 + if (obj instanceof AllowedAddressPair) {
82 - final AllowedAddressPair that = (AllowedAddressPair) obj; 82 + final AllowedAddressPair that = (AllowedAddressPair) obj;
83 - return Objects.equals(this.ip, that.ip) 83 + return Objects.equals(this.ip, that.ip)
84 - && Objects.equals(this.mac, that.mac); 84 + && Objects.equals(this.mac, that.mac);
85 - } 85 + }
86 - return false; 86 + return false;
87 - } 87 + }
88 - 88 +
89 - @Override 89 + @Override
90 - public String toString() { 90 + public String toString() {
91 - return toStringHelper(this).add("ip", ip).add("mac", mac).toString(); 91 + return toStringHelper(this).add("ip", ip).add("mac", mac).toString();
92 - } 92 + }
93 - 93 +
94 -} 94 +}
......
1 +package org.onosproject.vtnrsc;
2 +
3 +import static com.google.common.base.Preconditions.checkNotNull;
4 +
5 +import java.util.Objects;
6 +
7 +public final class BindingHostId {
8 + private final String bindingHostId;
9 +
10 + // Public construction is prohibited
11 + private BindingHostId(String bindingHostId) {
12 + checkNotNull(bindingHostId, "BindingHosttId cannot be null");
13 + this.bindingHostId = bindingHostId;
14 + }
15 +
16 + /**
17 + * Creates a BindingHostId identifier.
18 + *
19 + * @param bindingHostId the bindingHostId identifier
20 + * @return the bindingHostId identifier
21 + */
22 + public static BindingHostId bindingHostId(String bindingHostId) {
23 + return new BindingHostId(bindingHostId);
24 + }
25 +
26 + /**
27 + * Returns the bindingHostId identifier.
28 + *
29 + * @return the bindingHostId identifier
30 + */
31 + public String bindingHostId() {
32 + return bindingHostId;
33 + }
34 +
35 + @Override
36 + public int hashCode() {
37 + return Objects.hash(bindingHostId);
38 + }
39 +
40 + @Override
41 + public boolean equals(Object obj) {
42 + if (this == obj) {
43 + return true;
44 + }
45 + if (obj instanceof BindingHostId) {
46 + final BindingHostId that = (BindingHostId) obj;
47 + return this.getClass() == that.getClass()
48 + && Objects.equals(this.bindingHostId, that.bindingHostId);
49 + }
50 + return false;
51 + }
52 +
53 + @Override
54 + public String toString() {
55 + return bindingHostId;
56 + }
57 +}
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 -import static com.google.common.base.Preconditions.checkNotNull; 19 +import static com.google.common.base.Preconditions.checkNotNull;
20 -import java.util.Objects; 20 +import java.util.Objects;
21 - 21 +
22 -import org.onlab.packet.IpAddress; 22 +import org.onlab.packet.IpAddress;
23 - 23 +
24 -/** 24 +/**
25 - * The continuous IP address range between the start address and the end address 25 + * The continuous IP address range between the start address and the end address
26 - * for the allocation pools. 26 + * for the allocation pools.
27 - */ 27 + */
28 -public final class DefaultAllocationPool implements AllocationPool { 28 +public final class DefaultAllocationPool implements AllocationPool {
29 - 29 +
30 - private final IpAddress startIp; 30 + private final IpAddress startIp;
31 - private final IpAddress endIp; 31 + private final IpAddress endIp;
32 - 32 +
33 - /** 33 + /**
34 - * Creates an AllocationPool by using the start IP address and the end IP 34 + * Creates an AllocationPool by using the start IP address and the end IP
35 - * address. 35 + * address.
36 - * 36 + *
37 - * @param startIp the start IP address of the allocation pool 37 + * @param startIp the start IP address of the allocation pool
38 - * @param endIp the end IP address of the allocation pool 38 + * @param endIp the end IP address of the allocation pool
39 - */ 39 + */
40 - public DefaultAllocationPool(IpAddress startIp, IpAddress endIp) { 40 + public DefaultAllocationPool(IpAddress startIp, IpAddress endIp) {
41 - checkNotNull(startIp, "StartIp cannot be null"); 41 + checkNotNull(startIp, "StartIp cannot be null");
42 - checkNotNull(endIp, "EndIp cannot be null"); 42 + checkNotNull(endIp, "EndIp cannot be null");
43 - this.startIp = startIp; 43 + this.startIp = startIp;
44 - this.endIp = endIp; 44 + this.endIp = endIp;
45 - } 45 + }
46 - 46 +
47 - @Override 47 + @Override
48 - public IpAddress startIp() { 48 + public IpAddress startIp() {
49 - return startIp; 49 + return startIp;
50 - } 50 + }
51 - 51 +
52 - @Override 52 + @Override
53 - public IpAddress endIp() { 53 + public IpAddress endIp() {
54 - return endIp; 54 + return endIp;
55 - } 55 + }
56 - 56 +
57 - @Override 57 + @Override
58 - public int hashCode() { 58 + public int hashCode() {
59 - return Objects.hash(startIp, endIp); 59 + return Objects.hash(startIp, endIp);
60 - } 60 + }
61 - 61 +
62 - @Override 62 + @Override
63 - public boolean equals(Object obj) { 63 + public boolean equals(Object obj) {
64 - if (this == obj) { 64 + if (this == obj) {
65 - return true; 65 + return true;
66 - } 66 + }
67 - if (obj instanceof DefaultAllocationPool) { 67 + if (obj instanceof DefaultAllocationPool) {
68 - final DefaultAllocationPool other = (DefaultAllocationPool) obj; 68 + final DefaultAllocationPool other = (DefaultAllocationPool) obj;
69 - return Objects.equals(this.startIp, other.startIp) 69 + return Objects.equals(this.startIp, other.startIp)
70 - && Objects.equals(this.endIp, other.endIp); 70 + && Objects.equals(this.endIp, other.endIp);
71 - } 71 + }
72 - return false; 72 + return false;
73 - } 73 + }
74 - 74 +
75 - @Override 75 + @Override
76 - public String toString() { 76 + public String toString() {
77 - return toStringHelper(this).add("startIp", startIp).add("endIp", endIp) 77 + return toStringHelper(this).add("startIp", startIp).add("endIp", endIp)
78 - .toString(); 78 + .toString();
79 - } 79 + }
80 -} 80 +}
81 - 81 +
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 - 19 +
20 -import java.util.Objects; 20 +import java.util.Objects;
21 - 21 +
22 -import org.onlab.packet.IpAddress; 22 +import org.onlab.packet.IpAddress;
23 -import org.onlab.packet.IpPrefix; 23 +import org.onlab.packet.IpPrefix;
24 - 24 +
25 -/** 25 +/**
26 - * Host route dictionaries for the subnet. 26 + * Host route dictionaries for the subnet.
27 - */ 27 + */
28 -public final class DefaultHostRoute implements HostRoute { 28 +public final class DefaultHostRoute implements HostRoute {
29 - 29 +
30 - private final IpAddress nexthop; 30 + private final IpAddress nexthop;
31 - private final IpPrefix destination; 31 + private final IpPrefix destination;
32 - 32 +
33 - /** 33 + /**
34 - * 34 + *
35 - * Creates a DefaultHostRoute by using the next hop and the destination. 35 + * Creates a DefaultHostRoute by using the next hop and the destination.
36 - * 36 + *
37 - * @param nexthop of the DefaultHostRoute 37 + * @param nexthop of the DefaultHostRoute
38 - * @param destination of the DefaultHostRoute 38 + * @param destination of the DefaultHostRoute
39 - */ 39 + */
40 - public DefaultHostRoute(IpAddress nexthop, IpPrefix destination) { 40 + public DefaultHostRoute(IpAddress nexthop, IpPrefix destination) {
41 - this.nexthop = nexthop; 41 + this.nexthop = nexthop;
42 - this.destination = destination; 42 + this.destination = destination;
43 - } 43 + }
44 - 44 +
45 - @Override 45 + @Override
46 - public IpAddress nexthop() { 46 + public IpAddress nexthop() {
47 - return nexthop; 47 + return nexthop;
48 - } 48 + }
49 - 49 +
50 - @Override 50 + @Override
51 - public IpPrefix destination() { 51 + public IpPrefix destination() {
52 - return destination; 52 + return destination;
53 - } 53 + }
54 - 54 +
55 - @Override 55 + @Override
56 - public String toString() { 56 + public String toString() {
57 - return toStringHelper(this).add("nexthop", nexthop) 57 + return toStringHelper(this).add("nexthop", nexthop)
58 - .add("destination", destination).toString(); 58 + .add("destination", destination).toString();
59 - } 59 + }
60 - 60 +
61 - @Override 61 + @Override
62 - public int hashCode() { 62 + public int hashCode() {
63 - return Objects.hash(nexthop, destination); 63 + return Objects.hash(nexthop, destination);
64 - } 64 + }
65 - 65 +
66 - @Override 66 + @Override
67 - public boolean equals(Object obj) { 67 + public boolean equals(Object obj) {
68 - if (this == obj) { 68 + if (this == obj) {
69 - return true; 69 + return true;
70 - } 70 + }
71 - if (obj instanceof DefaultHostRoute) { 71 + if (obj instanceof DefaultHostRoute) {
72 - final DefaultHostRoute other = (DefaultHostRoute) obj; 72 + final DefaultHostRoute other = (DefaultHostRoute) obj;
73 - return Objects.equals(this.nexthop, other.nexthop) 73 + return Objects.equals(this.nexthop, other.nexthop)
74 - && Objects.equals(this.destination, other.destination); 74 + && Objects.equals(this.destination, other.destination);
75 - } 75 + }
76 - return false; 76 + return false;
77 - } 77 + }
78 - 78 +
79 -} 79 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 - 19 +
20 -import java.util.Objects; 20 +import java.util.Objects;
21 - 21 +
22 -import org.onlab.packet.IpAddress; 22 +import org.onlab.packet.IpAddress;
23 -import org.onlab.packet.IpAddress.Version; 23 +import org.onlab.packet.IpAddress.Version;
24 -import org.onlab.packet.IpPrefix; 24 +import org.onlab.packet.IpPrefix;
25 - 25 +
26 -/** 26 +/**
27 - * Default implementation of Subnet interface . 27 + * Default implementation of Subnet interface .
28 - */ 28 + */
29 -public final class DefaultSubnet implements Subnet { 29 +public final class DefaultSubnet implements Subnet {
30 - private final SubnetId id; 30 + private final SubnetId id;
31 - private final String subnetName; 31 + private final String subnetName;
32 - private final TenantNetworkId networkId; 32 + private final TenantNetworkId networkId;
33 - private final TenantId tenantId; 33 + private final TenantId tenantId;
34 - private final Version ipVersion; 34 + private final Version ipVersion;
35 - private final IpPrefix cidr; 35 + private final IpPrefix cidr;
36 - private final IpAddress gatewayIp; 36 + private final IpAddress gatewayIp;
37 - private final boolean dhcpEnabled; 37 + private final boolean dhcpEnabled;
38 - private final boolean shared; 38 + private final boolean shared;
39 - private final Mode ipV6AddressMode; 39 + private final Mode ipV6AddressMode;
40 - private final Mode ipV6RaMode; 40 + private final Mode ipV6RaMode;
41 - private final Iterable<HostRoute> hostRoutes; 41 + private final Iterable<HostRoute> hostRoutes;
42 - private final Iterable<AllocationPool> allocationPools; 42 + private final Iterable<AllocationPool> allocationPools;
43 - 43 +
44 - /** 44 + /**
45 - * Creates a subnet object. 45 + * Creates a subnet object.
46 - * 46 + *
47 - * @param id subnet identifier 47 + * @param id subnet identifier
48 - * @param subnetName the name of subnet 48 + * @param subnetName the name of subnet
49 - * @param networkId network identifier 49 + * @param networkId network identifier
50 - * @param tenantId tenant identifier 50 + * @param tenantId tenant identifier
51 - * @param cidr the cidr 51 + * @param ipVersion Version of ipv4 or ipv6
52 - * @param gatewayIp gateway ip 52 + * @param cidr the cidr
53 - * @param dhcpEnabled dhcp enabled or not 53 + * @param gatewayIp gateway ip
54 - * @param shared indicates whether this network is shared across all 54 + * @param dhcpEnabled dhcp enabled or not
55 - * tenants, By default, only administrative user can change this 55 + * @param shared indicates whether this network is shared across all
56 - * value 56 + * tenants, By default, only administrative user can change this
57 - * @param hostRoutes a collection of host routes 57 + * value
58 - * @param ipV6AddressMode ipV6AddressMode 58 + * @param hostRoutes a collection of host routes
59 - * @param ipV6RaMode ipV6RaMode 59 + * @param ipV6AddressMode ipV6AddressMode
60 - * @param allocationPoolsIt a collection of allocationPools 60 + * @param ipV6RaMode ipV6RaMode
61 - */ 61 + * @param allocationPoolsIt a collection of allocationPools
62 - public DefaultSubnet(SubnetId id, String subnetName, 62 + */
63 - TenantNetworkId networkId, TenantId tenantId, 63 + public DefaultSubnet(SubnetId id, String subnetName,
64 - Version ipVersion, IpPrefix cidr, IpAddress gatewayIp, 64 + TenantNetworkId networkId, TenantId tenantId,
65 - boolean dhcpEnabled, boolean shared, 65 + Version ipVersion, IpPrefix cidr, IpAddress gatewayIp,
66 - Iterable<HostRoute> hostRoutes, Mode ipV6AddressMode, 66 + boolean dhcpEnabled, boolean shared,
67 - Mode ipV6RaMode, 67 + Iterable<HostRoute> hostRoutes, Mode ipV6AddressMode,
68 - Iterable<AllocationPool> allocationPoolsIt) { 68 + Mode ipV6RaMode,
69 - this.id = id; 69 + Iterable<AllocationPool> allocationPoolsIt) {
70 - this.subnetName = subnetName; 70 + this.id = id;
71 - this.networkId = networkId; 71 + this.subnetName = subnetName;
72 - this.tenantId = tenantId; 72 + this.networkId = networkId;
73 - this.ipVersion = ipVersion; 73 + this.tenantId = tenantId;
74 - this.cidr = cidr; 74 + this.ipVersion = ipVersion;
75 - this.gatewayIp = gatewayIp; 75 + this.cidr = cidr;
76 - this.dhcpEnabled = dhcpEnabled; 76 + this.gatewayIp = gatewayIp;
77 - this.shared = shared; 77 + this.dhcpEnabled = dhcpEnabled;
78 - this.ipV6AddressMode = ipV6AddressMode; 78 + this.shared = shared;
79 - this.ipV6RaMode = ipV6RaMode; 79 + this.ipV6AddressMode = ipV6AddressMode;
80 - this.hostRoutes = hostRoutes; 80 + this.ipV6RaMode = ipV6RaMode;
81 - this.allocationPools = allocationPoolsIt; 81 + this.hostRoutes = hostRoutes;
82 - } 82 + this.allocationPools = allocationPoolsIt;
83 - 83 + }
84 - @Override 84 +
85 - public SubnetId id() { 85 + @Override
86 - return id; 86 + public SubnetId id() {
87 - } 87 + return id;
88 - 88 + }
89 - @Override 89 +
90 - public String subnetName() { 90 + @Override
91 - return subnetName; 91 + public String subnetName() {
92 - } 92 + return subnetName;
93 - 93 + }
94 - @Override 94 +
95 - public TenantNetworkId networkId() { 95 + @Override
96 - return networkId; 96 + public TenantNetworkId networkId() {
97 - } 97 + return networkId;
98 - 98 + }
99 - @Override 99 +
100 - public TenantId tenantId() { 100 + @Override
101 - return tenantId; 101 + public TenantId tenantId() {
102 - } 102 + return tenantId;
103 - 103 + }
104 - @Override 104 +
105 - public Version ipVersion() { 105 + @Override
106 - return ipVersion; 106 + public Version ipVersion() {
107 - } 107 + return ipVersion;
108 - 108 + }
109 - @Override 109 +
110 - public IpPrefix cidr() { 110 + @Override
111 - return cidr; 111 + public IpPrefix cidr() {
112 - } 112 + return cidr;
113 - 113 + }
114 - @Override 114 +
115 - public IpAddress gatewayIp() { 115 + @Override
116 - return gatewayIp; 116 + public IpAddress gatewayIp() {
117 - } 117 + return gatewayIp;
118 - 118 + }
119 - @Override 119 +
120 - public boolean dhcpEnabled() { 120 + @Override
121 - return dhcpEnabled; 121 + public boolean dhcpEnabled() {
122 - } 122 + return dhcpEnabled;
123 - 123 + }
124 - @Override 124 +
125 - public boolean shared() { 125 + @Override
126 - return shared; 126 + public boolean shared() {
127 - } 127 + return shared;
128 - 128 + }
129 - @Override 129 +
130 - public Iterable<HostRoute> hostRoutes() { 130 + @Override
131 - return hostRoutes; 131 + public Iterable<HostRoute> hostRoutes() {
132 - } 132 + return hostRoutes;
133 - 133 + }
134 - @Override 134 +
135 - public Mode ipV6AddressMode() { 135 + @Override
136 - return ipV6AddressMode; 136 + public Mode ipV6AddressMode() {
137 - } 137 + return ipV6AddressMode;
138 - 138 + }
139 - @Override 139 +
140 - public Mode ipV6RaMode() { 140 + @Override
141 - return ipV6RaMode; 141 + public Mode ipV6RaMode() {
142 - } 142 + return ipV6RaMode;
143 - 143 + }
144 - @Override 144 +
145 - public Iterable<AllocationPool> allocationPools() { 145 + @Override
146 - return allocationPools; 146 + public Iterable<AllocationPool> allocationPools() {
147 - } 147 + return allocationPools;
148 - 148 + }
149 - @Override 149 +
150 - public int hashCode() { 150 + @Override
151 - return Objects.hash(id, subnetName, ipVersion, cidr, gatewayIp, 151 + public int hashCode() {
152 - dhcpEnabled, shared, tenantId); 152 + return Objects.hash(id, subnetName, ipVersion, cidr, gatewayIp,
153 - } 153 + dhcpEnabled, shared, tenantId);
154 - 154 + }
155 - @Override 155 +
156 - public boolean equals(Object obj) { 156 + @Override
157 - if (this == obj) { 157 + public boolean equals(Object obj) {
158 - return true; 158 + if (this == obj) {
159 - } 159 + return true;
160 - if (obj instanceof DefaultSubnet) { 160 + }
161 - final DefaultSubnet that = (DefaultSubnet) obj; 161 + if (obj instanceof DefaultSubnet) {
162 - return Objects.equals(this.id, that.id) 162 + final DefaultSubnet that = (DefaultSubnet) obj;
163 - && Objects.equals(this.subnetName, that.subnetName) 163 + return Objects.equals(this.id, that.id)
164 - && Objects.equals(this.ipVersion, that.ipVersion) 164 + && Objects.equals(this.subnetName, that.subnetName)
165 - && Objects.equals(this.cidr, that.cidr) 165 + && Objects.equals(this.ipVersion, that.ipVersion)
166 - && Objects.equals(this.shared, that.shared) 166 + && Objects.equals(this.cidr, that.cidr)
167 - && Objects.equals(this.gatewayIp, that.gatewayIp) 167 + && Objects.equals(this.shared, that.shared)
168 - && Objects.equals(this.dhcpEnabled, that.dhcpEnabled); 168 + && Objects.equals(this.gatewayIp, that.gatewayIp)
169 - } 169 + && Objects.equals(this.dhcpEnabled, that.dhcpEnabled);
170 - return false; 170 + }
171 - } 171 + return false;
172 - 172 + }
173 - @Override 173 +
174 - public String toString() { 174 + @Override
175 - return toStringHelper(this).add("id", id).add("subnetName", subnetName) 175 + public String toString() {
176 - .add("ipVersion", ipVersion).add("cidr", cidr) 176 + return toStringHelper(this).add("id", id).add("subnetName", subnetName)
177 - .add("shared", shared).add("gatewayIp", gatewayIp) 177 + .add("ipVersion", ipVersion).add("cidr", cidr)
178 - .add("dhcpEnabled", dhcpEnabled).toString(); 178 + .add("shared", shared).add("gatewayIp", gatewayIp)
179 - } 179 + .add("dhcpEnabled", dhcpEnabled).toString();
180 - 180 + }
181 -} 181 +
182 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 - 19 +
20 -import java.util.Objects; 20 +import java.util.Objects;
21 - 21 +
22 -/** 22 +/**
23 - * Default implementation of TenantNetwork interface. 23 + * Default implementation of TenantNetwork interface.
24 - */ 24 + */
25 -public final class DefaultTenantNetwork implements TenantNetwork { 25 +public final class DefaultTenantNetwork implements TenantNetwork {
26 - private final TenantNetworkId id; 26 + private final TenantNetworkId id;
27 - private final String name; 27 + private final String name;
28 - private final boolean adminStateUp; 28 + private final boolean adminStateUp;
29 - private final State state; 29 + private final State state;
30 - private final boolean shared; 30 + private final boolean shared;
31 - private final Type type; 31 + private final Type type;
32 - private final TenantId tenantId; 32 + private final TenantId tenantId;
33 - private final boolean routerExternal; 33 + private final boolean routerExternal;
34 - private final PhysicalNetwork physicalNetwork; 34 + private final PhysicalNetwork physicalNetwork;
35 - private final SegmentationId segmentationId; 35 + private final SegmentationId segmentationId;
36 - 36 +
37 - /** 37 + /**
38 - * Creates a neutronNetwork element attributed to the specified provider. 38 + * Creates a neutronNetwork element attributed to the specified provider.
39 - * 39 + *
40 - * @param id network identifier 40 + * @param id network identifier
41 - * @param name the network name 41 + * @param name the network name
42 - * @param adminStateUp administrative state of the network 42 + * @param adminStateUp administrative state of the network
43 - * @param state the network state 43 + * @param state the network state
44 - * @param shared indicates whether this network is shared across all 44 + * @param shared indicates whether this network is shared across all
45 - * tenants, By default, only administrative user can change this 45 + * tenants, By default, only administrative user can change this
46 - * value 46 + * value
47 - * @param tenantId tenant identifier 47 + * @param tenantId tenant identifier
48 - * @param routerExternal network routerExternal 48 + * @param routerExternal network routerExternal
49 - * @param type the network type 49 + * @param type the network type
50 - * @param physicalNetwork physicalNetwork identifier 50 + * @param physicalNetwork physicalNetwork identifier
51 - * @param segmentationId segmentation identifier 51 + * @param segmentationId segmentation identifier
52 - */ 52 + */
53 - public DefaultTenantNetwork(TenantNetworkId id, String name, 53 + public DefaultTenantNetwork(TenantNetworkId id, String name,
54 - boolean adminStateUp, State state, 54 + boolean adminStateUp, State state,
55 - boolean shared, TenantId tenantId, 55 + boolean shared, TenantId tenantId,
56 - boolean routerExternal, Type type, 56 + boolean routerExternal, Type type,
57 - PhysicalNetwork physicalNetwork, 57 + PhysicalNetwork physicalNetwork,
58 - SegmentationId segmentationId) { 58 + SegmentationId segmentationId) {
59 - this.id = id; 59 + this.id = id;
60 - this.name = name; 60 + this.name = name;
61 - this.adminStateUp = adminStateUp; 61 + this.adminStateUp = adminStateUp;
62 - this.state = state; 62 + this.state = state;
63 - this.shared = shared; 63 + this.shared = shared;
64 - this.type = type; 64 + this.type = type;
65 - this.tenantId = tenantId; 65 + this.tenantId = tenantId;
66 - this.routerExternal = routerExternal; 66 + this.routerExternal = routerExternal;
67 - this.physicalNetwork = physicalNetwork; 67 + this.physicalNetwork = physicalNetwork;
68 - this.segmentationId = segmentationId; 68 + this.segmentationId = segmentationId;
69 - } 69 + }
70 - 70 +
71 - @Override 71 + @Override
72 - public TenantNetworkId id() { 72 + public TenantNetworkId id() {
73 - return id; 73 + return id;
74 - } 74 + }
75 - 75 +
76 - @Override 76 + @Override
77 - public String name() { 77 + public String name() {
78 - return name; 78 + return name;
79 - } 79 + }
80 - 80 +
81 - @Override 81 + @Override
82 - public boolean adminStateUp() { 82 + public boolean adminStateUp() {
83 - return adminStateUp; 83 + return adminStateUp;
84 - } 84 + }
85 - 85 +
86 - @Override 86 + @Override
87 - public State state() { 87 + public State state() {
88 - return state; 88 + return state;
89 - } 89 + }
90 - 90 +
91 - @Override 91 + @Override
92 - public boolean shared() { 92 + public boolean shared() {
93 - return shared; 93 + return shared;
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public TenantId tenantId() { 97 + public TenantId tenantId() {
98 - return tenantId; 98 + return tenantId;
99 - } 99 + }
100 - 100 +
101 - @Override 101 + @Override
102 - public boolean routerExternal() { 102 + public boolean routerExternal() {
103 - return routerExternal; 103 + return routerExternal;
104 - } 104 + }
105 - 105 +
106 - @Override 106 + @Override
107 - public Type type() { 107 + public Type type() {
108 - return type; 108 + return type;
109 - } 109 + }
110 - 110 +
111 - @Override 111 + @Override
112 - public PhysicalNetwork physicalNetwork() { 112 + public PhysicalNetwork physicalNetwork() {
113 - return physicalNetwork; 113 + return physicalNetwork;
114 - } 114 + }
115 - 115 +
116 - @Override 116 + @Override
117 - public SegmentationId segmentationId() { 117 + public SegmentationId segmentationId() {
118 - return segmentationId; 118 + return segmentationId;
119 - } 119 + }
120 - 120 +
121 - @Override 121 + @Override
122 - public int hashCode() { 122 + public int hashCode() {
123 - return Objects.hash(id, name, adminStateUp, state, shared, tenantId, 123 + return Objects.hash(id, name, adminStateUp, state, shared, tenantId,
124 - routerExternal, type, physicalNetwork, 124 + routerExternal, type, physicalNetwork,
125 - segmentationId); 125 + segmentationId);
126 - } 126 + }
127 - 127 +
128 - @Override 128 + @Override
129 - public boolean equals(Object obj) { 129 + public boolean equals(Object obj) {
130 - if (this == obj) { 130 + if (this == obj) {
131 - return true; 131 + return true;
132 - } 132 + }
133 - if (obj instanceof DefaultTenantNetwork) { 133 + if (obj instanceof DefaultTenantNetwork) {
134 - final DefaultTenantNetwork that = (DefaultTenantNetwork) obj; 134 + final DefaultTenantNetwork that = (DefaultTenantNetwork) obj;
135 - return Objects.equals(this.id, that.id) 135 + return Objects.equals(this.id, that.id)
136 - && Objects.equals(this.name, that.name) 136 + && Objects.equals(this.name, that.name)
137 - && Objects.equals(this.adminStateUp, that.adminStateUp) 137 + && Objects.equals(this.adminStateUp, that.adminStateUp)
138 - && Objects.equals(this.state, that.state) 138 + && Objects.equals(this.state, that.state)
139 - && Objects.equals(this.shared, that.shared) 139 + && Objects.equals(this.shared, that.shared)
140 - && Objects.equals(this.tenantId, that.tenantId) 140 + && Objects.equals(this.tenantId, that.tenantId)
141 - && Objects.equals(this.routerExternal, that.routerExternal) 141 + && Objects.equals(this.routerExternal, that.routerExternal)
142 - && Objects.equals(this.type, that.type) 142 + && Objects.equals(this.type, that.type)
143 - && Objects.equals(this.physicalNetwork, 143 + && Objects.equals(this.physicalNetwork,
144 - that.physicalNetwork) 144 + that.physicalNetwork)
145 - && Objects.equals(this.segmentationId, that.segmentationId); 145 + && Objects.equals(this.segmentationId, that.segmentationId);
146 - } 146 + }
147 - return false; 147 + return false;
148 - } 148 + }
149 - 149 +
150 - @Override 150 + @Override
151 - public String toString() { 151 + public String toString() {
152 - return toStringHelper(this).add("id", id).add("name", name) 152 + return toStringHelper(this).add("id", id).add("name", name)
153 - .add("adminStateUp", adminStateUp).add("state", state) 153 + .add("adminStateUp", adminStateUp).add("state", state)
154 - .add("shared", shared).add("tenantId", tenantId) 154 + .add("shared", shared).add("tenantId", tenantId)
155 - .add("routeExternal", routerExternal).add("type", type) 155 + .add("routeExternal", routerExternal).add("type", type)
156 - .add("physicalNetwork", physicalNetwork) 156 + .add("physicalNetwork", physicalNetwork)
157 - .add("segmentationId", segmentationId).toString(); 157 + .add("segmentationId", segmentationId).toString();
158 - } 158 + }
159 - 159 +
160 -} 160 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 - 19 +
20 -import java.util.Collection; 20 +import java.util.Collection;
21 -import java.util.Map; 21 +import java.util.Map;
22 -import java.util.Objects; 22 +import java.util.Objects;
23 - 23 +import java.util.Set;
24 -import org.onlab.packet.MacAddress; 24 +
25 -import org.onosproject.net.DeviceId; 25 +import org.onlab.packet.MacAddress;
26 -import org.onosproject.net.HostId; 26 +import org.onosproject.net.DeviceId;
27 - 27 +
28 -/** 28 +/**
29 - * Default implementation of VirtualPort interface . 29 + * Default implementation of VirtualPort interface .
30 - */ 30 + */
31 -public final class DefaultVirtualPort implements VirtualPort { 31 +public final class DefaultVirtualPort implements VirtualPort {
32 - private final VirtualPortId id; 32 + private final VirtualPortId id;
33 - private final TenantNetworkId networkId; 33 + private final TenantNetworkId networkId;
34 - private final Boolean adminStateUp; 34 + private final Boolean adminStateUp;
35 - private final String name; 35 + private final String name;
36 - private final State state; 36 + private final State state;
37 - private final MacAddress macAddress; 37 + private final MacAddress macAddress;
38 - private final TenantId tenantId; 38 + private final TenantId tenantId;
39 - private final String deviceOwner; 39 + private final String deviceOwner;
40 - private final DeviceId deviceId; 40 + private final DeviceId deviceId;
41 - private final FixedIp fixedIp; 41 + private final Set<FixedIp> fixedIps;
42 - private final HostId bindingHostId; 42 + private final BindingHostId bindingHostId;
43 - private final String bindingVnicType; 43 + private final String bindingVnicType;
44 - private final String bindingVifType; 44 + private final String bindingVifType;
45 - private final String bindingVifDetails; 45 + private final String bindingVifDetails;
46 - private final Collection<AllowedAddressPair> allowedAddressPairs; 46 + private final Collection<AllowedAddressPair> allowedAddressPairs;
47 - private final Collection<SecurityGroup> securityGroups; 47 + private final Collection<SecurityGroup> securityGroups;
48 - 48 +
49 - /** 49 + /**
50 - * Creates a VirtualPort object. 50 + * Creates a VirtualPort object.
51 - * 51 + *
52 - * @param id the virtual port identifier 52 + * @param id the virtual port identifier
53 - * @param networkId the network identifier 53 + * @param networkId the network identifier
54 - * @param adminStateUp adminStateup true or false 54 + * @param adminStateUp adminStateup true or false
55 - * @param strMap the map of properties of virtual port 55 + * @param strMap the map of properties of virtual port
56 - * @param state virtual port state 56 + * @param state virtual port state
57 - * @param macAddress the MAC address 57 + * @param macAddress the MAC address
58 - * @param tenantId the tenant identifier 58 + * @param tenantId the tenant identifier
59 - * @param deviceId the device identifier 59 + * @param deviceId the device identifier
60 - * @param fixedIp the fixed IP 60 + * @param fixedIps set of fixed IP
61 - * @param bindingHostId the binding host identifier 61 + * @param bindingHostId the binding host identifier
62 - * @param allowedAddressPairs the collection of allowdeAddressPairs 62 + * @param allowedAddressPairs the collection of allowdeAddressPairs
63 - * @param securityGroups the collection of securityGroups 63 + * @param securityGroups the collection of securityGroups
64 - */ 64 + */
65 - public DefaultVirtualPort(VirtualPortId id, 65 + public DefaultVirtualPort(VirtualPortId id,
66 - TenantNetworkId networkId, 66 + TenantNetworkId networkId,
67 - Boolean adminStateUp, 67 + Boolean adminStateUp,
68 - Map<String, String> strMap, 68 + Map<String, String> strMap,
69 - State state, 69 + State state,
70 - MacAddress macAddress, 70 + MacAddress macAddress,
71 - TenantId tenantId, 71 + TenantId tenantId,
72 - DeviceId deviceId, 72 + DeviceId deviceId,
73 - FixedIp fixedIp, 73 + Set<FixedIp> fixedIps,
74 - HostId bindingHostId, 74 + BindingHostId bindingHostId,
75 - Collection<AllowedAddressPair> allowedAddressPairs, 75 + Collection<AllowedAddressPair> allowedAddressPairs,
76 - Collection<SecurityGroup> securityGroups) { 76 + Collection<SecurityGroup> securityGroups) {
77 - this.id = id; 77 + this.id = id;
78 - this.networkId = networkId; 78 + this.networkId = networkId;
79 - this.adminStateUp = adminStateUp; 79 + this.adminStateUp = adminStateUp;
80 - this.name = strMap.get("name"); 80 + this.name = strMap.get("name");
81 - this.state = state; 81 + this.state = state;
82 - this.macAddress = macAddress; 82 + this.macAddress = macAddress;
83 - this.tenantId = tenantId; 83 + this.tenantId = tenantId;
84 - this.deviceOwner = strMap.get("deviceOwner"); 84 + this.deviceOwner = strMap.get("deviceOwner");
85 - this.deviceId = deviceId; 85 + this.deviceId = deviceId;
86 - this.fixedIp = fixedIp; 86 + this.fixedIps = fixedIps;
87 - this.bindingHostId = bindingHostId; 87 + this.bindingHostId = bindingHostId;
88 - this.bindingVnicType = strMap.get("bindingVnicType"); 88 + this.bindingVnicType = strMap.get("bindingVnicType");
89 - this.bindingVifType = strMap.get("bindingVifType"); 89 + this.bindingVifType = strMap.get("bindingVifType");
90 - this.bindingVifDetails = strMap.get("bindingVifDetails"); 90 + this.bindingVifDetails = strMap.get("bindingVifDetails");
91 - this.allowedAddressPairs = allowedAddressPairs; 91 + this.allowedAddressPairs = allowedAddressPairs;
92 - this.securityGroups = securityGroups; 92 + this.securityGroups = securityGroups;
93 - } 93 + }
94 - 94 +
95 - @Override 95 + @Override
96 - public VirtualPortId portId() { 96 + public VirtualPortId portId() {
97 - return id; 97 + return id;
98 - } 98 + }
99 - 99 +
100 - @Override 100 + @Override
101 - public TenantNetworkId networkId() { 101 + public TenantNetworkId networkId() {
102 - return networkId; 102 + return networkId;
103 - } 103 + }
104 - 104 +
105 - @Override 105 + @Override
106 - public String name() { 106 + public String name() {
107 - return name; 107 + return name;
108 - } 108 + }
109 - 109 +
110 - @Override 110 + @Override
111 - public boolean adminStateUp() { 111 + public boolean adminStateUp() {
112 - return adminStateUp; 112 + return adminStateUp;
113 - } 113 + }
114 - 114 +
115 - @Override 115 + @Override
116 - public State state() { 116 + public State state() {
117 - return state; 117 + return state;
118 - } 118 + }
119 - 119 +
120 - @Override 120 + @Override
121 - public MacAddress macAddress() { 121 + public MacAddress macAddress() {
122 - return macAddress; 122 + return macAddress;
123 - } 123 + }
124 - 124 +
125 - @Override 125 + @Override
126 - public TenantId tenantId() { 126 + public TenantId tenantId() {
127 - return tenantId; 127 + return tenantId;
128 - } 128 + }
129 - 129 +
130 - @Override 130 + @Override
131 - public DeviceId deviceId() { 131 + public DeviceId deviceId() {
132 - return deviceId; 132 + return deviceId;
133 - } 133 + }
134 - 134 +
135 - @Override 135 + @Override
136 - public String deviceOwner() { 136 + public String deviceOwner() {
137 - return deviceOwner; 137 + return deviceOwner;
138 - } 138 + }
139 - 139 +
140 - @Override 140 + @Override
141 - public Collection<AllowedAddressPair> allowedAddressPairs() { 141 + public Collection<AllowedAddressPair> allowedAddressPairs() {
142 - return allowedAddressPairs; 142 + return allowedAddressPairs;
143 - } 143 + }
144 - 144 +
145 - @Override 145 + @Override
146 - public FixedIp fixedIps() { 146 + public Set<FixedIp> fixedIps() {
147 - return fixedIp; 147 + return fixedIps;
148 - } 148 + }
149 - 149 +
150 - @Override 150 + @Override
151 - public HostId bindingHostId() { 151 + public BindingHostId bindingHostId() {
152 - return bindingHostId; 152 + return bindingHostId;
153 - } 153 + }
154 - 154 +
155 - @Override 155 + @Override
156 - public String bindingVnicType() { 156 + public String bindingVnicType() {
157 - return bindingVifType; 157 + return bindingVifType;
158 - } 158 + }
159 - 159 +
160 - @Override 160 + @Override
161 - public String bindingVifType() { 161 + public String bindingVifType() {
162 - return bindingVifType; 162 + return bindingVifType;
163 - } 163 + }
164 - 164 +
165 - @Override 165 + @Override
166 - public String bindingVifDetails() { 166 + public String bindingVifDetails() {
167 - return bindingVifDetails; 167 + return bindingVifDetails;
168 - } 168 + }
169 - 169 +
170 - @Override 170 + @Override
171 - public Collection<SecurityGroup> securityGroups() { 171 + public Collection<SecurityGroup> securityGroups() {
172 - return securityGroups; 172 + return securityGroups;
173 - } 173 + }
174 - 174 +
175 - @Override 175 + @Override
176 - public int hashCode() { 176 + public int hashCode() {
177 - return Objects.hash(id, networkId, adminStateUp, name, state, 177 + return Objects.hash(id, networkId, adminStateUp, name, state,
178 - macAddress, tenantId, deviceId, deviceOwner, 178 + macAddress, tenantId, deviceId, deviceOwner,
179 - allowedAddressPairs, fixedIp, bindingHostId, 179 + allowedAddressPairs, fixedIps, bindingHostId,
180 - bindingVnicType, bindingVifType, bindingVifDetails, 180 + bindingVnicType, bindingVifType, bindingVifDetails,
181 - securityGroups); 181 + securityGroups);
182 - } 182 + }
183 - 183 +
184 - @Override 184 + @Override
185 - public boolean equals(Object obj) { 185 + public boolean equals(Object obj) {
186 - if (this == obj) { 186 + if (this == obj) {
187 - return true; 187 + return true;
188 - } 188 + }
189 - if (obj instanceof DefaultVirtualPort) { 189 + if (obj instanceof DefaultVirtualPort) {
190 - final DefaultVirtualPort that = (DefaultVirtualPort) obj; 190 + final DefaultVirtualPort that = (DefaultVirtualPort) obj;
191 - return Objects.equals(this.id, that.id) 191 + return Objects.equals(this.id, that.id)
192 - && Objects.equals(this.networkId, that.networkId) 192 + && Objects.equals(this.networkId, that.networkId)
193 - && Objects.equals(this.adminStateUp, that.adminStateUp) 193 + && Objects.equals(this.adminStateUp, that.adminStateUp)
194 - && Objects.equals(this.state, that.state) 194 + && Objects.equals(this.state, that.state)
195 - && Objects.equals(this.name, that.name) 195 + && Objects.equals(this.name, that.name)
196 - && Objects.equals(this.tenantId, that.tenantId) 196 + && Objects.equals(this.tenantId, that.tenantId)
197 - && Objects.equals(this.macAddress, that.macAddress) 197 + && Objects.equals(this.macAddress, that.macAddress)
198 - && Objects.equals(this.deviceId, that.deviceId) 198 + && Objects.equals(this.deviceId, that.deviceId)
199 - && Objects.equals(this.deviceOwner, that.deviceOwner) 199 + && Objects.equals(this.deviceOwner, that.deviceOwner)
200 - && Objects.equals(this.allowedAddressPairs, 200 + && Objects.equals(this.allowedAddressPairs,
201 - that.allowedAddressPairs) 201 + that.allowedAddressPairs)
202 - && Objects.equals(this.fixedIp, that.fixedIp) 202 + && Objects.equals(this.fixedIps, that.fixedIps)
203 - && Objects.equals(this.bindingHostId, that.bindingHostId) 203 + && Objects.equals(this.bindingHostId, that.bindingHostId)
204 - && Objects.equals(this.bindingVifDetails, 204 + && Objects.equals(this.bindingVifDetails,
205 - that.bindingVifDetails) 205 + that.bindingVifDetails)
206 - && Objects.equals(this.bindingVifType, that.bindingVifType) 206 + && Objects.equals(this.bindingVifType, that.bindingVifType)
207 - && Objects.equals(this.bindingVnicType, 207 + && Objects.equals(this.bindingVnicType,
208 - that.bindingVnicType) 208 + that.bindingVnicType)
209 - && Objects.equals(this.securityGroups, that.securityGroups); 209 + && Objects.equals(this.securityGroups, that.securityGroups);
210 - } 210 + }
211 - return false; 211 + return false;
212 - } 212 + }
213 - 213 +
214 - @Override 214 + @Override
215 - public String toString() { 215 + public String toString() {
216 - return toStringHelper(this).add("id", id).add("network_id", networkId) 216 + return toStringHelper(this).add("id", id).add("network_id", networkId)
217 - .add("adminStateUp", adminStateUp).add("state", state) 217 + .add("adminStateUp", adminStateUp).add("state", state)
218 - .add("name", name).add("state", state) 218 + .add("name", name).add("state", state)
219 - .add("macAddress", macAddress).add("tenantId", tenantId) 219 + .add("macAddress", macAddress).add("tenantId", tenantId)
220 - .add("deviced", deviceId).add("deviceOwner", deviceOwner) 220 + .add("deviced", deviceId).add("deviceOwner", deviceOwner)
221 - .add("allowedAddressPairs", allowedAddressPairs) 221 + .add("allowedAddressPairs", allowedAddressPairs)
222 - .add("fixedIp", fixedIp).add("bindingHostId", bindingHostId) 222 + .add("fixedIp", fixedIps).add("bindingHostId", bindingHostId)
223 - .add("bindingVnicType", bindingVnicType) 223 + .add("bindingVnicType", bindingVnicType)
224 - .add("bindingVifDetails", bindingVifDetails) 224 + .add("bindingVifDetails", bindingVifDetails)
225 - .add("bindingVifType", bindingVifType) 225 + .add("bindingVifType", bindingVifType)
226 - .add("securityGroups", securityGroups).toString(); 226 + .add("securityGroups", securityGroups).toString();
227 - } 227 + }
228 - 228 +
229 -} 229 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 -import static com.google.common.base.Preconditions.checkNotNull; 19 +import static com.google.common.base.Preconditions.checkNotNull;
20 - 20 +
21 -import java.util.Objects; 21 +import java.util.Objects;
22 - 22 +
23 -import org.onlab.packet.IpAddress; 23 +import org.onlab.packet.IpAddress;
24 - 24 +
25 -/** 25 +/**
26 - * Immutable representation of a IP address for the port, Include the IP address 26 + * Immutable representation of a IP address for the port, Include the IP address
27 - * and subnet identity. 27 + * and subnet identity.
28 - */ 28 + */
29 -public final class FixedIp { 29 +public final class FixedIp {
30 - private final SubnetId subnetId; 30 + private final SubnetId subnetId;
31 - private final IpAddress ip; 31 + private final IpAddress ip;
32 - // Public construction is prohibited 32 + // Public construction is prohibited
33 - private FixedIp(SubnetId subnetId, IpAddress ip) { 33 + private FixedIp(SubnetId subnetId, IpAddress ip) {
34 - checkNotNull(subnetId, "SubnetId cannot be null"); 34 + checkNotNull(subnetId, "SubnetId cannot be null");
35 - checkNotNull(ip, "IpAddress cannot be null"); 35 + checkNotNull(ip, "IpAddress cannot be null");
36 - this.subnetId = subnetId; 36 + this.subnetId = subnetId;
37 - this.ip = ip; 37 + this.ip = ip;
38 - } 38 + }
39 - 39 +
40 - /** 40 + /**
41 - * Returns the FixedIp subnet identifier. 41 + * Returns the FixedIp subnet identifier.
42 - * 42 + *
43 - * @return subnet identifier 43 + * @return subnet identifier
44 - */ 44 + */
45 - public SubnetId subnetId() { 45 + public SubnetId subnetId() {
46 - return subnetId; 46 + return subnetId;
47 - } 47 + }
48 - 48 +
49 - /** 49 + /**
50 - * Returns the FixedIp IP address. 50 + * Returns the FixedIp IP address.
51 - * 51 + *
52 - * @return IP address 52 + * @return IP address
53 - */ 53 + */
54 - public IpAddress ip() { 54 + public IpAddress ip() {
55 - return ip; 55 + return ip;
56 - } 56 + }
57 - 57 +
58 - /** 58 + /**
59 - * Creates a fixed ip using the supplied fixedIp. 59 + * Creates a fixed ip using the supplied fixedIp.
60 - * 60 + *
61 - * @param subnetId subnet identity 61 + * @param subnetId subnet identity
62 - * @param ip IP address 62 + * @param ip IP address
63 - * @return FixedIp 63 + * @return FixedIp
64 - */ 64 + */
65 - public static FixedIp fixedIp(SubnetId subnetId, IpAddress ip) { 65 + public static FixedIp fixedIp(SubnetId subnetId, IpAddress ip) {
66 - return new FixedIp(subnetId, ip); 66 + return new FixedIp(subnetId, ip);
67 - } 67 + }
68 - 68 +
69 - @Override 69 + @Override
70 - public int hashCode() { 70 + public int hashCode() {
71 - return Objects.hash(subnetId, ip); 71 + return Objects.hash(subnetId, ip);
72 - } 72 + }
73 - 73 +
74 - @Override 74 + @Override
75 - public boolean equals(Object obj) { 75 + public boolean equals(Object obj) {
76 - if (this == obj) { 76 + if (this == obj) {
77 - return true; 77 + return true;
78 - } 78 + }
79 - if (obj instanceof FixedIp) { 79 + if (obj instanceof FixedIp) {
80 - final FixedIp that = (FixedIp) obj; 80 + final FixedIp that = (FixedIp) obj;
81 - return Objects.equals(this.subnetId, that.subnetId) 81 + return Objects.equals(this.subnetId, that.subnetId)
82 - && Objects.equals(this.ip, that.ip); 82 + && Objects.equals(this.ip, that.ip);
83 - } 83 + }
84 - return false; 84 + return false;
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public String toString() { 88 + public String toString() {
89 - return toStringHelper(this).add("subnetId", subnetId).add("ip", ip) 89 + return toStringHelper(this).add("subnetId", subnetId).add("ip", ip)
90 - .toString(); 90 + .toString();
91 - } 91 + }
92 - 92 +
93 -} 93 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import org.onlab.packet.IpAddress; 18 +import org.onlab.packet.IpAddress;
19 -import org.onlab.packet.IpPrefix; 19 +import org.onlab.packet.IpPrefix;
20 - 20 +
21 -/** 21 +/**
22 - * Host route dictionaries for the subnet. 22 + * Host route dictionaries for the subnet.
23 - */ 23 + */
24 -public interface HostRoute { 24 +public interface HostRoute {
25 - 25 +
26 - /** 26 + /**
27 - * Returns the next hop address. 27 + * Returns the next hop address.
28 - * 28 + *
29 - * @return next hop address 29 + * @return next hop address
30 - */ 30 + */
31 - IpAddress nexthop(); 31 + IpAddress nexthop();
32 - 32 +
33 - /** 33 + /**
34 - * Returns the destination address. 34 + * Returns the destination address.
35 - * 35 + *
36 - * @return destination address 36 + * @return destination address
37 - */ 37 + */
38 - IpPrefix destination(); 38 + IpPrefix destination();
39 -} 39 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
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 physicalnetwork identity. 23 + * Immutable representation of a physical network identity.
24 - */ 24 + */
25 -public final class PhysicalNetwork { 25 +public final class PhysicalNetwork {
26 - 26 +
27 - private final String physicalnetwork; 27 + private final String physicalNetwork;
28 - 28 +
29 - // Public construction is prohibited 29 + // Public construction is prohibited
30 - private PhysicalNetwork(String physicalnetwork) { 30 + private PhysicalNetwork(String physicalNetwork) {
31 - checkNotNull(physicalnetwork, "Physicalnetwork cannot be null"); 31 + checkNotNull(physicalNetwork, "PhysicalNetwork cannot be null");
32 - this.physicalnetwork = physicalnetwork; 32 + this.physicalNetwork = physicalNetwork;
33 - } 33 + }
34 - 34 +
35 - /** 35 + /**
36 - * Creates a network id using the physicalnetwork. 36 + * Creates a PhysicalNetwork object.
37 - * 37 + *
38 - * @param physicalnetwork network String 38 + * @param physicalNetwork physical network
39 - * @return physicalnetwork 39 + * @return physical network
40 - */ 40 + */
41 - public static PhysicalNetwork physicalNetwork(String physicalnetwork) { 41 + public static PhysicalNetwork physicalNetwork(String physicalNetwork) {
42 - return new PhysicalNetwork(physicalnetwork); 42 + return new PhysicalNetwork(physicalNetwork);
43 - } 43 + }
44 - 44 +
45 - /** 45 + /**
46 - * 46 + * Returns a physicalNetwork.
47 - * @return physicalnetwork 47 + *
48 - */ 48 + * @return physical network
49 - public String physicalnetwork() { 49 + */
50 - return physicalnetwork; 50 + public String physicalNetwork() {
51 - } 51 + return physicalNetwork;
52 - 52 + }
53 - @Override 53 +
54 - public int hashCode() { 54 + @Override
55 - return Objects.hash(physicalnetwork); 55 + public int hashCode() {
56 - } 56 + return Objects.hash(physicalNetwork);
57 - 57 + }
58 - @Override 58 +
59 - public boolean equals(Object obj) { 59 + @Override
60 - if (this == obj) { 60 + public boolean equals(Object obj) {
61 - return true; 61 + if (this == obj) {
62 - } 62 + return true;
63 - if (obj instanceof PhysicalNetwork) { 63 + }
64 - final PhysicalNetwork that = (PhysicalNetwork) obj; 64 + if (obj instanceof PhysicalNetwork) {
65 - return this.getClass() == that.getClass() 65 + final PhysicalNetwork that = (PhysicalNetwork) obj;
66 - && Objects.equals(this.physicalnetwork, 66 + return this.getClass() == that.getClass()
67 - that.physicalnetwork); 67 + && Objects.equals(this.physicalNetwork,
68 - } 68 + that.physicalNetwork);
69 - return false; 69 + }
70 - } 70 + return false;
71 - 71 + }
72 - @Override 72 +
73 - public String toString() { 73 + @Override
74 - return physicalnetwork; 74 + public String toString() {
75 - } 75 + return physicalNetwork;
76 - 76 + }
77 -} 77 +
78 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import static com.google.common.base.MoreObjects.toStringHelper; 20 +import static com.google.common.base.MoreObjects.toStringHelper;
21 -import static com.google.common.base.Preconditions.checkNotNull; 21 +import static com.google.common.base.Preconditions.checkNotNull;
22 - 22 +
23 -/** 23 +/**
24 - * Immutable representation of a security group. 24 + * Immutable representation of a security group.
25 - */ 25 + */
26 -public final class SecurityGroup { 26 +public final class SecurityGroup {
27 - private final String securityGroup; 27 + private final String securityGroup;
28 - 28 +
29 - /** 29 + /**
30 - * Returns the securityGroup. 30 + * Returns the securityGroup.
31 - * 31 + *
32 - * @return securityGroup 32 + * @return securityGroup
33 - */ 33 + */
34 - public String securityGroup() { 34 + public String securityGroup() {
35 - return securityGroup; 35 + return securityGroup;
36 - } 36 + }
37 - // Public construction is prohibited 37 + // Public construction is prohibited
38 - private SecurityGroup(String securityGroup) { 38 + private SecurityGroup(String securityGroup) {
39 - checkNotNull(securityGroup, "SecurityGroup cannot be null"); 39 + checkNotNull(securityGroup, "SecurityGroup cannot be null");
40 - this.securityGroup = securityGroup; 40 + this.securityGroup = securityGroup;
41 - } 41 + }
42 - 42 +
43 - /** 43 + /**
44 - * Creates a securityGroup using the supplied securityGroup. 44 + * Creates a securityGroup using the supplied securityGroup.
45 - * 45 + *
46 - * @param securityGroup security group 46 + * @param securityGroup security group
47 - * @return securityGroup 47 + * @return securityGroup
48 - */ 48 + */
49 - public static SecurityGroup securityGroup(String securityGroup) { 49 + public static SecurityGroup securityGroup(String securityGroup) {
50 - return new SecurityGroup(securityGroup); 50 + return new SecurityGroup(securityGroup);
51 - } 51 + }
52 - 52 +
53 - @Override 53 + @Override
54 - public int hashCode() { 54 + public int hashCode() {
55 - return Objects.hash(securityGroup); 55 + return Objects.hash(securityGroup);
56 - } 56 + }
57 - 57 +
58 - @Override 58 + @Override
59 - public boolean equals(Object obj) { 59 + public boolean equals(Object obj) {
60 - if (this == obj) { 60 + if (this == obj) {
61 - return true; 61 + return true;
62 - } 62 + }
63 - if (obj instanceof SecurityGroup) { 63 + if (obj instanceof SecurityGroup) {
64 - final SecurityGroup that = (SecurityGroup) obj; 64 + final SecurityGroup that = (SecurityGroup) obj;
65 - return this.getClass() == that.getClass() 65 + return this.getClass() == that.getClass()
66 - && Objects.equals(this.securityGroup, that.securityGroup); 66 + && Objects.equals(this.securityGroup, that.securityGroup);
67 - } 67 + }
68 - return false; 68 + return false;
69 - } 69 + }
70 - 70 +
71 - @Override 71 + @Override
72 - public String toString() { 72 + public String toString() {
73 - return toStringHelper(this).add("securityGroup", securityGroup) 73 + return toStringHelper(this).add("securityGroup", securityGroup)
74 - .toString(); 74 + .toString();
75 - } 75 + }
76 - 76 +
77 -} 77 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
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 identifier. 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 SegmentationId object. 36 + * Creates a SegmentationId object.
37 - * 37 + *
38 - * @param segmentationId segmentation identifier 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 + * Returns the segmentation identifier.
47 - * 47 + *
48 - * @return segmentationId 48 + * @return segmentationId
49 - */ 49 + */
50 - public String segmentationId() { 50 + public String segmentationId() {
51 - return segmentationId; 51 + return segmentationId;
52 - } 52 + }
53 - 53 +
54 - @Override 54 + @Override
55 - public int hashCode() { 55 + public int hashCode() {
56 - return Objects.hash(segmentationId); 56 + return Objects.hash(segmentationId);
57 - } 57 + }
58 - 58 +
59 - @Override 59 + @Override
60 - public boolean equals(Object obj) { 60 + public boolean equals(Object obj) {
61 - if (this == obj) { 61 + if (this == obj) {
62 - return true; 62 + return true;
63 - } 63 + }
64 - if (obj instanceof SegmentationId) { 64 + if (obj instanceof SegmentationId) {
65 - final SegmentationId that = (SegmentationId) obj; 65 + final SegmentationId that = (SegmentationId) obj;
66 - return this.getClass() == that.getClass() 66 + return this.getClass() == that.getClass()
67 - && Objects.equals(this.segmentationId, that.segmentationId); 67 + && Objects.equals(this.segmentationId, that.segmentationId);
68 - } 68 + }
69 - return false; 69 + return false;
70 - } 70 + }
71 - 71 +
72 - @Override 72 + @Override
73 - public String toString() { 73 + public String toString() {
74 - return segmentationId; 74 + return segmentationId;
75 - } 75 + }
76 - 76 +
77 -} 77 +}
......
1 -/* 1 +/*
2 - *Copyright 2014 Open Networking Laboratory 2 + *Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - *Licensed under the Apache License, Version 2.0 (the "License"); 4 + *Licensed under the Apache License, Version 2.0 (the "License");
5 - *you may not use this file except in compliance with 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 6 + *You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - *Unless required by applicable law or agreed to in writing, software 10 + *Unless required by applicable law or agreed to in writing, software
11 - *distributed under the License is distributed on an "AS IS" BASIS, 11 + *distributed under the License is distributed on an "AS IS" BASIS,
12 - *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - *See the License for the specific language governing permissions and 13 + *See the License for the specific language governing permissions and
14 - *limitations under the License. 14 + *limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import org.onlab.packet.IpAddress; 18 +import org.onlab.packet.IpAddress;
19 -import org.onlab.packet.IpAddress.Version; 19 +import org.onlab.packet.IpAddress.Version;
20 -import org.onlab.packet.IpPrefix; 20 +import org.onlab.packet.IpPrefix;
21 - 21 +
22 -/** 22 +/**
23 - * Representation of a subnet. 23 + * Representation of a subnet.
24 - */ 24 + */
25 -public interface Subnet { 25 +public interface Subnet {
26 - 26 +
27 - /** 27 + /**
28 - * Coarse classification of the type of the ipV6Mode. 28 + * Coarse classification of the type of the ipV6Mode.
29 - */ 29 + */
30 - public enum Mode { 30 + public enum Mode {
31 - DHCPV6_STATEFUL, DHCPV6_STATELESS, SLAAC 31 + DHCPV6_STATEFUL, DHCPV6_STATELESS, SLAAC
32 - } 32 + }
33 - 33 +
34 - /** 34 + /**
35 - * Returns the subnet identifier. 35 + * Returns the subnet identifier.
36 - * 36 + *
37 - * @return identifier 37 + * @return identifier
38 - */ 38 + */
39 - SubnetId id(); 39 + SubnetId id();
40 - 40 +
41 - /** 41 + /**
42 - * Returns the name of the subnet. 42 + * Returns the name of the subnet.
43 - * 43 + *
44 - * @return subnetName 44 + * @return subnetName
45 - */ 45 + */
46 - String subnetName(); 46 + String subnetName();
47 - 47 +
48 - /** 48 + /**
49 - * Returns the network identifier. 49 + * Returns the network identifier.
50 - * 50 + *
51 - * @return the network identifier 51 + * @return the network identifier
52 - */ 52 + */
53 - TenantNetworkId networkId(); 53 + TenantNetworkId networkId();
54 - 54 +
55 - /** 55 + /**
56 - * Returns tenant identifier. 56 + * Returns tenant identifier.
57 - * 57 + *
58 - * @return the tenant identifier 58 + * @return the tenant identifier
59 - */ 59 + */
60 - TenantId tenantId(); 60 + TenantId tenantId();
61 - 61 +
62 - /** 62 + /**
63 - * Returns the IP version, which is 4 or 6. 63 + * Returns the IP version, which is 4 or 6.
64 - * 64 + *
65 - * @return ipVersion 65 + * @return ipVersion
66 - */ 66 + */
67 - Version ipVersion(); 67 + Version ipVersion();
68 - 68 +
69 - /** 69 + /**
70 - * Returns the cidr. 70 + * Returns the cidr.
71 - * 71 + *
72 - * @return cidr 72 + * @return cidr
73 - */ 73 + */
74 - IpPrefix cidr(); 74 + IpPrefix cidr();
75 - 75 +
76 - /** 76 + /**
77 - * Returns the gateway IP address. 77 + * Returns the gateway IP address.
78 - * 78 + *
79 - * @return gatewayIp 79 + * @return gatewayIp
80 - */ 80 + */
81 - IpAddress gatewayIp(); 81 + IpAddress gatewayIp();
82 - 82 +
83 - /** 83 + /**
84 - * Returns true if DHCP is enabled and return false if DHCP is disabled. 84 + * Returns true if DHCP is enabled and return false if DHCP is disabled.
85 - * 85 + *
86 - * @return true or false 86 + * @return true or false
87 - */ 87 + */
88 - boolean dhcpEnabled(); 88 + boolean dhcpEnabled();
89 - 89 +
90 - /** 90 + /**
91 - * Indicates whether this tenantNetwork is shared across all tenants. By 91 + * Indicates whether this tenantNetwork is shared across all tenants. By
92 - * default, only administrative user can change this value. 92 + * default, only administrative user can change this value.
93 - * 93 + *
94 - * @return true or false 94 + * @return true or false
95 - */ 95 + */
96 - boolean shared(); 96 + boolean shared();
97 - 97 +
98 - /** 98 + /**
99 - * Returns a collection of hostRoutes. 99 + * Returns a collection of hostRoutes.
100 - * 100 + *
101 - * @return a collection of hostRoutes 101 + * @return a collection of hostRoutes
102 - */ 102 + */
103 - Iterable<HostRoute> hostRoutes(); 103 + Iterable<HostRoute> hostRoutes();
104 - 104 +
105 - /** 105 + /**
106 - * Returns the ipV6AddressMode. A valid value is dhcpv6-stateful, 106 + * Returns the ipV6AddressMode. A valid value is dhcpv6-stateful,
107 - * dhcpv6-stateless, or slaac. 107 + * dhcpv6-stateless, or slaac.
108 - * 108 + *
109 - * @return ipV6AddressMode whose value is dhcpv6-stateful, dhcpv6-stateless 109 + * @return ipV6AddressMode whose value is dhcpv6-stateful, dhcpv6-stateless
110 - * or slaac 110 + * or slaac
111 - */ 111 + */
112 - Mode ipV6AddressMode(); 112 + Mode ipV6AddressMode();
113 - 113 +
114 - /** 114 + /**
115 - * Returns the ipV6RaMode.A valid value is dhcpv6-stateful, 115 + * Returns the ipV6RaMode.A valid value is dhcpv6-stateful,
116 - * dhcpv6-stateless, or slaac. 116 + * dhcpv6-stateless, or slaac.
117 - * 117 + *
118 - * @return ipV6RaMode whose value is dhcpv6-stateful, dhcpv6-stateless or 118 + * @return ipV6RaMode whose value is dhcpv6-stateful, dhcpv6-stateless or
119 - * slaac 119 + * slaac
120 - */ 120 + */
121 - Mode ipV6RaMode(); 121 + Mode ipV6RaMode();
122 - 122 +
123 - /** 123 + /**
124 - * Returns a collection of allocation_pools. 124 + * Returns a collection of allocation_pools.
125 - * 125 + *
126 - * @return a collection of allocationPools 126 + * @return a collection of allocationPools
127 - */ 127 + */
128 - Iterable<AllocationPool> allocationPools(); 128 + Iterable<AllocationPool> allocationPools();
129 -} 129 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 - 19 +
20 -import java.util.Objects; 20 +import java.util.Objects;
21 - 21 +
22 -/** 22 +/**
23 - * Immutable representation of a subnet identifier. 23 + * Immutable representation of a subnet identifier.
24 - */ 24 + */
25 -public final class SubnetId { 25 +public final class SubnetId {
26 - 26 +
27 - private final String subnetId; 27 + private final String subnetId;
28 - 28 +
29 - // Public construction is prohibited 29 + // Public construction is prohibited
30 - private SubnetId(String subnetId) { 30 + private SubnetId(String subnetId) {
31 - checkNotNull(subnetId, "SubnetId cannot be null"); 31 + checkNotNull(subnetId, "SubnetId cannot be null");
32 - this.subnetId = subnetId; 32 + this.subnetId = subnetId;
33 - } 33 + }
34 - 34 +
35 - /** 35 + /**
36 - * Creates a Subnet identifier. 36 + * Creates a Subnet identifier.
37 - * 37 + *
38 - * @param subnetId the subnet identifier 38 + * @param subnetId the subnet identifier
39 - * @return the subnet identifier 39 + * @return the subnet identifier
40 - */ 40 + */
41 - public static SubnetId subnetId(String subnetId) { 41 + public static SubnetId subnetId(String subnetId) {
42 - return new SubnetId(subnetId); 42 + return new SubnetId(subnetId);
43 - } 43 + }
44 - 44 +
45 - /** 45 + /**
46 - * Returns the subnet identifier. 46 + * Returns the subnet identifier.
47 - * 47 + *
48 - * @return the subnet identifier 48 + * @return the subnet identifier
49 - */ 49 + */
50 - public String subnetId() { 50 + public String subnetId() {
51 - return subnetId; 51 + return subnetId;
52 - } 52 + }
53 - 53 +
54 - @Override 54 + @Override
55 - public int hashCode() { 55 + public int hashCode() {
56 - return Objects.hash(subnetId); 56 + return Objects.hash(subnetId);
57 - } 57 + }
58 - 58 +
59 - @Override 59 + @Override
60 - public boolean equals(Object obj) { 60 + public boolean equals(Object obj) {
61 - if (this == obj) { 61 + if (this == obj) {
62 - return true; 62 + return true;
63 - } 63 + }
64 - if (obj instanceof SubnetId) { 64 + if (obj instanceof SubnetId) {
65 - final SubnetId that = (SubnetId) obj; 65 + final SubnetId that = (SubnetId) obj;
66 - return this.getClass() == that.getClass() 66 + return this.getClass() == that.getClass()
67 - && Objects.equals(this.subnetId, that.subnetId); 67 + && Objects.equals(this.subnetId, that.subnetId);
68 - } 68 + }
69 - return false; 69 + return false;
70 - } 70 + }
71 - 71 +
72 - @Override 72 + @Override
73 - public String toString() { 73 + public String toString() {
74 - return subnetId; 74 + return subnetId;
75 - } 75 + }
76 -} 76 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
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 network identity. 23 + * Immutable representation of a tenant identifier.
24 - */ 24 + */
25 -public final class TenantId { 25 +public final class TenantId {
26 - 26 +
27 - private final String tenantid; 27 + private final String tenantId;
28 - 28 +
29 - // Public construction is prohibited 29 + // Public construction is prohibited
30 - private TenantId(String tenantid) { 30 + private TenantId(String tenantId) {
31 - this.tenantid = tenantid; 31 + this.tenantId = tenantId;
32 - } 32 + }
33 - 33 +
34 - /** 34 + /**
35 - * Creates a network id using the tenantid. 35 + * Creates a network id using the tenantid.
36 - * 36 + *
37 - * @param tenantid network String 37 + * @param tenantid network String
38 - * @return TenantId 38 + * @return TenantId
39 - */ 39 + */
40 - public static TenantId tenantId(String tenantid) { 40 + public static TenantId tenantId(String tenantid) {
41 - checkNotNull(tenantid, "Tenantid can not be null"); 41 + checkNotNull(tenantid, "Tenantid can not be null");
42 - return new TenantId(tenantid); 42 + return new TenantId(tenantid);
43 - } 43 + }
44 - 44 +
45 - /** 45 + /**
46 - * 46 + * Returns the tenant identifier.
47 - * @return tenantid 47 + *
48 - */ 48 + * @return the tenant identifier
49 - public String tenantid() { 49 + */
50 - return tenantid; 50 + public String tenantId() {
51 - } 51 + return tenantId;
52 - 52 + }
53 - @Override 53 +
54 - public int hashCode() { 54 + @Override
55 - return Objects.hash(tenantid); 55 + public int hashCode() {
56 - } 56 + return Objects.hash(tenantId);
57 - 57 + }
58 - @Override 58 +
59 - public boolean equals(Object obj) { 59 + @Override
60 - if (this == obj) { 60 + public boolean equals(Object obj) {
61 - return true; 61 + if (this == obj) {
62 - } 62 + return true;
63 - if (obj instanceof TenantId) { 63 + }
64 - final TenantId that = (TenantId) obj; 64 + if (obj instanceof TenantId) {
65 - return this.getClass() == that.getClass() 65 + final TenantId that = (TenantId) obj;
66 - && Objects.equals(this.tenantid, that.tenantid); 66 + return this.getClass() == that.getClass()
67 - } 67 + && Objects.equals(this.tenantId, that.tenantId);
68 - return false; 68 + }
69 - } 69 + return false;
70 - 70 + }
71 - @Override 71 +
72 - public String toString() { 72 + @Override
73 - return tenantid; 73 + public String toString() {
74 - } 74 + return tenantId;
75 - 75 + }
76 -} 76 +
77 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -/** 18 +/**
19 - * Representation of the tenantNetwork. 19 + * Representation of the tenantNetwork.
20 - */ 20 + */
21 -public interface TenantNetwork { 21 +public interface TenantNetwork {
22 - 22 +
23 - /** 23 + /**
24 - * Coarse classification of the state of the tenantNetwork. 24 + * Coarse classification of the state of the tenantNetwork.
25 - */ 25 + */
26 - public enum State { 26 + public enum State {
27 - /** 27 + /**
28 - * Signifies that a tenantNetwork is currently active.This state means 28 + * Signifies that a tenantNetwork is currently active.This state means
29 - * that this network is available. 29 + * that this network is available.
30 - */ 30 + */
31 - ACTIVE, 31 + ACTIVE,
32 - /** 32 + /**
33 - * Signifies that a tenantNetwork is currently built. 33 + * Signifies that a tenantNetwork is currently built.
34 - */ 34 + */
35 - BUILD, 35 + BUILD,
36 - /** 36 + /**
37 - * Signifies that a tenantNetwork is currently unavailable. 37 + * Signifies that a tenantNetwork is currently unavailable.
38 - */ 38 + */
39 - DOWN, 39 + DOWN,
40 - /** 40 + /**
41 - * Signifies that a tenantNetwork is currently error. 41 + * Signifies that a tenantNetwork is currently error.
42 - */ 42 + */
43 - ERROR 43 + ERROR
44 - } 44 + }
45 - 45 +
46 - /** 46 + /**
47 - * Coarse classification of the type of the tenantNetwork. 47 + * Coarse classification of the type of the tenantNetwork.
48 - */ 48 + */
49 - public enum Type { 49 + public enum Type {
50 - /** 50 + /**
51 - * Signifies that a tenantNetwork is local. 51 + * Signifies that a tenantNetwork is local.
52 - */ 52 + */
53 - LOCAL 53 + LOCAL
54 - } 54 + }
55 - 55 +
56 - /** 56 + /**
57 - * Returns the tenantNetwork identifier. 57 + * Returns the tenantNetwork identifier.
58 - * 58 + *
59 - * @return tenantNetwork identifier 59 + * @return tenantNetwork identifier
60 - */ 60 + */
61 - TenantNetworkId id(); 61 + TenantNetworkId id();
62 - 62 +
63 - /** 63 + /**
64 - * Returns the tenantNetwork name. 64 + * Returns the tenantNetwork name.
65 - * 65 + *
66 - * @return tenantNetwork name 66 + * @return tenantNetwork name
67 - */ 67 + */
68 - String name(); 68 + String name();
69 - 69 +
70 - /** 70 + /**
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 true or false 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 tenant network state 81 + * @return tenant network state
82 - */ 82 + */
83 - State state(); 83 + State state();
84 - 84 +
85 - /** 85 + /**
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 true or false 89 + * @return true or false
90 - */ 90 + */
91 - boolean shared(); 91 + boolean shared();
92 - 92 +
93 - /** 93 + /**
94 - * Returns the UUID of the tenant that will own the tenantNetwork. This 94 + * Returns the UUID of the tenant that will own the tenantNetwork. This
95 - * tenant can be different from the tenant that makes the create 95 + * tenant can be different from the tenant that makes the create
96 - * tenantNetwork request. 96 + * tenantNetwork request.
97 - * 97 + *
98 - * @return tenantNetwork tenant identifier 98 + * @return the tenant identifier
99 - */ 99 + */
100 - TenantId tenantId(); 100 + TenantId tenantId();
101 - 101 +
102 - /** 102 + /**
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 or false 106 + * @return true or false
107 - */ 107 + */
108 - boolean routerExternal(); 108 + boolean routerExternal();
109 - 109 +
110 - /** 110 + /**
111 - * Returns the tenantNetwork Type. 111 + * Returns the tenantNetwork Type.
112 - * 112 + *
113 - * @return tenantNetwork Type 113 + * @return tenantNetwork Type
114 - */ 114 + */
115 - Type type(); 115 + Type type();
116 - 116 +
117 - /** 117 + /**
118 - * Returns the tenantNetwork physical network. 118 + * Returns the tenantNetwork physical network.
119 - * 119 + *
120 - * @return tenantNetwork physical network 120 + * @return tenantNetwork physical network
121 - */ 121 + */
122 - PhysicalNetwork physicalNetwork(); 122 + PhysicalNetwork physicalNetwork();
123 - 123 +
124 - /** 124 + /**
125 - * Returns the tenantNetwork segmentation id. 125 + * Returns the tenantNetwork segmentation id.
126 - * 126 + *
127 - * @return tenantNetwork segmentation id 127 + * @return tenantNetwork segmentation id
128 - */ 128 + */
129 - SegmentationId segmentationId(); 129 + SegmentationId segmentationId();
130 -} 130 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 -import static com.google.common.base.Preconditions.checkNotNull; 19 +import static com.google.common.base.Preconditions.checkNotNull;
20 - 20 +
21 -/** 21 +/**
22 - * Immutable representation of a tenantNetwork identity. 22 + * Immutable representation of a tenantNetwork identity.
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 identifier. 34 + * Creates a TenantNetwork identifier.
35 - * 35 + *
36 - * @param networkId tenantNetwork identify string 36 + * @param networkId tenantNetwork identify string
37 - * @return the attached tenantNetwork identifier 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 + * Returns tenantNetwork identifier.
46 - * 46 + *
47 - * @return the tenantNetwork identifier 47 + * @return the tenantNetwork identifier
48 - */ 48 + */
49 - public String networkId() { 49 + public String networkId() {
50 - return networkId; 50 + return networkId;
51 - } 51 + }
52 - 52 +
53 - @Override 53 + @Override
54 - public int hashCode() { 54 + public int hashCode() {
55 - return Objects.hash(networkId); 55 + return Objects.hash(networkId);
56 - } 56 + }
57 - 57 +
58 - @Override 58 + @Override
59 - public boolean equals(Object obj) { 59 + public boolean equals(Object obj) {
60 - if (this == obj) { 60 + if (this == obj) {
61 - return true; 61 + return true;
62 - } 62 + }
63 - if (obj instanceof TenantNetworkId) { 63 + if (obj instanceof TenantNetworkId) {
64 - final TenantNetworkId that = (TenantNetworkId) obj; 64 + final TenantNetworkId that = (TenantNetworkId) obj;
65 - return this.getClass() == that.getClass() 65 + return this.getClass() == that.getClass()
66 - && Objects.equals(this.networkId, that.networkId); 66 + && Objects.equals(this.networkId, that.networkId);
67 - } 67 + }
68 - return false; 68 + return false;
69 - } 69 + }
70 - 70 +
71 - @Override 71 + @Override
72 - public String toString() { 72 + public String toString() {
73 - return networkId; 73 + return networkId;
74 - } 74 + }
75 - 75 +
76 -} 76 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import java.util.Collection; 18 +import java.util.Collection;
19 - 19 +import java.util.Set;
20 -import org.onlab.packet.MacAddress; 20 +
21 -import org.onosproject.net.DeviceId; 21 +import org.onlab.packet.MacAddress;
22 -import org.onosproject.net.HostId; 22 +import org.onosproject.net.DeviceId;
23 - 23 +
24 -/** 24 +/**
25 - * Representation of the VirtualPort. 25 + * Representation of the VirtualPort.
26 - */ 26 + */
27 -public interface VirtualPort { 27 +public interface VirtualPort {
28 - /** 28 + /**
29 - * Coarse classification of the type of the virtual port. 29 + * Coarse classification of the type of the virtual port.
30 - */ 30 + */
31 - public enum State { 31 + public enum State {
32 - /** 32 + /**
33 - * Signifies that a virtualPort is currently active,This state mean that 33 + * Signifies that a virtualPort is currently active,This state mean that
34 - * this virtualPort is available. 34 + * this virtualPort is available.
35 - */ 35 + */
36 - ACTIVE, 36 + ACTIVE,
37 - /** 37 + /**
38 - * Signifies that a virtualPort is currently unavailable. 38 + * Signifies that a virtualPort is currently unavailable.
39 - */ 39 + */
40 - DOWN; 40 + DOWN;
41 - } 41 + }
42 - 42 +
43 - /** 43 + /**
44 - * Returns the virtualPort identifier. 44 + * Returns the virtualPort identifier.
45 - * 45 + *
46 - * @return virtualPort identifier 46 + * @return virtualPort identifier
47 - */ 47 + */
48 - VirtualPortId portId(); 48 + VirtualPortId portId();
49 - 49 +
50 - /** 50 + /**
51 - * Returns the network identifier. 51 + * Returns the network identifier.
52 - * 52 + *
53 - * @return tenantNetwork identifier 53 + * @return tenantNetwork identifier
54 - */ 54 + */
55 - TenantNetworkId networkId(); 55 + TenantNetworkId networkId();
56 - 56 +
57 - /** 57 + /**
58 - * Returns the symbolic name for the virtualPort. 58 + * Returns the symbolic name for the virtualPort.
59 - * 59 + *
60 - * @return virtualPort name 60 + * @return virtualPort name
61 - */ 61 + */
62 - String name(); 62 + String name();
63 - 63 +
64 - /** 64 + /**
65 - * Returns the administrative status of the port,which is up(true) or 65 + * Returns the administrative status of the port,which is up(true) or
66 - * down(false). 66 + * down(false).
67 - * 67 + *
68 - * @return true if the administrative status of the port is up 68 + * @return true if the administrative status of the port is up
69 - */ 69 + */
70 - boolean adminStateUp(); 70 + boolean adminStateUp();
71 - 71 +
72 - /** 72 + /**
73 - * Returns the state. 73 + * Returns the state.
74 - * 74 + *
75 - * @return state 75 + * @return state
76 - */ 76 + */
77 - State state(); 77 + State state();
78 - 78 +
79 - /** 79 + /**
80 - * Returns the MAC address. 80 + * Returns the MAC address.
81 - * 81 + *
82 - * @return MAC Address 82 + * @return MAC Address
83 - */ 83 + */
84 - MacAddress macAddress(); 84 + MacAddress macAddress();
85 - 85 +
86 - /** 86 + /**
87 - * Returns the port tenantId. 87 + * Returns the port tenantId.
88 - * 88 + *
89 - * @return port tenantId 89 + * @return port tenantId
90 - */ 90 + */
91 - TenantId tenantId(); 91 + TenantId tenantId();
92 - 92 +
93 - /** 93 + /**
94 - * Returns the device identifier. 94 + * Returns the device identifier.
95 - * 95 + *
96 - * @return deviceId 96 + * @return deviceId
97 - */ 97 + */
98 - DeviceId deviceId(); 98 + DeviceId deviceId();
99 - 99 +
100 - /** 100 + /**
101 - * Returns the identifier of the entity that uses this port. 101 + * Returns the identifier of the entity that uses this port.
102 - * 102 + *
103 - * @return deviceOwner 103 + * @return deviceOwner
104 - */ 104 + */
105 - String deviceOwner(); 105 + String deviceOwner();
106 - 106 +
107 - /** 107 + /**
108 - * Returns the virtualPort allowedAddressPairs. 108 + * Returns the virtualPort allowedAddressPairs.
109 - * 109 + *
110 - * @return virtualPort allowedAddressPairs 110 + * @return virtualPort allowedAddressPairs
111 - */ 111 + */
112 - Collection<AllowedAddressPair> allowedAddressPairs(); 112 + Collection<AllowedAddressPair> allowedAddressPairs();
113 - 113 +
114 - /** 114 + /**
115 - * Returns the IP address for the port, Include the IP address and subnet 115 + * Returns set of IP addresses for the port, include the IP addresses and subnet
116 - * identity. 116 + * identity.
117 - * 117 + *
118 - * @return port fixedIps 118 + * @return FixedIps Set of fixedIp
119 - */ 119 + */
120 - FixedIp fixedIps(); 120 + Set<FixedIp> fixedIps();
121 - 121 +
122 - /** 122 + /**
123 - * Returns the virtualPort bindinghostId. 123 + * Returns the virtualPort bindinghostId.
124 - * 124 + *
125 - * @return virtualPort bindinghostId 125 + * @return virtualPort bindinghostId
126 - */ 126 + */
127 - HostId bindingHostId(); 127 + BindingHostId bindingHostId();
128 - 128 +
129 - /** 129 + /**
130 - * Returns the virtualPort bindingVnicType. 130 + * Returns the virtualPort bindingVnicType.
131 - * 131 + *
132 - * @return virtualPort bindingVnicType 132 + * @return virtualPort bindingVnicType
133 - */ 133 + */
134 - String bindingVnicType(); 134 + String bindingVnicType();
135 - 135 +
136 - /** 136 + /**
137 - * Returns the virtualPort bindingVifType. 137 + * Returns the virtualPort bindingVifType.
138 - * 138 + *
139 - * @return virtualPort bindingVifType 139 + * @return virtualPort bindingVifType
140 - */ 140 + */
141 - String bindingVifType(); 141 + String bindingVifType();
142 - 142 +
143 - /** 143 + /**
144 - * Returns the virtualPort bindingvifDetail. 144 + * Returns the virtualPort bindingvifDetail.
145 - * 145 + *
146 - * @return virtualPort bindingvifDetail 146 + * @return virtualPort bindingvifDetail
147 - */ 147 + */
148 - String bindingVifDetails(); 148 + String bindingVifDetails();
149 - 149 +
150 - /** 150 + /**
151 - * Returns the security groups. 151 + * Returns the security groups.
152 - * 152 + *
153 - * @return port security groups 153 + * @return port security groups
154 - */ 154 + */
155 - Iterable<SecurityGroup> securityGroups(); 155 + Iterable<SecurityGroup> securityGroups();
156 -} 156 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc; 16 +package org.onosproject.vtnrsc;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 - 19 +
20 -import java.util.Objects; 20 +import java.util.Objects;
21 - 21 +
22 -/** 22 +/**
23 - * Immutable representation of a virtual port identifier. 23 + * Immutable representation of a virtual port identifier.
24 - */ 24 + */
25 -public final class VirtualPortId { 25 +public final class VirtualPortId {
26 - private final String portId; 26 + private final String portId;
27 - // Public construction is prohibited 27 + // Public construction is prohibited
28 - private VirtualPortId(String virtualPortId) { 28 + private VirtualPortId(String virtualPortId) {
29 - checkNotNull(virtualPortId, "VirtualPortId cannot be null"); 29 + checkNotNull(virtualPortId, "VirtualPortId cannot be null");
30 - this.portId = virtualPortId; 30 + this.portId = virtualPortId;
31 - } 31 + }
32 - 32 +
33 - public String portId() { 33 + public String portId() {
34 - return portId; 34 + return portId;
35 - } 35 + }
36 - 36 +
37 - /** 37 + /**
38 - * Creates a virtualPort id using the supplied portId. 38 + * Creates a virtualPort id using the supplied portId.
39 - * 39 + *
40 - * @param portId virtualport identifier 40 + * @param portId virtualport identifier
41 - * @return VirtualPortId 41 + * @return VirtualPortId
42 - */ 42 + */
43 - public static VirtualPortId portId(String portId) { 43 + public static VirtualPortId portId(String portId) {
44 - return new VirtualPortId(portId); 44 + return new VirtualPortId(portId);
45 - } 45 + }
46 - 46 +
47 - @Override 47 + @Override
48 - public int hashCode() { 48 + public int hashCode() {
49 - return Objects.hash(portId); 49 + return Objects.hash(portId);
50 - } 50 + }
51 - 51 +
52 - @Override 52 + @Override
53 - public boolean equals(Object obj) { 53 + public boolean equals(Object obj) {
54 - if (this == obj) { 54 + if (this == obj) {
55 - return true; 55 + return true;
56 - } 56 + }
57 - if (obj instanceof VirtualPortId) { 57 + if (obj instanceof VirtualPortId) {
58 - final VirtualPortId that = (VirtualPortId) obj; 58 + final VirtualPortId that = (VirtualPortId) obj;
59 - return this.getClass() == that.getClass() 59 + return this.getClass() == that.getClass()
60 - && Objects.equals(this.portId, that.portId); 60 + && Objects.equals(this.portId, that.portId);
61 - } 61 + }
62 - return false; 62 + return false;
63 - } 63 + }
64 - 64 +
65 - @Override 65 + @Override
66 - public String toString() { 66 + public String toString() {
67 - return portId; 67 + return portId;
68 - } 68 + }
69 - 69 +
70 -} 70 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.subnet; 16 +package org.onosproject.vtnrsc.subnet;
17 - 17 +
18 -import org.onosproject.app.vtnrsc.Subnet; 18 +import org.onosproject.vtnrsc.Subnet;
19 -import org.onosproject.app.vtnrsc.SubnetId; 19 +import org.onosproject.vtnrsc.SubnetId;
20 - 20 +
21 - 21 +
22 -/** 22 +/**
23 - * Service for interacting with the inventory of subnets. 23 + * Service for interacting with the inventory of subnets.
24 - */ 24 + */
25 -public interface SubnetService { 25 +public interface SubnetService {
26 - /** 26 + /**
27 - * Returns the subnet with the specified identifier. 27 + * Returns the subnet with the specified identifier.
28 - * 28 + *
29 - * @param subnetId subnet identifier 29 + * @param subnetId subnet identifier
30 - * @return true or false 30 + * @return true or false
31 - */ 31 + */
32 - boolean exists(SubnetId subnetId); 32 + boolean exists(SubnetId subnetId);
33 - /** 33 + /**
34 - * Returns a collection of the currently known subnets. 34 + * Returns a collection of the currently known subnets.
35 - * 35 + *
36 - * @return iterable collection of subnets 36 + * @return iterable collection of subnets
37 - */ 37 + */
38 - Iterable<Subnet> getSubnets(); 38 + Iterable<Subnet> getSubnets();
39 - 39 +
40 - /** 40 + /**
41 - * Returns the subnet with the specified identifier. 41 + * Returns the subnet with the specified identifier.
42 - * 42 + *
43 - * @param subnetId subnet identifier 43 + * @param subnetId subnet identifier
44 - * @return subnet or null if one with the given identifier is not known 44 + * @return subnet or null if one with the given identifier is not known
45 - */ 45 + */
46 - Subnet getSubnet(SubnetId subnetId); 46 + Subnet getSubnet(SubnetId subnetId);
47 - /** 47 + /**
48 - * Creates new subnets. 48 + * Creates new subnets.
49 - * 49 + *
50 - * @param subnets the iterable collection of subnets 50 + * @param subnets the iterable collection of subnets
51 - * @return true if the identifier subnet has been created right 51 + * @return true if the identifier subnet has been created right
52 - */ 52 + */
53 - boolean createSubnets(Iterable<Subnet> subnets); 53 + boolean createSubnets(Iterable<Subnet> subnets);
54 - 54 +
55 - /** 55 + /**
56 - * Updates existing subnets. 56 + * Updates existing subnets.
57 - * 57 + *
58 - * @param subnets the iterable collection of subnets 58 + * @param subnets the iterable collection of subnets
59 - * @return true if all subnets were updated successfully 59 + * @return true if all subnets were updated successfully
60 - */ 60 + */
61 - boolean updateSubnets(Iterable<Subnet> subnets); 61 + boolean updateSubnets(Iterable<Subnet> subnets);
62 - 62 +
63 - /** 63 + /**
64 - * Administratively removes the specified subnets from the store. 64 + * Administratively removes the specified subnets from the store.
65 - * 65 + *
66 - * @param subnetIds the iterable collection of subnets identifier 66 + * @param subnetIds the iterable collection of subnets identifier
67 - * @return true if remove identifier subnets successfully 67 + * @return true if remove identifier subnets successfully
68 - */ 68 + */
69 - boolean removeSubnets(Iterable<SubnetId> subnetIds); 69 + boolean removeSubnets(Iterable<SubnetId> subnetIds);
70 - 70 +
71 - 71 +
72 -} 72 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.subnet.impl; 16 +package org.onosproject.vtnrsc.subnet.impl;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 -import static org.slf4j.LoggerFactory.getLogger; 19 +import static org.slf4j.LoggerFactory.getLogger;
20 - 20 +
21 -import java.util.Collections; 21 +import java.util.Collections;
22 - 22 +import java.util.concurrent.ConcurrentHashMap;
23 -import org.apache.felix.scr.annotations.Activate; 23 +
24 -import org.apache.felix.scr.annotations.Component; 24 +import org.apache.felix.scr.annotations.Activate;
25 -import org.apache.felix.scr.annotations.Deactivate; 25 +import org.apache.felix.scr.annotations.Component;
26 -import org.apache.felix.scr.annotations.Reference; 26 +import org.apache.felix.scr.annotations.Deactivate;
27 -import org.apache.felix.scr.annotations.ReferenceCardinality; 27 +import org.apache.felix.scr.annotations.Reference;
28 -import org.apache.felix.scr.annotations.Service; 28 +import org.apache.felix.scr.annotations.ReferenceCardinality;
29 -import org.onlab.util.KryoNamespace; 29 +import org.apache.felix.scr.annotations.Service;
30 -import org.onosproject.app.vtnrsc.Subnet; 30 +import org.onosproject.store.service.StorageService;
31 -import org.onosproject.app.vtnrsc.SubnetId; 31 +import org.onosproject.vtnrsc.Subnet;
32 -import org.onosproject.app.vtnrsc.subnet.SubnetService; 32 +import org.onosproject.vtnrsc.SubnetId;
33 -import org.onosproject.app.vtnrsc.tenantnetwork.TenantNetworkService; 33 +import org.onosproject.vtnrsc.subnet.SubnetService;
34 -import org.onosproject.store.service.EventuallyConsistentMap; 34 +import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
35 -import org.onosproject.store.service.MultiValuedTimestamp; 35 +import org.slf4j.Logger;
36 -import org.onosproject.store.service.StorageService; 36 +
37 -import org.onosproject.store.service.WallClockTimestamp; 37 +/**
38 -import org.slf4j.Logger; 38 + * Provides implementation of the Subnet service.
39 - 39 + */
40 -/** 40 +@Component(immediate = true)
41 - * Provides implementation of the Subnet service. 41 +@Service
42 - */ 42 +public class SubnetManager implements SubnetService {
43 -@Component(immediate = true) 43 +
44 -@Service 44 + private static final String SUBNET_ID_NULL = "Subnet ID cannot be null";
45 -public class SubnetManager implements SubnetService { 45 + private static final String SUBNET_NOT_NULL = "Subnet cannot be null";
46 - 46 +
47 - private static final String SUBNET_ID_NULL = "Subnet ID cannot be null"; 47 + private final Logger log = getLogger(getClass());
48 - private static final String SUBNET_NOT_NULL = "Subnet cannot be null"; 48 +
49 - 49 + protected ConcurrentHashMap<SubnetId, Subnet> subnetStore =
50 - private final Logger log = getLogger(getClass()); 50 + new ConcurrentHashMap<>();
51 - 51 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
52 - private EventuallyConsistentMap<SubnetId, Subnet> subnetStore; 52 + protected StorageService storageService;
53 - 53 +
54 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 54 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
55 - protected StorageService storageService; 55 + protected TenantNetworkService tenantNetworkService;
56 - 56 +
57 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 57 + @Activate
58 - protected TenantNetworkService tenantNetworkService; 58 + public void activate() {
59 - 59 + log.info("SubnetManager started");
60 - @Activate 60 + }
61 - public void activate() { 61 +
62 - KryoNamespace.Builder serializer = KryoNamespace.newBuilder() 62 + @Deactivate
63 - .register(MultiValuedTimestamp.class); 63 + public void deactivate() {
64 - subnetStore = storageService 64 + subnetStore.clear();
65 - .<SubnetId, Subnet>eventuallyConsistentMapBuilder() 65 + log.info("SubnetManager stopped");
66 - .withName("all_subnet").withSerializer(serializer) 66 + }
67 - .withTimestampProvider((k, v) -> new WallClockTimestamp()) 67 +
68 - .build(); 68 + @Override
69 - 69 + public Iterable<Subnet> getSubnets() {
70 - log.info("SubnetManager started"); 70 + return Collections.unmodifiableCollection(subnetStore.values());
71 - } 71 + }
72 - 72 +
73 - @Deactivate 73 + @Override
74 - public void deactivate() { 74 + public Subnet getSubnet(SubnetId subnetId) {
75 - subnetStore.destroy(); 75 + checkNotNull(subnetId, SUBNET_ID_NULL);
76 - log.info("SubnetManager stopped"); 76 + return subnetStore.get(subnetId);
77 - } 77 + }
78 - 78 +
79 - @Override 79 + @Override
80 - public Iterable<Subnet> getSubnets() { 80 + public boolean exists(SubnetId subnetId) {
81 - return Collections.unmodifiableCollection(subnetStore.values()); 81 + checkNotNull(subnetId, SUBNET_ID_NULL);
82 - } 82 + return subnetStore.containsKey(subnetId);
83 - 83 + }
84 - @Override 84 +
85 - public Subnet getSubnet(SubnetId subnetId) { 85 + @Override
86 - checkNotNull(subnetId, SUBNET_ID_NULL); 86 + public boolean createSubnets(Iterable<Subnet> subnets) {
87 - return subnetStore.get(subnetId); 87 + checkNotNull(subnets, SUBNET_NOT_NULL);
88 - } 88 + for (Subnet subnet : subnets) {
89 - 89 + if (!tenantNetworkService.exists(subnet.networkId())) {
90 - @Override 90 + log.debug("The network identifier that the subnet {} belong to is not exist",
91 - public boolean exists(SubnetId subnetId) { 91 + subnet.networkId().toString(), subnet.id().toString());
92 - checkNotNull(subnetId, SUBNET_ID_NULL); 92 + return false;
93 - return subnetStore.containsKey(subnetId); 93 + }
94 - } 94 + subnetStore.put(subnet.id(), subnet);
95 - 95 + if (!subnetStore.containsKey(subnet.id())) {
96 - @Override 96 + log.debug("The identified subnet whose identifier is {} create failed",
97 - public boolean createSubnets(Iterable<Subnet> subnets) { 97 + subnet.id().toString());
98 - checkNotNull(subnets, SUBNET_NOT_NULL); 98 + return false;
99 - for (Subnet subnet : subnets) { 99 + }
100 - if (!tenantNetworkService.exists(subnet.networkId())) { 100 + }
101 - log.debug("The network identifier that the subnet {} belong to is not exist", 101 + return true;
102 - subnet.networkId().toString(), subnet.id().toString()); 102 + }
103 - return false; 103 +
104 - } 104 + @Override
105 - subnetStore.put(subnet.id(), subnet); 105 + public boolean updateSubnets(Iterable<Subnet> subnets) {
106 - if (!subnetStore.containsKey(subnet.id())) { 106 + checkNotNull(subnets, SUBNET_NOT_NULL);
107 - log.debug("The identified subnet whose identifier is {} create failed", 107 + if (subnets != null) {
108 - subnet.id().toString()); 108 + for (Subnet subnet : subnets) {
109 - return false; 109 + if (!subnetStore.containsKey(subnet.id())) {
110 - } 110 + log.debug("The subnet is not exist whose identifier is {}",
111 - } 111 + subnet.id().toString());
112 - return true; 112 + return false;
113 - } 113 + }
114 - 114 +
115 - @Override 115 + subnetStore.put(subnet.id(), subnet);
116 - public boolean updateSubnets(Iterable<Subnet> subnets) { 116 +
117 - checkNotNull(subnets, SUBNET_NOT_NULL); 117 + if (!subnet.equals(subnetStore.get(subnet.id()))) {
118 - if (subnets != null) { 118 + log.debug("The subnet is updated failed whose identifier is {}",
119 - for (Subnet subnet : subnets) { 119 + subnet.id().toString());
120 - if (!subnetStore.containsKey(subnet.id())) { 120 + return false;
121 - log.debug("The subnet is not exist whose identifier is {}", 121 + }
122 - subnet.id().toString()); 122 + }
123 - return false; 123 + }
124 - } 124 + return true;
125 - 125 + }
126 - subnetStore.put(subnet.id(), subnet); 126 +
127 - 127 + @Override
128 - if (!subnet.equals(subnetStore.get(subnet.id()))) { 128 + public boolean removeSubnets(Iterable<SubnetId> subnetIds) {
129 - log.debug("The subnet is updated failed whose identifier is {}", 129 + checkNotNull(subnetIds, SUBNET_ID_NULL);
130 - subnet.id().toString()); 130 + if (subnetIds != null) {
131 - return false; 131 + for (SubnetId subnetId : subnetIds) {
132 - } 132 + subnetStore.remove(subnetId);
133 - } 133 + if (subnetStore.containsKey(subnetId)) {
134 - } 134 + log.debug("The subnet created is failed whose identifier is {}",
135 - return true; 135 + subnetId.toString());
136 - } 136 + return false;
137 - 137 + }
138 - @Override 138 + }
139 - public boolean removeSubnets(Iterable<SubnetId> subnetIds) { 139 + }
140 - checkNotNull(subnetIds, SUBNET_ID_NULL); 140 + return true;
141 - if (subnetIds != null) { 141 + }
142 - for (SubnetId subnetId : subnetIds) { 142 +
143 - subnetStore.remove(subnetId); 143 +}
144 - if (subnetStore.containsKey(subnetId)) {
145 - log.debug("The subnet created is failed whose identifier is {}",
146 - subnetId.toString());
147 - return false;
148 - }
149 - }
150 - }
151 - return true;
152 - }
153 -
154 -}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.tenantnetwork; 16 +package org.onosproject.vtnrsc.tenantnetwork;
17 - 17 +
18 -import org.onosproject.app.vtnrsc.TenantNetwork; 18 +import org.onosproject.vtnrsc.TenantNetwork;
19 -import org.onosproject.app.vtnrsc.TenantNetworkId; 19 +import org.onosproject.vtnrsc.TenantNetworkId;
20 - 20 +
21 -/** 21 +/**
22 - * Service for interacting with the inventory of tenantNetwork. 22 + * Service for interacting with the inventory of tenantNetwork.
23 - */ 23 + */
24 -public interface TenantNetworkService { 24 +public interface TenantNetworkService {
25 - 25 +
26 - /** 26 + /**
27 - * Returns if the tenantNetwork is existed. 27 + * Returns if the tenantNetwork is existed.
28 - * 28 + *
29 - * @param networkId tenantNetwork identifier 29 + * @param networkId tenantNetwork identifier
30 - * @return true or false if one with the given identifier exists. 30 + * @return true or false if one with the given identifier exists.
31 - */ 31 + */
32 - boolean exists(TenantNetworkId networkId); 32 + boolean exists(TenantNetworkId networkId);
33 - 33 +
34 - /** 34 + /**
35 - * Returns the number of tenantNetwork known to the system. 35 + * Returns the number of tenantNetwork known to the system.
36 - * 36 + *
37 - * @return number of tenantNetwork. 37 + * @return number of tenantNetwork.
38 - */ 38 + */
39 - int getNetworkCount(); 39 + int getNetworkCount();
40 - 40 +
41 - /** 41 + /**
42 - * Returns an iterable collection of the currently known tenantNetwork. 42 + * Returns an iterable collection of the currently known tenantNetwork.
43 - * 43 + *
44 - * @return collection of tenantNetwork. 44 + * @return collection of tenantNetwork.
45 - */ 45 + */
46 - Iterable<TenantNetwork> getNetworks(); 46 + Iterable<TenantNetwork> getNetworks();
47 - 47 +
48 - /** 48 + /**
49 - * Returns the tenantNetwork with the identifier. 49 + * Returns the tenantNetwork with the identifier.
50 - * 50 + *
51 - * @param networkId TenantNetwork identifier 51 + * @param networkId TenantNetwork identifier
52 - * @return TenantNetwork or null if one with the given identifier is not 52 + * @return TenantNetwork or null if one with the given identifier is not
53 - * known. 53 + * known.
54 - */ 54 + */
55 - TenantNetwork getNetwork(TenantNetworkId networkId); 55 + TenantNetwork getNetwork(TenantNetworkId networkId);
56 - 56 +
57 - /** 57 + /**
58 - * Creates tenantNetworks by networks. 58 + * Creates tenantNetworks by networks.
59 - * 59 + *
60 - * @param networks the collection of tenantNetworks 60 + * @param networks the collection of tenantNetworks
61 - * @return true if all given identifiers created successfully. 61 + * @return true if all given identifiers created successfully.
62 - */ 62 + */
63 - boolean createNetworks(Iterable<TenantNetwork> networks); 63 + boolean createNetworks(Iterable<TenantNetwork> networks);
64 - 64 +
65 - /** 65 + /**
66 - * Updates tenantNetworks by tenantNetworks. 66 + * Updates tenantNetworks by tenantNetworks.
67 - * 67 + *
68 - * @param networks the collection of tenantNetworks 68 + * @param networks the collection of tenantNetworks
69 - * @return true if all given identifiers updated successfully. 69 + * @return true if all given identifiers updated successfully.
70 - */ 70 + */
71 - boolean updateNetworks(Iterable<TenantNetwork> networks); 71 + boolean updateNetworks(Iterable<TenantNetwork> networks);
72 - 72 +
73 - /** 73 + /**
74 - * Deletes tenantNetwork by tenantNetworkIds. 74 + * Deletes tenantNetwork by tenantNetworkIds.
75 - * 75 + *
76 - * @param networksId the collection of tenantNetworkIds 76 + * @param networksIds the collection of tenantNetworkIds
77 - * @return true if the specified tenantNetwork deleted successfully. 77 + * @return true if the specified tenantNetworks deleted successfully.
78 - */ 78 + */
79 - boolean removeNetworks(Iterable<TenantNetworkId> networksId); 79 + boolean removeNetworks(Iterable<TenantNetworkId> networksIds);
80 -} 80 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.tenantnetwork.impl; 16 +package org.onosproject.vtnrsc.tenantnetwork.impl;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 -import static org.slf4j.LoggerFactory.getLogger; 19 +import static org.slf4j.LoggerFactory.getLogger;
20 - 20 +
21 -import java.util.Collections; 21 +import java.util.Collections;
22 - 22 +import java.util.concurrent.ConcurrentHashMap;
23 -import org.apache.felix.scr.annotations.Activate; 23 +
24 -import org.apache.felix.scr.annotations.Component; 24 +import org.apache.felix.scr.annotations.Activate;
25 -import org.apache.felix.scr.annotations.Deactivate; 25 +import org.apache.felix.scr.annotations.Component;
26 -import org.apache.felix.scr.annotations.Reference; 26 +import org.apache.felix.scr.annotations.Deactivate;
27 -import org.apache.felix.scr.annotations.ReferenceCardinality; 27 +import org.apache.felix.scr.annotations.Service;
28 -import org.apache.felix.scr.annotations.Service; 28 +import org.onosproject.vtnrsc.TenantNetwork;
29 -import org.onlab.util.KryoNamespace; 29 +import org.onosproject.vtnrsc.TenantNetworkId;
30 -import org.onosproject.app.vtnrsc.TenantNetwork; 30 +import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
31 -import org.onosproject.app.vtnrsc.TenantNetworkId; 31 +import org.slf4j.Logger;
32 -import org.onosproject.app.vtnrsc.tenantnetwork.TenantNetworkService; 32 +
33 -import org.onosproject.store.service.EventuallyConsistentMap; 33 +/**
34 -import org.onosproject.store.service.MultiValuedTimestamp; 34 + * Provides implementation of the tenantNetworkService.
35 -import org.onosproject.store.service.StorageService; 35 + */
36 -import org.onosproject.store.service.WallClockTimestamp; 36 +@Component(immediate = true)
37 -import org.slf4j.Logger; 37 +@Service
38 - 38 +public class TenantNetworkManager implements TenantNetworkService {
39 -/** 39 +
40 - * Provides implementation of the tenantNetworkService. 40 + private static final String NETWORK_ID_NULL = "Network ID cannot be null";
41 - */ 41 + private static final String NETWORK_NOT_NULL = "Network ID cannot be null";
42 -@Component(immediate = true) 42 +
43 -@Service 43 + protected ConcurrentHashMap<TenantNetworkId, TenantNetwork> networkIdAsKeyStore =
44 -public class TenantNetworkManager implements TenantNetworkService { 44 + new ConcurrentHashMap<>();
45 - 45 +
46 - private static final String NETWORK_ID_NULL = "Network ID cannot be null"; 46 + private final Logger log = getLogger(getClass());
47 - private static final String NETWORK_NOT_NULL = "Network ID cannot be null"; 47 +
48 - 48 + @Activate
49 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 49 + public void activate() {
50 - protected StorageService storageService; 50 + log.info("Started");
51 - private EventuallyConsistentMap<TenantNetworkId, TenantNetwork> networkIdAsKeyStore; 51 + }
52 - private final Logger log = getLogger(getClass()); 52 +
53 - 53 + @Deactivate
54 - @Activate 54 + public void deactivate() {
55 - public void activate() { 55 + networkIdAsKeyStore.clear();
56 - KryoNamespace.Builder serializer = KryoNamespace.newBuilder() 56 + log.info("Stopped");
57 - .register(MultiValuedTimestamp.class); 57 + }
58 - networkIdAsKeyStore = storageService 58 +
59 - .<TenantNetworkId, TenantNetwork>eventuallyConsistentMapBuilder() 59 + @Override
60 - .withName("all_network").withSerializer(serializer) 60 + public boolean exists(TenantNetworkId networkId) {
61 - .withTimestampProvider((k, v) -> new WallClockTimestamp()) 61 + checkNotNull(networkId, NETWORK_ID_NULL);
62 - .build(); 62 + return networkIdAsKeyStore.containsKey(networkId);
63 - log.info("Started"); 63 + }
64 - } 64 +
65 - 65 + @Override
66 - @Deactivate 66 + public int getNetworkCount() {
67 - public void deactivate() { 67 + return networkIdAsKeyStore.size();
68 - networkIdAsKeyStore.destroy(); 68 + }
69 - log.info("Stopped"); 69 +
70 - } 70 + @Override
71 - 71 + public Iterable<TenantNetwork> getNetworks() {
72 - @Override 72 + return Collections.unmodifiableCollection(networkIdAsKeyStore.values());
73 - public boolean exists(TenantNetworkId networkId) { 73 + }
74 - checkNotNull(networkId, NETWORK_ID_NULL); 74 +
75 - return networkIdAsKeyStore.containsKey(networkId); 75 + @Override
76 - } 76 + public TenantNetwork getNetwork(TenantNetworkId networkId) {
77 - 77 + checkNotNull(networkId, NETWORK_ID_NULL);
78 - @Override 78 + return networkIdAsKeyStore.get(networkId);
79 - public int getNetworkCount() { 79 + }
80 - return networkIdAsKeyStore.size(); 80 +
81 - } 81 + @Override
82 - 82 + public boolean createNetworks(Iterable<TenantNetwork> networks) {
83 - @Override 83 + checkNotNull(networks, NETWORK_NOT_NULL);
84 - public Iterable<TenantNetwork> getNetworks() { 84 + for (TenantNetwork network : networks) {
85 - return Collections.unmodifiableCollection(networkIdAsKeyStore.values()); 85 + networkIdAsKeyStore.put(network.id(), network);
86 - } 86 + if (!networkIdAsKeyStore.containsKey(network.id())) {
87 - 87 + log.debug("The tenantNetwork is created failed which identifier was {}", network.id()
88 - @Override 88 + .toString());
89 - public TenantNetwork getNetwork(TenantNetworkId networkId) { 89 + return false;
90 - checkNotNull(networkId, NETWORK_ID_NULL); 90 + }
91 - return networkIdAsKeyStore.get(networkId); 91 + }
92 - } 92 + return true;
93 - 93 + }
94 - @Override 94 +
95 - public boolean createNetworks(Iterable<TenantNetwork> networks) { 95 + @Override
96 - checkNotNull(networks, NETWORK_NOT_NULL); 96 + public boolean updateNetworks(Iterable<TenantNetwork> networks) {
97 - for (TenantNetwork network : networks) { 97 + checkNotNull(networks, NETWORK_NOT_NULL);
98 - networkIdAsKeyStore.put(network.id(), network); 98 + for (TenantNetwork network : networks) {
99 - if (!networkIdAsKeyStore.containsKey(network.id())) { 99 + if (!networkIdAsKeyStore.containsKey(network.id())) {
100 - log.debug("the network created failed which identifier was {}", network.id() 100 + log.debug("The tenantNetwork is not exist whose identifier was {} ",
101 - .toString()); 101 + network.id().toString());
102 - return false; 102 + return false;
103 - } 103 + }
104 - } 104 +
105 - return true; 105 + networkIdAsKeyStore.put(network.id(), network);
106 - } 106 +
107 - 107 + if (!network.equals(networkIdAsKeyStore.get(network.id()))) {
108 - @Override 108 + log.debug("The tenantNetwork is updated failed whose identifier was {} ",
109 - public boolean updateNetworks(Iterable<TenantNetwork> networks) { 109 + network.id().toString());
110 - checkNotNull(networks, NETWORK_NOT_NULL); 110 + return false;
111 - for (TenantNetwork network : networks) { 111 + }
112 - if (!networkIdAsKeyStore.containsKey(network.id())) { 112 +
113 - log.debug("the tenantNetwork did not exist whose identifier was {} ", 113 + }
114 - network.id().toString()); 114 + return true;
115 - return false; 115 + }
116 - } 116 +
117 - 117 + @Override
118 - networkIdAsKeyStore.put(network.id(), network); 118 + public boolean removeNetworks(Iterable<TenantNetworkId> networkIds) {
119 - 119 + checkNotNull(networkIds, NETWORK_NOT_NULL);
120 - if (network.equals(networkIdAsKeyStore.get(network.id()))) { 120 + for (TenantNetworkId networkId : networkIds) {
121 - log.debug("the network updated failed whose identifier was {} ", 121 + networkIdAsKeyStore.remove(networkId);
122 - network.id().toString()); 122 + if (networkIdAsKeyStore.containsKey(networkId)) {
123 - return false; 123 + log.debug("The tenantNetwork is removed failed whose identifier was {}",
124 - } 124 + networkId.toString());
125 - 125 + return false;
126 - } 126 + }
127 - return true; 127 + }
128 - } 128 + return true;
129 - 129 + }
130 - @Override 130 +}
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.vtnrsc.tunnel;
17 +
18 +import org.onosproject.vtnrsc.Subnet;
19 +import org.onosproject.vtnrsc.SubnetId;
20 +
21 +
22 +/**
23 + * Service for interacting with the inventory of subnets.
24 + */
25 +public interface TunnelConfigService {
26 + /**
27 + * Returns the subnet with the specified identifier.
28 + *
29 + * @param subnetId subnet identifier
30 + * @return true or false
31 + */
32 + boolean exists(SubnetId subnetId);
33 + /**
34 + * Returns a collection of the currently known subnets.
35 + *
36 + * @return iterable collection of subnets
37 + */
38 + Iterable<Subnet> getSubnets();
39 +
40 + /**
41 + * Returns the subnet with the specified identifier.
42 + *
43 + * @param subnetId subnet identifier
44 + * @return subnet or null if one with the given identifier is not known
45 + */
46 + Subnet getSubnet(SubnetId subnetId);
47 + /**
48 + * Creates new subnets.
49 + *
50 + * @param subnets the iterable collection of subnets
51 + * @return true if the identifier subnet has been created right
52 + */
53 + boolean createSubnets(Iterable<Subnet> subnets);
54 +
55 + /**
56 + * Updates existing subnets.
57 + *
58 + * @param subnets the iterable collection of subnets
59 + * @return true if all subnets were updated successfully
60 + */
61 + boolean updateSubnets(Iterable<Subnet> subnets);
62 +
63 + /**
64 + * Administratively removes the specified subnets from the store.
65 + *
66 + * @param subnetIds the iterable collection of subnets identifier
67 + * @return true if remove identifier subnets successfully
68 + */
69 + boolean removeSubnets(Iterable<SubnetId> subnetIds);
70 +
71 +
72 +}
1 -/* 1 +/*
2 - * Copyright 2015 Open Porting Laboratory 2 + * Copyright 2015 Open Porting Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.virtualport; 16 +package org.onosproject.vtnrsc.virtualport;
17 - 17 +
18 -import java.util.Collection; 18 +import java.util.Collection;
19 - 19 +
20 -import org.onosproject.app.vtnrsc.TenantNetworkId; 20 +import org.onosproject.net.DeviceId;
21 -import org.onosproject.app.vtnrsc.TenantId; 21 +import org.onosproject.vtnrsc.TenantId;
22 -import org.onosproject.app.vtnrsc.VirtualPort; 22 +import org.onosproject.vtnrsc.TenantNetworkId;
23 -import org.onosproject.app.vtnrsc.VirtualPortId; 23 +import org.onosproject.vtnrsc.VirtualPort;
24 -import org.onosproject.net.DeviceId; 24 +import org.onosproject.vtnrsc.VirtualPortId;
25 - 25 +
26 -/** 26 +/**
27 - * Service for interacting with the inventory of virtualPort. 27 + * Service for interacting with the inventory of virtualPort.
28 - */ 28 + */
29 -public interface VirtualPortService { 29 +public interface VirtualPortService {
30 - /** 30 + /**
31 - * Returns if the virtualPort is existed. 31 + * Returns if the virtualPort is existed.
32 - * 32 + *
33 - * @param virtualPortId virtualPort identifier 33 + * @param virtualPortId virtualPort identifier
34 - * @return true or false if one with the given identifier is not existed. 34 + * @return true or false if one with the given identifier is not existed.
35 - */ 35 + */
36 - boolean exists(VirtualPortId virtualPortId); 36 + boolean exists(VirtualPortId virtualPortId);
37 - 37 +
38 - /** 38 + /**
39 - * Returns the virtualPort with the identifier. 39 + * Returns the virtualPort with the identifier.
40 - * 40 + *
41 - * @param virtualPortId virtualPort ID 41 + * @param virtualPortId virtualPort ID
42 - * @return VirtualPort or null if one with the given ID is not know. 42 + * @return VirtualPort or null if one with the given ID is not know.
43 - */ 43 + */
44 - VirtualPort getPort(VirtualPortId virtualPortId); 44 + VirtualPort getPort(VirtualPortId virtualPortId);
45 - 45 +
46 - /** 46 + /**
47 - * Returns the collection of the currently known virtualPort. 47 + * Returns the collection of the currently known virtualPort.
48 - */ 48 + * @return collection of VirtualPort.
49 - Collection<VirtualPort> getPorts(); 49 + */
50 - 50 + Collection<VirtualPort> getPorts();
51 - /** 51 +
52 - * Returns the collection of the virtualPorts associated with the networkId. 52 + /**
53 - * 53 + * Returns the collection of the virtualPorts associated with the networkId.
54 - * @param networkId the network identifer 54 + *
55 - * @return collection of virtualPort. 55 + * @param networkId the network identifer
56 - */ 56 + * @return collection of virtualPort.
57 - Collection<VirtualPort> getPorts(TenantNetworkId networkId); 57 + */
58 - 58 + Collection<VirtualPort> getPorts(TenantNetworkId networkId);
59 - /** 59 +
60 - * Returns the collection of the virtualPorts associated with the tenantId. 60 + /**
61 - * 61 + * Returns the collection of the virtualPorts associated with the tenantId.
62 - * @param tenantId the tenant identifier 62 + *
63 - * @return collection of virtualPorts. 63 + * @param tenantId the tenant identifier
64 - */ 64 + * @return collection of virtualPorts.
65 - Collection<VirtualPort> getPorts(TenantId tenantId); 65 + */
66 - 66 + Collection<VirtualPort> getPorts(TenantId tenantId);
67 - /** 67 +
68 - * Returns the collection of the virtualPorts associated with the deviceId. 68 + /**
69 - * 69 + * Returns the collection of the virtualPorts associated with the deviceId.
70 - * @param deviceId the device identifier 70 + *
71 - * @return collection of virtualPort. 71 + * @param deviceId the device identifier
72 - */ 72 + * @return collection of virtualPort.
73 - Collection<VirtualPort> getPorts(DeviceId deviceId); 73 + */
74 - 74 + Collection<VirtualPort> getPorts(DeviceId deviceId);
75 - /** 75 +
76 - * Creates virtualPorts by virtualPorts. 76 + /**
77 - * 77 + * Creates virtualPorts by virtualPorts.
78 - * @param virtualPorts the iterable collection of virtualPorts 78 + *
79 - * @return true if all given identifiers created successfully. 79 + * @param virtualPorts the iterable collection of virtualPorts
80 - */ 80 + * @return true if all given identifiers created successfully.
81 - boolean createPorts(Iterable<VirtualPort> virtualPorts); 81 + */
82 - 82 + boolean createPorts(Iterable<VirtualPort> virtualPorts);
83 - /** 83 +
84 - * Updates virtualPorts by virtualPorts. 84 + /**
85 - * 85 + * Updates virtualPorts by virtualPorts.
86 - * @param virtualPorts the iterable collection of virtualPorts 86 + *
87 - * @return true if all given identifiers updated successfully. 87 + * @param virtualPorts the iterable collection of virtualPorts
88 - */ 88 + * @return true if all given identifiers updated successfully.
89 - boolean updatePorts(Iterable<VirtualPort> virtualPorts); 89 + */
90 - 90 + boolean updatePorts(Iterable<VirtualPort> virtualPorts);
91 - /** 91 +
92 - * Deletes virtualPortIds by virtualPortIds. 92 + /**
93 - * 93 + * Deletes virtualPortIds by virtualPortIds.
94 - * @param virtualPortIds the iterable collection of virtualPort identifiers 94 + *
95 - * @return true or false if one with the given identifier to delete is 95 + * @param virtualPortIds the iterable collection of virtualPort identifiers
96 - * successfully. 96 + * @return true or false if one with the given identifier to delete is
97 - */ 97 + * successfully.
98 - boolean removePorts(Iterable<VirtualPortId> virtualPortIds); 98 + */
99 -} 99 + boolean removePorts(Iterable<VirtualPortId> virtualPortIds);
100 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.virtualport.impl; 16 +package org.onosproject.vtnrsc.virtualport.impl;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 - 19 +
20 -import java.util.Collection; 20 +import java.util.Collection;
21 -import java.util.Collections; 21 +import java.util.Collections;
22 - 22 +import java.util.concurrent.ConcurrentHashMap;
23 -import org.apache.felix.scr.annotations.Activate; 23 +
24 -import org.apache.felix.scr.annotations.Component; 24 +import org.apache.felix.scr.annotations.Activate;
25 -import org.apache.felix.scr.annotations.Deactivate; 25 +import org.apache.felix.scr.annotations.Component;
26 -import org.apache.felix.scr.annotations.Reference; 26 +import org.apache.felix.scr.annotations.Deactivate;
27 -import org.apache.felix.scr.annotations.ReferenceCardinality; 27 +import org.apache.felix.scr.annotations.Reference;
28 -import org.apache.felix.scr.annotations.Service; 28 +import org.apache.felix.scr.annotations.ReferenceCardinality;
29 -import org.onlab.util.KryoNamespace; 29 +import org.apache.felix.scr.annotations.Service;
30 -import org.onosproject.net.DeviceId; 30 +import org.onosproject.net.DeviceId;
31 -import org.onosproject.store.service.EventuallyConsistentMap; 31 +import org.onosproject.store.service.StorageService;
32 -import org.onosproject.store.service.MultiValuedTimestamp; 32 +import org.onosproject.vtnrsc.TenantId;
33 -import org.onosproject.store.service.StorageService; 33 +import org.onosproject.vtnrsc.TenantNetworkId;
34 -import org.onosproject.store.service.WallClockTimestamp; 34 +import org.onosproject.vtnrsc.VirtualPort;
35 -import org.onosproject.app.vtnrsc.TenantId; 35 +import org.onosproject.vtnrsc.VirtualPortId;
36 -import org.onosproject.app.vtnrsc.TenantNetworkId; 36 +import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
37 -import org.onosproject.app.vtnrsc.VirtualPort; 37 +import org.onosproject.vtnrsc.virtualport.VirtualPortService;
38 -import org.onosproject.app.vtnrsc.VirtualPortId; 38 +import org.slf4j.Logger;
39 -import org.onosproject.app.vtnrsc.tenantnetwork.TenantNetworkService; 39 +import org.slf4j.LoggerFactory;
40 -import org.onosproject.app.vtnrsc.virtualport.VirtualPortService; 40 +
41 -import org.slf4j.Logger; 41 +/**
42 -import org.slf4j.LoggerFactory; 42 + * Provides implementation of the VirtualPort APIs.
43 - 43 + */
44 -/** 44 +@Component(immediate = true)
45 - * Provides implementation of the VirtualPort APIs. 45 +@Service
46 - */ 46 +public class VirtualPortManager implements VirtualPortService {
47 -@Component(immediate = true) 47 +
48 -@Service 48 + private final Logger log = LoggerFactory.getLogger(getClass());
49 -public class VirtualPortManager implements VirtualPortService { 49 +
50 - 50 + private static final String VIRTUALPORT_ID_NULL = "VirtualPort ID cannot be null";
51 - private final Logger log = LoggerFactory.getLogger(getClass()); 51 + private static final String VIRTUALPORT_NOT_NULL = "VirtualPort cannot be null";
52 - 52 + private static final String TENANTID_NOT_NULL = "TenantId cannot be null";
53 - private static final String VIRTUALPORT_ID_NULL = "VirtualPort ID cannot be null"; 53 + private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null";
54 - private static final String VIRTUALPORT_NOT_NULL = "VirtualPort cannot be null"; 54 + private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null";
55 - private static final String TENANTID_NOT_NULL = "TenantId cannot be null"; 55 +
56 - private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null"; 56 + protected ConcurrentHashMap<VirtualPortId, VirtualPort> vPortStore =
57 - private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null"; 57 + new ConcurrentHashMap<>();
58 - 58 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
59 - private EventuallyConsistentMap<VirtualPortId, VirtualPort> vPortStore; 59 + protected StorageService storageService;
60 - 60 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
61 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 61 + protected TenantNetworkService networkService;
62 - protected StorageService storageService; 62 +
63 - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 63 + @Activate
64 - protected TenantNetworkService networkService; 64 + public void activate() {
65 - 65 + log.info("Started");
66 - @Activate 66 + }
67 - public void activate() { 67 +
68 - KryoNamespace.Builder seriallizer = KryoNamespace.newBuilder() 68 + @Deactivate
69 - .register(MultiValuedTimestamp.class); 69 + public void deactivate() {
70 - vPortStore = storageService 70 + vPortStore.clear();
71 - .<VirtualPortId, VirtualPort>eventuallyConsistentMapBuilder() 71 + log.info("Stoppped");
72 - .withName("vPortId_vPort").withSerializer(seriallizer) 72 + }
73 - .withTimestampProvider((k, v) -> new WallClockTimestamp()) 73 +
74 - .build(); 74 + @Override
75 - log.info("Started"); 75 + public boolean exists(VirtualPortId vPortId) {
76 - } 76 + checkNotNull(vPortId, VIRTUALPORT_ID_NULL);
77 - 77 + return vPortStore.containsKey(vPortId);
78 - @Deactivate 78 + }
79 - public void deactivate() { 79 +
80 - vPortStore.destroy(); 80 + @Override
81 - log.info("Stoppped"); 81 + public VirtualPort getPort(VirtualPortId vPortId) {
82 - } 82 + checkNotNull(vPortId, VIRTUALPORT_ID_NULL);
83 - 83 + return vPortStore.get(vPortId);
84 - @Override 84 + }
85 - public boolean exists(VirtualPortId vPortId) { 85 +
86 - checkNotNull(vPortId, VIRTUALPORT_ID_NULL); 86 + @Override
87 - return vPortStore.containsKey(vPortId); 87 + public Collection<VirtualPort> getPorts() {
88 - } 88 + return Collections.unmodifiableCollection(vPortStore.values());
89 - 89 + }
90 - @Override 90 +
91 - public VirtualPort getPort(VirtualPortId vPortId) { 91 + @Override
92 - checkNotNull(vPortId, VIRTUALPORT_ID_NULL); 92 + public Collection<VirtualPort> getPorts(TenantNetworkId networkId) {
93 - return vPortStore.get(vPortId); 93 + checkNotNull(networkId, NETWORKID_NOT_NULL);
94 - } 94 + Collection<VirtualPort> vPortWithNetworkIds = vPortStore.values();
95 - 95 + for (VirtualPort vPort : vPortWithNetworkIds) {
96 - @Override 96 + if (!vPort.networkId().equals(networkId)) {
97 - public Collection<VirtualPort> getPorts() { 97 + vPortWithNetworkIds.remove(vPort);
98 - return Collections.unmodifiableCollection(vPortStore.values()); 98 + }
99 - } 99 + }
100 - 100 + return vPortWithNetworkIds;
101 - @Override 101 + }
102 - public Collection<VirtualPort> getPorts(TenantNetworkId networkId) { 102 +
103 - checkNotNull(networkId, NETWORKID_NOT_NULL); 103 + @Override
104 - Collection<VirtualPort> vPortWithNetworkIds = vPortStore.values(); 104 + public Collection<VirtualPort> getPorts(TenantId tenantId) {
105 - for (VirtualPort vPort : vPortWithNetworkIds) { 105 + checkNotNull(tenantId, TENANTID_NOT_NULL);
106 - if (!vPort.networkId().equals(networkId)) { 106 + Collection<VirtualPort> vPortWithTenantIds = vPortStore.values();
107 - vPortWithNetworkIds.remove(vPort); 107 + for (VirtualPort vPort : vPortWithTenantIds) {
108 - } 108 + if (!vPort.tenantId().equals(tenantId)) {
109 - } 109 + vPortWithTenantIds.remove(vPort);
110 - return vPortWithNetworkIds; 110 + }
111 - } 111 + }
112 - 112 + return vPortWithTenantIds;
113 - @Override 113 + }
114 - public Collection<VirtualPort> getPorts(TenantId tenantId) { 114 +
115 - checkNotNull(tenantId, TENANTID_NOT_NULL); 115 + @Override
116 - Collection<VirtualPort> vPortWithTenantIds = vPortStore.values(); 116 + public Collection<VirtualPort> getPorts(DeviceId deviceId) {
117 - for (VirtualPort vPort : vPortWithTenantIds) { 117 + checkNotNull(deviceId, DEVICEID_NOT_NULL);
118 - if (!vPort.tenantId().equals(tenantId)) { 118 + Collection<VirtualPort> vPortWithDeviceIds = vPortStore.values();
119 - vPortWithTenantIds.remove(vPort); 119 + for (VirtualPort vPort : vPortWithDeviceIds) {
120 - } 120 + if (!vPort.deviceId().equals(deviceId)) {
121 - } 121 + vPortWithDeviceIds.remove(vPort);
122 - return vPortWithTenantIds; 122 + }
123 - } 123 + }
124 - 124 + return vPortWithDeviceIds;
125 - @Override 125 + }
126 - public Collection<VirtualPort> getPorts(DeviceId deviceId) { 126 +
127 - checkNotNull(deviceId, DEVICEID_NOT_NULL); 127 + @Override
128 - Collection<VirtualPort> vPortWithDeviceIds = vPortStore.values(); 128 + public boolean createPorts(Iterable<VirtualPort> vPorts) {
129 - for (VirtualPort vPort : vPortWithDeviceIds) { 129 + checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
130 - if (!vPort.deviceId().equals(deviceId)) { 130 + for (VirtualPort vPort : vPorts) {
131 - vPortWithDeviceIds.remove(vPort); 131 + log.debug("vPortId is {} ", vPort.portId().toString());
132 - } 132 + vPortStore.put(vPort.portId(), vPort);
133 - } 133 + if (!vPortStore.containsKey(vPort.portId())) {
134 - return vPortWithDeviceIds; 134 + log.debug("The virtualPort is created failed whose identifier is {} ",
135 - } 135 + vPort.portId().toString());
136 - 136 + return false;
137 - @Override 137 + }
138 - public boolean createPorts(Iterable<VirtualPort> vPorts) { 138 + }
139 - checkNotNull(vPorts, VIRTUALPORT_NOT_NULL); 139 + return true;
140 - for (VirtualPort vPort : vPorts) { 140 + }
141 - log.debug("vPortId is {} ", vPort.portId().toString()); 141 +
142 - vPortStore.put(vPort.portId(), vPort); 142 + @Override
143 - if (!vPortStore.containsKey(vPort.portId())) { 143 + public boolean updatePorts(Iterable<VirtualPort> vPorts) {
144 - log.debug("the virtualPort created failed whose identifier was {} ", 144 + checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
145 - vPort.portId().toString()); 145 + if (vPorts != null) {
146 - return false; 146 + for (VirtualPort vPort : vPorts) {
147 - } 147 + vPortStore.put(vPort.portId(), vPort);
148 - } 148 + if (!vPortStore.containsKey(vPort.portId())) {
149 - return true; 149 + log.debug("The virtualPort is not exist whose identifier is {}",
150 - } 150 + vPort.portId().toString());
151 - 151 + return false;
152 - @Override 152 + }
153 - public boolean updatePorts(Iterable<VirtualPort> vPorts) { 153 +
154 - checkNotNull(vPorts, VIRTUALPORT_NOT_NULL); 154 + vPortStore.put(vPort.portId(), vPort);
155 - if (vPorts != null) { 155 +
156 - for (VirtualPort vPort : vPorts) { 156 + if (!vPort.equals(vPortStore.get(vPort.portId()))) {
157 - vPortStore.put(vPort.portId(), vPort); 157 + log.debug("The virtualPort is updated failed whose identifier is {}",
158 - if (!vPortStore.containsKey(vPort.portId())) { 158 + vPort.portId().toString());
159 - log.debug("the virtualPort did not exist whose identifier was {}", 159 + return false;
160 - vPort.portId().toString()); 160 + }
161 - return false; 161 + }
162 - } 162 + }
163 - 163 + return true;
164 - vPortStore.put(vPort.portId(), vPort); 164 + }
165 - 165 +
166 - if (!vPort.equals(vPortStore.get(vPort.portId()))) { 166 + @Override
167 - log.debug("the virtualPort updated failed whose identifier was {}", 167 + public boolean removePorts(Iterable<VirtualPortId> vPortIds) {
168 - vPort.portId().toString()); 168 + checkNotNull(vPortIds, VIRTUALPORT_ID_NULL);
169 - return false; 169 + if (vPortIds != null) {
170 - } 170 + for (VirtualPortId vPortId : vPortIds) {
171 - } 171 + vPortStore.remove(vPortId);
172 - } 172 + if (vPortStore.containsKey(vPortId)) {
173 - return true; 173 + log.debug("The virtualPort is removed failed whose identifier is {}",
174 - } 174 + vPortId.toString());
175 - 175 + return false;
176 - @Override 176 + }
177 - public boolean removePorts(Iterable<VirtualPortId> vPortIds) { 177 + }
178 - checkNotNull(vPortIds, VIRTUALPORT_ID_NULL); 178 + }
179 - if (vPortIds != null) { 179 + return true;
180 - for (VirtualPortId vPortId : vPortIds) { 180 + }
181 - vPortStore.remove(vPortId); 181 +
182 - if (vPortStore.containsKey(vPortId)) { 182 +}
183 - log.debug("the virtualPort removed failed whose identifier was {}",
184 - vPortId.toString());
185 - return false;
186 - }
187 - }
188 - }
189 - return true;
190 - }
191 -
192 -}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.web; 16 +package org.onosproject.vtnrsc.web;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 - 19 +
20 -import org.onosproject.app.vtnrsc.AllocationPool; 20 +import org.onosproject.codec.CodecContext;
21 -import org.onosproject.codec.CodecContext; 21 +import org.onosproject.codec.JsonCodec;
22 -import org.onosproject.codec.JsonCodec; 22 +import org.onosproject.vtnrsc.AllocationPool;
23 - 23 +
24 -import com.fasterxml.jackson.databind.node.ObjectNode; 24 +import com.fasterxml.jackson.databind.node.ObjectNode;
25 - 25 +
26 -/** 26 +/**
27 - * Subnet AllocationPool codec. 27 + * Subnet AllocationPool codec.
28 - */ 28 + */
29 -public final class AllocationPoolsCodec extends JsonCodec<AllocationPool> { 29 +public final class AllocationPoolsCodec extends JsonCodec<AllocationPool> {
30 - 30 +
31 - @Override 31 + @Override
32 - public ObjectNode encode(AllocationPool alocPool, CodecContext context) { 32 + public ObjectNode encode(AllocationPool alocPool, CodecContext context) {
33 - checkNotNull(alocPool, "AllocationPools cannot be null"); 33 + checkNotNull(alocPool, "AllocationPools cannot be null");
34 - ObjectNode result = context.mapper().createObjectNode() 34 + ObjectNode result = context.mapper().createObjectNode()
35 - .put("start", alocPool.startIp().toString()) 35 + .put("start", alocPool.startIp().toString())
36 - .put("end", alocPool.endIp().toString()); 36 + .put("end", alocPool.endIp().toString());
37 - return result; 37 + return result;
38 - } 38 + }
39 - 39 +
40 -} 40 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.web; 16 +package org.onosproject.vtnrsc.web;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 - 19 +
20 -import org.onosproject.app.vtnrsc.AllowedAddressPair; 20 +import org.onosproject.codec.CodecContext;
21 -import org.onosproject.codec.CodecContext; 21 +import org.onosproject.codec.JsonCodec;
22 -import org.onosproject.codec.JsonCodec; 22 +import org.onosproject.vtnrsc.AllowedAddressPair;
23 - 23 +
24 -import com.fasterxml.jackson.databind.node.ObjectNode; 24 +import com.fasterxml.jackson.databind.node.ObjectNode;
25 - 25 +
26 -/** 26 +/**
27 - * VirtualPort AllowedAddressPair codec. 27 + * VirtualPort AllowedAddressPair codec.
28 - */ 28 + */
29 -public final class AllowedAddressPairCodec extends JsonCodec<AllowedAddressPair> { 29 +public final class AllowedAddressPairCodec extends JsonCodec<AllowedAddressPair> {
30 - 30 +
31 - @Override 31 + @Override
32 - public ObjectNode encode(AllowedAddressPair alocAddPair, CodecContext context) { 32 + public ObjectNode encode(AllowedAddressPair alocAddPair, CodecContext context) {
33 - checkNotNull(alocAddPair, "AllowedAddressPair cannot be null"); 33 + checkNotNull(alocAddPair, "AllowedAddressPair cannot be null");
34 - ObjectNode result = context.mapper().createObjectNode() 34 + ObjectNode result = context.mapper().createObjectNode()
35 - .put("ip_address", alocAddPair.ip().toString()) 35 + .put("ip_address", alocAddPair.ip().toString())
36 - .put("mac_address", alocAddPair.mac().toString()); 36 + .put("mac_address", alocAddPair.mac().toString());
37 - return result; 37 + return result;
38 - } 38 + }
39 - 39 +
40 -} 40 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.web; 16 +package org.onosproject.vtnrsc.web;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 - 19 +
20 -import org.onosproject.app.vtnrsc.FixedIp; 20 +import org.onosproject.codec.CodecContext;
21 -import org.onosproject.codec.CodecContext; 21 +import org.onosproject.codec.JsonCodec;
22 -import org.onosproject.codec.JsonCodec; 22 +import org.onosproject.vtnrsc.FixedIp;
23 - 23 +
24 -import com.fasterxml.jackson.databind.node.ObjectNode; 24 +import com.fasterxml.jackson.databind.node.ObjectNode;
25 - 25 +
26 -/** 26 +/**
27 - * VirtualPort FixedIp codec. 27 + * VirtualPort FixedIp codec.
28 - */ 28 + */
29 -public final class FixedIpCodec extends JsonCodec<FixedIp> { 29 +public final class FixedIpCodec extends JsonCodec<FixedIp> {
30 - 30 +
31 - @Override 31 + @Override
32 - public ObjectNode encode(FixedIp fixIp, CodecContext context) { 32 + public ObjectNode encode(FixedIp fixIp, CodecContext context) {
33 - checkNotNull(fixIp, "FixedIp cannot be null"); 33 + checkNotNull(fixIp, "FixedIp cannot be null");
34 - ObjectNode result = context.mapper().createObjectNode() 34 + ObjectNode result = context.mapper().createObjectNode()
35 - .put("subnet_id", fixIp.subnetId().toString()) 35 + .put("subnet_id", fixIp.subnetId().toString())
36 - .put("ip_address", fixIp.ip().toString()); 36 + .put("ip_address", fixIp.ip().toString());
37 - return result; 37 + return result;
38 - } 38 + }
39 - 39 +
40 -} 40 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.web; 16 +package org.onosproject.vtnrsc.web;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 - 19 +
20 -import org.onosproject.codec.CodecContext; 20 +import org.onosproject.codec.CodecContext;
21 -import org.onosproject.codec.JsonCodec; 21 +import org.onosproject.codec.JsonCodec;
22 -import org.onosproject.app.vtnrsc.HostRoute; 22 +import org.onosproject.vtnrsc.HostRoute;
23 - 23 +
24 -import com.fasterxml.jackson.databind.node.ObjectNode; 24 +import com.fasterxml.jackson.databind.node.ObjectNode;
25 - 25 +
26 -/** 26 +/**
27 - * Subnet HostRoute codec. 27 + * Subnet HostRoute codec.
28 - */ 28 + */
29 -public final class HostRoutesCodec extends JsonCodec<HostRoute> { 29 +public final class HostRoutesCodec extends JsonCodec<HostRoute> {
30 - 30 +
31 - @Override 31 + @Override
32 - public ObjectNode encode(HostRoute hostRoute, CodecContext context) { 32 + public ObjectNode encode(HostRoute hostRoute, CodecContext context) {
33 - checkNotNull(hostRoute, "HostRoute cannot be null"); 33 + checkNotNull(hostRoute, "HostRoute cannot be null");
34 - ObjectNode result = context.mapper().createObjectNode() 34 + ObjectNode result = context.mapper().createObjectNode()
35 - .put("nexthop", hostRoute.nexthop().toString()) 35 + .put("nexthop", hostRoute.nexthop().toString())
36 - .put("destination", hostRoute.destination().toString()); 36 + .put("destination", hostRoute.destination().toString());
37 - return result; 37 + return result;
38 - } 38 + }
39 - 39 +
40 -} 40 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.web; 16 +package org.onosproject.vtnrsc.web;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 - 19 +
20 -import org.onosproject.app.vtnrsc.SecurityGroup; 20 +import org.onosproject.codec.CodecContext;
21 -import org.onosproject.codec.CodecContext; 21 +import org.onosproject.codec.JsonCodec;
22 -import org.onosproject.codec.JsonCodec; 22 +import org.onosproject.vtnrsc.SecurityGroup;
23 - 23 +
24 -import com.fasterxml.jackson.databind.node.ObjectNode; 24 +import com.fasterxml.jackson.databind.node.ObjectNode;
25 - 25 +
26 -/** 26 +/**
27 - * Virtualport SecurityGroup codec. 27 + * Virtualport SecurityGroup codec.
28 - */ 28 + */
29 -public final class SecurityGroupCodec extends JsonCodec<SecurityGroup> { 29 +public final class SecurityGroupCodec extends JsonCodec<SecurityGroup> {
30 - 30 +
31 - @Override 31 + @Override
32 - public ObjectNode encode(SecurityGroup securGroup, CodecContext context) { 32 + public ObjectNode encode(SecurityGroup securGroup, CodecContext context) {
33 - checkNotNull(securGroup, "SecurityGroup cannot be null"); 33 + checkNotNull(securGroup, "SecurityGroup cannot be null");
34 - ObjectNode result = context.mapper().createObjectNode() 34 + ObjectNode result = context.mapper().createObjectNode()
35 - .put("security_group", securGroup.securityGroup()); 35 + .put("security_group", securGroup.securityGroup());
36 - return result; 36 + return result;
37 - } 37 + }
38 - 38 +
39 -} 39 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.web; 16 +package org.onosproject.vtnrsc.web;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 - 19 +
20 -import org.onosproject.app.vtnrsc.Subnet; 20 +import org.onosproject.codec.CodecContext;
21 -import org.onosproject.codec.CodecContext; 21 +import org.onosproject.codec.JsonCodec;
22 -import org.onosproject.codec.JsonCodec; 22 +import org.onosproject.vtnrsc.Subnet;
23 - 23 +
24 -import com.fasterxml.jackson.databind.node.ObjectNode; 24 +import com.fasterxml.jackson.databind.node.ObjectNode;
25 - 25 +
26 -/** 26 +/**
27 - * Subnet JSON codec. 27 + * Subnet JSON codec.
28 - */ 28 + */
29 -public final class SubnetCodec extends JsonCodec<Subnet> { 29 +public final class SubnetCodec extends JsonCodec<Subnet> {
30 - @Override 30 + @Override
31 - public ObjectNode encode(Subnet subnet, CodecContext context) { 31 + public ObjectNode encode(Subnet subnet, CodecContext context) {
32 - checkNotNull(subnet, "Subnet cannot be null"); 32 + checkNotNull(subnet, "Subnet cannot be null");
33 - ObjectNode result = context.mapper().createObjectNode() 33 + ObjectNode result = context.mapper().createObjectNode()
34 - .put("id", subnet.id().toString()) 34 + .put("id", subnet.id().toString())
35 - .put("gate_ip", subnet.gatewayIp().toString()) 35 + .put("gate_ip", subnet.gatewayIp().toString())
36 - .put("network_id", subnet.networkId().toString()) 36 + .put("network_id", subnet.networkId().toString())
37 - .put("name", subnet.subnetName().toString()) 37 + .put("name", subnet.subnetName().toString())
38 - .put("ip_version", subnet.ipVersion().toString()) 38 + .put("ip_version", subnet.ipVersion().toString())
39 - .put("cidr", subnet.cidr().toString()) 39 + .put("cidr", subnet.cidr().toString())
40 - .put("shared", subnet.shared()) 40 + .put("shared", subnet.shared())
41 - .put("enabled_dchp", subnet.dhcpEnabled()) 41 + .put("enabled_dchp", subnet.dhcpEnabled())
42 - .put("tenant_id", subnet.tenantId().toString()); 42 + .put("tenant_id", subnet.tenantId().toString());
43 - result.set("alloction_pools", new AllocationPoolsCodec().encode(subnet 43 + result.set("alloction_pools", new AllocationPoolsCodec().encode(subnet
44 - .allocationPools(), context)); 44 + .allocationPools(), context));
45 - result.set("host_routes", 45 + result.set("host_routes",
46 - new HostRoutesCodec().encode(subnet.hostRoutes(), context)); 46 + new HostRoutesCodec().encode(subnet.hostRoutes(), context));
47 - return result; 47 + return result;
48 - } 48 + }
49 -} 49 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.web; 16 +package org.onosproject.vtnrsc.web;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 - 19 +
20 -import org.onosproject.codec.CodecContext; 20 +import org.onosproject.codec.CodecContext;
21 -import org.onosproject.codec.JsonCodec; 21 +import org.onosproject.codec.JsonCodec;
22 -import org.onosproject.app.vtnrsc.TenantNetwork; 22 +import org.onosproject.vtnrsc.TenantNetwork;
23 - 23 +
24 -import com.fasterxml.jackson.databind.node.ObjectNode; 24 +import com.fasterxml.jackson.databind.node.ObjectNode;
25 - 25 +
26 -/** 26 +/**
27 - * TenantNetwork JSON codec. 27 + * TenantNetwork JSON codec.
28 - */ 28 + */
29 -public final class TenantNetworkCodec extends JsonCodec<TenantNetwork> { 29 +public final class TenantNetworkCodec extends JsonCodec<TenantNetwork> {
30 - 30 +
31 - @Override 31 + @Override
32 - public ObjectNode encode(TenantNetwork network, CodecContext context) { 32 + public ObjectNode encode(TenantNetwork network, CodecContext context) {
33 - checkNotNull(network, "Network cannot be null"); 33 + checkNotNull(network, "Network cannot be null");
34 - ObjectNode result = context.mapper().createObjectNode() 34 + ObjectNode result = context.mapper().createObjectNode()
35 - .put("id", network.id().toString()) 35 + .put("id", network.id().toString())
36 - .put("name", network.name().toString()) 36 + .put("name", network.name().toString())
37 - .put("admin_state_up", network.adminStateUp()) 37 + .put("admin_state_up", network.adminStateUp())
38 - .put("status", "" + network.state()) 38 + .put("status", "" + network.state())
39 - .put("shared", network.shared()) 39 + .put("shared", network.shared())
40 - .put("tenant_id", network.tenantId().toString()) 40 + .put("tenant_id", network.tenantId().toString())
41 - .put("router:external", network.routerExternal()) 41 + .put("router:external", network.routerExternal())
42 - .put("provider:network_type", "" + network.type()) 42 + .put("provider:network_type", "" + network.type())
43 - .put("provider:physical_network", network.physicalNetwork().toString()) 43 + .put("provider:physical_network", network.physicalNetwork().toString())
44 - .put("provider:segmentation_id", network.segmentationId().toString()); 44 + .put("provider:segmentation_id", network.segmentationId().toString());
45 - return result; 45 + return result;
46 - } 46 + }
47 -} 47 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.app.vtnrsc.web; 16 +package org.onosproject.vtnrsc.web;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 - 19 +
20 -import org.onosproject.codec.CodecContext; 20 +import org.onosproject.codec.CodecContext;
21 -import org.onosproject.codec.JsonCodec; 21 +import org.onosproject.codec.JsonCodec;
22 -import org.onosproject.app.vtnrsc.VirtualPort; 22 +import org.onosproject.vtnrsc.VirtualPort;
23 - 23 +
24 -import com.fasterxml.jackson.databind.node.ObjectNode; 24 +import com.fasterxml.jackson.databind.node.ObjectNode;
25 - 25 +
26 -/** 26 +/**
27 - * VirtualPort JSON codec. 27 + * VirtualPort JSON codec.
28 - */ 28 + */
29 -public final class VirtualPortCodec extends JsonCodec<VirtualPort> { 29 +public final class VirtualPortCodec extends JsonCodec<VirtualPort> {
30 - @Override 30 + @Override
31 - public ObjectNode encode(VirtualPort vPort, CodecContext context) { 31 + public ObjectNode encode(VirtualPort vPort, CodecContext context) {
32 - checkNotNull(vPort, "VPort cannot be null"); 32 + checkNotNull(vPort, "VPort cannot be null");
33 - ObjectNode result = context 33 + ObjectNode result = context
34 - .mapper() 34 + .mapper()
35 - .createObjectNode() 35 + .createObjectNode()
36 - .put("id", vPort.portId().toString()) 36 + .put("id", vPort.portId().toString())
37 - .put("network_id", vPort.networkId().toString()) 37 + .put("network_id", vPort.networkId().toString())
38 - .put("admin_state_up", vPort.adminStateUp()) 38 + .put("admin_state_up", vPort.adminStateUp())
39 - .put("name", vPort.name().toString()) 39 + .put("name", vPort.name().toString())
40 - .put("status", vPort.state().toString()) 40 + .put("status", vPort.state().toString())
41 - .put("mac_address", vPort.macAddress().toString()) 41 + .put("mac_address", vPort.macAddress().toString())
42 - .put("tenant_id", vPort.tenantId().toString()) 42 + .put("tenant_id", vPort.tenantId().toString())
43 - .put("device_id", vPort.deviceId().toString()) 43 + .put("device_id", vPort.deviceId().toString())
44 - .put("device_owner", vPort.deviceOwner().toString()) 44 + .put("device_owner", vPort.deviceOwner().toString())
45 - .put("binding:vnic_type", vPort.bindingVnicType().toString()) 45 + .put("binding:vnic_type", vPort.bindingVnicType().toString())
46 - .put("binding:Vif_type", vPort.bindingVifType().toString()) 46 + .put("binding:Vif_type", vPort.bindingVifType().toString())
47 - .put("binding:host_id", vPort.bindingHostId().mac().toString()) 47 + .put("binding:host_id", vPort.bindingHostId().toString())
48 - .put("binding:vif_details", vPort.bindingVifDetails().toString()); 48 + .put("binding:vif_details", vPort.bindingVifDetails().toString());
49 - result.set("allowed_address_pairs", new AllowedAddressPairCodec().encode( 49 + result.set("allowed_address_pairs", new AllowedAddressPairCodec().encode(
50 - vPort.allowedAddressPairs(), context)); 50 + vPort.allowedAddressPairs(), context));
51 - result.set("fixed_ips", new FixedIpCodec().encode( 51 + result.set("fixed_ips", new FixedIpCodec().encode(
52 - vPort.fixedIps(), context)); 52 + vPort.fixedIps(), context));
53 - result.set("security_groups", new SecurityGroupCodec().encode( 53 + result.set("security_groups", new SecurityGroupCodec().encode(
54 - vPort.securityGroups(), context)); 54 + vPort.securityGroups(), context));
55 - return result; 55 + return result;
56 - } 56 + }
57 -} 57 +}
......
1 -<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
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 -<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
18 - <repository>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repository>
19 - <feature name="onos-app-vtnweb" version="@FEATURE-VERSION"
20 - description="ONOS app vtnweb components">
21 - <feature>onos-app-vtnrsc</feature>
22 - <bundle>mvn:org.onosproject/vtnweb/@ONOS-VERSION
23 - </bundle>
24 - </feature>
25 -</features>
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.vtnweb.resources; 16 +package org.onosproject.vtnweb.resources;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 -import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; 19 +import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
20 - 20 +
21 -import java.io.IOException; 21 +import java.io.IOException;
22 -import java.io.InputStream; 22 +import java.io.InputStream;
23 -import java.util.Collections; 23 +import java.util.Collections;
24 -import java.util.HashMap; 24 +import java.util.HashMap;
25 -import java.util.HashSet; 25 +import java.util.HashSet;
26 -import java.util.Map; 26 +import java.util.Map;
27 -import java.util.Set; 27 +import java.util.Set;
28 -import java.util.concurrent.ConcurrentMap; 28 +import java.util.concurrent.ConcurrentMap;
29 - 29 +
30 -import javax.ws.rs.Consumes; 30 +import javax.ws.rs.Consumes;
31 -import javax.ws.rs.DELETE; 31 +import javax.ws.rs.DELETE;
32 -import javax.ws.rs.GET; 32 +import javax.ws.rs.GET;
33 -import javax.ws.rs.POST; 33 +import javax.ws.rs.POST;
34 -import javax.ws.rs.PUT; 34 +import javax.ws.rs.PUT;
35 -import javax.ws.rs.Path; 35 +import javax.ws.rs.Path;
36 -import javax.ws.rs.PathParam; 36 +import javax.ws.rs.PathParam;
37 -import javax.ws.rs.Produces; 37 +import javax.ws.rs.Produces;
38 -import javax.ws.rs.core.MediaType; 38 +import javax.ws.rs.core.MediaType;
39 -import javax.ws.rs.core.Response; 39 +import javax.ws.rs.core.Response;
40 - 40 +
41 -import org.onlab.packet.IpAddress; 41 +import org.onlab.packet.IpAddress;
42 -import org.onlab.packet.IpAddress.Version; 42 +import org.onlab.packet.IpAddress.Version;
43 -import org.onlab.packet.IpPrefix; 43 +import org.onlab.packet.IpPrefix;
44 -import org.onlab.util.ItemNotFoundException; 44 +import org.onlab.util.ItemNotFoundException;
45 -import org.onosproject.app.vtnrsc.AllocationPool; 45 +import org.onosproject.rest.AbstractWebResource;
46 -import org.onosproject.app.vtnrsc.DefaultAllocationPool; 46 +import org.onosproject.vtnrsc.AllocationPool;
47 -import org.onosproject.app.vtnrsc.DefaultHostRoute; 47 +import org.onosproject.vtnrsc.DefaultAllocationPool;
48 -import org.onosproject.app.vtnrsc.DefaultSubnet; 48 +import org.onosproject.vtnrsc.DefaultHostRoute;
49 -import org.onosproject.app.vtnrsc.HostRoute; 49 +import org.onosproject.vtnrsc.DefaultSubnet;
50 -import org.onosproject.app.vtnrsc.Subnet; 50 +import org.onosproject.vtnrsc.HostRoute;
51 -import org.onosproject.app.vtnrsc.Subnet.Mode; 51 +import org.onosproject.vtnrsc.Subnet;
52 -import org.onosproject.app.vtnrsc.SubnetId; 52 +import org.onosproject.vtnrsc.SubnetId;
53 -import org.onosproject.app.vtnrsc.TenantId; 53 +import org.onosproject.vtnrsc.TenantId;
54 -import org.onosproject.app.vtnrsc.TenantNetworkId; 54 +import org.onosproject.vtnrsc.TenantNetworkId;
55 -import org.onosproject.app.vtnrsc.subnet.SubnetService; 55 +import org.onosproject.vtnrsc.Subnet.Mode;
56 -import org.onosproject.app.vtnrsc.web.SubnetCodec; 56 +import org.onosproject.vtnrsc.subnet.SubnetService;
57 -import org.onosproject.rest.AbstractWebResource; 57 +import org.onosproject.vtnrsc.web.SubnetCodec;
58 -import org.slf4j.Logger; 58 +import org.slf4j.Logger;
59 -import org.slf4j.LoggerFactory; 59 +import org.slf4j.LoggerFactory;
60 - 60 +
61 -import com.fasterxml.jackson.databind.JsonNode; 61 +import com.fasterxml.jackson.databind.JsonNode;
62 -import com.fasterxml.jackson.databind.ObjectMapper; 62 +import com.fasterxml.jackson.databind.ObjectMapper;
63 -import com.fasterxml.jackson.databind.node.ObjectNode; 63 +import com.fasterxml.jackson.databind.node.ObjectNode;
64 -import com.google.common.collect.Maps; 64 +import com.google.common.collect.Maps;
65 - 65 +
66 -@Path("subnets") 66 +@Path("subnets")
67 -public class SubnetWebResource extends AbstractWebResource { 67 +public class SubnetWebResource extends AbstractWebResource {
68 - private final Logger log = LoggerFactory.getLogger(SubnetWebResource.class); 68 + private final Logger log = LoggerFactory.getLogger(SubnetWebResource.class);
69 - public static final String SUBNET_NOT_CREATE = "Subnets is failed to create!"; 69 + public static final String SUBNET_NOT_CREATE = "Subnets is failed to create!";
70 - public static final String SUBNET_NOT_FOUND = "Subnets is failed to update!"; 70 + public static final String SUBNET_NOT_FOUND = "Subnets is failed to update!";
71 - public static final String JSON_NOT_NULL = "JsonNode can not be null"; 71 + public static final String JSON_NOT_NULL = "JsonNode can not be null";
72 - 72 +
73 - @GET 73 + @GET
74 - @Produces(MediaType.APPLICATION_JSON) 74 + @Produces(MediaType.APPLICATION_JSON)
75 - public Response listSubnets() { 75 + public Response listSubnets() {
76 - Iterable<Subnet> subnets = get(SubnetService.class).getSubnets(); 76 + Iterable<Subnet> subnets = get(SubnetService.class).getSubnets();
77 - ObjectNode result = new ObjectMapper().createObjectNode(); 77 + ObjectNode result = new ObjectMapper().createObjectNode();
78 - result.set("subnets", new SubnetCodec().encode(subnets, this)); 78 + result.set("subnets", new SubnetCodec().encode(subnets, this));
79 - return ok(result.toString()).build(); 79 + return ok(result.toString()).build();
80 - } 80 + }
81 - 81 +
82 - @GET 82 + @GET
83 - @Path("{subnetUUID}") 83 + @Path("{subnetUUID}")
84 - @Produces(MediaType.APPLICATION_JSON) 84 + @Produces(MediaType.APPLICATION_JSON)
85 - public Response getSubnet(@PathParam("subnetUUID") String id) { 85 + public Response getSubnet(@PathParam("subnetUUID") String id) {
86 - 86 +
87 - if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) { 87 + if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) {
88 - return ok("the subnet does not exists").build(); 88 + return ok("The subnet does not exists").build();
89 - } 89 + }
90 - Subnet sub = nullIsNotFound(get(SubnetService.class) 90 + Subnet sub = nullIsNotFound(get(SubnetService.class)
91 - .getSubnet(SubnetId.subnetId(id)), 91 + .getSubnet(SubnetId.subnetId(id)),
92 - SUBNET_NOT_FOUND); 92 + SUBNET_NOT_FOUND);
93 - 93 +
94 - ObjectNode result = new ObjectMapper().createObjectNode(); 94 + ObjectNode result = new ObjectMapper().createObjectNode();
95 - result.set("subnet", new SubnetCodec().encode(sub, this)); 95 + result.set("subnet", new SubnetCodec().encode(sub, this));
96 - return ok(result.toString()).build(); 96 + return ok(result.toString()).build();
97 - } 97 + }
98 - 98 +
99 - @POST 99 + @POST
100 - @Produces(MediaType.APPLICATION_JSON) 100 + @Produces(MediaType.APPLICATION_JSON)
101 - @Consumes(MediaType.APPLICATION_JSON) 101 + @Consumes(MediaType.APPLICATION_JSON)
102 - public Response createSubnet(final InputStream input) { 102 + public Response createSubnet(final InputStream input) {
103 - 103 +
104 - try { 104 + try {
105 - ObjectMapper mapper = new ObjectMapper(); 105 + ObjectMapper mapper = new ObjectMapper();
106 - JsonNode subnode = mapper.readTree(input); 106 + JsonNode subnode = mapper.readTree(input);
107 - Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode); 107 + Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
108 - Boolean result = nullIsNotFound((get(SubnetService.class) 108 + Boolean result = nullIsNotFound((get(SubnetService.class)
109 - .createSubnets(subnets)), 109 + .createSubnets(subnets)),
110 - SUBNET_NOT_CREATE); 110 + SUBNET_NOT_CREATE);
111 - 111 +
112 - if (!result) { 112 + if (!result) {
113 - return Response.status(204).entity(SUBNET_NOT_CREATE).build(); 113 + return Response.status(204).entity(SUBNET_NOT_CREATE).build();
114 - } 114 + }
115 - return Response.status(202).entity(result.toString()).build(); 115 + return Response.status(202).entity(result.toString()).build();
116 - } catch (Exception e) { 116 + } catch (Exception e) {
117 - return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString()) 117 + return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
118 - .build(); 118 + .build();
119 - } 119 + }
120 - } 120 + }
121 - 121 +
122 - @PUT 122 + @PUT
123 - @Path("{subnetUUID}") 123 + @Path("{subnetUUID}")
124 - @Produces(MediaType.APPLICATION_JSON) 124 + @Produces(MediaType.APPLICATION_JSON)
125 - @Consumes(MediaType.APPLICATION_JSON) 125 + @Consumes(MediaType.APPLICATION_JSON)
126 - public Response updateSubnet(@PathParam("id") String id, 126 + public Response updateSubnet(@PathParam("id") String id,
127 - final InputStream input) { 127 + final InputStream input) {
128 - try { 128 + try {
129 - ObjectMapper mapper = new ObjectMapper(); 129 + ObjectMapper mapper = new ObjectMapper();
130 - JsonNode subnode = mapper.readTree(input); 130 + JsonNode subnode = mapper.readTree(input);
131 - Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode); 131 + Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
132 - Boolean result = nullIsNotFound(get(SubnetService.class) 132 + Boolean result = nullIsNotFound(get(SubnetService.class)
133 - .updateSubnets(subnets), SUBNET_NOT_FOUND); 133 + .updateSubnets(subnets), SUBNET_NOT_FOUND);
134 - if (!result) { 134 + if (!result) {
135 - return Response.status(204).entity(SUBNET_NOT_FOUND).build(); 135 + return Response.status(204).entity(SUBNET_NOT_FOUND).build();
136 - } 136 + }
137 - return Response.status(203).entity(result.toString()).build(); 137 + return Response.status(203).entity(result.toString()).build();
138 - } catch (Exception e) { 138 + } catch (Exception e) {
139 - return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString()) 139 + return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
140 - .build(); 140 + .build();
141 - } 141 + }
142 - } 142 + }
143 - 143 +
144 - @Path("{subnetUUID}") 144 + @Path("{subnetUUID}")
145 - @DELETE 145 + @DELETE
146 - public Response deleteSingleSubnet(@PathParam("subnetUUID") String id) 146 + public Response deleteSingleSubnet(@PathParam("subnetUUID") String id)
147 - throws IOException { 147 + throws IOException {
148 - try { 148 + try {
149 - SubnetId subId = SubnetId.subnetId(id); 149 + SubnetId subId = SubnetId.subnetId(id);
150 - Set<SubnetId> subIds = new HashSet<SubnetId>(); 150 + Set<SubnetId> subIds = new HashSet<SubnetId>();
151 - subIds.add(subId); 151 + subIds.add(subId);
152 - get(SubnetService.class).removeSubnets(subIds); 152 + get(SubnetService.class).removeSubnets(subIds);
153 - return Response.status(201).entity("SUCCESS").build(); 153 + return Response.status(201).entity("SUCCESS").build();
154 - } catch (Exception e) { 154 + } catch (Exception e) {
155 - return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString()) 155 + return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
156 - .build(); 156 + .build();
157 - } 157 + }
158 - } 158 + }
159 - 159 +
160 - private Iterable<Subnet> createOrUpdateByInputStream(JsonNode subnode) { 160 + private Iterable<Subnet> createOrUpdateByInputStream(JsonNode subnode) {
161 - checkNotNull(subnode, JSON_NOT_NULL); 161 + checkNotNull(subnode, JSON_NOT_NULL);
162 - Iterable<Subnet> subnets = null; 162 + Iterable<Subnet> subnets = null;
163 - JsonNode subnetNodes = subnode.get("subnets"); 163 + JsonNode subnetNodes = subnode.get("subnets");
164 - if (subnetNodes == null) { 164 + if (subnetNodes == null) {
165 - subnetNodes = subnode.get("subnet"); 165 + subnetNodes = subnode.get("subnet");
166 - } 166 + }
167 - log.debug("subnetNodes is {}", subnetNodes.toString()); 167 + log.debug("subnetNodes is {}", subnetNodes.toString());
168 - if (subnetNodes.isArray()) { 168 + if (subnetNodes.isArray()) {
169 - subnets = changeJsonToSubs(subnetNodes); 169 + subnets = changeJsonToSubs(subnetNodes);
170 - } else { 170 + } else {
171 - subnets = changeJsonToSub(subnetNodes); 171 + subnets = changeJsonToSub(subnetNodes);
172 - } 172 + }
173 - return subnets; 173 + return subnets;
174 - } 174 + }
175 - 175 +
176 - /** 176 + /**
177 - * Returns a collection of subnets from subnetNodes. 177 + * Returns a collection of subnets from subnetNodes.
178 - * 178 + *
179 - * @param subnetNodes the subnet json node 179 + * @param subnetNodes the subnet json node
180 - * @return subnets a collection of subnets 180 + * @return subnets a collection of subnets
181 - */ 181 + */
182 - public Iterable<Subnet> changeJsonToSubs(JsonNode subnetNodes) { 182 + public Iterable<Subnet> changeJsonToSubs(JsonNode subnetNodes) {
183 - checkNotNull(subnetNodes, JSON_NOT_NULL); 183 + checkNotNull(subnetNodes, JSON_NOT_NULL);
184 - Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>(); 184 + Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>();
185 - for (JsonNode subnetNode : subnetNodes) { 185 + for (JsonNode subnetNode : subnetNodes) {
186 - if (subnetNode.hasNonNull("id")) { 186 + if (!subnetNode.hasNonNull("id")) {
187 - return null; 187 + return null;
188 - } 188 + }
189 - SubnetId id = SubnetId.subnetId(subnetNode.get("id").asText()); 189 + SubnetId id = SubnetId.subnetId(subnetNode.get("id").asText());
190 - String subnetName = subnetNode.get("name").asText(); 190 + String subnetName = subnetNode.get("name").asText();
191 - TenantId tenantId = TenantId.tenantId(subnetNode.get("tenant_id") 191 + TenantId tenantId = TenantId
192 - .asText()); 192 + .tenantId(subnetNode.get("tenant_id").asText());
193 - TenantNetworkId networkId = TenantNetworkId.networkId(subnetNode 193 + TenantNetworkId networkId = TenantNetworkId
194 - .get("network_id").asText()); 194 + .networkId(subnetNode.get("network_id").asText());
195 - Version ipVersion = Version.valueOf(subnetNode.get("ip_version") 195 + Version ipVersion = Version
196 - .asText()); 196 + .valueOf(subnetNode.get("ip_version").asText());
197 - IpPrefix cidr = IpPrefix.valueOf(subnetNode.get("cidr").asText()); 197 + IpPrefix cidr = IpPrefix.valueOf(subnetNode.get("cidr").asText());
198 - IpAddress gatewayIp = IpAddress.valueOf(subnetNode 198 + IpAddress gatewayIp = IpAddress
199 - .get("gateway_ip").asText()); 199 + .valueOf(subnetNode.get("gateway_ip").asText());
200 - Boolean dhcpEnabled = subnetNode.get("enable_dhcp").asBoolean(); 200 + Boolean dhcpEnabled = subnetNode.get("enable_dhcp").asBoolean();
201 - Boolean shared = subnetNode.get("shared").asBoolean(); 201 + Boolean shared = subnetNode.get("shared").asBoolean();
202 - JsonNode hostRoutes = subnetNode.get("host_routes"); 202 + JsonNode hostRoutes = subnetNode.get("host_routes");
203 - Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes); 203 + Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
204 - JsonNode allocationPools = subnetNode.get("allocation_pools"); 204 + JsonNode allocationPools = subnetNode.get("allocation_pools");
205 - Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools); 205 + Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
206 - Mode ipV6AddressMode = Mode.valueOf(subnetNode 206 + Mode ipV6AddressMode = Mode
207 - .get("ipv6_address_mode").asText()); 207 + .valueOf(subnetNode.get("ipv6_address_mode").asText());
208 - Mode ipV6RaMode = Mode.valueOf(subnetNode.get("ipv6_ra_mode") 208 + Mode ipV6RaMode = Mode
209 - .asText()); 209 + .valueOf(subnetNode.get("ipv6_ra_mode").asText());
210 - Subnet subnet = new DefaultSubnet(id, subnetName, networkId, 210 + Subnet subnet = new DefaultSubnet(id, subnetName, networkId,
211 - tenantId, ipVersion, cidr, 211 + tenantId, ipVersion, cidr,
212 - gatewayIp, dhcpEnabled, shared, 212 + gatewayIp, dhcpEnabled, shared,
213 - hostRoutesIt, ipV6AddressMode, 213 + hostRoutesIt, ipV6AddressMode,
214 - ipV6RaMode, allocationPoolsIt); 214 + ipV6RaMode, allocationPoolsIt);
215 - subMap.put(id, subnet); 215 + subMap.put(id, subnet);
216 - } 216 + }
217 - return Collections.unmodifiableCollection(subMap.values()); 217 + return Collections.unmodifiableCollection(subMap.values());
218 - } 218 + }
219 - 219 +
220 - /** 220 + /**
221 - * Returns a collection of subnets from subnetNodes. 221 + * Returns a collection of subnets from subnetNodes.
222 - * 222 + *
223 - * @param subnetNodes the subnet json node 223 + * @param subnetNodes the subnet json node
224 - * @return subnets a collection of subnets 224 + * @return subnets a collection of subnets
225 - */ 225 + */
226 - public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) { 226 + public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) {
227 - checkNotNull(subnetNodes, JSON_NOT_NULL); 227 + checkNotNull(subnetNodes, JSON_NOT_NULL);
228 - Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>(); 228 + Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>();
229 - SubnetId id = SubnetId.subnetId(subnetNodes.get("id").asText()); 229 + if (!subnetNodes.hasNonNull("id")) {
230 - String subnetName = subnetNodes.get("name").asText(); 230 + return null;
231 - TenantId tenantId = TenantId.tenantId(subnetNodes.get("tenant_id") 231 + }
232 - .asText()); 232 + SubnetId id = SubnetId.subnetId(subnetNodes.get("id").asText());
233 - TenantNetworkId networkId = TenantNetworkId.networkId(subnetNodes 233 + String subnetName = subnetNodes.get("name").asText();
234 - .get("network_id").asText()); 234 + TenantId tenantId = TenantId
235 - Version ipVersion = Version.valueOf(subnetNodes.get("ip_version") 235 + .tenantId(subnetNodes.get("tenant_id").asText());
236 - .asText()); 236 + TenantNetworkId networkId = TenantNetworkId
237 - IpPrefix cidr = IpPrefix.valueOf(subnetNodes.get("cidr").asText()); 237 + .networkId(subnetNodes.get("network_id").asText());
238 - IpAddress gatewayIp = IpAddress.valueOf(subnetNodes.get("gateway_ip") 238 + String version = subnetNodes.get("ip_version").asText();
239 - .asText()); 239 + Version ipVersion;
240 - Boolean dhcpEnabled = subnetNodes.get("enable_dhcp").asBoolean(); 240 + switch (version) {
241 - Boolean shared = subnetNodes.get("shared").asBoolean(); 241 + case "4":
242 - JsonNode hostRoutes = subnetNodes.get("host_routes"); 242 + ipVersion = Version.INET;
243 - Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes); 243 + break;
244 - JsonNode allocationPools = subnetNodes.get("allocation_pools"); 244 + case "6":
245 - Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools); 245 + ipVersion = Version.INET;
246 - Mode ipV6AddressMode = Mode.valueOf(subnetNodes 246 + break;
247 - .get("ipv6_address_mode").asText()); 247 + default:
248 - Mode ipV6RaMode = Mode 248 + ipVersion = null;
249 - .valueOf(subnetNodes.get("ipv6_ra_mode").asText()); 249 + }
250 - Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId, 250 +
251 - ipVersion, cidr, gatewayIp, 251 + IpPrefix cidr = IpPrefix.valueOf(subnetNodes.get("cidr").asText());
252 - dhcpEnabled, shared, hostRoutesIt, 252 + IpAddress gatewayIp = IpAddress
253 - ipV6AddressMode, ipV6RaMode, 253 + .valueOf(subnetNodes.get("gateway_ip").asText());
254 - allocationPoolsIt); 254 + Boolean dhcpEnabled = subnetNodes.get("enable_dhcp").asBoolean();
255 - subMap.put(id, subnet); 255 + Boolean shared = subnetNodes.get("shared").asBoolean();
256 - return Collections.unmodifiableCollection(subMap.values()); 256 + JsonNode hostRoutes = subnetNodes.get("host_routes");
257 - } 257 + Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
258 - 258 + JsonNode allocationPools = subnetNodes.get("allocation_pools");
259 - /** 259 + Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
260 - * Changes JsonNode alocPools to a collection of the alocPools. 260 +
261 - * 261 + Mode ipV6AddressMode = getMode(subnetNodes.get("ipv6_address_mode")
262 - * @param allocationPools the allocationPools JsonNode 262 + .asText());
263 - * @return a collection of allocationPools 263 + Mode ipV6RaMode = getMode(subnetNodes.get("ipv6_ra_mode").asText());
264 - */ 264 +
265 - public Iterable<AllocationPool> jsonNodeToAllocationPools(JsonNode allocationPools) { 265 + Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId,
266 - checkNotNull(allocationPools, JSON_NOT_NULL); 266 + ipVersion, cidr, gatewayIp,
267 - ConcurrentMap<Integer, AllocationPool> alocplMaps = Maps 267 + dhcpEnabled, shared, hostRoutesIt,
268 - .newConcurrentMap(); 268 + ipV6AddressMode, ipV6RaMode,
269 - Integer i = 0; 269 + allocationPoolsIt);
270 - for (JsonNode node : allocationPools) { 270 + subMap.put(id, subnet);
271 - IpAddress startIp = IpAddress.valueOf(node.get("start").asText()); 271 + return Collections.unmodifiableCollection(subMap.values());
272 - IpAddress endIp = IpAddress.valueOf(node.get("end").asText()); 272 + }
273 - AllocationPool alocPls = new DefaultAllocationPool(startIp, endIp); 273 +
274 - alocplMaps.putIfAbsent(i, alocPls); 274 + /**
275 - i++; 275 + * Gets ipv6_address_mode or ipv6_ra_mode type.
276 - } 276 + *
277 - return Collections.unmodifiableCollection(alocplMaps.values()); 277 + * @param mode the String value in JsonNode
278 - } 278 + * @return ipV6Mode Mode of the ipV6Mode
279 - 279 + */
280 - /** 280 + private Mode getMode(String mode) {
281 - * Changes hostRoutes JsonNode to a collection of the hostRoutes. 281 + Mode ipV6Mode;
282 - * 282 + if (mode == null) {
283 - * @param hostRoutes the hostRoutes json node 283 + return null;
284 - * @return a collection of hostRoutes 284 + }
285 - */ 285 + switch (mode) {
286 - public Iterable<HostRoute> jsonNodeToHostRoutes(JsonNode hostRoutes) { 286 + case "dhcpv6-stateful":
287 - checkNotNull(hostRoutes, JSON_NOT_NULL); 287 + ipV6Mode = Mode.DHCPV6_STATEFUL;
288 - ConcurrentMap<Integer, HostRoute> hostRouteMaps = Maps 288 + break;
289 - .newConcurrentMap(); 289 + case "dhcpv6-stateless":
290 - Integer i = 0; 290 + ipV6Mode = Mode.DHCPV6_STATELESS;
291 - for (JsonNode node : hostRoutes) { 291 + break;
292 - IpAddress nexthop = IpAddress.valueOf(node.get("nexthop").asText()); 292 + case "slaac":
293 - IpPrefix destination = IpPrefix.valueOf(node.get("destination") 293 + ipV6Mode = Mode.SLAAC;
294 - .asText()); 294 + break;
295 - HostRoute hostRoute = new DefaultHostRoute(nexthop, destination); 295 + default:
296 - hostRouteMaps.putIfAbsent(i, hostRoute); 296 + ipV6Mode = null;
297 - i++; 297 + }
298 - } 298 + return ipV6Mode;
299 - return Collections.unmodifiableCollection(hostRouteMaps.values()); 299 + }
300 - } 300 +
301 - 301 + /**
302 - /** 302 + * Changes JsonNode alocPools to a collection of the alocPools.
303 - * Returns the specified item if that items is null; otherwise throws not 303 + *
304 - * found exception. 304 + * @param allocationPools the allocationPools JsonNode
305 - * 305 + * @return a collection of allocationPools
306 - * @param item item to check 306 + */
307 - * @param <T> item type 307 + public Iterable<AllocationPool> jsonNodeToAllocationPools(JsonNode allocationPools) {
308 - * @param message not found message 308 + checkNotNull(allocationPools, JSON_NOT_NULL);
309 - * @return item if not null 309 + ConcurrentMap<Integer, AllocationPool> alocplMaps = Maps
310 - * @throws org.onlab.util.ItemNotFoundException if item is null 310 + .newConcurrentMap();
311 - */ 311 + Integer i = 0;
312 - protected <T> T nullIsNotFound(T item, String message) { 312 + for (JsonNode node : allocationPools) {
313 - if (item == null) { 313 + IpAddress startIp = IpAddress.valueOf(node.get("start").asText());
314 - throw new ItemNotFoundException(message); 314 + IpAddress endIp = IpAddress.valueOf(node.get("end").asText());
315 - } 315 + AllocationPool alocPls = new DefaultAllocationPool(startIp, endIp);
316 - return item; 316 + alocplMaps.putIfAbsent(i, alocPls);
317 - } 317 + i++;
318 - 318 + }
319 -} 319 + return Collections.unmodifiableCollection(alocplMaps.values());
320 + }
321 +
322 + /**
323 + * Changes hostRoutes JsonNode to a collection of the hostRoutes.
324 + *
325 + * @param hostRoutes the hostRoutes json node
326 + * @return a collection of hostRoutes
327 + */
328 + public Iterable<HostRoute> jsonNodeToHostRoutes(JsonNode hostRoutes) {
329 + checkNotNull(hostRoutes, JSON_NOT_NULL);
330 + ConcurrentMap<Integer, HostRoute> hostRouteMaps = Maps
331 + .newConcurrentMap();
332 + Integer i = 0;
333 + for (JsonNode node : hostRoutes) {
334 + IpAddress nexthop = IpAddress.valueOf(node.get("nexthop").asText());
335 + IpPrefix destination = IpPrefix.valueOf(node.get("destination")
336 + .asText());
337 + HostRoute hostRoute = new DefaultHostRoute(nexthop, destination);
338 + hostRouteMaps.putIfAbsent(i, hostRoute);
339 + i++;
340 + }
341 + return Collections.unmodifiableCollection(hostRouteMaps.values());
342 + }
343 +
344 + /**
345 + * Returns the specified item if that items is null; otherwise throws not
346 + * found exception.
347 + *
348 + * @param item item to check
349 + * @param <T> item type
350 + * @param message not found message
351 + * @return item if not null
352 + * @throws org.onlab.util.ItemNotFoundException if item is null
353 + */
354 + protected <T> T nullIsNotFound(T item, String message) {
355 + if (item == null) {
356 + throw new ItemNotFoundException(message);
357 + }
358 + return item;
359 + }
360 +
361 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.vtnweb.resources; 16 +package org.onosproject.vtnweb.resources;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 -import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; 19 +import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
20 -import static javax.ws.rs.core.Response.Status.OK; 20 +import static javax.ws.rs.core.Response.Status.OK;
21 - 21 +
22 -import java.io.InputStream; 22 +import java.io.InputStream;
23 -import java.util.Collections; 23 +import java.util.Collections;
24 -import java.util.HashSet; 24 +import java.util.HashSet;
25 -import java.util.Iterator; 25 +import java.util.Iterator;
26 -import java.util.Set; 26 +import java.util.Set;
27 -import java.util.concurrent.ConcurrentMap; 27 +import java.util.concurrent.ConcurrentMap;
28 - 28 +
29 -import javax.ws.rs.Consumes; 29 +import javax.ws.rs.Consumes;
30 -import javax.ws.rs.DELETE; 30 +import javax.ws.rs.DELETE;
31 -import javax.ws.rs.GET; 31 +import javax.ws.rs.GET;
32 -import javax.ws.rs.POST; 32 +import javax.ws.rs.POST;
33 -import javax.ws.rs.PUT; 33 +import javax.ws.rs.PUT;
34 -import javax.ws.rs.Path; 34 +import javax.ws.rs.Path;
35 -import javax.ws.rs.PathParam; 35 +import javax.ws.rs.PathParam;
36 -import javax.ws.rs.Produces; 36 +import javax.ws.rs.Produces;
37 -import javax.ws.rs.QueryParam; 37 +import javax.ws.rs.QueryParam;
38 -import javax.ws.rs.core.MediaType; 38 +import javax.ws.rs.core.MediaType;
39 -import javax.ws.rs.core.Response; 39 +import javax.ws.rs.core.Response;
40 - 40 +
41 -import org.onlab.util.ItemNotFoundException; 41 +import org.onlab.util.ItemNotFoundException;
42 -import org.onosproject.app.vtnrsc.DefaultTenantNetwork; 42 +import org.onosproject.rest.AbstractWebResource;
43 -import org.onosproject.app.vtnrsc.PhysicalNetwork; 43 +import org.onosproject.vtnrsc.DefaultTenantNetwork;
44 -import org.onosproject.app.vtnrsc.SegmentationId; 44 +import org.onosproject.vtnrsc.PhysicalNetwork;
45 -import org.onosproject.app.vtnrsc.TenantId; 45 +import org.onosproject.vtnrsc.SegmentationId;
46 -import org.onosproject.app.vtnrsc.TenantNetwork; 46 +import org.onosproject.vtnrsc.TenantId;
47 -import org.onosproject.app.vtnrsc.TenantNetwork.State; 47 +import org.onosproject.vtnrsc.TenantNetwork;
48 -import org.onosproject.app.vtnrsc.TenantNetwork.Type; 48 +import org.onosproject.vtnrsc.TenantNetworkId;
49 -import org.onosproject.app.vtnrsc.TenantNetworkId; 49 +import org.onosproject.vtnrsc.TenantNetwork.State;
50 -import org.onosproject.app.vtnrsc.tenantnetwork.TenantNetworkService; 50 +import org.onosproject.vtnrsc.TenantNetwork.Type;
51 -import org.onosproject.app.vtnrsc.web.TenantNetworkCodec; 51 +import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
52 -import org.onosproject.rest.AbstractWebResource; 52 +import org.onosproject.vtnrsc.web.TenantNetworkCodec;
53 -import org.slf4j.Logger; 53 +import org.slf4j.Logger;
54 -import org.slf4j.LoggerFactory; 54 +import org.slf4j.LoggerFactory;
55 - 55 +
56 -import com.fasterxml.jackson.databind.JsonNode; 56 +import com.fasterxml.jackson.databind.JsonNode;
57 -import com.fasterxml.jackson.databind.ObjectMapper; 57 +import com.fasterxml.jackson.databind.ObjectMapper;
58 -import com.fasterxml.jackson.databind.node.ObjectNode; 58 +import com.fasterxml.jackson.databind.node.ObjectNode;
59 -import com.google.common.collect.Maps; 59 +import com.google.common.collect.Maps;
60 - 60 +
61 -/** 61 +/**
62 - * REST resource for interacting with the inventory of networks. 62 + * REST resource for interacting with the inventory of networks.
63 - */ 63 + */
64 -@Path("networks") 64 +@Path("networks")
65 -public class TenantNetworkWebResource extends AbstractWebResource { 65 +public class TenantNetworkWebResource extends AbstractWebResource {
66 - public static final String NETWORK_NOT_FOUND = "Network is not found"; 66 + public static final String NETWORK_NOT_FOUND = "Network is not found";
67 - public static final String NETWORK_ID_EXIST = "Network id is existed"; 67 + public static final String NETWORK_ID_EXIST = "Network id is existed";
68 - public static final String NETWORK_ID_NOT_EXIST = "Network id is not existed"; 68 + public static final String NETWORK_ID_NOT_EXIST = "Network id is not existed";
69 - public static final String CREATE_NETWORK = "create network"; 69 + public static final String CREATE_NETWORK = "create network";
70 - public static final String UPDATE_NETWORK = "update network"; 70 + public static final String UPDATE_NETWORK = "update network";
71 - public static final String DELETE_NETWORK = "delete network"; 71 + public static final String DELETE_NETWORK = "delete network";
72 - public static final String JSON_NOT_NULL = "JsonNode can not be null"; 72 + public static final String JSON_NOT_NULL = "JsonNode can not be null";
73 - 73 +
74 - protected static final Logger log = LoggerFactory 74 + protected static final Logger log = LoggerFactory
75 - .getLogger(TenantNetworkWebResource.class); 75 + .getLogger(TenantNetworkWebResource.class);
76 - private final ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps 76 + private final ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
77 - .newConcurrentMap(); 77 + .newConcurrentMap();
78 - 78 +
79 - @GET 79 + @GET
80 - @Produces({ MediaType.APPLICATION_JSON }) 80 + @Produces({ MediaType.APPLICATION_JSON })
81 - public Response getNetworks(@QueryParam("id") String queryId, 81 + public Response getNetworks(@QueryParam("id") String queryId,
82 - @QueryParam("name") String queryName, 82 + @QueryParam("name") String queryName,
83 - @QueryParam("admin_state_up") String queryadminStateUp, 83 + @QueryParam("admin_state_up") String queryadminStateUp,
84 - @QueryParam("status") String querystate, 84 + @QueryParam("status") String querystate,
85 - @QueryParam("shared") String queryshared, 85 + @QueryParam("shared") String queryshared,
86 - @QueryParam("tenant_id") String querytenantId, 86 + @QueryParam("tenant_id") String querytenantId,
87 - @QueryParam("router:external") String routerExternal, 87 + @QueryParam("router:external") String routerExternal,
88 - @QueryParam("provider:network_type") String type, 88 + @QueryParam("provider:network_type") String type,
89 - @QueryParam("provider:physical_network") String physicalNetwork, 89 + @QueryParam("provider:physical_network") String physicalNetwork,
90 - @QueryParam("provider:segmentation_id") String segmentationId) { 90 + @QueryParam("provider:segmentation_id") String segmentationId) {
91 - Iterable<TenantNetwork> networks = get(TenantNetworkService.class) 91 + Iterable<TenantNetwork> networks = get(TenantNetworkService.class)
92 - .getNetworks(); 92 + .getNetworks();
93 - Iterator<TenantNetwork> networkors = networks.iterator(); 93 + Iterator<TenantNetwork> networkors = networks.iterator();
94 - while (networkors.hasNext()) { 94 + while (networkors.hasNext()) {
95 - TenantNetwork network = networkors.next(); 95 + TenantNetwork network = networkors.next();
96 - if ((queryId == null || queryId.equals(network.id().toString())) 96 + if ((queryId == null || queryId.equals(network.id().toString()))
97 - && (queryName == null || queryName.equals(network.name() 97 + && (queryName == null || queryName.equals(network.name()
98 - .toString())) 98 + .toString()))
99 - && (queryadminStateUp == null || queryadminStateUp 99 + && (queryadminStateUp == null || queryadminStateUp
100 - .equals(network.adminStateUp())) 100 + .equals(network.adminStateUp()))
101 - && (querystate == null || querystate.equals(network.state() 101 + && (querystate == null || querystate.equals(network.state()
102 - .toString())) 102 + .toString()))
103 - && (queryshared == null || queryshared.equals(network 103 + && (queryshared == null || queryshared.equals(network
104 - .shared())) 104 + .shared()))
105 - && (querytenantId == null || querytenantId.equals(network 105 + && (querytenantId == null || querytenantId.equals(network
106 - .tenantId().toString())) 106 + .tenantId().toString()))
107 - && (routerExternal == null || routerExternal.equals(network 107 + && (routerExternal == null || routerExternal.equals(network
108 - .routerExternal())) 108 + .routerExternal()))
109 - && (type == null || type.equals(network.type())) 109 + && (type == null || type.equals(network.type()))
110 - && (physicalNetwork == null || physicalNetwork 110 + && (physicalNetwork == null || physicalNetwork
111 - .equals(network.physicalNetwork())) 111 + .equals(network.physicalNetwork()))
112 - && (segmentationId == null || segmentationId.equals(network 112 + && (segmentationId == null || segmentationId.equals(network
113 - .segmentationId()))) { 113 + .segmentationId()))) {
114 - networksMap.putIfAbsent(network.id(), network); 114 + networksMap.putIfAbsent(network.id(), network);
115 - } 115 + }
116 - } 116 + }
117 - networks = Collections.unmodifiableCollection(networksMap.values()); 117 + networks = Collections.unmodifiableCollection(networksMap.values());
118 - ObjectNode result = new ObjectMapper().createObjectNode(); 118 + ObjectNode result = new ObjectMapper().createObjectNode();
119 - result.set("networks", new TenantNetworkCodec().encode(networks, this)); 119 + result.set("networks", new TenantNetworkCodec().encode(networks, this));
120 - 120 +
121 - return ok(result.toString()).build(); 121 + return ok(result.toString()).build();
122 - } 122 + }
123 - 123 +
124 - private State isState(String state) { 124 + private State isState(String state) {
125 - if (state.equals("ACTIVE")) { 125 + if (state.equals("ACTIVE")) {
126 - return TenantNetwork.State.ACTIVE; 126 + return TenantNetwork.State.ACTIVE;
127 - } else if (state.equals("BUILD")) { 127 + } else if (state.equals("BUILD")) {
128 - return TenantNetwork.State.BUILD; 128 + return TenantNetwork.State.BUILD;
129 - } else if (state.equals("DOWN")) { 129 + } else if (state.equals("DOWN")) {
130 - return TenantNetwork.State.DOWN; 130 + return TenantNetwork.State.DOWN;
131 - } else if (state.equals("ERROR")) { 131 + } else if (state.equals("ERROR")) {
132 - return TenantNetwork.State.ERROR; 132 + return TenantNetwork.State.ERROR;
133 - } else { 133 + } else {
134 - return null; 134 + return null;
135 - } 135 + }
136 - } 136 + }
137 - 137 +
138 - private Type isType(String type) { 138 + private Type isType(String type) {
139 - if (type.equals("LOCAL")) { 139 + if (type.equals("LOCAL")) {
140 - return TenantNetwork.Type.LOCAL; 140 + return TenantNetwork.Type.LOCAL;
141 - } else { 141 + } else {
142 - return null; 142 + return null;
143 - } 143 + }
144 - } 144 + }
145 - 145 +
146 - @GET 146 + @GET
147 - @Path("{id}") 147 + @Path("{id}")
148 - @Produces({ MediaType.APPLICATION_JSON }) 148 + @Produces({ MediaType.APPLICATION_JSON })
149 - public Response getNetwork(@PathParam("id") String id) { 149 + public Response getNetwork(@PathParam("id") String id) {
150 - 150 +
151 - if (!get(TenantNetworkService.class).exists(TenantNetworkId 151 + if (!get(TenantNetworkService.class).exists(TenantNetworkId
152 - .networkId(id))) { 152 + .networkId(id))) {
153 - return ok("The tenantNetwork does not exists").build(); 153 + return ok("The tenantNetwork does not exists").build();
154 - } 154 + }
155 - TenantNetwork network = nullIsNotFound(get(TenantNetworkService.class) 155 + TenantNetwork network = nullIsNotFound(get(TenantNetworkService.class)
156 - .getNetwork(TenantNetworkId.networkId(id)), NETWORK_NOT_FOUND); 156 + .getNetwork(TenantNetworkId.networkId(id)), NETWORK_NOT_FOUND);
157 - ObjectNode result = new ObjectMapper().createObjectNode(); 157 + ObjectNode result = new ObjectMapper().createObjectNode();
158 - result.set("network", new TenantNetworkCodec().encode(network, this)); 158 + result.set("network", new TenantNetworkCodec().encode(network, this));
159 - 159 +
160 - return ok(result.toString()).build(); 160 + return ok(result.toString()).build();
161 - 161 +
162 - } 162 + }
163 - 163 +
164 - @POST 164 + @POST
165 - @Produces(MediaType.APPLICATION_JSON) 165 + @Produces(MediaType.APPLICATION_JSON)
166 - @Consumes(MediaType.APPLICATION_JSON) 166 + @Consumes(MediaType.APPLICATION_JSON)
167 - public Response createNetworks(InputStream input) { 167 + public Response createNetworks(InputStream input) {
168 - try { 168 + try {
169 - ObjectMapper mapper = new ObjectMapper(); 169 + ObjectMapper mapper = new ObjectMapper();
170 - JsonNode cfg = mapper.readTree(input); 170 + JsonNode cfg = mapper.readTree(input);
171 - JsonNode nodes = null; 171 + JsonNode nodes = null;
172 - Iterable<TenantNetwork> networks = null; 172 + Iterable<TenantNetwork> networks = null;
173 - if (cfg.get("network") != null) { 173 + if (cfg.get("network") != null) {
174 - nodes = cfg.get("network"); 174 + nodes = cfg.get("network");
175 - if (nodes.isArray()) { 175 + if (nodes.isArray()) {
176 - networks = changeJson2objs(nodes); 176 + networks = changeJson2objs(nodes);
177 - } else { 177 + } else {
178 - networks = changeJson2obj(CREATE_NETWORK, null, nodes); 178 + networks = changeJson2obj(CREATE_NETWORK, null, nodes);
179 - } 179 + }
180 - } else if (cfg.get("networks") != null) { 180 + } else if (cfg.get("networks") != null) {
181 - nodes = cfg.get("networks"); 181 + nodes = cfg.get("networks");
182 - networks = changeJson2objs(nodes); 182 + networks = changeJson2objs(nodes);
183 - } 183 + }
184 - Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class) 184 + Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)
185 - .createNetworks(networks)), 185 + .createNetworks(networks)),
186 - NETWORK_NOT_FOUND); 186 + NETWORK_NOT_FOUND);
187 - 187 +
188 - if (!issuccess) { 188 + if (!issuccess) {
189 - return Response.status(INTERNAL_SERVER_ERROR) 189 + return Response.status(INTERNAL_SERVER_ERROR)
190 - .entity(NETWORK_ID_EXIST).build(); 190 + .entity(NETWORK_ID_EXIST).build();
191 - } 191 + }
192 - return Response.status(OK).entity(issuccess.toString()).build(); 192 + return Response.status(OK).entity(issuccess.toString()).build();
193 - } catch (Exception e) { 193 + } catch (Exception e) {
194 - log.error("Creates tenantNetwork exception {}.", e.toString()); 194 + log.error("Creates tenantNetwork exception {}.", e.toString());
195 - return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString()) 195 + return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
196 - .build(); 196 + .build();
197 - } 197 + }
198 - } 198 + }
199 - 199 +
200 - @PUT 200 + @PUT
201 - @Path("{id}") 201 + @Path("{id}")
202 - @Produces(MediaType.APPLICATION_JSON) 202 + @Produces(MediaType.APPLICATION_JSON)
203 - @Consumes(MediaType.APPLICATION_JSON) 203 + @Consumes(MediaType.APPLICATION_JSON)
204 - public Response updateNetworks(@PathParam("id") String id, InputStream input) { 204 + public Response updateNetworks(@PathParam("id") String id, InputStream input) {
205 - try { 205 + try {
206 - ObjectMapper mapper = new ObjectMapper(); 206 + ObjectMapper mapper = new ObjectMapper();
207 - JsonNode cfg = mapper.readTree(input); 207 + JsonNode cfg = mapper.readTree(input);
208 - JsonNode nodes = null; 208 + JsonNode nodes = null;
209 - Iterable<TenantNetwork> networks = null; 209 + Iterable<TenantNetwork> networks = null;
210 - if (cfg.get("network") != null) { 210 + if (cfg.get("network") != null) {
211 - nodes = cfg.get("network"); 211 + nodes = cfg.get("network");
212 - if (nodes.isArray()) { 212 + if (nodes.isArray()) {
213 - networks = changeJson2objs(nodes); 213 + networks = changeJson2objs(nodes);
214 - } else { 214 + } else {
215 - networks = changeJson2obj(UPDATE_NETWORK, 215 + networks = changeJson2obj(UPDATE_NETWORK,
216 - TenantNetworkId.networkId(id), 216 + TenantNetworkId.networkId(id),
217 - nodes); 217 + nodes);
218 - } 218 + }
219 - } else if (cfg.get("networks") != null) { 219 + } else if (cfg.get("networks") != null) {
220 - nodes = cfg.get("networks"); 220 + nodes = cfg.get("networks");
221 - networks = changeJson2objs(nodes); 221 + networks = changeJson2objs(nodes);
222 - } 222 + }
223 - Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class) 223 + Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)
224 - .updateNetworks(networks)), 224 + .updateNetworks(networks)),
225 - NETWORK_NOT_FOUND); 225 + NETWORK_NOT_FOUND);
226 - if (!issuccess) { 226 + if (!issuccess) {
227 - return Response.status(INTERNAL_SERVER_ERROR) 227 + return Response.status(INTERNAL_SERVER_ERROR)
228 - .entity(NETWORK_ID_NOT_EXIST).build(); 228 + .entity(NETWORK_ID_NOT_EXIST).build();
229 - } 229 + }
230 - return Response.status(OK).entity(issuccess.toString()).build(); 230 + return Response.status(OK).entity(issuccess.toString()).build();
231 - } catch (Exception e) { 231 + } catch (Exception e) {
232 - log.error("Updates tenantNetwork failed because of exception {}.", 232 + log.error("Updates tenantNetwork failed because of exception {}.",
233 - e.toString()); 233 + e.toString());
234 - return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString()) 234 + return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
235 - .build(); 235 + .build();
236 - } 236 + }
237 - } 237 + }
238 - 238 +
239 - @DELETE 239 + @DELETE
240 - @Path("{id}") 240 + @Path("{id}")
241 - public Response deleteNetworks(@PathParam("id") String id) { 241 + public Response deleteNetworks(@PathParam("id") String id) {
242 - log.debug("Deletes network by identifier {}.", id); 242 + log.debug("Deletes network by identifier {}.", id);
243 - Set<TenantNetworkId> networkSet = new HashSet<TenantNetworkId>(); 243 + Set<TenantNetworkId> networkSet = new HashSet<TenantNetworkId>();
244 - networkSet.add(TenantNetworkId.networkId(id)); 244 + networkSet.add(TenantNetworkId.networkId(id));
245 - Boolean issuccess = nullIsNotFound(get(TenantNetworkService.class) 245 + Boolean issuccess = nullIsNotFound(get(TenantNetworkService.class)
246 - .removeNetworks(networkSet), NETWORK_NOT_FOUND); 246 + .removeNetworks(networkSet), NETWORK_NOT_FOUND);
247 - if (!issuccess) { 247 + if (!issuccess) {
248 - log.debug("Network identifier {} is not existed", id); 248 + log.debug("Network identifier {} is not existed", id);
249 - return Response.status(INTERNAL_SERVER_ERROR) 249 + return Response.status(INTERNAL_SERVER_ERROR)
250 - .entity(NETWORK_ID_NOT_EXIST).build(); 250 + .entity(NETWORK_ID_NOT_EXIST).build();
251 - } 251 + }
252 - return Response.status(OK).entity(issuccess.toString()).build(); 252 + return Response.status(OK).entity(issuccess.toString()).build();
253 - } 253 + }
254 - 254 +
255 - /** 255 + /**
256 - * Returns a collection of tenantNetworks. 256 + * Returns a collection of tenantNetworks.
257 - * 257 + *
258 - * @param flag the flag 258 + * @param flag the flag
259 - * @param networkId network identifier 259 + * @param networkId network identifier
260 - * @param node the network json node 260 + * @param node the network json node
261 - * @return a collection of tenantNetworks 261 + * @return a collection of tenantNetworks
262 - */ 262 + */
263 - public Iterable<TenantNetwork> changeJson2obj(String flag, 263 + public Iterable<TenantNetwork> changeJson2obj(String flag,
264 - TenantNetworkId networkId, 264 + TenantNetworkId networkId,
265 - JsonNode node) { 265 + JsonNode node) {
266 - checkNotNull(node, JSON_NOT_NULL); 266 + checkNotNull(node, JSON_NOT_NULL);
267 - TenantNetwork network = null; 267 + TenantNetwork network = null;
268 - ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps 268 + ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
269 - .newConcurrentMap(); 269 + .newConcurrentMap();
270 - if (node != null) { 270 + if (node != null) {
271 - String name = node.get("name").asText(); 271 + String name = node.get("name").asText();
272 - boolean adminStateUp = node.get("admin_state_up").asBoolean(); 272 + boolean adminStateUp = node.get("admin_state_up").asBoolean();
273 - String state = node.get("status").asText(); 273 + String state = node.get("status").asText();
274 - boolean shared = node.get("shared").asBoolean(); 274 + boolean shared = node.get("shared").asBoolean();
275 - String tenantId = node.get("tenant_id").asText(); 275 + String tenantId = node.get("tenant_id").asText();
276 - boolean routerExternal = node.get("router:external").asBoolean(); 276 + boolean routerExternal = node.get("router:external").asBoolean();
277 - String type = node.get("provider:network_type").asText(); 277 + String type = node.get("provider:network_type").asText();
278 - String physicalNetwork = node.get("provider:physical_network") 278 + String physicalNetwork = node.get("provider:physical_network")
279 - .asText(); 279 + .asText();
280 - String segmentationId = node.get("provider:segmentation_id") 280 + String segmentationId = node.get("provider:segmentation_id")
281 - .asText(); 281 + .asText();
282 - TenantNetworkId id = null; 282 + TenantNetworkId id = null;
283 - if (flag == CREATE_NETWORK) { 283 + if (flag == CREATE_NETWORK) {
284 - id = TenantNetworkId.networkId(node.get("id").asText()); 284 + id = TenantNetworkId.networkId(node.get("id").asText());
285 - } else if (flag == UPDATE_NETWORK) { 285 + } else if (flag == UPDATE_NETWORK) {
286 - id = networkId; 286 + id = networkId;
287 - } 287 + }
288 - network = new DefaultTenantNetwork( 288 + network = new DefaultTenantNetwork(
289 - id, 289 + id,
290 - name, 290 + name,
291 - adminStateUp, 291 + adminStateUp,
292 - isState(state), 292 + isState(state),
293 - shared, 293 + shared,
294 - TenantId.tenantId(tenantId), 294 + TenantId.tenantId(tenantId),
295 - routerExternal, 295 + routerExternal,
296 - isType(type), 296 + isType(type),
297 - PhysicalNetwork 297 + PhysicalNetwork
298 - .physicalNetwork(physicalNetwork), 298 + .physicalNetwork(physicalNetwork),
299 - SegmentationId 299 + SegmentationId
300 - .segmentationId(segmentationId)); 300 + .segmentationId(segmentationId));
301 - networksMap.putIfAbsent(id, network); 301 + networksMap.putIfAbsent(id, network);
302 - } 302 + }
303 - return Collections.unmodifiableCollection(networksMap.values()); 303 + return Collections.unmodifiableCollection(networksMap.values());
304 - } 304 + }
305 - 305 +
306 - /** 306 + /**
307 - * Returns a collection of tenantNetworks. 307 + * Returns a collection of tenantNetworks.
308 - * 308 + *
309 - * @param nodes the network jsonnodes 309 + * @param nodes the network jsonnodes
310 - * @return a collection of tenantNetworks 310 + * @return a collection of tenantNetworks
311 - */ 311 + */
312 - public Iterable<TenantNetwork> changeJson2objs(JsonNode nodes) { 312 + public Iterable<TenantNetwork> changeJson2objs(JsonNode nodes) {
313 - checkNotNull(nodes, JSON_NOT_NULL); 313 + checkNotNull(nodes, JSON_NOT_NULL);
314 - TenantNetwork network = null; 314 + TenantNetwork network = null;
315 - ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps 315 + ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
316 - .newConcurrentMap(); 316 + .newConcurrentMap();
317 - if (nodes != null) { 317 + if (nodes != null) {
318 - for (JsonNode node : nodes) { 318 + for (JsonNode node : nodes) {
319 - String id = node.get("id").asText(); 319 + String id = node.get("id").asText();
320 - String name = node.get("name").asText(); 320 + String name = node.get("name").asText();
321 - boolean adminStateUp = node.get("admin_state_up").asBoolean(); 321 + boolean adminStateUp = node.get("admin_state_up").asBoolean();
322 - String state = node.get("status").asText(); 322 + String state = node.get("status").asText();
323 - boolean shared = node.get("shared").asBoolean(); 323 + boolean shared = node.get("shared").asBoolean();
324 - String tenantId = node.get("tenant_id").asText(); 324 + String tenantId = node.get("tenant_id").asText();
325 - boolean routerExternal = node.get("router:external") 325 + boolean routerExternal = node.get("router:external")
326 - .asBoolean(); 326 + .asBoolean();
327 - String type = node.get("provider:network_type").asText(); 327 + String type = node.get("provider:network_type").asText();
328 - String physicalNetwork = node.get("provider:physical_network") 328 + String physicalNetwork = node.get("provider:physical_network")
329 - .asText(); 329 + .asText();
330 - String segmentationId = node.get("provider:segmentation_id") 330 + String segmentationId = node.get("provider:segmentation_id")
331 - .asText(); 331 + .asText();
332 - network = new DefaultTenantNetwork( 332 + network = new DefaultTenantNetwork(
333 - TenantNetworkId 333 + TenantNetworkId
334 - .networkId(id), 334 + .networkId(id),
335 - name, 335 + name,
336 - adminStateUp, 336 + adminStateUp,
337 - isState(state), 337 + isState(state),
338 - shared, 338 + shared,
339 - TenantId.tenantId(tenantId), 339 + TenantId.tenantId(tenantId),
340 - routerExternal, 340 + routerExternal,
341 - isType(type), 341 + isType(type),
342 - PhysicalNetwork 342 + PhysicalNetwork
343 - .physicalNetwork(physicalNetwork), 343 + .physicalNetwork(physicalNetwork),
344 - SegmentationId 344 + SegmentationId
345 - .segmentationId(segmentationId)); 345 + .segmentationId(segmentationId));
346 - networksMap.putIfAbsent(TenantNetworkId.networkId(id), network); 346 + networksMap.putIfAbsent(TenantNetworkId.networkId(id), network);
347 - } 347 + }
348 - } 348 + }
349 - return Collections.unmodifiableCollection(networksMap.values()); 349 + return Collections.unmodifiableCollection(networksMap.values());
350 - } 350 + }
351 - 351 +
352 - /** 352 + /**
353 - * Returns the specified item if that items is null; otherwise throws not 353 + * Returns the specified item if that items is null; otherwise throws not
354 - * found exception. 354 + * found exception.
355 - * 355 + *
356 - * @param item item to check 356 + * @param item item to check
357 - * @param <T> item type 357 + * @param <T> item type
358 - * @param message not found message 358 + * @param message not found message
359 - * @return item if not null 359 + * @return item if not null
360 - * @throws org.onlab.util.ItemNotFoundException if item is null 360 + * @throws org.onlab.util.ItemNotFoundException if item is null
361 - */ 361 + */
362 - protected <T> T nullIsNotFound(T item, String message) { 362 + protected <T> T nullIsNotFound(T item, String message) {
363 - if (item == null) { 363 + if (item == null) {
364 - throw new ItemNotFoundException(message); 364 + throw new ItemNotFoundException(message);
365 - } 365 + }
366 - return item; 366 + return item;
367 - } 367 + }
368 -} 368 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.vtnweb.resources; 16 +package org.onosproject.vtnweb.resources;
17 - 17 +
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import static com.google.common.base.Preconditions.checkNotNull;
19 -import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; 19 +import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
20 -import static javax.ws.rs.core.Response.Status.OK; 20 +import static javax.ws.rs.core.Response.Status.OK;
21 - 21 +
22 -import java.io.InputStream; 22 +import java.io.InputStream;
23 -import java.util.Collection; 23 +import java.util.Collection;
24 -import java.util.Collections; 24 +import java.util.Collections;
25 -import java.util.HashMap; 25 +import java.util.HashMap;
26 -import java.util.HashSet; 26 +import java.util.HashSet;
27 -import java.util.Map; 27 +import java.util.Map;
28 -import java.util.Set; 28 +import java.util.Set;
29 -import java.util.concurrent.ConcurrentMap; 29 +import java.util.concurrent.ConcurrentMap;
30 - 30 +
31 -import javax.ws.rs.Consumes; 31 +import javax.ws.rs.Consumes;
32 -import javax.ws.rs.DELETE; 32 +import javax.ws.rs.DELETE;
33 -import javax.ws.rs.GET; 33 +import javax.ws.rs.GET;
34 -import javax.ws.rs.POST; 34 +import javax.ws.rs.POST;
35 -import javax.ws.rs.PUT; 35 +import javax.ws.rs.PUT;
36 -import javax.ws.rs.Path; 36 +import javax.ws.rs.Path;
37 -import javax.ws.rs.PathParam; 37 +import javax.ws.rs.PathParam;
38 -import javax.ws.rs.Produces; 38 +import javax.ws.rs.Produces;
39 -import javax.ws.rs.core.MediaType; 39 +import javax.ws.rs.core.MediaType;
40 -import javax.ws.rs.core.Response; 40 +import javax.ws.rs.core.Response;
41 - 41 +
42 -import org.onlab.packet.IpAddress; 42 +import org.onlab.packet.IpAddress;
43 -import org.onlab.packet.MacAddress; 43 +import org.onlab.packet.MacAddress;
44 -import org.onlab.util.ItemNotFoundException; 44 +import org.onlab.util.ItemNotFoundException;
45 -import org.onosproject.net.DeviceId; 45 +import org.onosproject.net.DeviceId;
46 -import org.onosproject.net.HostId; 46 +import org.onosproject.rest.AbstractWebResource;
47 -import org.onosproject.rest.AbstractWebResource; 47 +import org.onosproject.vtnrsc.AllowedAddressPair;
48 -import org.onosproject.app.vtnrsc.AllowedAddressPair; 48 +import org.onosproject.vtnrsc.BindingHostId;
49 -import org.onosproject.app.vtnrsc.DefaultVirtualPort; 49 +import org.onosproject.vtnrsc.DefaultVirtualPort;
50 -import org.onosproject.app.vtnrsc.FixedIp; 50 +import org.onosproject.vtnrsc.FixedIp;
51 -import org.onosproject.app.vtnrsc.SecurityGroup; 51 +import org.onosproject.vtnrsc.SecurityGroup;
52 -import org.onosproject.app.vtnrsc.SubnetId; 52 +import org.onosproject.vtnrsc.SubnetId;
53 -import org.onosproject.app.vtnrsc.TenantId; 53 +import org.onosproject.vtnrsc.TenantId;
54 -import org.onosproject.app.vtnrsc.TenantNetworkId; 54 +import org.onosproject.vtnrsc.TenantNetworkId;
55 -import org.onosproject.app.vtnrsc.VirtualPort; 55 +import org.onosproject.vtnrsc.VirtualPort;
56 -import org.onosproject.app.vtnrsc.VirtualPortId; 56 +import org.onosproject.vtnrsc.VirtualPortId;
57 -import org.onosproject.app.vtnrsc.VirtualPort.State; 57 +import org.onosproject.vtnrsc.VirtualPort.State;
58 -import org.onosproject.app.vtnrsc.virtualport.VirtualPortService; 58 +import org.onosproject.vtnrsc.virtualport.VirtualPortService;
59 -import org.onosproject.app.vtnrsc.web.VirtualPortCodec; 59 +import org.onosproject.vtnrsc.web.VirtualPortCodec;
60 -import org.slf4j.Logger; 60 +import org.slf4j.Logger;
61 -import org.slf4j.LoggerFactory; 61 +import org.slf4j.LoggerFactory;
62 - 62 +
63 -import com.fasterxml.jackson.databind.JsonNode; 63 +import com.fasterxml.jackson.databind.JsonNode;
64 -import com.fasterxml.jackson.databind.ObjectMapper; 64 +import com.fasterxml.jackson.databind.ObjectMapper;
65 -import com.fasterxml.jackson.databind.node.ObjectNode; 65 +import com.fasterxml.jackson.databind.node.ObjectNode;
66 -import com.google.common.collect.Maps; 66 +import com.google.common.collect.Maps;
67 - 67 +
68 -/** 68 +/**
69 - * REST resource for interacting with the inventory of infrastructure 69 + * REST resource for interacting with the inventory of infrastructure
70 - * virtualPort. 70 + * virtualPort.
71 - */ 71 + */
72 -@Path("ports") 72 +@Path("ports")
73 -public class VirtualPortWebResource extends AbstractWebResource { 73 +public class VirtualPortWebResource extends AbstractWebResource {
74 - public static final String VPORT_NOT_FOUND = "VirtualPort is not found"; 74 + public static final String VPORT_NOT_FOUND = "VirtualPort is not found";
75 - public static final String VPORT_ID_EXIST = "VirtualPort id is exist"; 75 + public static final String VPORT_ID_EXIST = "VirtualPort id is exist";
76 - public static final String VPORT_ID_NOT_EXIST = "VirtualPort id is not exist"; 76 + public static final String VPORT_ID_NOT_EXIST = "VirtualPort id is not exist";
77 - public static final String JSON_NOT_NULL = "JsonNode can not be null"; 77 + public static final String JSON_NOT_NULL = "JsonNode can not be null";
78 - protected static final Logger log = LoggerFactory 78 + protected static final Logger log = LoggerFactory
79 - .getLogger(VirtualPortService.class); 79 + .getLogger(VirtualPortService.class);
80 - 80 +
81 - @GET 81 + @GET
82 - @Produces({ MediaType.APPLICATION_JSON }) 82 + @Produces({ MediaType.APPLICATION_JSON })
83 - public Response getPorts() { 83 + public Response getPorts() {
84 - Iterable<VirtualPort> virtualPorts = get(VirtualPortService.class) 84 + Iterable<VirtualPort> virtualPorts = get(VirtualPortService.class)
85 - .getPorts(); 85 + .getPorts();
86 - ObjectNode result = new ObjectMapper().createObjectNode(); 86 + ObjectNode result = new ObjectMapper().createObjectNode();
87 - result.set("ports", new VirtualPortCodec().encode(virtualPorts, this)); 87 + result.set("ports", new VirtualPortCodec().encode(virtualPorts, this));
88 - return ok(result.toString()).build(); 88 + return ok(result.toString()).build();
89 - } 89 + }
90 - 90 +
91 - @GET 91 + @GET
92 - @Path("{id}") 92 + @Path("{id}")
93 - @Produces({ MediaType.APPLICATION_JSON }) 93 + @Produces({ MediaType.APPLICATION_JSON })
94 - public Response getportsById(@PathParam("id") String id) { 94 + public Response getportsById(@PathParam("id") String id) {
95 - 95 +
96 - if (!get(VirtualPortService.class).exists(VirtualPortId.portId(id))) { 96 + if (!get(VirtualPortService.class).exists(VirtualPortId.portId(id))) {
97 - return ok("the virtualPort does not exists").build(); 97 + return ok("the virtualPort does not exists").build();
98 - } 98 + }
99 - VirtualPort virtualPort = nullIsNotFound(get(VirtualPortService.class) 99 + VirtualPort virtualPort = nullIsNotFound(get(VirtualPortService.class)
100 - .getPort(VirtualPortId.portId(id)), VPORT_NOT_FOUND); 100 + .getPort(VirtualPortId.portId(id)), VPORT_NOT_FOUND);
101 - ObjectNode result = new ObjectMapper().createObjectNode(); 101 + ObjectNode result = new ObjectMapper().createObjectNode();
102 - result.set("ports", new VirtualPortCodec().encode(virtualPort, this)); 102 + result.set("ports", new VirtualPortCodec().encode(virtualPort, this));
103 - return ok(result.toString()).build(); 103 + return ok(result.toString()).build();
104 - } 104 + }
105 - 105 +
106 - @POST 106 + @POST
107 - @Consumes(MediaType.APPLICATION_JSON) 107 + @Consumes(MediaType.APPLICATION_JSON)
108 - @Produces(MediaType.APPLICATION_JSON) 108 + @Produces(MediaType.APPLICATION_JSON)
109 - public Response createPorts(InputStream input) { 109 + public Response createPorts(InputStream input) {
110 - try { 110 + try {
111 - ObjectMapper mapper = new ObjectMapper(); 111 + ObjectMapper mapper = new ObjectMapper();
112 - JsonNode cfg = mapper.readTree(input); 112 + JsonNode cfg = mapper.readTree(input);
113 - Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg); 113 + Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
114 - Boolean issuccess = nullIsNotFound(get(VirtualPortService.class) 114 + Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
115 - .createPorts(vPorts), VPORT_NOT_FOUND); 115 + .createPorts(vPorts), VPORT_NOT_FOUND);
116 - if (!issuccess) { 116 + if (!issuccess) {
117 - return Response.status(INTERNAL_SERVER_ERROR) 117 + return Response.status(INTERNAL_SERVER_ERROR)
118 - .entity(VPORT_ID_NOT_EXIST).build(); 118 + .entity(VPORT_ID_NOT_EXIST).build();
119 - } 119 + }
120 - return Response.status(OK).entity(issuccess.toString()).build(); 120 + return Response.status(OK).entity(issuccess.toString()).build();
121 - } catch (Exception e) { 121 + } catch (Exception e) {
122 - log.error("Creates VirtualPort failed because of exception {}", 122 + log.error("Creates VirtualPort failed because of exception {}",
123 - e.toString()); 123 + e.toString());
124 - return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString()) 124 + return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
125 - .build(); 125 + .build();
126 - } 126 + }
127 - } 127 + }
128 - 128 +
129 - @Path("{portUUID}") 129 + @Path("{portUUID}")
130 - @DELETE 130 + @DELETE
131 - public Response deletePorts(@PathParam("portUUID") String id) { 131 + public Response deletePorts(@PathParam("portUUID") String id) {
132 - Set<VirtualPortId> vPortIds = new HashSet<VirtualPortId>(); 132 + Set<VirtualPortId> vPortIds = new HashSet<VirtualPortId>();
133 - try { 133 + try {
134 - if (id != null) { 134 + if (id != null) {
135 - vPortIds.add(VirtualPortId.portId(id)); 135 + vPortIds.add(VirtualPortId.portId(id));
136 - } 136 + }
137 - Boolean issuccess = nullIsNotFound(get(VirtualPortService.class) 137 + Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
138 - .removePorts(vPortIds), VPORT_NOT_FOUND); 138 + .removePorts(vPortIds), VPORT_NOT_FOUND);
139 - if (!issuccess) { 139 + if (!issuccess) {
140 - return Response.status(INTERNAL_SERVER_ERROR) 140 + return Response.status(INTERNAL_SERVER_ERROR)
141 - .entity(VPORT_ID_NOT_EXIST).build(); 141 + .entity(VPORT_ID_NOT_EXIST).build();
142 - } 142 + }
143 - return Response.status(OK).entity(issuccess.toString()).build(); 143 + return Response.status(OK).entity(issuccess.toString()).build();
144 - } catch (Exception e) { 144 + } catch (Exception e) {
145 - log.error("Deletes VirtualPort failed because of exception {}", 145 + log.error("Deletes VirtualPort failed because of exception {}",
146 - e.toString()); 146 + e.toString());
147 - return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString()) 147 + return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
148 - .build(); 148 + .build();
149 - } 149 + }
150 - } 150 + }
151 - 151 +
152 - @PUT 152 + @PUT
153 - @Path("{id}") 153 + @Path("{id}")
154 - @Consumes(MediaType.APPLICATION_JSON) 154 + @Consumes(MediaType.APPLICATION_JSON)
155 - @Produces(MediaType.APPLICATION_JSON) 155 + @Produces(MediaType.APPLICATION_JSON)
156 - public Response updatePorts(@PathParam("id") String id, InputStream input) { 156 + public Response updatePorts(@PathParam("id") String id, InputStream input) {
157 - try { 157 + try {
158 - ObjectMapper mapper = new ObjectMapper(); 158 + ObjectMapper mapper = new ObjectMapper();
159 - JsonNode cfg = mapper.readTree(input); 159 + JsonNode cfg = mapper.readTree(input);
160 - Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg); 160 + Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
161 - Boolean issuccess = nullIsNotFound(get(VirtualPortService.class) 161 + Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
162 - .updatePorts(vPorts), VPORT_NOT_FOUND); 162 + .updatePorts(vPorts), VPORT_NOT_FOUND);
163 - if (!issuccess) { 163 + if (!issuccess) {
164 - return Response.status(INTERNAL_SERVER_ERROR) 164 + return Response.status(INTERNAL_SERVER_ERROR)
165 - .entity(VPORT_ID_NOT_EXIST).build(); 165 + .entity(VPORT_ID_NOT_EXIST).build();
166 - } 166 + }
167 - return Response.status(OK).entity(issuccess.toString()).build(); 167 + return Response.status(OK).entity(issuccess.toString()).build();
168 - } catch (Exception e) { 168 + } catch (Exception e) {
169 - log.error("Updates failed because of exception {}", e.toString()); 169 + log.error("Updates failed because of exception {}", e.toString());
170 - return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString()) 170 + return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
171 - .build(); 171 + .build();
172 - } 172 + }
173 - } 173 + }
174 - 174 +
175 - /** 175 + /**
176 - * Returns a Object of the currently known infrastructure virtualPort. 176 + * Returns a Object of the currently known infrastructure virtualPort.
177 - * 177 + *
178 - * @param vPortNode the virtualPort json node 178 + * @param vPortNode the virtualPort json node
179 - * @return a collection of virtualPorts 179 + * @return a collection of virtualPorts
180 - */ 180 + */
181 - public Iterable<VirtualPort> createOrUpdateByInputStream(JsonNode vPortNode) { 181 + public Iterable<VirtualPort> createOrUpdateByInputStream(JsonNode vPortNode) {
182 - checkNotNull(vPortNode, JSON_NOT_NULL); 182 + checkNotNull(vPortNode, JSON_NOT_NULL);
183 - JsonNode vPortNodes = vPortNode.get("ports"); 183 + JsonNode vPortNodes = vPortNode.get("ports");
184 - if (vPortNodes == null) { 184 + if (vPortNodes == null) {
185 - vPortNodes = vPortNode.get("port"); 185 + vPortNodes = vPortNode.get("port");
186 - } 186 + }
187 - if (vPortNodes.isArray()) { 187 + if (vPortNodes.isArray()) {
188 - return changeJsonToPorts(vPortNodes); 188 + return changeJsonToPorts(vPortNodes);
189 - } else { 189 + } else {
190 - return changeJsonToPort(vPortNodes); 190 + return changeJsonToPort(vPortNodes);
191 - } 191 + }
192 - } 192 + }
193 - 193 +
194 - /** 194 + /**
195 - * Returns the iterable collection of virtualports from subnetNodes. 195 + * Returns the iterable collection of virtualports from subnetNodes.
196 - * 196 + *
197 - * @param vPortNodes the virtualPort json node 197 + * @param vPortNodes the virtualPort json node
198 - * @return virtualPorts a collection of virtualPorts 198 + * @return virtualPorts a collection of virtualPorts
199 - */ 199 + */
200 - public Iterable<VirtualPort> changeJsonToPorts(JsonNode vPortNodes) { 200 + public Iterable<VirtualPort> changeJsonToPorts(JsonNode vPortNodes) {
201 - checkNotNull(vPortNodes, JSON_NOT_NULL); 201 + checkNotNull(vPortNodes, JSON_NOT_NULL);
202 - Map<VirtualPortId, VirtualPort> portMap = new HashMap<VirtualPortId, VirtualPort>(); 202 + Map<VirtualPortId, VirtualPort> portMap = new HashMap<VirtualPortId, VirtualPort>();
203 - Map<String, String> strMap = new HashMap<String, String>(); 203 + Map<String, String> strMap = new HashMap<String, String>();
204 - for (JsonNode vPortnode : vPortNodes) { 204 + for (JsonNode vPortnode : vPortNodes) {
205 - VirtualPortId id = VirtualPortId.portId(vPortnode.get("id") 205 + VirtualPortId id = VirtualPortId.portId(vPortnode.get("id")
206 - .asText()); 206 + .asText());
207 - String name = vPortnode.get("name").asText(); 207 + String name = vPortnode.get("name").asText();
208 - TenantId tenantId = TenantId.tenantId(vPortnode.get("tenant_id") 208 + TenantId tenantId = TenantId.tenantId(vPortnode.get("tenant_id")
209 - .asText()); 209 + .asText());
210 - TenantNetworkId networkId = TenantNetworkId.networkId(vPortnode 210 + TenantNetworkId networkId = TenantNetworkId.networkId(vPortnode
211 - .get("network_id").asText()); 211 + .get("network_id").asText());
212 - Boolean adminStateUp = vPortnode.get("admin_state_up").asBoolean(); 212 + Boolean adminStateUp = vPortnode.get("admin_state_up").asBoolean();
213 - String state = vPortnode.get("status").asText(); 213 + String state = vPortnode.get("status").asText();
214 - MacAddress macAddress = MacAddress.valueOf(vPortnode 214 + MacAddress macAddress = MacAddress.valueOf(vPortnode
215 - .get("mac_address").asText()); 215 + .get("mac_address").asText());
216 - DeviceId deviceId = DeviceId.deviceId(vPortnode.get("device_id") 216 + DeviceId deviceId = DeviceId.deviceId(vPortnode.get("device_id")
217 - .asText()); 217 + .asText());
218 - String deviceOwner = vPortnode.get("device_owner").asText(); 218 + String deviceOwner = vPortnode.get("device_owner").asText();
219 - JsonNode fixedIpNode = vPortnode.get("fixed_ips"); 219 + JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
220 - FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode); 220 + Set<FixedIp> fixedIps = new HashSet<FixedIp>();
221 - HostId bindingHostId = HostId.hostId(MacAddress.valueOf(vPortnode 221 + for (JsonNode fixedIpNode : fixedIpNodes) {
222 - .get("binding:host_id").asText())); 222 + FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
223 - String bindingVnicType = vPortnode.get("binding:vnic_type") 223 + fixedIps.add(fixedIp);
224 - .asText(); 224 + }
225 - String bindingVifType = vPortnode.get("binding:vif_type").asText(); 225 +
226 - String bindingVifDetails = vPortnode.get("binding:vif_details") 226 + BindingHostId bindingHostId = BindingHostId
227 - .asText(); 227 + .bindingHostId(vPortnode.get("binding:host_id").asText());
228 - JsonNode allowedAddressPairJsonNode = vPortnode 228 + String bindingVnicType = vPortnode.get("binding:vnic_type")
229 - .get("allowed_address_pairs"); 229 + .asText();
230 - Collection<AllowedAddressPair> allowedAddressPairs = 230 + String bindingVifType = vPortnode.get("binding:vif_type").asText();
231 - jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode); 231 + String bindingVifDetails = vPortnode.get("binding:vif_details")
232 - JsonNode securityGroupNode = vPortnode.get("security_groups"); 232 + .asText();
233 - Collection<SecurityGroup> securityGroups = 233 + JsonNode allowedAddressPairJsonNode = vPortnode
234 - jsonNodeToSecurityGroup(securityGroupNode); 234 + .get("allowed_address_pairs");
235 - strMap.putIfAbsent("name", name); 235 + Collection<AllowedAddressPair> allowedAddressPairs =
236 - strMap.putIfAbsent("deviceOwner", deviceOwner); 236 + jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
237 - strMap.putIfAbsent("bindingVnicType", bindingVnicType); 237 + JsonNode securityGroupNode = vPortnode.get("security_groups");
238 - strMap.putIfAbsent("bindingVifType", bindingVifType); 238 + Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
239 - strMap.putIfAbsent("bindingVifDetails", bindingVifDetails); 239 + strMap.put("name", name);
240 - VirtualPort vPort = new DefaultVirtualPort(id, networkId, 240 + strMap.put("deviceOwner", deviceOwner);
241 - adminStateUp, strMap, 241 + strMap.put("bindingVnicType", bindingVnicType);
242 - isState(state), 242 + strMap.put("bindingVifType", bindingVifType);
243 - macAddress, tenantId, 243 + strMap.put("bindingVifDetails", bindingVifDetails);
244 - deviceId, fixedIp, 244 + VirtualPort vPort = new DefaultVirtualPort(id, networkId,
245 - bindingHostId, 245 + adminStateUp, strMap,
246 - allowedAddressPairs, 246 + isState(state),
247 - securityGroups); 247 + macAddress, tenantId,
248 - portMap.put(id, vPort); 248 + deviceId, fixedIps,
249 - } 249 + bindingHostId,
250 - return Collections.unmodifiableCollection(portMap.values()); 250 + allowedAddressPairs,
251 - } 251 + securityGroups);
252 - 252 + portMap.put(id, vPort);
253 - /** 253 + }
254 - * Returns a collection of virtualPorts from subnetNodes. 254 + return Collections.unmodifiableCollection(portMap.values());
255 - * 255 + }
256 - * @param vPortNodes the virtualPort json node 256 +
257 - * @return virtualPorts a collection of virtualPorts 257 + /**
258 - */ 258 + * Returns a collection of virtualPorts from subnetNodes.
259 - public Iterable<VirtualPort> changeJsonToPort(JsonNode vPortNodes) { 259 + *
260 - checkNotNull(vPortNodes, JSON_NOT_NULL); 260 + * @param vPortNodes the virtualPort json node
261 - Map<VirtualPortId, VirtualPort> vportMap = new HashMap<VirtualPortId, VirtualPort>(); 261 + * @return virtualPorts a collection of virtualPorts
262 - Map<String, String> strMap = new HashMap<String, String>(); 262 + */
263 - VirtualPortId id = VirtualPortId.portId(vPortNodes.get("id").asText()); 263 + public Iterable<VirtualPort> changeJsonToPort(JsonNode vPortNodes) {
264 - String name = vPortNodes.get("name").asText(); 264 + checkNotNull(vPortNodes, JSON_NOT_NULL);
265 - TenantId tenantId = TenantId.tenantId(vPortNodes.get("tenant_id") 265 + Map<VirtualPortId, VirtualPort> vportMap = new HashMap<VirtualPortId, VirtualPort>();
266 - .asText()); 266 + Map<String, String> strMap = new HashMap<String, String>();
267 - TenantNetworkId networkId = TenantNetworkId.networkId(vPortNodes 267 + VirtualPortId id = VirtualPortId.portId(vPortNodes.get("id").asText());
268 - .get("network_id").asText()); 268 + String name = vPortNodes.get("name").asText();
269 - Boolean adminStateUp = vPortNodes.get("admin_state_up").asBoolean(); 269 + TenantId tenantId = TenantId.tenantId(vPortNodes.get("tenant_id")
270 - String state = vPortNodes.get("status").asText(); 270 + .asText());
271 - MacAddress macAddress = MacAddress.valueOf(vPortNodes 271 + TenantNetworkId networkId = TenantNetworkId.networkId(vPortNodes
272 - .get("mac_address").asText()); 272 + .get("network_id").asText());
273 - DeviceId deviceId = DeviceId.deviceId(vPortNodes.get("device_id") 273 + Boolean adminStateUp = vPortNodes.get("admin_state_up").asBoolean();
274 - .asText()); 274 + String state = vPortNodes.get("status").asText();
275 - String deviceOwner = vPortNodes.get("device_owner").asText(); 275 + MacAddress macAddress = MacAddress.valueOf(vPortNodes
276 - JsonNode fixedIpNode = vPortNodes.get("fixed_ips"); 276 + .get("mac_address").asText());
277 - FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode); 277 + DeviceId deviceId = DeviceId.deviceId(vPortNodes.get("device_id")
278 - HostId bindingHostId = HostId.hostId(MacAddress.valueOf(vPortNodes 278 + .asText());
279 - .get("binding:host_id").asText())); 279 + String deviceOwner = vPortNodes.get("device_owner").asText();
280 - String bindingVnicType = vPortNodes.get("binding:vnic_type").asText(); 280 + JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
281 - String bindingVifType = vPortNodes.get("binding:vif_type").asText(); 281 + Set<FixedIp> fixedIps = new HashSet<FixedIp>();
282 - String bindingVifDetails = vPortNodes.get("binding:vif_details") 282 + for (JsonNode fixedIpNode : fixedIpNodes) {
283 - .asText(); 283 + FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
284 - JsonNode allowedAddressPairJsonNode = vPortNodes 284 + fixedIps.add(fixedIp);
285 - .get("allowed_address_pairs"); 285 + }
286 - Collection<AllowedAddressPair> allowedAddressPairs = 286 +
287 - jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode); 287 + BindingHostId bindingHostId = BindingHostId
288 - JsonNode securityGroupNode = vPortNodes.get("security_groups"); 288 + .bindingHostId(vPortNodes.get("binding:host_id").asText());
289 - Collection<SecurityGroup> securityGroups = 289 + String bindingVnicType = vPortNodes.get("binding:vnic_type").asText();
290 - jsonNodeToSecurityGroup(securityGroupNode); 290 + String bindingVifType = vPortNodes.get("binding:vif_type").asText();
291 - strMap.putIfAbsent("name", name); 291 + String bindingVifDetails = vPortNodes.get("binding:vif_details")
292 - strMap.putIfAbsent("deviceOwner", deviceOwner); 292 + .asText();
293 - strMap.putIfAbsent("bindingVnicType", bindingVnicType); 293 + JsonNode allowedAddressPairJsonNode = vPortNodes
294 - strMap.putIfAbsent("bindingVifType", bindingVifType); 294 + .get("allowed_address_pairs");
295 - strMap.putIfAbsent("bindingVifDetails", bindingVifDetails); 295 + Collection<AllowedAddressPair> allowedAddressPairs =
296 - VirtualPort vPort = new DefaultVirtualPort(id, networkId, adminStateUp, 296 + jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
297 - strMap, isState(state), 297 + JsonNode securityGroupNode = vPortNodes.get("security_groups");
298 - macAddress, tenantId, 298 + Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
299 - deviceId, fixedIp, 299 + strMap.put("name", name);
300 - bindingHostId, 300 + strMap.put("deviceOwner", deviceOwner);
301 - allowedAddressPairs, 301 + strMap.put("bindingVnicType", bindingVnicType);
302 - securityGroups); 302 + strMap.put("bindingVifType", bindingVifType);
303 - vportMap.put(id, vPort); 303 + strMap.put("bindingVifDetails", bindingVifDetails);
304 - 304 + VirtualPort vPort = new DefaultVirtualPort(id, networkId, adminStateUp,
305 - return Collections.unmodifiableCollection(vportMap.values()); 305 + strMap, isState(state),
306 - } 306 + macAddress, tenantId,
307 - 307 + deviceId, fixedIps,
308 - /** 308 + bindingHostId,
309 - * Returns a Object of the currently known infrastructure virtualPort. 309 + allowedAddressPairs,
310 - * 310 + securityGroups);
311 - * @param allowedAddressPairs the allowedAddressPairs json node 311 + vportMap.put(id, vPort);
312 - * @return a collection of allowedAddressPair 312 +
313 - */ 313 + return Collections.unmodifiableCollection(vportMap.values());
314 - public Collection<AllowedAddressPair> jsonNodeToAllowedAddressPair(JsonNode allowedAddressPairs) { 314 + }
315 - checkNotNull(allowedAddressPairs, JSON_NOT_NULL); 315 +
316 - ConcurrentMap<Integer, AllowedAddressPair> allowMaps = Maps 316 + /**
317 - .newConcurrentMap(); 317 + * Returns a Object of the currently known infrastructure virtualPort.
318 - int i = 0; 318 + *
319 - for (JsonNode node : allowedAddressPairs) { 319 + * @param allowedAddressPairs the allowedAddressPairs json node
320 - IpAddress ip = IpAddress.valueOf(node.get("ip_address").asText()); 320 + * @return a collection of allowedAddressPair
321 - MacAddress mac = MacAddress.valueOf(node.get("mac_address") 321 + */
322 - .asText()); 322 + public Collection<AllowedAddressPair> jsonNodeToAllowedAddressPair(JsonNode allowedAddressPairs) {
323 - AllowedAddressPair allows = AllowedAddressPair 323 + checkNotNull(allowedAddressPairs, JSON_NOT_NULL);
324 - .allowedAddressPair(ip, mac); 324 + ConcurrentMap<Integer, AllowedAddressPair> allowMaps = Maps
325 - allowMaps.put(i, allows); 325 + .newConcurrentMap();
326 - i++; 326 + int i = 0;
327 - } 327 + for (JsonNode node : allowedAddressPairs) {
328 - log.debug("The jsonNode of allowedAddressPairallow is {}" 328 + IpAddress ip = IpAddress.valueOf(node.get("ip_address").asText());
329 - + allowedAddressPairs.toString()); 329 + MacAddress mac = MacAddress.valueOf(node.get("mac_address")
330 - return Collections.unmodifiableCollection(allowMaps.values()); 330 + .asText());
331 - } 331 + AllowedAddressPair allows = AllowedAddressPair
332 - 332 + .allowedAddressPair(ip, mac);
333 - /** 333 + allowMaps.put(i, allows);
334 - * Returns a collection of virtualPorts. 334 + i++;
335 - * 335 + }
336 - * @param securityGroups the virtualPort jsonnode 336 + log.debug("The jsonNode of allowedAddressPairallow is {}"
337 - * @return a collection of securityGroups 337 + + allowedAddressPairs.toString());
338 - */ 338 + return Collections.unmodifiableCollection(allowMaps.values());
339 - public Collection<SecurityGroup> jsonNodeToSecurityGroup(JsonNode securityGroups) { 339 + }
340 - checkNotNull(securityGroups, JSON_NOT_NULL); 340 +
341 - ConcurrentMap<Integer, SecurityGroup> securMaps = Maps 341 + /**
342 - .newConcurrentMap(); 342 + * Returns a collection of virtualPorts.
343 - int i = 0; 343 + *
344 - for (JsonNode node : securityGroups) { 344 + * @param securityGroups the virtualPort jsonnode
345 - SecurityGroup securityGroup = SecurityGroup.securityGroup(node 345 + * @return a collection of securityGroups
346 - .get("security_group").asText()); 346 + */
347 - securMaps.put(i, securityGroup); 347 + public Collection<SecurityGroup> jsonNodeToSecurityGroup(JsonNode securityGroups) {
348 - i++; 348 + checkNotNull(securityGroups, JSON_NOT_NULL);
349 - } 349 + ConcurrentMap<Integer, SecurityGroup> securMaps = Maps
350 - return Collections.unmodifiableCollection(securMaps.values()); 350 + .newConcurrentMap();
351 - } 351 + int i = 0;
352 - 352 + for (JsonNode node : securityGroups) {
353 - /** 353 + SecurityGroup securityGroup = SecurityGroup
354 - * Returns a collection of fixedIps. 354 + .securityGroup(node.asText());
355 - * 355 + securMaps.put(i, securityGroup);
356 - * @param fixedIpNode the fixedIp jsonnode 356 + i++;
357 - * @return a collection of SecurityGroup 357 + }
358 - */ 358 + return Collections.unmodifiableCollection(securMaps.values());
359 - public FixedIp jsonNodeToFixedIps(JsonNode fixedIpNode) { 359 + }
360 - SubnetId subnetId = SubnetId.subnetId(fixedIpNode.get("subnet_id") 360 +
361 - .asText()); 361 + /**
362 - IpAddress ipAddress = IpAddress.valueOf(fixedIpNode.get("ip_address") 362 + * Returns a collection of fixedIps.
363 - .asText()); 363 + *
364 - FixedIp fixedIps = FixedIp.fixedIp(subnetId, ipAddress); 364 + * @param fixedIpNode the fixedIp jsonnode
365 - return fixedIps; 365 + * @return a collection of SecurityGroup
366 - } 366 + */
367 - 367 + public FixedIp jsonNodeToFixedIps(JsonNode fixedIpNode) {
368 - /** 368 + SubnetId subnetId = SubnetId.subnetId(fixedIpNode.get("subnet_id")
369 - * Returns VirtualPort State. 369 + .asText());
370 - * 370 + IpAddress ipAddress = IpAddress.valueOf(fixedIpNode.get("ip_address")
371 - * @param state the virtualport state 371 + .asText());
372 - * @return the virtualPort state 372 + FixedIp fixedIps = FixedIp.fixedIp(subnetId, ipAddress);
373 - */ 373 + return fixedIps;
374 - private State isState(String state) { 374 + }
375 - if (state.equals("ACTIVE")) { 375 +
376 - return VirtualPort.State.ACTIVE; 376 + /**
377 - } else { 377 + * Returns VirtualPort State.
378 - return VirtualPort.State.DOWN; 378 + *
379 - } 379 + * @param state the virtualport state
380 - 380 + * @return the virtualPort state
381 - } 381 + */
382 - 382 + private State isState(String state) {
383 - /** 383 + if (state.equals("ACTIVE")) {
384 - * Returns the specified item if that items is null; otherwise throws not 384 + return VirtualPort.State.ACTIVE;
385 - * found exception. 385 + } else {
386 - * 386 + return VirtualPort.State.DOWN;
387 - * @param item item to check 387 + }
388 - * @param <T> item type 388 +
389 - * @param message not found message 389 + }
390 - * @return item if not null 390 +
391 - * @throws org.onlab.util.ItemNotFoundException if item is null 391 + /**
392 - */ 392 + * Returns the specified item if that items is null; otherwise throws not
393 - protected <T> T nullIsNotFound(T item, String message) { 393 + * found exception.
394 - if (item == null) { 394 + *
395 - throw new ItemNotFoundException(message); 395 + * @param item item to check
396 - } 396 + * @param <T> item type
397 - return item; 397 + * @param message not found message
398 - } 398 + * @return item if not null
399 -} 399 + * @throws org.onlab.util.ItemNotFoundException if item is null
400 + */
401 + protected <T> T nullIsNotFound(T item, String message) {
402 + if (item == null) {
403 + throw new ItemNotFoundException(message);
404 + }
405 + return item;
406 + }
407 +}
......