use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project genius by opendaylight.
the class ItmUtils method getBridgeDpid.
/**
* Gets the bridge datapath ID from Network topology Node's OvsdbBridgeAugmentation, in the Operational DS.
*
* @param node Network Topology Node
*
* @param bridge bridge name
*
* @param dataBroker data broker handle to perform operations on datastore
*
* @return the datapath ID of bridge in string form
*/
public static String getBridgeDpid(Node node, String bridge, DataBroker dataBroker) {
OvsdbBridgeAugmentation ovsdbBridgeAugmentation = null;
Node bridgeNode = null;
String datapathId = null;
NodeId ovsdbNodeId = node.getKey().getNodeId();
NodeId brNodeId = new NodeId(ovsdbNodeId.getValue() + "/" + ITMConstants.BRIDGE_URI_PREFIX + "/" + bridge);
InstanceIdentifier<Node> bridgeIid = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(IfmConstants.OVSDB_TOPOLOGY_ID)).child(Node.class, new NodeKey(brNodeId));
Optional<Node> opBridgeNode = ItmUtils.read(LogicalDatastoreType.OPERATIONAL, bridgeIid, dataBroker);
if (opBridgeNode.isPresent()) {
bridgeNode = opBridgeNode.get();
}
if (bridgeNode != null) {
ovsdbBridgeAugmentation = bridgeNode.getAugmentation(OvsdbBridgeAugmentation.class);
}
if (ovsdbBridgeAugmentation != null && ovsdbBridgeAugmentation.getDatapathId() != null) {
datapathId = ovsdbBridgeAugmentation.getDatapathId().getValue();
}
return datapathId;
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project genius by opendaylight.
the class SouthboundUtils method addAllPortsToBridge.
/*
* Add all tunnels ports corresponding to the bridge to the topology config DS.
*/
public void addAllPortsToBridge(BridgeEntry bridgeEntry, InterfaceManagerCommonUtils interfaceManagerCommonUtils, InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid, OvsdbBridgeAugmentation bridgeNew) {
String bridgeName = bridgeNew.getBridgeName().getValue();
LOG.debug("adding all ports to bridge: {}", bridgeName);
List<BridgeInterfaceEntry> bridgeInterfaceEntries = bridgeEntry.getBridgeInterfaceEntry();
if (bridgeInterfaceEntries != null) {
for (BridgeInterfaceEntry bridgeInterfaceEntry : bridgeInterfaceEntries) {
String portName = bridgeInterfaceEntry.getInterfaceName();
InterfaceKey interfaceKey = new InterfaceKey(portName);
Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
if (iface != null) {
IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
if (ifTunnel != null) {
if (!(interfacemgrProvider.isItmDirectTunnelsEnabled() && ifTunnel.isInternal())) {
addTunnelPortToBridge(ifTunnel, bridgeIid, iface, portName);
}
if (isOfTunnel(ifTunnel)) {
LOG.debug("Using OFTunnel. Only one tunnel port will be added");
return;
}
}
} else {
LOG.debug("Interface {} not found in config DS", portName);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project genius by opendaylight.
the class HwVTEPConfigRemoveHelper method removeConfiguration.
public static List<ListenableFuture<Void>> removeConfiguration(ManagedNewTransactionRunner txRunner, Interface interfaceOld, InstanceIdentifier<Node> physicalSwitchNodeId, InstanceIdentifier<Node> globalNodeId) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
LOG.info("removing hwvtep configuration for {}", interfaceOld.getName());
if (globalNodeId != null) {
IfTunnel ifTunnel = interfaceOld.getAugmentation(IfTunnel.class);
// removeTunnelTableEntry(defaultOperShardTransaction, ifTunnel, physicalSwitchNodeId);
// Topology configuration shard
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> removeTerminationEndPoint(tx, ifTunnel, globalNodeId)));
// Default operational shard
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
InterfaceManagerCommonUtils.deleteStateEntry(interfaceOld.getName(), tx);
InterfaceMetaUtils.removeTunnelToInterfaceMap(physicalSwitchNodeId, tx, ifTunnel);
}));
}
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology in project controller by opendaylight.
the class EventSourceTopologyTest method topicTestHelper.
private void topicTestHelper() throws Exception {
constructorTestHelper();
createTopicInputMock = mock(CreateTopicInput.class);
eventSourceTopology = new EventSourceTopology(dataBrokerMock, rpcProviderRegistryMock);
NotificationPattern notificationPattern = new NotificationPattern("value1");
doReturn(notificationPattern).when(createTopicInputMock).getNotificationPattern();
Pattern pattern = new Pattern("valuePattern1");
doReturn(pattern).when(createTopicInputMock).getNodeIdPattern();
listenerRegistrationMock = mock(ListenerRegistration.class);
doReturn(listenerRegistrationMock).when(dataBrokerMock).registerDataTreeChangeListener(any(DataTreeIdentifier.class), any(EventSourceTopic.class));
ReadOnlyTransaction readOnlyTransactionMock = mock(ReadOnlyTransaction.class);
doReturn(readOnlyTransactionMock).when(dataBrokerMock).newReadOnlyTransaction();
CheckedFuture checkedFutureMock = mock(CheckedFuture.class);
doReturn(checkedFutureMock).when(readOnlyTransactionMock).read(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class));
Optional optionalMock = mock(Optional.class);
doReturn(optionalMock).when(checkedFutureMock).checkedGet();
doReturn(true).when(optionalMock).isPresent();
Topology topologyMock = mock(Topology.class);
doReturn(topologyMock).when(optionalMock).get();
Node nodeMock = mock(Node.class);
List<Node> nodeList = new ArrayList<>();
nodeList.add(nodeMock);
doReturn(nodeList).when(topologyMock).getNode();
NodeId nodeId = new NodeId("nodeIdValue1");
doReturn(nodeId).when(nodeMock).getNodeId();
}
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 Ipv4ReachabilityTopologyBuilderTest method testIpv4ReachabilityTopologyBuilder.
@Test
public void testIpv4ReachabilityTopologyBuilder() throws TransactionCommitFailedException, ReadFailedException {
// create route
updateIpv4Route(createIpv4Route(NEXT_HOP));
readDataOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier(), topology -> {
final TopologyTypes1 topologyTypes = topology.getTopologyTypes().getAugmentation(TopologyTypes1.class);
assertNotNull(topologyTypes);
assertNotNull(topologyTypes.getBgpIpv4ReachabilityTopology());
assertEquals(1, topology.getNode().size());
final Node node = topology.getNode().get(0);
assertEquals(NEXT_HOP, node.getNodeId().getValue());
assertEquals(ROUTE_IP4PREFIX, node.getAugmentation(Node1.class).getIgpNodeAttributes().getPrefix().get(0).getPrefix().getIpv4Prefix().getValue());
return topology;
});
// update route
updateIpv4Route(createIpv4Route(NEW_NEXT_HOP));
readDataOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(1, topology.getNode().size());
final Node nodeUpdated = topology.getNode().get(0);
assertEquals(NEW_NEXT_HOP, nodeUpdated.getNodeId().getValue());
assertEquals(ROUTE_IP4PREFIX, nodeUpdated.getAugmentation(Node1.class).getIgpNodeAttributes().getPrefix().get(0).getPrefix().getIpv4Prefix().getValue());
return topology;
});
// delete route
final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
wTx.delete(LogicalDatastoreType.OPERATIONAL, this.ipv4RouteIID);
wTx.submit();
readDataOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(0, topology.getNode().size());
return topology;
});
this.ipv4TopoBuilder.close();
checkNotPresentOperational(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier());
}
Aggregations