use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey in project netvirt by opendaylight.
the class L2GwValidateCli method verifyVlanBindings.
private boolean verifyVlanBindings(InstanceIdentifier<Node> nodeIid, String logicalSwitchName, Devices hwVtepDevice, Integer defaultVlanId) {
boolean valid = true;
NodeId nodeId = nodeIid.firstKeyOf(Node.class).getNodeId();
if (hwVtepDevice.getInterfaces() == null) {
return false;
}
for (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.devices.Interfaces deviceInterface : hwVtepDevice.getInterfaces()) {
NodeId switchNodeId = HwvtepSouthboundUtils.createManagedNodeId(nodeId, hwVtepDevice.getDeviceName());
InstanceIdentifier<Node> physicalSwitchNodeIid = topoIid.child(Node.class, new NodeKey(switchNodeId));
InstanceIdentifier<TerminationPoint> terminationPointIid = getPhysicalPortTerminationPointIid(switchNodeId, deviceInterface.getInterfaceName());
TerminationPoint operationalTerminationPoint = (TerminationPoint) getData(operationalNodesData, physicalSwitchNodeIid, terminationPointIid);
if (operationalTerminationPoint == null) {
valid = false;
pw.println("Failed to find the operational port " + deviceInterface.getInterfaceName() + " for node " + hwVtepDevice.getDeviceName() + " nodeid " + nodeId.getValue());
continue;
}
TerminationPoint configTerminationPoint = (TerminationPoint) getData(configNodesData, physicalSwitchNodeIid, terminationPointIid);
if (configTerminationPoint == null) {
valid = false;
pw.println("Failed to find the configurational port " + deviceInterface.getInterfaceName() + " for node " + hwVtepDevice.getDeviceName() + " for logical switch " + logicalSwitchName + " nodeid " + nodeId.getValue());
continue;
}
List<VlanBindings> expectedVlans = new ArrayList<>();
if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) {
for (Integer vlanId : deviceInterface.getSegmentationIds()) {
expectedVlans.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, vlanId, logicalSwitchName));
}
} else {
expectedVlans.add(HwvtepSouthboundUtils.createVlanBinding(nodeId, defaultVlanId, logicalSwitchName));
}
HwvtepPhysicalPortAugmentation portAugmentation = configTerminationPoint.getAugmentation(HwvtepPhysicalPortAugmentation.class);
if (portAugmentation == null || HwvtepHAUtil.isEmptyList(portAugmentation.getVlanBindings())) {
pw.println("Failed to find the config vlan bindings for port " + deviceInterface.getInterfaceName() + " for node " + hwVtepDevice.getDeviceName() + " for logical switch " + logicalSwitchName + " nodeid " + nodeId.getValue());
valid = false;
continue;
}
portAugmentation = operationalTerminationPoint.getAugmentation(HwvtepPhysicalPortAugmentation.class);
if (portAugmentation == null || HwvtepHAUtil.isEmptyList(portAugmentation.getVlanBindings())) {
pw.println("Failed to find the operational vlan bindings for port " + deviceInterface.getInterfaceName() + " for node " + hwVtepDevice.getDeviceName() + " for logical switch " + logicalSwitchName + " nodeid " + nodeId.getValue());
valid = false;
continue;
}
VlanBindings expectedBindings = !expectedVlans.isEmpty() ? expectedVlans.get(0) : null;
boolean foundBindings = false;
List<VlanBindings> vlanBindingses = configTerminationPoint.getAugmentation(HwvtepPhysicalPortAugmentation.class).getVlanBindings();
for (VlanBindings actual : vlanBindingses) {
if (actual.equals(expectedBindings)) {
foundBindings = true;
break;
}
}
if (!foundBindings) {
pw.println("Mismatch in vlan bindings for port " + deviceInterface.getInterfaceName() + " for node " + hwVtepDevice.getDeviceName() + " for logical switch " + logicalSwitchName + " nodeid " + nodeId.getValue());
pw.println("Failed to find the vlan bindings " + expectedBindings);
pw.println("Actual bindings present in config are ");
for (VlanBindings actual : vlanBindingses) {
pw.println(actual.toString());
}
valid = false;
}
}
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey in project netvirt by opendaylight.
the class StatisticsImpl method getNodeAggregatedResult.
private boolean getNodeAggregatedResult(List<CounterResult> aggregatedCounters, BigInteger dpId) {
InstanceIdentifier<Node> nodeInstanceIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(CountersUtils.getNodeId(dpId)))).build();
Optional<Node> nodeOptional = MDSALUtil.read(db, LogicalDatastoreType.OPERATIONAL, nodeInstanceIdentifier);
if (!nodeOptional.isPresent()) {
return false;
}
Node node = nodeOptional.get();
CounterResultDataStructure counters = counterRetriever.getNodeCountersDirect(node);
if (counters == null || counters.isEmpty()) {
return false;
}
CounterResultDataStructure aggregatedResultsDS = CountersUtils.aggregateCounters(counters, CountersUtils.getNodeId(dpId));
createCounterResults(aggregatedCounters, aggregatedResultsDS);
return !aggregatedCounters.isEmpty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey in project netvirt by opendaylight.
the class StatisticsImpl method getNodeResult.
private boolean getNodeResult(List<CounterResult> counters, BigInteger dpId) {
InstanceIdentifier<Node> nodeInstanceIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(CountersUtils.getNodeId(dpId)))).build();
Optional<Node> nodeOptional = MDSALUtil.read(db, LogicalDatastoreType.OPERATIONAL, nodeInstanceIdentifier);
if (!nodeOptional.isPresent()) {
return false;
}
Node node = nodeOptional.get();
CounterResultDataStructure counterResultDS = counterRetriever.getNodeCountersDirect(node);
if (counterResultDS == null) {
return false;
}
createCounterResults(counters, counterResultDS);
return !counters.isEmpty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey in project netvirt by opendaylight.
the class CounterRetriever method getSwitchFlowCountersDirect.
public CounterResultDataStructure getSwitchFlowCountersDirect(BigInteger dpId, Match match) {
NodeRef nodeRef = new NodeRef(InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId(CountersUtils.getNodeId(dpId)))).toInstance());
GetFlowStatisticsInputBuilder gfsib = new GetFlowStatisticsInputBuilder();
gfsib.setNode(nodeRef);
gfsib.setMatch(match);
gfsib.setStoreStats(false);
Future<RpcResult<GetFlowStatisticsOutput>> rpcResultFuture = odlDirectStatsService.getFlowStatistics(gfsib.build());
RpcResult<GetFlowStatisticsOutput> rpcResult = null;
try {
rpcResult = rpcResultFuture.get();
} catch (InterruptedException | ExecutionException e) {
counters.failedGettingFlowCounters.inc();
LOG.warn("Unable to retrieve flow counters for match {}", match);
return null;
}
if (rpcResult != null && rpcResult.isSuccessful() && rpcResult.getResult() != null) {
GetFlowStatisticsOutput flowStatsOutput = rpcResult.getResult();
return createSwitchFlowResultMapDirect(flowStatsOutput);
} else {
counters.failedGettingFlowCounters.inc();
LOG.warn("Unable to retrieve flow counters for match {}", match);
return null;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey in project netvirt by opendaylight.
the class CounterRetriever method getNodeConnectorStatisticsInputBuilder.
private GetNodeConnectorStatisticsInput getNodeConnectorStatisticsInputBuilder(NodeId nodeId, NodeConnectorId nodeConnectorId) {
NodeRef nodeRef = new NodeRef(InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(nodeId)).toInstance());
GetNodeConnectorStatisticsInputBuilder nodeConnectorBuilder = new GetNodeConnectorStatisticsInputBuilder().setNode(nodeRef).setNodeConnectorId(nodeConnectorId);
GetNodeConnectorStatisticsInput gncsi = nodeConnectorBuilder.build();
return gncsi;
}
Aggregations