Search in sources :

Example 71 with DriverHandler

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

the class FujitsuVoltOnuOperConfig method loopbackEthOnu.

@Override
public String loopbackEthOnu(String target) {
    DriverHandler handler = handler();
    NetconfController controller = handler.get(NetconfController.class);
    MastershipService mastershipService = handler.get(MastershipService.class);
    DeviceId ncDeviceId = handler.data().deviceId();
    checkNotNull(controller, "Netconf controller is null");
    String reply = null;
    String[] data = null;
    String[] ethId = null;
    if (!mastershipService.isLocalMaster(ncDeviceId)) {
        log.warn("Not master for {} Use {} to execute command", ncDeviceId, mastershipService.getMasterFor(ncDeviceId));
        return null;
    }
    data = target.split(COLON);
    if (data.length > TWO) {
        log.error("Invalid number of parameters {}", target);
        return null;
    }
    ethId = checkIdString(data[FIRST_PART], THREE);
    if (ethId == null) {
        log.error("Invalid ETH port identifier {}", data[FIRST_PART]);
        return null;
    }
    if (data.length > ONE) {
        if (!LOOPBACKMODES.contains(data[SECOND_PART])) {
            log.error("Unsupported parameter: {}", data[SECOND_PART]);
            return null;
        }
    }
    try {
        StringBuilder request = new StringBuilder();
        request.append(ANGLE_LEFT + ONU_ETHPORT_LOOPBACK + SPACE);
        request.append(VOLT_NE_NAMESPACE + ANGLE_RIGHT + NEW_LINE);
        request.append(buildStartTag(PONLINK_ID, false)).append(ethId[FIRST_PART]).append(buildEndTag(PONLINK_ID)).append(buildStartTag(ONU_ID, false)).append(ethId[SECOND_PART]).append(buildEndTag(ONU_ID)).append(buildStartTag(ETHPORT_ID, false)).append(ethId[THIRD_PART]).append(buildEndTag(ETHPORT_ID));
        if (data.length > ONE) {
            request.append(buildStartTag(LOOPBACK_MODE, false)).append(data[SECOND_PART]).append(buildEndTag(LOOPBACK_MODE));
        }
        request.append(buildEndTag(ONU_ETHPORT_LOOPBACK));
        reply = controller.getDevicesMap().get(ncDeviceId).getSession().doWrappedRpc(request.toString());
    } catch (NetconfException e) {
        log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
    }
    return reply;
}
Also used : NetconfException(org.onosproject.netconf.NetconfException) DeviceId(org.onosproject.net.DeviceId) DriverHandler(org.onosproject.net.driver.DriverHandler) MastershipService(org.onosproject.mastership.MastershipService) NetconfController(org.onosproject.netconf.NetconfController)

Example 72 with DriverHandler

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

the class FujitsuVoltOnuOperConfig method rebootOnu.

@Override
public String rebootOnu(String target) {
    DriverHandler handler = handler();
    NetconfController controller = handler.get(NetconfController.class);
    MastershipService mastershipService = handler.get(MastershipService.class);
    DeviceId ncDeviceId = handler.data().deviceId();
    checkNotNull(controller, "Netconf controller is null");
    String reply = null;
    String[] onuId = null;
    if (!mastershipService.isLocalMaster(ncDeviceId)) {
        log.warn("Not master for {} Use {} to execute command", ncDeviceId, mastershipService.getMasterFor(ncDeviceId));
        return null;
    }
    onuId = checkIdString(target, TWO);
    if (onuId == null) {
        log.error("Invalid ONU identifier {}", target);
        return null;
    }
    try {
        StringBuilder request = new StringBuilder();
        request.append(ANGLE_LEFT + ONU_REBOOT + SPACE);
        request.append(VOLT_NE_NAMESPACE + ANGLE_RIGHT + NEW_LINE);
        request.append(buildStartTag(PONLINK_ID, false)).append(onuId[FIRST_PART]).append(buildEndTag(PONLINK_ID)).append(buildStartTag(ONU_ID, false)).append(onuId[SECOND_PART]).append(buildEndTag(ONU_ID)).append(buildEndTag(ONU_REBOOT));
        reply = controller.getDevicesMap().get(ncDeviceId).getSession().doWrappedRpc(request.toString());
    } catch (NetconfException e) {
        log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
    }
    return reply;
}
Also used : NetconfException(org.onosproject.netconf.NetconfException) DeviceId(org.onosproject.net.DeviceId) DriverHandler(org.onosproject.net.driver.DriverHandler) MastershipService(org.onosproject.mastership.MastershipService) NetconfController(org.onosproject.netconf.NetconfController)

Example 73 with DriverHandler

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

the class FujitsuVoltPonLinkConfig method setPonLink.

@Override
public boolean setPonLink(String target) {
    DriverHandler handler = handler();
    NetconfController controller = handler.get(NetconfController.class);
    MastershipService mastershipService = handler.get(MastershipService.class);
    DeviceId ncDeviceId = handler.data().deviceId();
    checkNotNull(controller, "Netconf controller is null");
    if (!mastershipService.isLocalMaster(ncDeviceId)) {
        log.warn("Not master for {} Use {} to execute command", ncDeviceId, mastershipService.getMasterFor(ncDeviceId));
        return false;
    }
    String[] data = checkSetInput(target);
    if (data == null) {
        log.error("Failed to check input: {}", target);
        return false;
    }
    boolean result = false;
    try {
        StringBuilder request = new StringBuilder();
        request.append(VOLT_NE_OPEN + VOLT_NE_NAMESPACE);
        request.append(ANGLE_RIGHT + NEW_LINE);
        request.append(buildStartTag(VOLT_PORTS)).append(buildStartTag(GPON_PONLINK_PORTS)).append(buildStartTag(GPON_PONLINK_PORT)).append(buildStartTag(PONLINK_ID, false)).append(data[FIRST_PART]).append(buildEndTag(PONLINK_ID)).append(buildStartTag(data[SECOND_PART], false)).append(data[THIRD_PART]).append(buildEndTag(data[SECOND_PART])).append(buildEndTag(GPON_PONLINK_PORT)).append(buildEndTag(GPON_PONLINK_PORTS)).append(buildEndTag(VOLT_PORTS)).append(VOLT_NE_CLOSE);
        result = controller.getDevicesMap().get(ncDeviceId).getSession().editConfig(RUNNING, null, request.toString());
    } catch (NetconfException e) {
        log.error("Cannot communicate to device {} exception {}", ncDeviceId, e);
    }
    return result;
}
Also used : NetconfException(org.onosproject.netconf.NetconfException) DeviceId(org.onosproject.net.DeviceId) DriverHandler(org.onosproject.net.driver.DriverHandler) MastershipService(org.onosproject.mastership.MastershipService) NetconfController(org.onosproject.netconf.NetconfController)

Example 74 with DriverHandler

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

the class VoltEthLoopbackCommand 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.loopbackEthOnu(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 75 with DriverHandler

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

the class VoltGetAlertFilterCommand method doExecute.

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

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