diff options
author | CNlucius <lukai1@huawei.com> | 2016-09-13 11:40:12 +0800 |
---|---|---|
committer | CNlucius <lukai1@huawei.com> | 2016-09-13 11:41:53 +0800 |
commit | b731e2f1dd0972409b136aebc7b463dd72c9cfad (patch) | |
tree | 5107d7d80c19ad8076c2c97c2b5ef8d1cf3ab903 /framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl | |
parent | ee93993458266114c29271a481ef9ce7ce621b2a (diff) |
ONOSFW-171
O/S-SFC-ONOS scenario documentation
Change-Id: I51ae1cf736ea24ab6680f8edca1b2bf5dd598365
Signed-off-by: CNlucius <lukai1@huawei.com>
Diffstat (limited to 'framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl')
2 files changed, 0 insertions, 269 deletions
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java deleted file mode 100644 index 9639e086..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.vtnrsc.virtualport.impl; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.apache.felix.scr.annotations.Service; -import org.onlab.packet.IpAddress; -import org.onosproject.core.ApplicationId; -import org.onosproject.core.CoreService; -import org.onosproject.net.DeviceId; -import org.onosproject.store.serializers.KryoNamespaces; -import org.onosproject.store.service.Serializer; -import org.onosproject.store.service.StorageService; -import org.onosproject.vtnrsc.AllowedAddressPair; -import org.onosproject.vtnrsc.BindingHostId; -import org.onosproject.vtnrsc.DefaultVirtualPort; -import org.onosproject.vtnrsc.FixedIp; -import org.onosproject.vtnrsc.SecurityGroup; -import org.onosproject.vtnrsc.SubnetId; -import org.onosproject.vtnrsc.TenantId; -import org.onosproject.vtnrsc.TenantNetworkId; -import org.onosproject.vtnrsc.VirtualPort; -import org.onosproject.vtnrsc.VirtualPortId; -import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService; -import org.onosproject.vtnrsc.virtualport.VirtualPortService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Provides implementation of the VirtualPort APIs. - */ -@Component(immediate = true) -@Service -public class VirtualPortManager implements VirtualPortService { - - private final Logger log = LoggerFactory.getLogger(getClass()); - - private static final String VIRTUALPORT = "vtn-virtual-port"; - private static final String VTNRSC_APP = "org.onosproject.vtnrsc"; - - private static final String VIRTUALPORT_ID_NULL = "VirtualPort ID cannot be null"; - private static final String VIRTUALPORT_NOT_NULL = "VirtualPort cannot be null"; - private static final String TENANTID_NOT_NULL = "TenantId cannot be null"; - private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null"; - private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null"; - private static final String FIXEDIP_NOT_NULL = "FixedIp cannot be null"; - private static final String IP_NOT_NULL = "Ip cannot be null"; - - protected Map<VirtualPortId, VirtualPort> vPortStore; - protected ApplicationId appId; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected StorageService storageService; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected TenantNetworkService networkService; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected CoreService coreService; - - @Activate - public void activate() { - - appId = coreService.registerApplication(VTNRSC_APP); - - vPortStore = storageService.<VirtualPortId, VirtualPort>consistentMapBuilder() - .withName(VIRTUALPORT) - .withApplicationId(appId) - .withPurgeOnUninstall() - .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API), - VirtualPortId.class, - TenantNetworkId.class, - VirtualPort.State.class, - TenantId.class, - AllowedAddressPair.class, - FixedIp.class, - BindingHostId.class, - SecurityGroup.class, - SubnetId.class, - IpAddress.class, - DefaultVirtualPort.class)) - .build().asJavaMap(); - log.info("Started"); - } - - @Deactivate - public void deactivate() { - vPortStore.clear(); - log.info("Stoppped"); - } - - @Override - public boolean exists(VirtualPortId vPortId) { - checkNotNull(vPortId, VIRTUALPORT_ID_NULL); - return vPortStore.containsKey(vPortId); - } - - @Override - public VirtualPort getPort(VirtualPortId vPortId) { - checkNotNull(vPortId, VIRTUALPORT_ID_NULL); - return vPortStore.get(vPortId); - } - - @Override - public VirtualPort getPort(FixedIp fixedIP) { - checkNotNull(fixedIP, FIXEDIP_NOT_NULL); - List<VirtualPort> vPorts = new ArrayList<>(); - vPortStore.values().stream().forEach(p -> { - Iterator<FixedIp> fixedIps = p.fixedIps().iterator(); - while (fixedIps.hasNext()) { - if (fixedIps.next().equals(fixedIP)) { - vPorts.add(p); - break; - } - } - }); - if (vPorts.size() == 0) { - return null; - } - return vPorts.get(0); - } - - @Override - public VirtualPort getPort(TenantNetworkId networkId, IpAddress ip) { - checkNotNull(networkId, NETWORKID_NOT_NULL); - checkNotNull(ip, IP_NOT_NULL); - List<VirtualPort> vPorts = new ArrayList<>(); - vPortStore.values().stream().filter(p -> p.networkId().equals(networkId)) - .forEach(p -> { - Iterator<FixedIp> fixedIps = p.fixedIps().iterator(); - while (fixedIps.hasNext()) { - if (fixedIps.next().ip().equals(ip)) { - vPorts.add(p); - break; - } - } - }); - if (vPorts.size() == 0) { - return null; - } - return vPorts.get(0); - } - - @Override - public Collection<VirtualPort> getPorts() { - return Collections.unmodifiableCollection(vPortStore.values()); - } - - @Override - public Collection<VirtualPort> getPorts(TenantNetworkId networkId) { - checkNotNull(networkId, NETWORKID_NOT_NULL); - return vPortStore.values().stream().filter(d -> d.networkId().equals(networkId)) - .collect(Collectors.toList()); - } - - @Override - public Collection<VirtualPort> getPorts(TenantId tenantId) { - checkNotNull(tenantId, TENANTID_NOT_NULL); - return vPortStore.values().stream().filter(d -> d.tenantId().equals(tenantId)) - .collect(Collectors.toList()); - } - - @Override - public Collection<VirtualPort> getPorts(DeviceId deviceId) { - checkNotNull(deviceId, DEVICEID_NOT_NULL); - return vPortStore.values().stream().filter(d -> d.deviceId().equals(deviceId)) - .collect(Collectors.toList()); - } - - @Override - public boolean createPorts(Iterable<VirtualPort> vPorts) { - checkNotNull(vPorts, VIRTUALPORT_NOT_NULL); - for (VirtualPort vPort : vPorts) { - log.debug("vPortId is {} ", vPort.portId().toString()); - vPortStore.put(vPort.portId(), vPort); - if (!vPortStore.containsKey(vPort.portId())) { - log.debug("The virtualPort is created failed whose identifier is {} ", - vPort.portId().toString()); - return false; - } - } - return true; - } - - @Override - public boolean updatePorts(Iterable<VirtualPort> vPorts) { - checkNotNull(vPorts, VIRTUALPORT_NOT_NULL); - for (VirtualPort vPort : vPorts) { - vPortStore.put(vPort.portId(), vPort); - if (!vPortStore.containsKey(vPort.portId())) { - log.debug("The virtualPort is not exist whose identifier is {}", - vPort.portId().toString()); - return false; - } - - vPortStore.put(vPort.portId(), vPort); - - if (!vPort.equals(vPortStore.get(vPort.portId()))) { - log.debug("The virtualPort is updated failed whose identifier is {}", - vPort.portId().toString()); - return false; - } - } - return true; - } - - @Override - public boolean removePorts(Iterable<VirtualPortId> vPortIds) { - checkNotNull(vPortIds, VIRTUALPORT_ID_NULL); - for (VirtualPortId vPortId : vPortIds) { - vPortStore.remove(vPortId); - if (vPortStore.containsKey(vPortId)) { - log.debug("The virtualPort is removed failed whose identifier is {}", - vPortId.toString()); - return false; - } - } - return true; - } - -} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java deleted file mode 100644 index 24eb0d3f..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Implementation of service for interacting with the inventory of virtual ports. - */ -package org.onosproject.vtnrsc.virtualport.impl; |