/** * Returns true if device does not accept flow rules, false otherwise. * * @param deviceId the device * @return true if device does not accept flow rule, false otherwise */ private boolean isNoFlowRule(DeviceId deviceId) { return NO_FLOWRULE_DEVICES.contains( Optional.ofNullable(deviceService.getDevice(deviceId)) .map(Device::type) .orElse(Type.OTHER)); }
@Override public void requestPackets(PacketRequest request) { DeviceId deviceid = request.deviceId().orElse(null); if (deviceid != null) { Device device = deviceService.getDevice(deviceid); if (device != null) { pushRule(deviceService.getDevice(deviceid), request); } } else { pushToAllDevices(request); } }
@Override public DomainId getDomain(DeviceId deviceId) { checkNotNull(deviceId); return Optional.ofNullable(deviceService.getDevice(deviceId)) .map(this::getAnnotatedDomainId) .orElse(null); }
@Override public void cancelPackets(PacketRequest request) { DeviceId deviceid = request.deviceId().orElse(null); if (deviceid != null) { Device device = deviceService.getDevice(deviceid); if (device != null) { removeRule(deviceService.getDevice(deviceid), request); } } else { removeFromAllDevices(request); } } }
/** * Returns true if device is wavelength transparent, false otherwise. * * @param deviceId the device * @return true if wavelength transparent, false otherwise */ private boolean isTransparent(DeviceId deviceId) { return TRANSPARENT_DEVICES.contains( Optional.ofNullable(deviceService.getDevice(deviceId)) .map(Device::type) .orElse(Type.OTHER)); } }
@Override public Iterator<Device> getClassifierOfTenant(TenantId tenantId) { checkNotNull(tenantId, TENANTID_NOT_NULL); Set<DeviceId> deviceIdSet = classifierOvsMap.get(tenantId); Set<Device> deviceSet = new HashSet<>(); if (deviceIdSet != null) { for (DeviceId deviceId : deviceIdSet) { deviceSet.add(deviceService.getDevice(deviceId)); } } return deviceSet.iterator(); }
@Override public Iterator<Device> getSffOfTenant(TenantId tenantId) { checkNotNull(tenantId, TENANTID_NOT_NULL); Set<DeviceId> deviceIdSet = sffOvsMap.get(tenantId); Set<Device> deviceSet = new HashSet<>(); if (deviceIdSet != null) { for (DeviceId deviceId : deviceIdSet) { deviceSet.add(deviceService.getDevice(deviceId)); } } return deviceSet.iterator(); }
@Override public void triggerProbe(DeviceId deviceId) { final Device device = deviceService.getDevice(deviceId); if (device != null) { filterAndTriggerTasks(Collections.singleton(device)); } }
@Override public Iterator<Device> getClassifierOfTenant(TenantId tenantId) { checkNotNull(tenantId, TENANTID_NOT_NULL); Set<DeviceId> deviceIdSet = classifierOvsMap.get(tenantId); Set<Device> deviceSet = new HashSet<>(); if (deviceIdSet != null) { for (DeviceId deviceId : deviceIdSet) { deviceSet.add(deviceService.getDevice(deviceId)); } } return deviceSet.iterator(); }
private Device getDevice(DeviceId deviceId) throws PiTranslationException { final Device device = deviceService.getDevice(deviceId); if (device == null) { throw new PiTranslationException("Unable to get device " + deviceId); } return device; }
@Override public Iterator<Device> getSffOfTenant(TenantId tenantId) { checkNotNull(tenantId, TENANTID_NOT_NULL); Set<DeviceId> deviceIdSet = sffOvsMap.get(tenantId); Set<Device> deviceSet = new HashSet<>(); if (deviceIdSet != null) { for (DeviceId deviceId : deviceIdSet) { deviceSet.add(deviceService.getDevice(deviceId)); } } return deviceSet.iterator(); }
private Device getDeviceByDpid(String dpid){ DeviceId deviceId = DeviceId.deviceId("of:" + dpid); return deviceService.getDevice(deviceId); }
private FlowRuleProgrammable getFlowRuleProgrammable(DeviceId deviceId) { Device device = deviceService.getDevice(deviceId); if (device.is(FlowRuleProgrammable.class)) { return device.as(FlowRuleProgrammable.class); } else { log.debug("Device {} is not flow rule programmable", deviceId); return null; } }
private GroupProgrammable getGroupProgrammable(DeviceId deviceId) { Device device = deviceService.getDevice(deviceId); if (device.is(GroupProgrammable.class)) { return device.as(GroupProgrammable.class); } else { log.debug("Device {} is not group programmable", deviceId); return null; } }
private MeterProgrammable getMeterProgrammable(DeviceId deviceId) { Device device = deviceService.getDevice(deviceId); if (device.is(MeterProgrammable.class)) { return device.as(MeterProgrammable.class); } else { log.debug("Device {} is not meter programmable", deviceId); return null; } }
@Override public void triggerProbe(DeviceId deviceId) { if (mastershipService.isLocalMaster(deviceId)) { triggerProbe(deviceService.getDevice(deviceId)); } }
@Override public void emit(OutboundPacket packet) { if (packet != null) { DeviceId deviceId = packet.sendThrough(); Device device = deviceService.getDevice(deviceId); if (device.is(PacketProgrammable.class)) { PacketProgrammable packetProgrammable = device.as(PacketProgrammable.class); packetProgrammable.emit(packet); } else { log.info("No PacketProgrammable behavior for device {}", deviceId); } } }
private void localEmit(OutboundPacket packet) { Device device = deviceService.getDevice(packet.sendThrough()); if (device == null) { return; } PacketProvider packetProvider = getProvider(device.providerId()); if (packetProvider != null) { packetProvider.emit(packet); } }
/** * Returns PCEP client. * * @return PCEP client */ private PcepClient getPcepClient(DeviceId deviceId) { Device device = deviceService.getDevice(deviceId); // In future projections instead of annotations will be used to fetch LSR ID. String lsrId = device.annotations().value(LSR_ID); PcepClient pcc = clientController.getClient(PccId.pccId(IpAddress.valueOf(lsrId))); return pcc; } }
/** * Returns PCEP client. * * @return PCEP client */ private PcepClient getPcepClient(DeviceId deviceId) { Device device = deviceService.getDevice(deviceId); // In future projections instead of annotations will be used to fetch LSR ID. String lsrId = device.annotations().value(LSRID); PcepClient pcc = clientController.getClient(PccId.pccId(IpAddress.valueOf(lsrId))); return pcc; } }