本文整理汇总了Java中org.opendaylight.controller.switchmanager.Switch类的典型用法代码示例。如果您正苦于以下问题:Java Switch类的具体用法?Java Switch怎么用?Java Switch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Switch类属于org.opendaylight.controller.switchmanager包,在下文中一共展示了Switch类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSwitchByNode
import org.opendaylight.controller.switchmanager.Switch; //导入依赖的package包/类
public Switch getSwitchByNode(Node node) {
Switch sw = new Switch(node);
sw.setNode(node);
MacAddress mac = (MacAddress) this.getNodeProp(node,
MacAddress.name);
if (mac != null) {
sw.setDataLayerAddress(mac.getMacAddress());
}
Set<NodeConnector> ncSet = getPhysicalNodeConnectors(node);
sw.setNodeConnectors(ncSet);
List<NodeConnector> ncList = new ArrayList<NodeConnector>();
for (NodeConnector nodeConnector : ncSet) {
if (spanNodeConnectors.contains(nodeConnector)) {
ncList.add(nodeConnector);
}
}
sw.addSpanPorts(ncList);
return sw;
}
示例2: 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;
}
示例3: addSingleNodes
import org.opendaylight.controller.switchmanager.Switch; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void addSingleNodes(List<Switch> nodes, ISwitchManager switchManager, String containerName) {
if (nodes == null) {
return;
}
for (Switch sw : nodes) {
Node n = sw.getNode();
// skip production node
if (nodeIgnore(n)) {
continue;
}
String description = getNodeDesc(n, switchManager);
if ((stagedNodes.containsKey(n.toString()) && metaCache.get(containerName).containsKey(n.toString())) || newNodes.containsKey(n.toString())) {
continue;
}
NodeBean node = createNodeBean(description, n);
// FIXME still doesn't display standalone node when last remaining link is removed
if (metaCache.get(containerName).containsKey(node.id()) && !stagedNodes.containsKey(node.id())) {
Map<String, Object> nodeEntry = metaCache.get(containerName).get(node.id());
Map<String, String> data = (Map<String, String>) nodeEntry.get("data");
data.put("$desc", description);
nodeEntry.put("data", data);
// clear adjacencies since this is now a single node
nodeEntry.put("adjacencies", new LinkedList<Map<String, Object>>());
stagedNodes.put(node.id(), nodeEntry);
} else {
newNodes.put(node.id(), node.out());
}
}
}
示例4: getNetworkDevices
import org.opendaylight.controller.switchmanager.Switch; //导入依赖的package包/类
@Override
public List<Switch> getNetworkDevices() {
Set<Node> nodeSet = getNodes();
List<Switch> swList = new ArrayList<Switch>();
if (nodeSet != null) {
for (Node node : nodeSet) {
swList.add(getSwitchByNode(node));
}
}
return swList;
}
示例5: 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;
}
示例6: getNodeFlows
import org.opendaylight.controller.switchmanager.Switch; //导入依赖的package包/类
@RequestMapping(value = "/node-flows")
@ResponseBody
public Map<String, Object> getNodeFlows(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;
}
IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper
.getInstance(IForwardingRulesManager.class, containerName, this);
if (frm == null) {
return null;
}
Map<String, Object> nodes = new HashMap<String, Object>();
for (Switch sw : switchManager.getNetworkDevices()) {
Node node = sw.getNode();
List<FlowConfig> flows = frm.getStaticFlows(node);
String nodeDesc = node.toString();
SwitchConfig config = switchManager.getSwitchConfig(node
.toString());
if ((config != null) && (config.getProperty(Description.propertyName) != null)) {
nodeDesc = ((Description) config.getProperty(Description.propertyName)).getValue();
}
nodes.put(nodeDesc, flows.size());
}
return nodes;
}
示例7: 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;
}
示例8: _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());
}
}