use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node in project netvirt by opendaylight.
the class ElanInterfaceManager method installDpnMacsInL2gwDevice.
/**
* Installs dpn macs in external device. first it checks if the physical
* locator towards this dpn tep is present or not if the physical locator is
* present go ahead and add the ucast macs otherwise update the mcast mac
* entry to include this dpn tep ip and schedule the job to put ucast macs
* once the physical locator is programmed in device
*
* @param elanName
* the elan name
* @param lstElanInterfaceNames
* the lst Elan interface names
* @param dpnId
* the dpn id
* @param externalNodeId
* the external node id
*/
private void installDpnMacsInL2gwDevice(String elanName, Set<String> lstElanInterfaceNames, BigInteger dpnId, NodeId externalNodeId) {
L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, externalNodeId.getValue());
if (elanL2GwDevice == null) {
LOG.debug("L2 gw device not found in elan cache for device name {}", externalNodeId);
return;
}
IpAddress dpnTepIp = elanItmUtils.getSourceDpnTepIp(dpnId, externalNodeId);
if (dpnTepIp == null) {
LOG.warn("Could not install dpn macs in l2gw device , dpnTepIp not found dpn : {} , nodeid : {}", dpnId, externalNodeId);
return;
}
String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName);
RemoteMcastMacs remoteMcastMac = elanL2GatewayUtils.readRemoteMcastMac(externalNodeId, logicalSwitchName, LogicalDatastoreType.OPERATIONAL);
boolean phyLocAlreadyExists = ElanL2GatewayUtils.checkIfPhyLocatorAlreadyExistsInRemoteMcastEntry(externalNodeId, remoteMcastMac, dpnTepIp);
LOG.debug("phyLocAlreadyExists = {} for locator [{}] in remote mcast entry for elan [{}], nodeId [{}]", phyLocAlreadyExists, String.valueOf(dpnTepIp.getValue()), elanName, externalNodeId.getValue());
List<PhysAddress> staticMacs = elanL2GatewayUtils.getElanDpnMacsFromInterfaces(lstElanInterfaceNames);
if (phyLocAlreadyExists) {
elanL2GatewayUtils.scheduleAddDpnMacsInExtDevice(elanName, dpnId, staticMacs, elanL2GwDevice);
return;
}
elanL2GatewayMulticastUtils.scheduleMcastMacUpdateJob(elanName, elanL2GwDevice);
elanL2GatewayUtils.scheduleAddDpnMacsInExtDevice(elanName, dpnId, staticMacs, elanL2GwDevice);
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node in project netvirt by opendaylight.
the class L2GwValidateCli method compareNodes.
private boolean compareNodes(Node node1, Node node2, boolean parentChildComparison, LogicalDatastoreType datastoreType) {
if (node1 == null || node2 == null) {
return false;
}
InstanceIdentifier<Node> nodeIid1 = HwvtepSouthboundUtils.createInstanceIdentifier(node1.getNodeId());
InstanceIdentifier<Node> nodeIid2 = HwvtepSouthboundUtils.createInstanceIdentifier(node2.getNodeId());
NodeId nodeId1 = nodeIid1.firstKeyOf(Node.class).getNodeId();
NodeId nodeId2 = nodeIid2.firstKeyOf(Node.class).getNodeId();
PhysicalSwitchAugmentation psAug1 = node1.getAugmentation(PhysicalSwitchAugmentation.class);
PhysicalSwitchAugmentation psAug2 = node2.getAugmentation(PhysicalSwitchAugmentation.class);
HwvtepGlobalAugmentation aug1 = node1.getAugmentation(HwvtepGlobalAugmentation.class);
HwvtepGlobalAugmentation aug2 = node2.getAugmentation(HwvtepGlobalAugmentation.class);
boolean globalNodes = psAug1 == null && psAug2 == null ? true : false;
MergeCommand[] commands = globalNodes ? globalCommands : physicalSwitchCommands;
for (MergeCommand cmd : commands) {
List<DataObject> data1 = null;
List<DataObject> data2 = null;
if (globalNodes) {
data1 = cmd.getData(aug1);
data2 = cmd.getData(aug2);
} else {
data1 = cmd.getData(node1);
data2 = cmd.getData(node2);
}
data1 = data1 == null ? Collections.EMPTY_LIST : data1;
data2 = data2 == null ? Collections.EMPTY_LIST : data2;
if (parentChildComparison) {
data2 = cmd.transform(nodeIid1, data2);
}
Function<DataObject, DataObject> withoutUuidTransformer = cmd::withoutUuid;
data1 = Lists.transform(data1, withoutUuidTransformer);
data2 = Lists.transform(data2, withoutUuidTransformer);
Map<Identifier<?>, DataObject> map1 = new HashMap<>();
Map<Identifier<?>, DataObject> map2 = new HashMap<>();
for (DataObject dataObject : data1) {
map1.put(cmd.getKey(dataObject), dataObject);
}
for (DataObject dataObject : data2) {
map2.put(cmd.getKey(dataObject), dataObject);
}
Set<DataObject> diff = Sets.newHashSet();
for (Entry<Identifier<?>, DataObject> entry : map1.entrySet()) {
DataObject obj1 = entry.getValue();
DataObject obj2 = map2.get(entry.getKey());
if (obj2 == null || !cmd.areEqual(obj1, obj2)) {
diff.add(obj1);
}
}
if (!diff.isEmpty()) {
if (parentChildComparison) {
pw.println("Missing " + cmd.getDescription() + " child entries in " + datastoreType + " parent node " + nodeId1 + " contain " + " more entries than child " + nodeId2 + " " + diff.size());
} else {
pw.println("Missing " + cmd.getDescription() + " op entries config " + nodeId1 + " contain " + " more entries than operational node " + diff.size());
}
if (diff.size() < 10) {
for (Object obj : diff) {
pw.println(cmd.getKey((DataObject) obj));
}
}
}
diff = Sets.newHashSet();
for (Entry<Identifier<?>, DataObject> entry : map2.entrySet()) {
DataObject obj1 = entry.getValue();
DataObject obj2 = map1.get(entry.getKey());
if (globalNodes || parentChildComparison) {
if (obj2 == null || !cmd.areEqual(obj1, obj2)) {
diff.add(obj1);
}
}
}
if (!diff.isEmpty()) {
if (parentChildComparison) {
pw.println("Extra " + cmd.getDescription() + " child entries in " + datastoreType + " node " + nodeId2 + " contain " + " more entries than parent node " + nodeId1 + " " + diff.size());
} else {
pw.println("Extra " + cmd.getDescription() + " operational node " + nodeId2 + " contain " + " more entries than config node " + diff.size());
}
if (diff.size() < 10) {
for (Object obj : diff) {
pw.println(cmd.getKey((DataObject) obj));
}
}
}
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node in project netvirt by opendaylight.
the class L2GwValidateCli method verifyL2GatewayConnections.
private void verifyL2GatewayConnections() {
boolean isValid = true;
for (L2gatewayConnection l2gatewayConnection : l2gatewayConnections) {
L2gateway l2gateway = uuidToL2Gateway.get(l2gatewayConnection.getL2gatewayId());
String logicalSwitchName = l2gatewayConnection.getNetworkId().getValue();
List<Devices> devices = l2gateway.getDevices();
for (Devices device : devices) {
L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(device.getDeviceName());
isValid = verifyL2GatewayDevice(l2gateway, device, l2GatewayDevice);
if (!isValid) {
continue;
}
NodeId nodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
InstanceIdentifier<Node> nodeIid = topoIid.child(Node.class, new NodeKey(nodeId));
isValid = verfiyLogicalSwitch(logicalSwitchName, nodeIid);
if (isValid) {
isValid = verifyMcastMac(logicalSwitchName, nodeIid);
verifyVlanBindings(nodeIid, logicalSwitchName, device, l2gatewayConnection.getSegmentId());
L2GatewayDevice elanL2gatewayDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(logicalSwitchName, nodeId.getValue());
if (elanL2gatewayDevice == null) {
pw.println("Failed elan l2gateway device not found for network " + logicalSwitchName + " and device " + device.getDeviceName() + " " + l2GatewayDevice.getHwvtepNodeId() + " l2gw connection id " + l2gatewayConnection.getUuid());
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node in project netvirt by opendaylight.
the class L2GwValidateCli method readNodes.
private void readNodes() throws ReadFailedException {
try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction()) {
InstanceIdentifier<Topology> topoId = HwvtepSouthboundUtils.createHwvtepTopologyInstanceIdentifier();
Optional<Topology> operationalTopoOptional = tx.read(LogicalDatastoreType.OPERATIONAL, topoId).checkedGet();
Optional<Topology> configTopoOptional = tx.read(LogicalDatastoreType.CONFIGURATION, topoId).checkedGet();
if (operationalTopoOptional.isPresent()) {
for (Node node : operationalTopoOptional.get().getNode()) {
InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.getKey());
operationalNodes.put(nodeIid, node);
}
}
if (configTopoOptional.isPresent()) {
for (Node node : configTopoOptional.get().getNode()) {
InstanceIdentifier<Node> nodeIid = topoId.child(Node.class, node.getKey());
configNodes.put(nodeIid, node);
}
}
fillNodesData(operationalNodes, operationalNodesData);
fillNodesData(configNodes, configNodesData);
Optional<ElanInstances> elanInstancesOptional = tx.read(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(ElanInstances.class).build()).checkedGet();
if (elanInstancesOptional.isPresent() && elanInstancesOptional.get().getElanInstance() != null) {
for (ElanInstance elanInstance : elanInstancesOptional.get().getElanInstance()) {
elanInstanceMap.put(elanInstance.getElanInstanceName(), elanInstance);
}
}
l2gatewayConnections = L2GatewayConnectionUtils.getAllL2gatewayConnections(dataBroker);
l2gateways = L2GatewayConnectionUtils.getL2gatewayList(dataBroker);
for (L2gateway l2gateway : l2gateways) {
uuidToL2Gateway.put(l2gateway.getUuid(), l2gateway);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node in project netvirt by opendaylight.
the class L2GwValidateCli method verifyConfigVsOperationalDiff.
/**
* Checks the diff between config and operational topology nodes and prints it to the file if any.
* This will tell what is present in the controller config and not in the device
*/
private void verifyConfigVsOperationalDiff() {
for (Node cfgNode : configNodes.values()) {
InstanceIdentifier<Node> nodeId = topoIid.child(Node.class, cfgNode.getKey());
compareNodes(cfgNode, operationalNodes.get(nodeId), false, LogicalDatastoreType.CONFIGURATION);
}
}
Aggregations