Search in sources :

Example 81 with DriverHandler

use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.

the class VoltRebootOnuCommand method doExecute.

@Override
protected void doExecute() {
    DriverService service = get(DriverService.class);
    deviceId = DeviceId.deviceId(uri);
    DriverHandler h = service.createHandler(deviceId);
    VoltOnuOperConfig volt = h.behaviour(VoltOnuOperConfig.class);
    String reply = volt.rebootOnu(target);
    if (reply != null) {
        print("%s", reply);
    } else {
        print("No reply from %s", deviceId.toString());
    }
}
Also used : VoltOnuOperConfig(org.onosproject.drivers.fujitsu.behaviour.VoltOnuOperConfig) DriverHandler(org.onosproject.net.driver.DriverHandler) DriverService(org.onosproject.net.driver.DriverService)

Example 82 with DriverHandler

use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.

the class VoltSetAlertFilterCommand method doExecute.

@Override
protected void doExecute() {
    DriverService service = get(DriverService.class);
    deviceId = DeviceId.deviceId(uri);
    DriverHandler h = service.createHandler(deviceId);
    VoltAlertConfig volt = h.behaviour(VoltAlertConfig.class);
    volt.setAlertFilter(severity);
}
Also used : VoltAlertConfig(org.onosproject.drivers.fujitsu.behaviour.VoltAlertConfig) DriverHandler(org.onosproject.net.driver.DriverHandler) DriverService(org.onosproject.net.driver.DriverService)

Example 83 with DriverHandler

use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.

the class VoltSetOnuCommand method doExecute.

@Override
protected void doExecute() {
    DriverService service = get(DriverService.class);
    deviceId = DeviceId.deviceId(uri);
    DriverHandler h = service.createHandler(deviceId);
    VoltOnuConfig volt = h.behaviour(VoltOnuConfig.class);
    String reply = volt.setOnu(target);
    if (reply != null) {
        print("%s", reply);
    } else {
        print("No reply from %s", deviceId.toString());
    }
}
Also used : DriverHandler(org.onosproject.net.driver.DriverHandler) VoltOnuConfig(org.onosproject.drivers.fujitsu.behaviour.VoltOnuConfig) DriverService(org.onosproject.net.driver.DriverService)

Example 84 with DriverHandler

use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.

the class VoltSetPonLinkCommand method doExecute.

@Override
protected void doExecute() {
    DriverService service = get(DriverService.class);
    deviceId = DeviceId.deviceId(uri);
    DriverHandler h = service.createHandler(deviceId);
    VoltPonLinkConfig volt = h.behaviour(VoltPonLinkConfig.class);
    volt.setPonLink(target);
}
Also used : VoltPonLinkConfig(org.onosproject.drivers.fujitsu.behaviour.VoltPonLinkConfig) DriverHandler(org.onosproject.net.driver.DriverHandler) DriverService(org.onosproject.net.driver.DriverService)

Example 85 with DriverHandler

use of org.onosproject.net.driver.DriverHandler in project onos by opennetworkinglab.

the class LinkDiscoveryAristaImpl method createLinksDescs.

