Search in sources :

Example 91 with DeviceId

use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.

the class OpenFlowPolicerConfigurable method freePolicerId.

@Override
public void freePolicerId(PolicerId id) {
    // Init step
    DriverHandler handler = handler();
    // First step is to get MeterService
    MeterService meterService = handler.get(MeterService.class);
    // There was a problem, return none
    if (meterService == null) {
        log.warn("MeterService is null");
        return;
    }
    // Let's get the device id
    DeviceId deviceId = handler.data().deviceId();
    // Double check correspondence with device schema
    if (!deviceId.uri().getScheme().equals(OF_SCHEME)) {
        log.warn("The device {} does not seem to be managed by OpenFlow", deviceId);
        return;
    }
    // Double check correspondence with pid schema
    if (!id.uri().getScheme().equals(OF_SCHEME)) {
        log.warn("The id {} does not seem to be OpenFlow", id);
        return;
    }
    // Get the meter id
    MeterId meterId = getMeterIdFromPolicerId(id);
    // Free the meter id
    meterService.freeMeterId(deviceId, meterId);
}
Also used : DeviceId(org.onosproject.net.DeviceId) DriverHandler(org.onosproject.net.driver.DriverHandler) MeterService(org.onosproject.net.meter.MeterService) MeterId(org.onosproject.net.meter.MeterId)

Example 92 with DeviceId

use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.

the class DellRestOpenFlowControllerConfig method setControllers.

// Example test with ONOS CLI:
// device-setcontrollers rest:10.251.217.143:8008 tcp:1.2.3.4:2222
// TODO: assumes that of-instance 1 was in "no shutdown" state,
// check previous state
@Override
public void setControllers(List<ControllerInfo> controllers) {
    // Dell supports max 2 controllers per of-instance
    if (controllers.size() > MAX_CONTROLLERS) {
        log.warn("Cannot set more than 2 controllers.");
    }
    DriverHandler handler = handler();
    RestSBController controller = checkNotNull(handler.get(RestSBController.class));
    DeviceId deviceId = handler.data().deviceId();
    String controllerCommands = getControllerCommands(controllers).stream().reduce(String::concat).orElse("");
    InputStream payload = new StringBufferInputStream(String.format(SET_CONTROLLERS_XML, controllerCommands));
    String resp = controller.post(deviceId, CLI_REQUEST, payload, MediaType.valueOf("*/*"), String.class);
    log.info("{}", resp);
}
Also used : StringBufferInputStream(java.io.StringBufferInputStream) RestSBController(org.onosproject.protocol.rest.RestSBController) DeviceId(org.onosproject.net.DeviceId) StringBufferInputStream(java.io.StringBufferInputStream) InputStream(java.io.InputStream) DriverHandler(org.onosproject.net.driver.DriverHandler)

Example 93 with DeviceId

use of org.onosproject.net.DeviceId 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 94 with DeviceId

use of org.onosproject.net.DeviceId 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 95 with DeviceId

use of org.onosproject.net.DeviceId in project onos by opennetworkinglab.

the class K8sNodeManager method updateNode.

@Override
public void updateNode(K8sNode node) {
    checkNotNull(node, ERR_NULL_NODE);
    K8sNode intNode;
    K8sNode extNode;
    K8sNode localNode;
    K8sNode tunNode;
    K8sNode existingNode = nodeStore.node(node.hostname());
    checkNotNull(existingNode, ERR_NULL_NODE);
    DeviceId existIntgBridge = nodeStore.node(node.hostname()).intgBridge();
    if (node.intgBridge() == null) {
        intNode = node.updateIntgBridge(existIntgBridge);
        checkArgument(!hasIntgBridge(intNode.intgBridge(), intNode.hostname()), NOT_DUPLICATED_MSG, intNode.intgBridge());
    } else {
        intNode = node;
        checkArgument(!hasIntgBridge(intNode.intgBridge(), intNode.hostname()), NOT_DUPLICATED_MSG, intNode.intgBridge());
    }
    DeviceId existExtBridge = nodeStore.node(node.hostname()).extBridge();
    if (intNode.extBridge() == null) {
        extNode = intNode.updateExtBridge(existExtBridge);
        checkArgument(!hasExtBridge(extNode.extBridge(), extNode.hostname()), NOT_DUPLICATED_MSG, extNode.extBridge());
    } else {
        extNode = intNode;
        checkArgument(!hasExtBridge(extNode.extBridge(), extNode.hostname()), NOT_DUPLICATED_MSG, extNode.extBridge());
    }
    DeviceId existLocalBridge = nodeStore.node(node.hostname()).localBridge();
    if (extNode.localBridge() == null) {
        localNode = extNode.updateLocalBridge(existLocalBridge);
        checkArgument(!hasLocalBridge(localNode.localBridge(), localNode.hostname()), NOT_DUPLICATED_MSG, localNode.localBridge());
    } else {
        localNode = extNode;
        checkArgument(!hasLocalBridge(localNode.localBridge(), localNode.hostname()), NOT_DUPLICATED_MSG, localNode.localBridge());
    }
    if (node.mode() == NORMAL) {
        DeviceId existTunBridge = nodeStore.node(node.hostname()).tunBridge();
        if (localNode.tunBridge() == null) {
            tunNode = localNode.updateTunBridge(existTunBridge);
            checkArgument(!hasTunBridge(tunNode.tunBridge(), tunNode.hostname()), NOT_DUPLICATED_MSG, tunNode.tunBridge());
        } else {
            tunNode = localNode;
            checkArgument(!hasTunBridge(tunNode.tunBridge(), tunNode.hostname()), NOT_DUPLICATED_MSG, tunNode.tunBridge());
        }
        nodeStore.updateNode(tunNode);
    } else {
        nodeStore.updateNode(localNode);
    }
    log.info(String.format(MSG_NODE, extNode.hostname(), MSG_UPDATED));
}
Also used : K8sNode(org.onosproject.k8snode.api.K8sNode) DeviceId(org.onosproject.net.DeviceId)

Aggregations

DeviceId (org.onosproject.net.DeviceId)782 List (java.util.List)178 PortNumber (org.onosproject.net.PortNumber)170 Collectors (java.util.stream.Collectors)152 ConnectPoint (org.onosproject.net.ConnectPoint)152 Set (java.util.Set)138 DeviceService (org.onosproject.net.device.DeviceService)122 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)118 ArrayList (java.util.ArrayList)115 VlanId (org.onlab.packet.VlanId)115 Logger (org.slf4j.Logger)114 Collections (java.util.Collections)109 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)109 Device (org.onosproject.net.Device)107 Collection (java.util.Collection)106 Test (org.junit.Test)104 CoreService (org.onosproject.core.CoreService)103 FlowRule (org.onosproject.net.flow.FlowRule)101 ImmutableSet (com.google.common.collect.ImmutableSet)99 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)96