Search in sources :

Example 56 with Topology

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project bgpcep by opendaylight.

the class PcepStateUtils method displayNodeState.

/**
 * Display to stream operational state, rib Id is mandatory.
 *
 * @param dataBroker data broker
 * @param stream     where to print
 * @param topologyId mandatory, Topology where Node pertains
 * @param nodeId     mandatory, State per given Node Id will be printed
 */
public static void displayNodeState(@NonNull final DataBroker dataBroker, @NonNull final PrintStream stream, @NonNull final String topologyId, @NonNull final String nodeId) {
    final Node node = readNodeFromDataStore(dataBroker, topologyId, nodeId);
    if (node == null) {
        stream.println(String.format("Node [%s] not found", nodeId));
        return;
    }
    final PcepTopologyNodeStatsAug state = node.getAugmentation(PcepTopologyNodeStatsAug.class);
    if (state == null) {
        stream.println(String.format("State not found for [%s]", nodeId));
        return;
    }
    final PcepSessionState nodeState = state.getPcepSessionState();
    displayNodeState(topologyId, nodeId, nodeState, stream);
}
Also used : PcepTopologyNodeStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.stats.rev171113.PcepTopologyNodeStatsAug) PcepSessionState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.grouping.PcepSessionState) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)

Example 57 with Topology

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project netvirt by opendaylight.

the class L2GatewayConnectionListener method loadL2GwDeviceCache.

private void loadL2GwDeviceCache(final int trialNo) {
    scheduler.getScheduledExecutorService().schedule(() -> {
        if (trialNo == MAX_READ_TRIALS) {
            LOG.error("Failed to read config topology");
            return;
        }
        ReadOnlyTransaction tx = broker.newReadOnlyTransaction();
        InstanceIdentifier<Topology> topoIid = HwvtepSouthboundUtils.createHwvtepTopologyInstanceIdentifier();
        Futures.addCallback(tx.read(CONFIGURATION, topoIid), new FutureCallback<Optional<Topology>>() {

            @Override
            public void onSuccess(Optional<Topology> topologyOptional) {
                if (topologyOptional != null && topologyOptional.isPresent()) {
                    loadL2GwDeviceCache(topologyOptional.get().getNode());
                }
                registerListener(CONFIGURATION, broker);
            }

            @Override
            public void onFailure(Throwable throwable) {
                loadL2GwDeviceCache(trialNo + 1);
            }
        }, MoreExecutors.directExecutor());
        tx.close();
    }, 1, TimeUnit.SECONDS);
}
Also used : Optional(com.google.common.base.Optional) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)

Example 58 with Topology

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project netvirt by opendaylight.

the class HwvtepHAUtil method deletePSNodesOfNode.

/**
 * Delete PS data of HA node of Config Data tree.
 *
 * @param key Node object
 * @param haNode Ha Node from which to be deleted
 * @param tx Transaction
 * @throws ReadFailedException  Exception thrown if read fails
 */
