@Override public String value(String key) { if (filtered.contains(key)) { return null; } return delegate.value(key); }
/** * Get the ControllerIp from the device . * * @param device Device * @return Controller Ip */ public static String getControllerIpOfSwitch(Device device) { String url = device.annotations().value(SWITCH_CHANNEL_ID); return url.substring(0, url.lastIndexOf(":")); }
@Override public String toString() { Map<String, String> mapView = new HashMap<>(); keys().forEach(key -> mapView.put(key, delegate.value(key))); return mapView.toString(); } }
/** * Get the ControllerIp from the device . * * @param device Device * @return Controller Ip */ public String getControllerIpOfSwitch(Device device) { String url = device.annotations().value(SWITCH_CHANNEL_ID); return url.substring(0, url.lastIndexOf(":")); }
private boolean canMarkOnline(Device device) { final boolean providerMarkOnline = Boolean.parseBoolean( device.annotations().value(AnnotationKeys.PROVIDER_MARK_ONLINE)); return !providerMarkOnline; }
/** * Returns OpenstackPort object for the Port reference given. * * @param port Port object * @return OpenstackPort reference, or null when not found */ public OpenstackPort openstackPort(Port port) { String uuid = port.annotations().value(PORT_NAME).substring(3); return openstackPortList.stream().filter(p -> p.id().startsWith(uuid)) .findAny().orElse(null); }
@Override public ObjectNode encode(Annotations annotations, CodecContext context) { ObjectNode result = context.mapper().createObjectNode(); Set<String> keys = new TreeSet<>(annotations.keys()); for (String key : keys) { result.put(key, annotations.value(key)); } return result; }
private PortNumber getTunnelPort(DeviceId deviceId) { Port port = deviceService.getPorts(deviceId).stream() .filter(p -> p.annotations().value(PORT_NAME).equals( OpenstackSwitchingManager.PORTNAME_PREFIX_TUNNEL)) .findAny().orElse(null); if (port == null) { log.error("No TunnelPort was created."); return null; } return port.number(); }
@Override public OpenstackPort port(Port port) { String uuid = port.annotations().value(PORT_NAME).substring(3); return getPorts().stream() .filter(p -> p.id().startsWith(uuid)) .findAny().orElse(null); }
protected Optional<Host> getVmByPortId(String portId) { return Tools.stream(hostService.getHosts()) .filter(this::isValidHost) .filter(host -> host.annotations().value(PORT_ID).equals(portId)) .findFirst(); }
private PortNumber getVxlanPortNumber(DeviceId deviceId) { Iterable<Port> ports = deviceService.getPorts(deviceId); Port vxlanPort = Sets.newHashSet(ports).stream() .filter(p ->!p.number().equals(PortNumber.LOCAL)) .filter(p ->p.annotations().value(AnnotationKeys.PORT_NAME) .startsWith(VXLANPORT_HEAD)) .findFirst().get(); return vxlanPort.number(); } }
private String getPortStatStr(PortStatistics stat, Port port) { final String portName = port.annotations().value(AnnotationKeys.PORT_NAME); return String.format("port: %s(%s), ", stat.portNumber(), portName) + String.format("enabled: %b, ", port.isEnabled()) + String.format("pktRx: %d, ", stat.packetsReceived()) + String.format("pktTx: %d, ", stat.packetsSent()) + String.format("pktRxErr: %d, ", stat.packetsRxErrors()) + String.format("pktTxErr: %d, ", stat.packetsTxErrors()) + String.format("pktRxDrp: %d, ", stat.packetsRxDropped()) + String.format("pktTxDrp: %d", stat.packetsTxDropped()); }
private DomainId getAnnotatedDomainId(Device device) { if (!device.annotations().keys().contains(DOMAIN_ID)) { return DomainId.LOCAL; } else { return DomainId.domainId( device.annotations().value(DOMAIN_ID)); } } }
private void invalidatePipelinerIfNecessary(Device device) { DriverHandler handler = driverHandlers.get(device.id()); if (handler != null && !Objects.equals(handler.driver().name(), device.annotations().value(DRIVER))) { invalidatePipeliner(device.id()); } }
@Override public void onControllerVanished(Device controllerDevice) { if (controllerDevice == null) { log.error("The device is null"); return; } String dstIp = controllerDevice.annotations().value(CONTROLLER_IP_KEY); IpAddress dstIpAddress = IpAddress.valueOf(dstIp); DeviceId controllerDeviceId = controllerDevice.id(); if (mastershipService.isLocalMaster(controllerDeviceId)) { switchesOfController.remove(dstIpAddress); } }
@Override public DeviceId getSfToSffMaping(VirtualPortId portId) { checkNotNull(portId, "portId cannot be null"); VirtualPort vmPort = virtualPortService.getPort(portId); Set<Host> hostSet = hostService.getHostsByMac(vmPort.macAddress()); for (Host host : hostSet) { if (host.annotations().value(IFACEID).equals(vmPort.portId().portId())) { return host.location().deviceId(); } } return null; }
@Override public DeviceId getSfToSffMaping(VirtualPortId portId) { checkNotNull(portId, "portId cannot be null"); VirtualPort vmPort = virtualPortService.getPort(portId); Set<Host> hostSet = hostService.getHostsByMac(vmPort.macAddress()); for (Host host : hostSet) { if (host.annotations().value(IFACEID).equals(vmPort.portId().portId())) { return host.location().deviceId(); } } return null; }
private ConnectPoint staticPort(ConnectPoint connectPoint) { Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port()); String staticPort = port.annotations().value(AnnotationKeys.STATIC_PORT); // FIXME: need a better way to match the port if (staticPort != null) { for (Port p : deviceService.getPorts(connectPoint.deviceId())) { if (staticPort.equals(p.number().name())) { return new ConnectPoint(p.element().id(), p.number()); } } } return null; }
private ConnectPoint staticPort(ConnectPoint connectPoint) { Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port()); String staticPort = port.annotations().value(AnnotationKeys.STATIC_PORT); // FIXME: need a better way to match the port if (staticPort != null) { for (Port p : deviceService.getPorts(connectPoint.deviceId())) { if (staticPort.equals(p.number().name())) { return new ConnectPoint(p.element().id(), p.number()); } } } return null; }