当前位置: 首页>>代码示例>>Java>>正文


Java Switch.getNodeConnectors方法代码示例

本文整理汇总了Java中org.opendaylight.controller.switchmanager.Switch.getNodeConnectors方法的典型用法代码示例。如果您正苦于以下问题:Java Switch.getNodeConnectors方法的具体用法?Java Switch.getNodeConnectors怎么用?Java Switch.getNodeConnectors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opendaylight.controller.switchmanager.Switch的用法示例。


在下文中一共展示了Switch.getNodeConnectors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isPortValid

import org.opendaylight.controller.switchmanager.Switch; //导入方法依赖的package包/类
public boolean isPortValid(Switch sw, Short port) {
    if (port < 1) {
        log.debug("port {} is not valid", port);
        return false;
    }

    if (sw == null) {
        log.debug("switch info is not available. Skip checking if port is part of a switch or not.");
        return true;
    }

    Set<NodeConnector> nodeConnectorSet = sw.getNodeConnectors();
    for (NodeConnector nodeConnector : nodeConnectorSet) {
        if (((Short) nodeConnector.getID()).equals(port)) {
            return true;
        }
    }
    log.debug("port {} is not a valid port of node {}", port, sw.getNode());
    return false;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:21,代码来源:FlowConfig.java

示例2: getNodePorts

import org.opendaylight.controller.switchmanager.Switch; //导入方法依赖的package包/类
@RequestMapping(value = "/node-ports")
@ResponseBody
public Map<String, Object> getNodePorts(HttpServletRequest request, @RequestParam(required = false) String container) {
    String containerName = (container == null) ? GlobalConstants.DEFAULT.toString() : container;

    // Derive the privilege this user has on the current container
    String userName = request.getUserPrincipal().getName();
    if (DaylightWebUtil.getContainerPrivilege(userName, containerName, this) == Privilege.NONE) {
        return null;
    }

    ISwitchManager switchManager = (ISwitchManager) ServiceHelper
            .getInstance(ISwitchManager.class, containerName, this);
    if (switchManager == null) {
        return null;
    }

    Map<String, Object> nodes = new HashMap<String, Object>();
    Map<Short, String> port;

    for (Switch node : switchManager.getNetworkDevices()) {
        port = new HashMap<Short, String>(); // new port
        Set<NodeConnector> nodeConnectorSet = node.getNodeConnectors();

        if (nodeConnectorSet != null) {
            for (NodeConnector nodeConnector : nodeConnectorSet) {
                String nodeConnectorName = ((Name) switchManager
                        .getNodeConnectorProp(nodeConnector,
                                Name.NamePropName)).getValue();
                port.put((Short) nodeConnector.getID(), nodeConnectorName
                        + "(" + nodeConnector.getNodeConnectorIDString()
                        + ")");
            }
        }

        // add ports
        Map<String, Object> entry = new HashMap<String, Object>();
        entry.put("ports", port);

        // add name
        entry.put("name", getNodeDesc(node.getNode(), switchManager));

        // add to the node
        nodes.put(node.getNode().toString(), entry);
    }

    return nodes;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:49,代码来源:Flows.java

示例3: getNodePorts

import org.opendaylight.controller.switchmanager.Switch; //导入方法依赖的package包/类
@RequestMapping(value = "/nodeports")
@ResponseBody
public Map<String, Object> getNodePorts(HttpServletRequest request,
        @RequestParam(required = false) String container) {
    String containerName = (container == null) ? GlobalConstants.DEFAULT
            .toString() : container;

    // Derive the privilege this user has on the current container
    String userName = request.getUserPrincipal().getName();
    if (DaylightWebUtil.getContainerPrivilege(userName, containerName, this) == Privilege.NONE) {
        return null;
    }


    ISwitchManager switchManager = (ISwitchManager) ServiceHelper
            .getInstance(ISwitchManager.class, containerName, this);
    if (switchManager == null) {
        return null;
    }

    Map<String, Object> nodes = new HashMap<String, Object>();
    Map<Short, String> port;

    for (Switch node : switchManager.getNetworkDevices()) {
        port = new HashMap<Short, String>(); // new port
        Set<NodeConnector> nodeConnectorSet = node.getNodeConnectors();

        if (nodeConnectorSet != null) {
            for (NodeConnector nodeConnector : nodeConnectorSet) {
                String nodeConnectorName = ((Name) switchManager
                        .getNodeConnectorProp(nodeConnector,
                                Name.NamePropName)).getValue();
                port.put((Short) nodeConnector.getID(), nodeConnectorName
                        + "(" + nodeConnector.getID() + ")");
            }
        }

        nodes.put(node.getNode().toString(), port);
    }

    return nodes;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:43,代码来源:Devices.java

示例4: _pdm

import org.opendaylight.controller.switchmanager.Switch; //导入方法依赖的package包/类
public void _pdm(CommandInterpreter ci) {
    String st = ci.nextArgument();
    if (st == null) {
        ci.println("Please enter node id");
        return;
    }

    Node node = Node.fromString(st);
    if (node == null) {
        ci.println("Please enter node id");
        return;
    }

    Switch sw = getSwitchByNode(node);

    ci.println("          NodeConnector                        Name");
    if (sw == null) {
        return;
    }
    Set<NodeConnector> nodeConnectorSet = sw.getNodeConnectors();
    String nodeConnectorName;
    if (nodeConnectorSet != null && nodeConnectorSet.size() > 0) {
        for (NodeConnector nodeConnector : nodeConnectorSet) {
            Map<String, Property> propMap = getNodeConnectorProps(nodeConnector);
            nodeConnectorName = (propMap == null) ? null : ((Name) propMap
                    .get(Name.NamePropName)).getValue();
            if (nodeConnectorName != null) {
                Node nd = nodeConnector.getNode();
                if (!nd.equals(node)) {
                    log.debug("node not match {} {}", nd, node);
                }
                Map<String, NodeConnector> map = nodeConnectorNames
                        .get(node);
                if (map != null) {
                    NodeConnector nc = map.get(nodeConnectorName);
                    if (nc == null) {
                        log.debug("no nodeConnector named {}",
                                nodeConnectorName);
                    } else if (!nc.equals(nodeConnector)) {
                        log.debug("nodeConnector not match {} {}", nc,
                                nodeConnector);
                    }
                }
            }

            ci.println(nodeConnector
                    + "            "
                    + ((nodeConnectorName == null) ? "" : nodeConnectorName)
                    + "(" + nodeConnector.getID() + ")");
        }
        ci.println("Total number of NodeConnectors: "
                + nodeConnectorSet.size());
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:55,代码来源:SwitchManagerImpl.java


注:本文中的org.opendaylight.controller.switchmanager.Switch.getNodeConnectors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。