public static void deletePSNodesOfNode(InstanceIdentifier<Node> key, Node haNode, ReadWriteTransaction tx) throws ReadFailedException {
    // read from switches attribute and clean up them
    HwvtepGlobalAugmentation globalAugmentation = haNode.getAugmentation(HwvtepGlobalAugmentation.class);
    if (globalAugmentation == null) {
        return;
    }
    HashMap<InstanceIdentifier<Node>, Boolean> deleted = new HashMap<>();
    List<Switches> switches = globalAugmentation.getSwitches();
    if (switches != null) {
        for (Switches switche : switches) {
            InstanceIdentifier<Node> psId = (InstanceIdentifier<Node>) switche.getSwitchRef().getValue();
            deleteNodeIfPresent(tx, CONFIGURATION, psId);
            deleted.put(psId, Boolean.TRUE);
        }
    }
    // also read from managed by attribute of switches and cleanup them as a back up if the above cleanup fails
    Optional<Topology> topologyOptional = tx.read(CONFIGURATION, key.firstIdentifierOf(Topology.class)).checkedGet();
    String deletedNodeId = key.firstKeyOf(Node.class).getNodeId().getValue();
    if (topologyOptional.isPresent()) {
        Topology topology = topologyOptional.get();
        if (topology.getNode() != null) {
            for (Node psNode : topology.getNode()) {
                PhysicalSwitchAugmentation ps = psNode.getAugmentation(PhysicalSwitchAugmentation.class);
                if (ps != null) {
                    InstanceIdentifier<Node> iid = (InstanceIdentifier<Node>) ps.getManagedBy().getValue();
                    String nodeIdVal = iid.firstKeyOf(Node.class).getNodeId().getValue();
                    if (deletedNodeId.equals(nodeIdVal)) {
                        InstanceIdentifier<Node> psNodeId = convertToInstanceIdentifier(psNode.getNodeId().getValue());
                        if (deleted.containsKey(psNodeId)) {
                            deleteNodeIfPresent(tx, CONFIGURATION, psNodeId);
                        }
                    }
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) Switches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches) LogicalSwitches(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) HwvtepGlobalAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) PhysicalSwitchAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier)

Example 59 with Topology

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project netvirt by opendaylight.

the class NetworkL2gwDeviceInfoCli method doExecute.

@Override
protected Object doExecute() {
    List<Node> nodes = new ArrayList<>();
    Set<String> networks = new HashSet<>();
    if (nodeId == null) {
        Optional<Topology> topologyOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, createHwvtepTopologyInstanceIdentifier());
        if (topologyOptional.isPresent()) {
            nodes = topologyOptional.get().getNode();
        }
    } else {
        Optional<Node> nodeOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, createInstanceIdentifier(new NodeId(new Uri(nodeId))));
        if (nodeOptional.isPresent()) {
            nodes.add(nodeOptional.get());
        }
    }
    if (elanName == null) {
        // get all elan instance
        // get all device node id
        // print result
        Optional<ElanInstances> elanInstancesOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(ElanInstances.class).build());
        if (elanInstancesOptional.isPresent()) {
            List<ElanInstance> elans = elanInstancesOptional.get().getElanInstance();
            if (elans != null) {
                for (ElanInstance elan : elans) {
                    networks.add(elan.getElanInstanceName());
                }
            }
        }
    } else {
        networks.add(elanName);
    }
    for (Node node : nodes) {
        if (node.getNodeId().getValue().contains("physicalswitch")) {
            continue;
        }
        Node hwvtepConfigNode = HwvtepUtils.getHwVtepNode(dataBroker, LogicalDatastoreType.CONFIGURATION, node.getNodeId());
        Node hwvtepOpPsNode = getPSnode(node, LogicalDatastoreType.OPERATIONAL);
        Node hwvtepConfigPsNode = null;
        if (hwvtepOpPsNode != null) {
            hwvtepConfigPsNode = HwvtepUtils.getHwVtepNode(dataBroker, LogicalDatastoreType.CONFIGURATION, hwvtepOpPsNode.getNodeId());
            opPSNodes.put(node.getNodeId(), hwvtepOpPsNode);
        }
        opNodes.put(node.getNodeId(), node);
        configNodes.put(node.getNodeId(), hwvtepConfigNode);
        if (hwvtepConfigPsNode != null) {
            configPSNodes.put(node.getNodeId(), hwvtepConfigPsNode);
        }
    }
    for (String network : networks) {
        session.getConsole().println("Network info for " + network);
        for (Node node : nodes) {
            if (node.getNodeId().getValue().contains("physicalswitch")) {
                continue;
            }
            session.getConsole().println("Printing for node " + node.getNodeId().getValue());
            process(node.getNodeId(), network);
        }
    }
    return null;
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ArrayList(java.util.ArrayList) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) HashSet(java.util.HashSet)

Example 60 with Topology

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project netvirt by opendaylight.

the class StateManager method initializeNetvirtTopology.

private void initializeNetvirtTopology() {
    final TopologyId topologyId = new TopologyId("netvirt:1");
    InstanceIdentifier<Topology> path = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyId));
    TopologyBuilder tpb = new TopologyBuilder();
    tpb.setTopologyId(topologyId);
    try {
        txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(LogicalDatastoreType.OPERATIONAL, path, tpb.build())).get();
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("StateManager error initializing netvirt topology", e);
    }
}
Also used : IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) Logger(org.slf4j.Logger) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) IVpnManager(org.opendaylight.netvirt.vpnmanager.api.IVpnManager) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId) LoggerFactory(org.slf4j.LoggerFactory) IElanService(org.opendaylight.netvirt.elanmanager.api.IElanService) Singleton(javax.inject.Singleton) INeutronVpnManager(org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ExecutionException(java.util.concurrent.ExecutionException) Inject(javax.inject.Inject) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) IBgpManager(org.opendaylight.netvirt.bgpmanager.api.IBgpManager) PostConstruct(javax.annotation.PostConstruct) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder) TopologyKey(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey) TopologyBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) Topology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology) ExecutionException(java.util.concurrent.ExecutionException) TopologyId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)

Aggregations

Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)30 Topology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology)26 Test (org.junit.Test)20 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)15 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)12 TopologyId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId)12 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)12 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)10 Link (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link)10 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)10 TopologyBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder)9 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)8 Optional (com.google.common.base.Optional)7 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)7 TopologyKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey)7 ExecutionException (java.util.concurrent.ExecutionException)6 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)6 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)5 ArrayList (java.util.ArrayList)4