@Override public void deletePort(PortDescription port) { DriverHandler handler = handler(); OvsdbClientService ovsdbNode = getOvsdbNode(handler); Set<OvsdbBridge> ovsdbSet = ovsdbNode.getBridges(); if (ovsdbSet != null && ovsdbSet.size() > 0) { OvsdbBridge bridge = ovsdbSet.iterator().next(); ovsdbNode.dropPort(bridge.bridgeName().toString(), port.portNumber().toString()); } }
@Override public Collection<PortDescription> getPorts() { DriverHandler handler = handler(); OvsdbClientService ovsdbNode = getOvsdbNode(handler); Set<OvsdbPort> ovsdbSet = ovsdbNode.getPorts(); Collection<PortDescription> ports = Sets.newHashSet(); ovsdbSet.forEach( o -> { PortNumber port = PortNumber.portNumber(o.portNumber().value()); PortDescription description = new DefaultPortDescription(port, true); ports.add(description); }); return ports; }
@Override public Collection<BridgeDescription> getBridges() { DriverHandler handler = handler(); DeviceId deviceId = handler.data().deviceId(); OvsdbClientService ovsdbNode = getOvsdbNode(handler); Set<OvsdbBridge> ovsdbSet = ovsdbNode.getBridges(); Collection<BridgeDescription> bridges = Sets.newHashSet(); ovsdbSet.forEach( o -> { BridgeName bridgeName = BridgeName.bridgeName(o.bridgeName().toString()); DeviceId ownDeviceId = DeviceId.deviceId(o.datapathId().toString()); BridgeDescription description = new DefaultBridgeDescription(bridgeName, deviceId, ownDeviceId); bridges.add(description); }); return bridges; }
@Override public void deleteBridge(BridgeName bridgeName) { DriverHandler handler = handler(); OvsdbClientService ovsdbNode = getOvsdbNode(handler); ovsdbNode.dropBridge(bridgeName.name()); }