diff options
Diffstat (limited to 'framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb')
4 files changed, 0 insertions, 446 deletions
diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbBridgeConfig.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbBridgeConfig.java deleted file mode 100644 index 6451160a..00000000 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbBridgeConfig.java +++ /dev/null @@ -1,181 +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.driver.ovsdb; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import org.onlab.packet.IpAddress; -import org.onosproject.net.DefaultAnnotations; -import org.onosproject.net.DeviceId; -import org.onosproject.net.PortNumber; -import org.onosproject.net.behaviour.BridgeConfig; -import org.onosproject.net.behaviour.BridgeDescription; -import org.onosproject.net.behaviour.BridgeName; -import org.onosproject.net.behaviour.ControllerInfo; -import org.onosproject.net.behaviour.DefaultBridgeDescription; -import org.onosproject.net.device.DefaultPortDescription; -import org.onosproject.net.device.PortDescription; -import org.onosproject.net.driver.AbstractHandlerBehaviour; -import org.onosproject.net.driver.DriverHandler; -import org.onosproject.ovsdb.controller.OvsdbBridge; -import org.onosproject.ovsdb.controller.OvsdbClientService; -import org.onosproject.ovsdb.controller.OvsdbController; -import org.onosproject.ovsdb.controller.OvsdbNodeId; -import org.onosproject.ovsdb.controller.OvsdbPort; - -/** - * The implementation of BridageConfig. - */ -public class OvsdbBridgeConfig extends AbstractHandlerBehaviour - implements BridgeConfig { - - @Override - public void addBridge(BridgeName bridgeName) { - DriverHandler handler = handler(); - OvsdbClientService clientService = getOvsdbClientService(handler); - clientService.createBridge(bridgeName.name()); - } - - @Override - public void addBridge(BridgeName bridgeName, String dpid, String exPortName) { - DriverHandler handler = handler(); - OvsdbClientService clientService = getOvsdbClientService(handler); - clientService.createBridge(bridgeName.name(), dpid, exPortName); - } - - @Override - public boolean addBridge(BridgeName bridgeName, String dpid, List<ControllerInfo> controllers) { - DriverHandler handler = handler(); - OvsdbClientService clientService = getOvsdbClientService(handler); - return clientService.createBridge(bridgeName.name(), dpid, controllers); - } - - @Override - public void deleteBridge(BridgeName bridgeName) { - DriverHandler handler = handler(); - OvsdbClientService clientService = getOvsdbClientService(handler); - clientService.dropBridge(bridgeName.name()); - } - - @Override - public Collection<BridgeDescription> getBridges() { - DriverHandler handler = handler(); - DeviceId deviceId = handler.data().deviceId(); - OvsdbClientService clientService = getOvsdbClientService(handler); - Set<OvsdbBridge> bridges = clientService.getBridges(); - - return bridges.stream() - .map(x -> new DefaultBridgeDescription( - BridgeName.bridgeName(x.bridgeName().value()), - deviceId, - DeviceId.deviceId("of:" + x.datapathId().value()) - ) - ) - .collect(Collectors.toSet()); - } - - @Override - public void addPort(PortDescription port) { - DriverHandler handler = handler(); - OvsdbClientService clientService = getOvsdbClientService(handler); - Set<OvsdbBridge> ovsdbSet = clientService.getBridges(); - if (ovsdbSet != null && ovsdbSet.size() > 0) { - OvsdbBridge bridge = ovsdbSet.iterator().next(); - clientService.createPort(bridge.bridgeName().toString(), port - .portNumber().toString()); - } - } - - @Override - public void deletePort(PortDescription port) { - DriverHandler handler = handler(); - OvsdbClientService clientService = getOvsdbClientService(handler); - Set<OvsdbBridge> ovsdbSet = clientService.getBridges(); - if (ovsdbSet != null && ovsdbSet.size() > 0) { - OvsdbBridge bridge = ovsdbSet.iterator().next(); - clientService.dropPort(bridge.bridgeName().toString(), port - .portNumber().toString()); - } - } - - @Override - public Collection<PortDescription> getPorts() { - DriverHandler handler = handler(); - OvsdbClientService clientService = getOvsdbClientService(handler); - Set<OvsdbPort> ports = clientService.getPorts(); - - return ports.stream() - .map(x -> new DefaultPortDescription( - PortNumber.portNumber(x.portNumber().value()), - true, - DefaultAnnotations.builder() - .set("portName", x.portName().value()) - .build())) - .collect(Collectors.toSet()); - } - - // OvsdbNodeId(IP) is used in the adaptor while DeviceId(ovsdb:IP) - // is used in the core. So DeviceId need be changed to OvsdbNodeId. - private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) { - String[] splits = deviceId.toString().split(":"); - if (splits == null || splits.length < 1) { - return null; - } - IpAddress ipAddress = IpAddress.valueOf(splits[1]); - return new OvsdbNodeId(ipAddress, 0); - } - - // Used for getting OvsdbClientService. - private OvsdbClientService getOvsdbClientService(DriverHandler handler) { - OvsdbController ovsController = handler.get(OvsdbController.class); - DeviceId deviceId = handler.data().deviceId(); - OvsdbNodeId nodeId = changeDeviceIdToNodeId(deviceId); - return ovsController.getOvsdbClient(nodeId); - } - - @Override - public Set<PortNumber> getPortNumbers() { - DriverHandler handler = handler(); - OvsdbClientService clientService = getOvsdbClientService(handler); - Set<OvsdbPort> ports = clientService.getPorts(); - - return ports.stream() - .map(x -> PortNumber.portNumber( - x.portNumber().value(), - x.portName().value() - ) - ) - .collect(Collectors.toSet()); - } - - @Override - public List<PortNumber> getLocalPorts(Iterable<String> ifaceIds) { - List<PortNumber> ports = new ArrayList<>(); - DriverHandler handler = handler(); - OvsdbClientService clientService = getOvsdbClientService(handler); - Set<OvsdbPort> ovsdbSet = clientService.getLocalPorts(ifaceIds); - ovsdbSet.forEach(o -> { - PortNumber port = PortNumber.portNumber(o.portNumber().value(), - o.portName().value()); - ports.add(port); - }); - return ports; - } -} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbControllerConfig.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbControllerConfig.java deleted file mode 100644 index f116ab84..00000000 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbControllerConfig.java +++ /dev/null @@ -1,103 +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.driver.ovsdb; - -import com.google.common.collect.ImmutableSet; -import org.onlab.packet.IpAddress; -import org.onlab.packet.TpPort; -import org.onosproject.net.AnnotationKeys; -import org.onosproject.net.DeviceId; -import org.onosproject.net.behaviour.ControllerConfig; -import org.onosproject.net.behaviour.ControllerInfo; -import org.onosproject.net.device.DeviceService; -import org.onosproject.net.driver.AbstractHandlerBehaviour; -import org.onosproject.net.driver.DriverHandler; -import org.onosproject.ovsdb.controller.OvsdbBridge; -import org.onosproject.ovsdb.controller.OvsdbClientService; -import org.onosproject.ovsdb.controller.OvsdbController; -import org.onosproject.ovsdb.controller.OvsdbNodeId; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import static com.google.common.base.Preconditions.checkState; -import static org.onlab.util.Tools.delay; - -/** - * Implementation of controller config which allows to get and set controllers. - */ -public class OvsdbControllerConfig extends AbstractHandlerBehaviour implements ControllerConfig { - @Override - public List<ControllerInfo> getControllers() { - DriverHandler handler = handler(); - OvsdbClientService clientService = getOvsdbClientService(handler); - Set<ControllerInfo> controllers = clientService.getControllers( - handler().data().deviceId()); - return new ArrayList<>(controllers); - } - - @Override - public void setControllers(List<ControllerInfo> controllers) { - DriverHandler handler = handler(); - OvsdbClientService clientService = getOvsdbClientService(handler); - if (!clientService.getControllers(handler().data().deviceId()) - .equals(ImmutableSet.copyOf(controllers))) { - clientService.setControllersWithDeviceId(handler(). - data().deviceId(), controllers); - } - } - - // Used for getting OvsdbClientService. - private OvsdbClientService getOvsdbClientService(DriverHandler handler) { - OvsdbController ovsController = handler.get(OvsdbController.class); - DeviceService deviceService = handler.get(DeviceService.class); - DeviceId ofDeviceId = handler.data().deviceId(); - String[] mgmtAddress = deviceService.getDevice(ofDeviceId) - .annotations().value(AnnotationKeys.MANAGEMENT_ADDRESS).split(":"); - String targetIp = mgmtAddress[0]; - TpPort targetPort = null; - if (mgmtAddress.length > 1) { - targetPort = TpPort.tpPort(Integer.parseInt(mgmtAddress[1])); - } - - List<OvsdbNodeId> nodeIds = ovsController.getNodeIds().stream() - .filter(nodeId -> nodeId.getIpAddress().equals(targetIp)) - .collect(Collectors.toList()); - if (nodeIds.size() == 0) { - //TODO decide what port? - ovsController.connect(IpAddress.valueOf(targetIp), - targetPort == null ? TpPort.tpPort(6640) : targetPort); - delay(1000); //FIXME... connect is async - } - List<OvsdbClientService> clientServices = ovsController.getNodeIds().stream() - .filter(nodeId -> nodeId.getIpAddress().equals(targetIp)) - .map(ovsController::getOvsdbClient) - .filter(cs -> cs.getBridges().stream().anyMatch(b -> dpidMatches(b, ofDeviceId))) - .collect(Collectors.toList()); - checkState(clientServices.size() > 0, "No clientServices found"); - //FIXME add connection to management address if null --> done ? - return clientServices.size() > 0 ? clientServices.get(0) : null; - } - - private static boolean dpidMatches(OvsdbBridge bridge, DeviceId deviceId) { - String bridgeDpid = "of:" + bridge.datapathId().value(); - String ofDpid = deviceId.toString(); - return bridgeDpid.equals(ofDpid); - } -}
\ No newline at end of file diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbTunnelConfig.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbTunnelConfig.java deleted file mode 100644 index ad90ca44..00000000 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb/OvsdbTunnelConfig.java +++ /dev/null @@ -1,142 +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.driver.ovsdb; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import org.onlab.packet.IpAddress; -import org.onosproject.net.DefaultAnnotations; -import org.onosproject.net.DeviceId; -import org.onosproject.net.behaviour.BridgeName; -import org.onosproject.net.behaviour.DefaultTunnelDescription; -import org.onosproject.net.behaviour.IpTunnelEndPoint; -import org.onosproject.net.behaviour.TunnelConfig; -import org.onosproject.net.behaviour.TunnelDescription; -import org.onosproject.net.behaviour.TunnelName; -import org.onosproject.net.driver.AbstractHandlerBehaviour; -import org.onosproject.net.driver.DriverHandler; -import org.onosproject.ovsdb.controller.OvsdbClientService; -import org.onosproject.ovsdb.controller.OvsdbController; -import org.onosproject.ovsdb.controller.OvsdbNodeId; -import org.onosproject.ovsdb.controller.OvsdbTunnel; - -/** - * OVSDB-based implementation of tunnel config behaviour. - */ -public class OvsdbTunnelConfig extends AbstractHandlerBehaviour - implements TunnelConfig { - - private static final String DEFAULT_ADDRESS = "0.0.0.0"; - private static final String OPTION_LOCAL_IP = "local_ip"; - private static final String OPTION_REMOTE_IP = "remote_ip"; - - @Override - public void createTunnel(TunnelDescription tunnel) { - DriverHandler handler = handler(); - OvsdbClientService ovsdbNode = getOvsdbNode(handler); - IpTunnelEndPoint ipSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress - .valueOf(DEFAULT_ADDRESS)); - IpTunnelEndPoint ipDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress - .valueOf(DEFAULT_ADDRESS)); - if (tunnel.src() instanceof IpTunnelEndPoint) { - ipSrc = (IpTunnelEndPoint) tunnel.src(); - } - if (tunnel.dst() instanceof IpTunnelEndPoint) { - ipDst = (IpTunnelEndPoint) tunnel.dst(); - } - //Even if source point ip or destination point ip equals 0:0:0:0, it is still work-in-progress. - ovsdbNode.createTunnel(ipSrc.ip(), ipDst.ip()); - } - - @Override - public boolean createTunnelInterface(BridgeName bridgeName, TunnelDescription tunnel) { - Map<String, String> options = ((DefaultAnnotations) tunnel.annotations()).asMap(); - if (tunnel.src() != null) { - options.put(OPTION_LOCAL_IP, ((IpTunnelEndPoint) tunnel.src()).ip().toString()); - } - if (tunnel.dst() != null) { - options.put(OPTION_REMOTE_IP, ((IpTunnelEndPoint) tunnel.dst()).ip().toString()); - } - - DriverHandler handler = handler(); - OvsdbClientService ovsdbClient = getOvsdbNode(handler); - return ovsdbClient.createTunnel(bridgeName.name(), tunnel.tunnelName().toString(), - tunnel.type().toString().toLowerCase(), options); - } - - @Override - public void removeTunnel(TunnelDescription tunnel) { - DriverHandler handler = handler(); - OvsdbClientService ovsdbNode = getOvsdbNode(handler); - IpTunnelEndPoint ipSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress - .valueOf(DEFAULT_ADDRESS)); - IpTunnelEndPoint ipDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress - .valueOf(DEFAULT_ADDRESS)); - if (tunnel.src() instanceof IpTunnelEndPoint) { - ipSrc = (IpTunnelEndPoint) tunnel.src(); - } - if (tunnel.dst() instanceof IpTunnelEndPoint) { - ipDst = (IpTunnelEndPoint) tunnel.dst(); - } - //Even if source point ip or destination point ip equals 0:0:0:0, it is still work-in-progress. - ovsdbNode.dropTunnel(ipSrc.ip(), ipDst.ip()); - } - - @Override - public void updateTunnel(TunnelDescription tunnel) { - // TODO Auto-generated method stub - - } - - @Override - public Collection<TunnelDescription> getTunnels() { - DriverHandler handler = handler(); - OvsdbClientService ovsdbNode = getOvsdbNode(handler); - Set<OvsdbTunnel> tunnels = ovsdbNode.getTunnels(); - - return tunnels.stream() - .map(x -> - new DefaultTunnelDescription( - IpTunnelEndPoint.ipTunnelPoint(x.localIp()), - IpTunnelEndPoint.ipTunnelPoint(x.remoteIp()), - TunnelDescription.Type.VXLAN, - TunnelName.tunnelName(x.tunnelName().toString()) - ) - ) - .collect(Collectors.toSet()); - } - - // OvsdbNodeId(IP) is used in the adaptor while DeviceId(ovsdb:IP) - // is used in the core. So DeviceId need be changed to OvsdbNodeId. - private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) { - String[] splits = deviceId.toString().split(":"); - if (splits == null || splits.length < 1) { - return null; - } - IpAddress ipAddress = IpAddress.valueOf(splits[1]); - return new OvsdbNodeId(ipAddress, 0); - } - - private OvsdbClientService getOvsdbNode(DriverHandler handler) { - OvsdbController ovsController = handler.get(OvsdbController.class); - DeviceId deviceId = handler.data().deviceId(); - OvsdbNodeId nodeId = changeDeviceIdToNodeId(deviceId); - return ovsController.getOvsdbClient(nodeId); - } -} diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb/package-info.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb/package-info.java deleted file mode 100644 index 8d878a50..00000000 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/ovsdb/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. - */ - -/** - * Implementations of OVSDB protocol configurations. - */ -package org.onosproject.driver.ovsdb;
\ No newline at end of file |