Java Code Examples for org.onosproject.net.Device#Type
The following examples show how to use
org.onosproject.net.Device#Type .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IsisTopologyProvider.java From onos with Apache License 2.0 | 6 votes |
@Override public void routerAdded(IsisRouter isisRouter) { String systemId = isisRouter.systemId(); log.info("Added device {}", systemId); DeviceId deviceId = DeviceId.deviceId(IsisRouterId.uri(systemId)); Device.Type deviceType = Device.Type.ROUTER; //If our routerType is Dr or Bdr type is PSEUDO if (isisRouter.isDis()) { deviceType = Device.Type.ROUTER; } else { deviceType = Device.Type.VIRTUAL; } ChassisId cId = new ChassisId(); DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); newBuilder.set(AnnotationKeys.TYPE, "L3"); newBuilder.set("RouterId", systemId); DeviceDescription description = new DefaultDeviceDescription(IsisRouterId.uri(systemId), deviceType, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, cId, newBuilder.build()); deviceProviderService.deviceConnected(deviceId, description); System.out.println("Device added: " + systemId); }
Example 2
Source File: LldpLinkProviderTest.java From onos with Apache License 2.0 | 6 votes |
@Test public void updateDeviceTypeRule() { Device.Type deviceType1 = Device.Type.ROADM; Device.Type deviceType2 = Device.Type.SWITCH; Set<Device.Type> deviceTypes = new HashSet<>(); deviceTypes.add(deviceType1); cfg.deviceTypes(deviceTypes); configEvent(NetworkConfigEvent.Type.CONFIG_ADDED); deviceTypes.add(deviceType2); cfg.deviceTypes(deviceTypes); configEvent(NetworkConfigEvent.Type.CONFIG_UPDATED); assertAfter(EVENT_MS, () -> { assertTrue(provider.rules().getSuppressedDeviceType().contains(deviceType1)); assertTrue(provider.rules().getSuppressedDeviceType().contains(deviceType2)); }); }
Example 3
Source File: OpticalPathProvisioner.java From onos with Apache License 2.0 | 5 votes |
/** * Verifies if given link forms a cross-connection between packet and optical layer. * * @param link the link * @return true if the link is a cross-connect link, false otherwise */ private boolean isCrossConnectLink(Link link) { if (link.type() != Link.Type.OPTICAL) { return false; } Device.Type src = deviceService.getDevice(link.src().deviceId()).type(); Device.Type dst = deviceService.getDevice(link.dst().deviceId()).type(); return src != dst && ((isPacketLayer(src) && isTransportLayer(dst)) || (isPacketLayer(dst) && isTransportLayer(src))); }
Example 4
Source File: BasicDeviceOperator.java From onos with Apache License 2.0 | 5 votes |
/** * Generates a DeviceDescription containing fields from a DeviceDescription and * a DeviceConfig. * * @param cfg the device config entity from network config * @param descr a DeviceDescription * @return DeviceDescription based on both sources */ public static DeviceDescription combine(BasicDeviceConfig cfg, DeviceDescription descr) { if (cfg == null || descr == null) { return descr; } Device.Type type = descr.type(); if (cfg.type() != null && cfg.type() != type) { type = cfg.type(); } String manufacturer = descr.manufacturer(); if (cfg.manufacturer() != null && !cfg.manufacturer().equals(manufacturer)) { manufacturer = cfg.manufacturer(); } String hwVersion = descr.hwVersion(); if (cfg.hwVersion() != null && !cfg.hwVersion().equals(hwVersion)) { hwVersion = cfg.hwVersion(); } String swVersion = descr.swVersion(); if (cfg.swVersion() != null && !cfg.swVersion().equals(swVersion)) { swVersion = cfg.swVersion(); } String serial = descr.serialNumber(); if (cfg.serial() != null && !cfg.serial().equals(serial)) { serial = cfg.serial(); } SparseAnnotations sa = combine(cfg, descr.annotations()); return new DefaultDeviceDescription(descr.deviceUri(), type, manufacturer, hwVersion, swVersion, serial, descr.chassisId(), descr.isDefaultAvailable(), sa); }
Example 5
Source File: OpticalPathProvisionerTest.java From onos with Apache License 2.0 | 5 votes |
private static Device createDevice(long devIdNum, Device.Type type) { return new DefaultDevice(PROVIDER_ID, deviceIdOf(devIdNum), type, "manufacturer", "hwVersion", "swVersion", "serialNumber", new ChassisId(1)); }
Example 6
Source File: LldpLinkProviderTest.java From onos with Apache License 2.0 | 5 votes |
@Test public void addDeviceTypeRule() { Device.Type deviceType1 = Device.Type.ROADM; Device.Type deviceType2 = Device.Type.SWITCH; Set<Device.Type> deviceTypes = new HashSet<>(); deviceTypes.add(deviceType1); cfg.deviceTypes(deviceTypes); configEvent(NetworkConfigEvent.Type.CONFIG_ADDED); assertTrue(provider.rules().getSuppressedDeviceType().contains(deviceType1)); assertFalse(provider.rules().getSuppressedDeviceType().contains(deviceType2)); }
Example 7
Source File: ConfigOpticalDeviceDiscovery.java From onos with Apache License 2.0 | 5 votes |
@Override public DeviceDescription discoverDeviceDetails() { NetworkConfigService netcfg = handler().get(NetworkConfigService.class); DeviceId did = data().deviceId(); String unk = "UNKNOWN"; Optional<DeviceInjectionConfig> inject = Optional.ofNullable(netcfg.getConfig(did, DeviceInjectionConfig.class)); Optional<BasicDeviceConfig> basic = Optional.ofNullable(netcfg.getConfig(did, BasicDeviceConfig.class)); Device.Type type = basic.map(BasicDeviceConfig::type).orElse(Device.Type.SWITCH); String manufacturer = basic.map(BasicDeviceConfig::manufacturer).orElse(unk); String hwVersion = basic.map(BasicDeviceConfig::hwVersion).orElse(unk); String swVersion = basic.map(BasicDeviceConfig::swVersion).orElse(unk); String serialNumber = basic.map(BasicDeviceConfig::serial).orElse(unk); ChassisId chassis = new ChassisId(); // if inject is not specified, return default unavailable device boolean defaultAvailable = inject.isPresent(); return new DefaultDeviceDescription(did.uri(), type, manufacturer, hwVersion, swVersion, serialNumber, chassis, defaultAvailable); }
Example 8
Source File: VirtualNetworkDeviceManager.java From onos with Apache License 2.0 | 5 votes |
@Override public Iterable<Device> getDevices(Device.Type type) { checkNotNull(type, TYPE_NULL); return manager.getVirtualDevices(this.networkId) .stream() .filter(device -> type.equals(device.type())) .collect(Collectors.toSet()); }
Example 9
Source File: NetconfDeviceServiceMock.java From onos with Apache License 2.0 | 4 votes |
@Override public Iterable<Device> getDevices(Device.Type type) { return null; }
Example 10
Source File: BgpTopologyProvider.java From onos with Apache License 2.0 | 4 votes |
@Override public void addNode(BgpNodeLSNlriVer4 nodeNlri, PathAttrNlriDetails details) { log.debug("Add node {}", nodeNlri.toString()); if (deviceProviderService == null || deviceService == null) { return; } Device.Type deviceType = ROUTER; BgpDpid nodeUri = new BgpDpid(nodeNlri); DeviceId deviceId = deviceId(uri(nodeUri.toString())); ChassisId cId = new ChassisId(); /* * Check if device is already there (available) , if yes not updating to core. */ if (deviceService.isAvailable(deviceId)) { return; } DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); newBuilder.set(AnnotationKeys.TYPE, "L3"); newBuilder.set(ROUTING_UNIVERSE, Long.toString(nodeNlri.getIdentifier())); List<BgpValueType> tlvs = nodeNlri.getLocalNodeDescriptors().getNodedescriptors().getSubTlvs(); for (BgpValueType tlv : tlvs) { if (tlv instanceof AutonomousSystemTlv) { newBuilder.set(AS_NUMBER, Integer.toString(((AutonomousSystemTlv) tlv).getAsNum())); } else if (tlv instanceof BgpLSIdentifierTlv) { newBuilder.set(DOMAIN_IDENTIFIER, Integer.toString(((BgpLSIdentifierTlv) tlv).getBgpLsIdentifier())); } if (tlv.getType() == NodeDescriptors.IGP_ROUTERID_TYPE) { if (tlv instanceof IsIsPseudonode) { deviceType = VIRTUAL; newBuilder.set(AnnotationKeys.ROUTER_ID, nodeUri.isoNodeIdString(((IsIsPseudonode) tlv) .getIsoNodeId())); } else if (tlv instanceof OspfPseudonode) { deviceType = VIRTUAL; newBuilder .set(AnnotationKeys.ROUTER_ID, Integer.toString(((OspfPseudonode) tlv).getrouterID())); } else if (tlv instanceof IsIsNonPseudonode) { newBuilder.set(AnnotationKeys.ROUTER_ID, nodeUri.isoNodeIdString(((IsIsNonPseudonode) tlv) .getIsoNodeId())); } else if (tlv instanceof OspfNonPseudonode) { newBuilder.set(AnnotationKeys.ROUTER_ID, Integer.toString(((OspfNonPseudonode) tlv).getrouterID())); } } } DefaultAnnotations.Builder anntotations = DefaultAnnotations.builder(); anntotations = getAnnotations(newBuilder, true, details); DeviceDescription description = new DefaultDeviceDescription(uri(nodeUri.toString()), deviceType, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, cId, anntotations.build()); deviceProviderService.deviceConnected(deviceId, description); }
Example 11
Source File: OpenFlowSwitchAdapter.java From onos with Apache License 2.0 | 4 votes |
@Override public Device.Type deviceType() { return null; }
Example 12
Source File: OpenflowSwitchDriverAdapter.java From onos with Apache License 2.0 | 4 votes |
@Override public Device.Type deviceType() { return Device.Type.SWITCH; }
Example 13
Source File: CalientFiberSwitchHandshaker.java From onos with Apache License 2.0 | 4 votes |
@Override public Device.Type deviceType() { return Device.Type.FIBER_SWITCH; }
Example 14
Source File: LldpLinkProviderTest.java From onos with Apache License 2.0 | 4 votes |
@Override public Set<Device.Type> deviceTypes() { return ImmutableSet.copyOf(deviceTypes); }
Example 15
Source File: OpenFlowDeviceProviderTest.java From onos with Apache License 2.0 | 4 votes |
@Override public Device.Type deviceType() { return Device.Type.SWITCH; }
Example 16
Source File: OpenFlowGroupProviderTest.java From onos with Apache License 2.0 | 4 votes |
@Override public Device.Type deviceType() { return Device.Type.SWITCH; }
Example 17
Source File: OpenFlowPacketProviderTest.java From onos with Apache License 2.0 | 4 votes |
@Override public Device.Type deviceType() { return Device.Type.SWITCH; }
Example 18
Source File: DeviceDescription.java From onos with Apache License 2.0 | 2 votes |
/** * Returns the type of the infrastructure device. * * @return type of the device */ Device.Type type();
Example 19
Source File: DeviceService.java From onos with Apache License 2.0 | 2 votes |
/** * Returns an iterable collection of all devices currently available to the system by device type. * * @param type device type * @return device collection */ Iterable<Device> getAvailableDevices(Device.Type type);
Example 20
Source File: BasicDeviceConfig.java From onos with Apache License 2.0 | 2 votes |
/** * Returns the device type. * * @return device type override */ public Device.Type type() { return get(TYPE, null, Device.Type.class); }