private Set<LinkDescription> createLinksDescs(Optional<JsonNode> response) {
    DriverHandler handler = checkNotNull(handler());
    DeviceId localDeviceId = checkNotNull(handler.data().deviceId());
    DeviceService deviceService = handler.get(DeviceService.class);
    Set<LinkDescription> linkDescriptions = Sets.newHashSet();
    List<Port> ports = deviceService.getPorts(localDeviceId);
    if (ports.isEmpty() || Objects.isNull(response)) {
        return linkDescriptions;
    }
    if (!response.isPresent()) {
        return linkDescriptions;
    }
    log.debug("response: {}, {}", response, localDeviceId.toString());
    JsonNode res = response.get();
    if (res == null) {
        log.warn("result is null");
        return linkDescriptions;
    }
    JsonNode lldpNeighbors = res.findValue(LLDP_NEIGHBORS);
    if (lldpNeighbors == null) {
        log.warn("{} is null", LLDP_NEIGHBORS);
        return linkDescriptions;
    }
    Iterator<Map.Entry<String, JsonNode>> lldpNeighborsIter = lldpNeighbors.fields();
    while (lldpNeighborsIter.hasNext()) {
        Map.Entry<String, JsonNode> neighbor = lldpNeighborsIter.next();
        String lldpLocalPort = neighbor.getKey();
        JsonNode neighborValue = neighbor.getValue();
        log.debug("lldpLocalPort: {}", lldpLocalPort);
        log.debug("neighborValue: {}", neighborValue.toString());
        if (lldpLocalPort.isEmpty()) {
            continue;
        }
        JsonNode neighborInfo = neighborValue.findValue(LLDP_NEIGHBOR_INFO);
        if (neighborInfo == null) {
            log.warn("{} is null", LLDP_NEIGHBOR_INFO);
            continue;
        }
        Iterator<JsonNode> neighborInfoIter = neighborInfo.elements();
        while (neighborInfoIter.hasNext()) {
            JsonNode info = neighborInfoIter.next();
            String chassisIdType = info.get(CHASSIS_ID_TYPE).asText("");
            if (chassisIdType == null) {
                log.warn("{} is null", CHASSIS_ID_TYPE);
                continue;
            }
            if (!chassisIdType.equals(CHASSIS_ID_TYPE_MAC)) {
                log.warn("{} is not mac: {}", CHASSIS_ID_TYPE_MAC, chassisIdType);
                continue;
            }
            JsonNode remotePortNameNode = info.findValue(PORT_ID);
            if (remotePortNameNode == null) {
                continue;
            }
            String remoteChassisId = info.get(CHASSIS_ID).asText("");
            String remotePortName = remotePortNameNode.asText("");
            log.debug("{}: {}, {}: {}", CHASSIS_ID, remoteChassisId, PORT_ID, remotePortName);
            Optional<Port> localPort = findLocalPortByName(ports, lldpLocalPort);
            if (!localPort.isPresent()) {
                log.warn("local port not found. lldpLocalPort value: {}", lldpLocalPort);
                continue;
            }
            Optional<Device> remoteDevice = findRemoteDeviceByChassisId(deviceService, remoteChassisId);
            if (!remoteDevice.isPresent()) {
                log.warn("remote device not found. remoteChassisId value: {}", remoteChassisId);
                continue;
            }
            Optional<Port> remotePort = findDestinationPortByName(remotePortName, deviceService, remoteDevice.get());
            if (!remotePort.isPresent()) {
                log.warn("remote port not found. remotePortName value: {}", remotePortName);
                continue;
            }
            if (!localPort.get().isEnabled() || !remotePort.get().isEnabled()) {
                log.debug("Ports are disabled. Cannot create a link between {}/{} and {}/{}", localDeviceId, localPort.get(), remoteDevice.get().id(), remotePort.get());
                continue;
            }
            linkDescriptions.addAll(buildLinkPair(localDeviceId, localPort.get(), remoteDevice.get().id(), remotePort.get()));
        }
    }
    log.debug("returning linkDescriptions: {}", linkDescriptions);
    return linkDescriptions;
}
Also used : DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) LinkDescription(org.onosproject.net.link.LinkDescription) DeviceId(org.onosproject.net.DeviceId) Device(org.onosproject.net.Device) Port(org.onosproject.net.Port) DefaultPort(org.onosproject.net.DefaultPort) DeviceService(org.onosproject.net.device.DeviceService) JsonNode(com.fasterxml.jackson.databind.JsonNode) DriverHandler(org.onosproject.net.driver.DriverHandler) Map(java.util.Map)

Aggregations

DriverHandler (org.onosproject.net.driver.DriverHandler)104 DeviceId (org.onosproject.net.DeviceId)46 DriverService (org.onosproject.net.driver.DriverService)22 NetconfController (org.onosproject.netconf.NetconfController)22 NetconfException (org.onosproject.netconf.NetconfException)22 MastershipService (org.onosproject.mastership.MastershipService)20 ArrayList (java.util.ArrayList)12 DefaultDriverHandler (org.onosproject.net.driver.DefaultDriverHandler)12 ItemNotFoundException (org.onlab.util.ItemNotFoundException)9 DeviceService (org.onosproject.net.device.DeviceService)9 OvsdbClientService (org.onosproject.ovsdb.controller.OvsdbClientService)9 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)8 Driver (org.onosproject.net.driver.Driver)8 Test (org.junit.Test)7 ControllerInfo (org.onosproject.net.behaviour.ControllerInfo)6 RestSBController (org.onosproject.protocol.rest.RestSBController)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 PolicerConfigurable (org.onosproject.net.behaviour.trafficcontrol.PolicerConfigurable)5 PolicerId (org.onosproject.net.behaviour.trafficcontrol.PolicerId)5