Search in sources :

Example 81 with PortDescription

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

the class DellRestPortDiscovery method getPorts.

@Deprecated
public List<PortDescription> getPorts() {
    List<PortDescription> ports = Lists.newArrayList();
    DriverHandler handler = handler();
    RestSBController controller = checkNotNull(handler.get(RestSBController.class));
    DeviceId deviceId = handler.data().deviceId();
    String remotePortName = "";
    // read configuration from REST API
    HierarchicalConfiguration config = XmlConfigParser.loadXml(controller.get(deviceId, INTERFACES_REQUEST, MediaType.valueOf("*/*")));
    // get the interfaces part
    List<HierarchicalConfiguration> portsConfig = parseDellPorts(config);
    portsConfig.stream().forEach(sub -> {
        String portName = sub.getString(NAME);
        DefaultAnnotations.Builder annotations = DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, portName);
        // TODO: obtain proper port speed and type
        long portSpeed = 10_000;
        Port.Type portType = Port.Type.COPPER;
        PortNumber portNumber = PortNumber.fromString(remotePortName.replaceAll(TENGINTERFACENAME, ""));
        ports.add(DefaultPortDescription.builder().withPortNumber(portNumber).isEnabled(true).type(portType).portSpeed(portSpeed).annotations(annotations.build()).build());
    });
    return ImmutableList.copyOf(ports);
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DeviceId(org.onosproject.net.DeviceId) Port(org.onosproject.net.Port) DefaultPortDescription(org.onosproject.net.device.DefaultPortDescription) PortDescription(org.onosproject.net.device.PortDescription) HierarchicalConfiguration(org.apache.commons.configuration.HierarchicalConfiguration) RestSBController(org.onosproject.protocol.rest.RestSBController) DriverHandler(org.onosproject.net.driver.DriverHandler) PortNumber(org.onosproject.net.PortNumber)

Aggregations

PortDescription (org.onosproject.net.device.PortDescription)81 DefaultPortDescription (org.onosproject.net.device.DefaultPortDescription)41 Test (org.junit.Test)25 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)25 PortNumber (org.onosproject.net.PortNumber)24 DeviceId (org.onosproject.net.DeviceId)23 ArrayList (java.util.ArrayList)22 Port (org.onosproject.net.Port)22 DeviceEvent (org.onosproject.net.device.DeviceEvent)14 ProviderId (org.onosproject.net.provider.ProviderId)13 Device (org.onosproject.net.Device)12 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)11 DefaultPort (org.onosproject.net.DefaultPort)9 DeviceService (org.onosproject.net.device.DeviceService)9 NetconfSession (org.onosproject.netconf.NetconfSession)8 IOException (java.io.IOException)7 HashMap (java.util.HashMap)7 OduCltPortHelper.oduCltPortDescription (org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription)7 OmsPortHelper.omsPortDescription (org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription)7 OchPortHelper.ochPortDescription (org.onosproject.net.optical.device.OchPortHelper.ochPortDescription)6