/** * Returns the list of devices sorted using the device ID URIs. * * @param service device service * @return sorted device list */ public static List<Device> getSortedDevices(DeviceService service) { List<Device> devices = newArrayList(service.getDevices()); Collections.sort(devices, Comparators.ELEMENT_COMPARATOR); return devices; }
private void triggerCheckAllDevices() { filterAndTriggerTasks(deviceService.getDevices()); }
@Override public void initPolicy(String policy) { checkPermission(FLOWRULE_WRITE); this.policy = policy; deviceService.getDevices().forEach(device -> this.deviceCompositionTreeMap.put(device.id(), FlowObjectiveCompositionUtil.parsePolicyString(policy))); log.info("Initialize policy {}", policy); }
@Activate protected void activate() { executorService = newFixedThreadPool(4, groupedThreads("onos/objective-installer", "%d", log)); flowObjectiveStore.setDelegate(delegate); mastershipService.addListener(mastershipListener); deviceService.addListener(deviceListener); deviceService.getDevices().forEach(device -> setupPipelineHandler(device.id())); deviceCompositionTreeMap = Maps.newConcurrentMap(); log.info("Started"); }
/** * Returns the list of table statistics sorted using the device ID URIs and table IDs. * * @param deviceService device service * @param flowService flow rule service * @return sorted table statistics list */ protected SortedMap<Device, List<TableStatisticsEntry>> getSortedTableStats(DeviceService deviceService, FlowRuleService flowService) { SortedMap<Device, List<TableStatisticsEntry>> deviceTableStats = new TreeMap<>(Comparators.ELEMENT_COMPARATOR); List<TableStatisticsEntry> tableStatsList; Iterable<Device> devices = uri == null ? deviceService.getDevices() : Collections.singletonList(deviceService.getDevice(DeviceId.deviceId(uri))); for (Device d : devices) { tableStatsList = newArrayList(flowService.getFlowTableStatistics(d.id())); tableStatsList.sort((p1, p2) -> Integer.valueOf(p1.tableId()).compareTo(Integer.valueOf(p2.tableId()))); deviceTableStats.put(d, tableStatsList); } return deviceTableStats; }
@Deprecated @Override public Iterable<FlowRule> getFlowRulesById(ApplicationId id) { checkPermission(FLOWRULE_READ); Set<FlowRule> flowEntries = Sets.newHashSet(); for (Device d : deviceService.getDevices()) { for (FlowEntry flowEntry : store.getFlowEntries(d.id())) { if (flowEntry.appId() == id.id()) { flowEntries.add(flowEntry); } } } return flowEntries; }
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { // Delegate string completer StringsCompleter delegate = new StringsCompleter(); // Fetch our service and feed it's offerings to the string completer DeviceService service = AbstractShellCommand.get(DeviceService.class); Iterator<Device> it = service.getDevices().iterator(); SortedSet<String> strings = delegate.getStrings(); while (it.hasNext()) { strings.add(it.next().id().toString()); } // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
.map(deviceService::getDevice) .map(dev -> (Iterable<Device>) Collections.singletonList(dev)) .orElse(deviceService.getDevices());
@Override public Iterable<FlowEntry> getFlowEntriesById(ApplicationId id) { checkPermission(FLOWRULE_READ); Set<FlowEntry> flowEntries = Sets.newHashSet(); for (Device d : deviceService.getDevices()) { for (FlowEntry flowEntry : store.getFlowEntries(d.id())) { if (flowEntry.appId() == id.id()) { flowEntries.add(flowEntry); } } } return flowEntries; }
devices = deviceService.getDevices(); } else { Device dev = deviceService.getDevice(DeviceId.deviceId(uri)); devices = (dev == null) ? deviceService.getDevices() : Collections.singletonList(dev);
/** * Pushes a packet request flow rule to all devices. * * @param request the packet request */ private void pushToAllDevices(PacketRequest request) { log.debug("Pushing packet request {} to all devices", request); for (Device device : deviceService.getDevices()) { try { Driver driver = driverService.getDriver(device.id()); if (driver != null && Boolean.parseBoolean(driver.getProperty(SUPPORT_PACKET_REQUEST_PROPERTY))) { pushRule(device, request); } } catch (ItemNotFoundException e) { log.warn("Device driver not found for {}; not processing packet request {}", device.id(), request); } } }
@Override public Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId) { checkPermission(FLOWRULE_READ); Set<FlowRule> matches = Sets.newHashSet(); long toLookUp = ((long) appId.id() << 16) | groupId; for (Device d : deviceService.getDevices()) { for (FlowEntry flowEntry : store.getFlowEntries(d.id())) { if ((flowEntry.id().value() >>> 32) == toLookUp) { matches.add(flowEntry); } } } return matches; }
Collection<OpenstackSubnet> subnets = openstackService.subnets(); deviceService.getDevices().forEach(device -> { log.debug("device {} num of ports {} ", device.id(), deviceService.getPorts(device.id()).size());
deviceService.getDevices().forEach(device -> printCount(device, service)); } else { Device device = deviceService.getDevice(DeviceId.deviceId(uri));
@Override public int complete(Session session, CommandLine commandLine, List<String> candidates) { // Delegate string completer StringsCompleter delegate = new StringsCompleter(); // Fetch our service and feed it's offerings to the string completer DeviceService service = AbstractShellCommand.get(DeviceService.class); // Generate the device ID/port number identifiers for (Device device : service.getDevices()) { SortedSet<String> strings = delegate.getStrings(); for (Port port : service.getPorts(device.id())) { if (!port.number().isLogical()) { strings.add(device.id().toString() + "/" + port.number()); } } } // Now let the completer do the work for figuring out what to offer. return delegate.complete(session, commandLine, candidates); }
Iterable<Device> devices = deviceService.getDevices(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setOutput(PortNumber.portNumber(RandomUtils.nextInt(MAX_OUT_PORT))).build();