Search in sources :

Example 1 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class DefaultKubevirtNode method tunnelPort.

private PortNumber tunnelPort(String tunnelType) {
    if (dataIp == null) {
        return null;
    }
    DeviceService deviceService = DefaultServiceDirectory.getService(DeviceService.class);
    Port port = deviceService.getPorts(tunBridge).stream().filter(p -> p.isEnabled() && Objects.equals(p.annotations().value(PORT_NAME), tunnelType)).findAny().orElse(null);
    return port != null ? port.number() : null;
}
Also used : Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService)

Example 2 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class MappingsListCommand method doExecute.

@Override
protected void doExecute() {
    MappingStore.Type typeEnum = getTypeEnum(type);
    DeviceService deviceService = get(DeviceService.class);
    Iterable<Device> devices = deviceService.getDevices();
    if (outputJson()) {
        print(JSON_FORMAT, json(typeEnum, devices));
    } else {
        if (deviceId != null) {
            mappings = newArrayList(mappingService.getMappingEntries(typeEnum, DeviceId.deviceId(deviceId)));
            printMappings(DeviceId.deviceId(deviceId), mappings);
        } else {
            for (Device d : devices) {
                mappings = newArrayList(mappingService.getMappingEntries(typeEnum, d.id()));
                printMappings(d.id(), mappings);
            }
        }
    }
}
Also used : Device(org.onosproject.net.Device) DeviceService(org.onosproject.net.device.DeviceService) MappingStore(org.onosproject.mapping.MappingStore)

Example 3 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class TsCheckLoop method doExecute.

@Override
protected void doExecute() {
    NetworkDiagnosticService service = getService(NetworkDiagnosticService.class);
    DeviceService ds = getService(DeviceService.class);
    HostService hs = getService(HostService.class);
    FlowRuleService frs = getService(FlowRuleService.class);
    LinkService ls = getService(LinkService.class);
    service.findAnomalies(NetworkDiagnostic.Type.LOOP).forEach(loop -> print(loop.toString()));
}
Also used : HostService(org.onosproject.net.host.HostService) DeviceService(org.onosproject.net.device.DeviceService) FlowRuleService(org.onosproject.net.flow.FlowRuleService) LinkService(org.onosproject.net.link.LinkService) NetworkDiagnosticService(org.onosproject.fnl.intf.NetworkDiagnosticService)

Example 4 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class ServiceApplicationComponent method createOpticalIntent.

/**
 * Returns a new optical intent created from the method parameters.
 *
 * @param ingress ingress description (device/port)
 * @param egress egress description (device/port)
 * @param key intent key
 * @param appId application id. As per Intent class, it cannot be null
 *
 * @return created intent
 */
protected Intent createOpticalIntent(ConnectPoint ingress, ConnectPoint egress, Key key, ApplicationId appId) {
    if (ingress == null || egress == null) {
        log.error("Invalid endpoint(s) for optical intent: ingress {}, egress {}", ingress, egress);
        return null;
    }
    DeviceService ds = opticalView(deviceService);
    Port srcPort = ds.getPort(ingress.deviceId(), ingress.port());
    Port dstPort = ds.getPort(egress.deviceId(), egress.port());
    if (srcPort == null || dstPort == null) {
        log.error("Invalid port(s) for optical intent: src {}, dst {}", srcPort, dstPort);
        return null;
    }
    OduSignalType signalType = ((OchPort) srcPort).signalType();
    return OpticalConnectivityIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(// TODO Revisit this.
    true).build();
}
Also used : OduSignalType(org.onosproject.net.OduSignalType) Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) DeviceService(org.onosproject.net.device.DeviceService) OchPort(org.onosproject.net.optical.OchPort)

Example 5 with DeviceService

use of org.onosproject.net.device.DeviceService in project onos by opennetworkinglab.

the class OpenstackNetworkingUtilTest method testHasIntfAleadyInDevice.

/**
 * Tests hasIntfAleadyInDevice method.
 */
@Test
public void testHasIntfAleadyInDevice() {
    DeviceService deviceService = new TestDeviceService();
    assertTrue(OpenstackNetworkingUtil.hasIntfAleadyInDevice(DeviceId.deviceId("deviceId"), "port1", deviceService));
    assertTrue(OpenstackNetworkingUtil.hasIntfAleadyInDevice(DeviceId.deviceId("deviceId"), "port2", deviceService));
    assertTrue(OpenstackNetworkingUtil.hasIntfAleadyInDevice(DeviceId.deviceId("deviceId"), "port3", deviceService));
    assertFalse(OpenstackNetworkingUtil.hasIntfAleadyInDevice(DeviceId.deviceId("deviceId"), "port4", deviceService));
}
Also used : DeviceService(org.onosproject.net.device.DeviceService) OpenstackNodeTest(org.onosproject.openstacknode.api.OpenstackNodeTest) Test(org.junit.Test) OpenstackFloatingIpWebResourceTest(org.onosproject.openstacknetworking.web.OpenstackFloatingIpWebResourceTest) OpenstackNetworkWebResourceTest(org.onosproject.openstacknetworking.web.OpenstackNetworkWebResourceTest)

Aggregations

DeviceService (org.onosproject.net.device.DeviceService)175 Device (org.onosproject.net.Device)72 DeviceId (org.onosproject.net.DeviceId)68 Port (org.onosproject.net.Port)55 ConnectPoint (org.onosproject.net.ConnectPoint)39 PortNumber (org.onosproject.net.PortNumber)38 List (java.util.List)27 Collectors (java.util.stream.Collectors)23 Set (java.util.Set)22 Logger (org.slf4j.Logger)19 ArrayList (java.util.ArrayList)18 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)18 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)17 Test (org.junit.Test)16 JsonNode (com.fasterxml.jackson.databind.JsonNode)15 Collections (java.util.Collections)15 Optional (java.util.Optional)15 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)15 IOException (java.io.IOException)14 Map (java.util.Map)13