Search in sources :

Example 6 with DriverHandler

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

the class FujitsuVoltNniLinkConfig method getNniLinks.

@Override
public String getNniLinks(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;
    if (!mastershipService.isLocalMaster(ncDeviceId)) {
        log.warn("Not master for {} Use {} to execute command", ncDeviceId, mastershipService.getMasterFor(ncDeviceId));
        return null;
    }
    try {
        StringBuilder request = new StringBuilder();
        request.append(VOLT_NE_OPEN + VOLT_NE_NAMESPACE).append(ANGLE_RIGHT + NEW_LINE).append(buildStartTag(VOLT_PORTS));
        if (target != null) {
            int nni;
            try {
                nni = Integer.parseInt(target);
                if (nni <= ZERO) {
                    log.error("Invalid integer for nnilink-id:{}", target);
                    return null;
                }
            } catch (NumberFormatException e) {
                log.error("Non-number input for nnilink-id:{}", target);
                return null;
            }
            request.append(buildStartTag(ETH_NNILINK_PORTS)).append(buildStartTag(ETH_NNILINK_PORT)).append(buildStartTag(NNILINK_ID, false)).append(target).append(buildEndTag(NNILINK_ID)).append(buildEndTag(ETH_NNILINK_PORT)).append(buildEndTag(ETH_NNILINK_PORTS));
        } else {
            request.append(buildEmptyTag(ETH_NNILINK_PORTS));
        }
        request.append(buildEndTag(VOLT_PORTS)).append(VOLT_NE_CLOSE);
        reply = controller.getDevicesMap().get(ncDeviceId).getSession().get(request.toString(), REPORT_ALL);
    } 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 7 with DriverHandler

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

the class FujitsuVoltPonLinkConfig method getPonLinks.

@Override
public String getPonLinks(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;
    if (!mastershipService.isLocalMaster(ncDeviceId)) {
        log.warn("Not master for {} Use {} to execute command", ncDeviceId, mastershipService.getMasterFor(ncDeviceId));
        return null;
    }
    try {
        StringBuilder request = new StringBuilder();
        request.append(VOLT_NE_OPEN + VOLT_NE_NAMESPACE);
        request.append(ANGLE_RIGHT + NEW_LINE);
        request.append(buildStartTag(VOLT_PORTS));
        if (target != null) {
            int pon;
            try {
                pon = Integer.parseInt(target);
                if (pon <= ZERO) {
                    log.error("Invalid integer for ponlink-id:{}", target);
                    return null;
                }
            } catch (NumberFormatException e) {
                log.error("Non-number input for ponlink-id:{}", target);
                return null;
            }
            request.append(buildStartTag(GPON_PONLINK_PORTS)).append(buildStartTag(GPON_PONLINK_PORT)).append(buildStartTag(PONLINK_ID, false)).append(target).append(buildEndTag(PONLINK_ID)).append(buildEndTag(GPON_PONLINK_PORT)).append(buildEndTag(GPON_PONLINK_PORTS));
        } else {
            request.append(buildEmptyTag(GPON_PONLINK_PORTS));
        }
        request.append(buildEndTag(VOLT_PORTS));
        request.append(VOLT_NE_CLOSE);
        reply = controller.getDevicesMap().get(ncDeviceId).getSession().get(request.toString(), REPORT_ALL);
    } 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 8 with DriverHandler

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

the class VoltSetNniLinkCommand method doExecute.

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

Example 9 with DriverHandler

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

the class VoltSubscribeCommand 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.subscribe(mode);
}
Also used : VoltAlertConfig(org.onosproject.drivers.fujitsu.behaviour.VoltAlertConfig) DriverHandler(org.onosproject.net.driver.DriverHandler) DriverService(org.onosproject.net.driver.DriverService)

Example 10 with DriverHandler

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

the class VoltGetAllCommand method doExecute.

@Override
protected void doExecute() {
    DriverService service = get(DriverService.class);
    deviceId = DeviceId.deviceId(uri);
    DriverHandler h = service.createHandler(deviceId);
    VoltNeConfig volt = h.behaviour(VoltNeConfig.class);
    String reply = volt.getAll();
    if (reply != null) {
        print("%s", reply);
    } else {
        print("No reply from %s", deviceId.toString());
    }
}
Also used : VoltNeConfig(org.onosproject.drivers.fujitsu.behaviour.VoltNeConfig) 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