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);
}
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);
}
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);
}
}
}
}
}
}
}
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;
}
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);
}
}
Aggregations