Search in sources :

Example 41 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project netvirt by opendaylight.

the class Ipv6NodeListener method add.

@Override
protected void add(InstanceIdentifier<FlowCapableNode> key, FlowCapableNode dataObjectModification) {
    LOG.trace("FlowCapableNode Added: key: {}", key);
    NodeKey nodeKey = key.firstKeyOf(Node.class);
    BigInteger dpnId = MDSALUtil.getDpnIdFromNodeName(nodeKey.getId());
    createTableMissEntry(dpnId);
}
Also used : BigInteger(java.math.BigInteger) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 42 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project netvirt by opendaylight.

the class AclNodeListener method add.

@Override
protected void add(InstanceIdentifier<FlowCapableNode> key, FlowCapableNode dataObjectModification) {
    NodeKey nodeKey = key.firstKeyOf(Node.class);
    BigInteger dpId = MDSALUtil.getDpnIdFromNodeName(nodeKey.getId());
    LOG.info("Received ACL node [{}] add event", dpId);
    if (securityGroupMode != null && securityGroupMode != SecurityGroupMode.Stateful) {
        LOG.error("Invalid security group mode ({}) obtained from AclserviceConfig. dpId={}", securityGroupMode, dpId);
        return;
    }
    jobCoordinator.enqueueJob(String.valueOf(dpId), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
        new AclNodeDefaultFlowsTxBuilder(dpId, mdsalManager, config, tx).build();
        LOG.info("Adding default ACL flows for dpId={}", dpId);
    })), AclConstants.JOB_MAX_RETRIES);
    LOG.trace("FlowCapableNode (dpid: {}) add event is processed.", dpId);
}
Also used : BigInteger(java.math.BigInteger) AclNodeDefaultFlowsTxBuilder(org.opendaylight.netvirt.aclservice.utils.AclNodeDefaultFlowsTxBuilder) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 43 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project netvirt by opendaylight.

the class QosNodeListener method add.

@Override
protected void add(InstanceIdentifier<FlowCapableNode> key, FlowCapableNode dataObjectModification) {
    NodeKey nodeKey = key.firstKeyOf(Node.class);
    BigInteger dpId = MDSALUtil.getDpnIdFromNodeName(nodeKey.getId());
    createTableMissEntry(dpId);
}
Also used : BigInteger(java.math.BigInteger) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 44 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.

the class ShellUtil method getNodeInfo.

public static OFNode getNodeInfo(final Long nodeId, final DataBroker broker) {
    OFNode ofNode = null;
    ReadOnlyTransaction tx = broker.newReadOnlyTransaction();
    InstanceIdentifier<Node> path = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(NODE_PREFIX + nodeId))).build();
    Optional<Node> result;
    try {
        CheckedFuture<Optional<Node>, ReadFailedException> checkedFuture = tx.read(LogicalDatastoreType.OPERATIONAL, path);
        result = checkedFuture.get();
        if (result.isPresent()) {
            Node node = result.get();
            String name = null;
            List<NodeConnector> nodeConnectors = null;
            List<String> portList = new ArrayList<>();
            FlowCapableNode flowCapableNode = node.<FlowCapableNode>getAugmentation(FlowCapableNode.class);
            if (flowCapableNode != null) {
                name = node.<FlowCapableNode>getAugmentation(FlowCapableNode.class).getDescription();
            } else {
                LOG.error("Error while converting OFNode:{} to FlowCapableNode: {}", node.getId());
                return null;
            }
            nodeConnectors = node.getNodeConnector();
            for (NodeConnector nodeConnector : nodeConnectors) {
                FlowCapableNodeConnector flowCapableNodeConnector = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
                if (flowCapableNodeConnector == null) {
                    LOG.error("Error for OFNode:{} while reading nodeConnectors {}", node.getId());
                    return null;
                } else {
                    String portName = flowCapableNodeConnector.getName();
                    portList.add(portName);
                }
            }
            ofNode = new OFNode(nodeId, name, portList);
        } else {
            LOG.error("OFNode with nodeId {} not present Inventory DS: {}", nodeId);
            return null;
        }
    } catch (ExecutionException | InterruptedException e) {
        LOG.error("Error reading node {} from Inventory DS: {}", nodeId, e);
    }
    return ofNode;
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Optional(com.google.common.base.Optional) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) ArrayList(java.util.ArrayList) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) ExecutionException(java.util.concurrent.ExecutionException) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 45 with FlowCapableNode

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode in project openflowplugin by opendaylight.

the class ShellUtil method getAllNodes.

@Nonnull
public static List<OFNode> getAllNodes(final DataBroker broker) {
    List<Node> nodes = null;
    ReadOnlyTransaction tx = broker.newReadOnlyTransaction();
    InstanceIdentifier<Nodes> path = InstanceIdentifier.builder(Nodes.class).build();
    try {
        CheckedFuture<Optional<Nodes>, ReadFailedException> checkedFuture = tx.read(LogicalDatastoreType.OPERATIONAL, path);
        Optional<Nodes> result = checkedFuture.get();
        if (result.isPresent()) {
            nodes = result.get().getNode();
        }
    } catch (ExecutionException | InterruptedException | NullPointerException e) {
        LOG.error("Error reading nodes from Inventory DS", e);
    }
    if (nodes != null) {
        List<OFNode> nodeList = new ArrayList<>();
        for (Node node : nodes) {
            String[] nodeId = node.getId().getValue().split(":");
            String name = null;
            FlowCapableNode flowCapableNode = node.<FlowCapableNode>getAugmentation(FlowCapableNode.class);
            if (flowCapableNode != null) {
                name = node.<FlowCapableNode>getAugmentation(FlowCapableNode.class).getDescription();
            } else {
                LOG.error("Error while converting OFNode: {} to FlowCapableNode", node.getId());
                return Collections.emptyList();
            }
            OFNode ofNode = new OFNode(Long.parseLong(nodeId[1]), name);
            LOG.trace("Added OFNode: {} to the list", ofNode.getNodeId());
            nodeList.add(ofNode);
        }
        Collections.sort(nodeList);
        return nodeList;
    }
    return Collections.emptyList();
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Optional(com.google.common.base.Optional) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) ArrayList(java.util.ArrayList) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) ExecutionException(java.util.concurrent.ExecutionException) Nonnull(javax.annotation.Nonnull)

Aggregations

FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)48 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)29 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)26 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)22 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)20 ArrayList (java.util.ArrayList)17 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)15 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)15 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)15 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)15 Test (org.junit.Test)14 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)14 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)13 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)11 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)10 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)9 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)9 CrudCounts (org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts)8 FlowCapableNodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder)8