use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.Updates in project genius by opendaylight.
the class OvsdbNodeListener method update.
@Override
public void update(@Nonnull Node originalOvsdbNode, Node updatedOvsdbNode) {
String newLocalIp = null;
String oldLocalIp = null;
String tzName = null;
String oldTzName = null;
String oldDpnBridgeName = null;
String newDpnBridgeName = null;
boolean newOfTunnel = false;
boolean isTepInfoUpdated = false;
boolean isTepInfoDeleted = false;
boolean isLocalIpAdded = false;
boolean isLocalIpRemoved = false;
boolean isLocalIpUpdated;
boolean isTzChanged = false;
boolean isDpnBrChanged = false;
LOG.trace("OvsdbNodeListener called for Ovsdb Node ({}) Update.", originalOvsdbNode.getNodeId().getValue());
LOG.trace("Update: originalOvsdbNode: {} updatedOvsdbNode: {}", originalOvsdbNode, updatedOvsdbNode);
// addTep, as TEP would not be added in node add case above
if (isBridgeDpIdAdded(originalOvsdbNode, updatedOvsdbNode)) {
processBridgeUpdate(updatedOvsdbNode);
return;
}
// get OVSDB TEP info from old ovsdb node
OvsdbTepInfo newTepInfoObj = getOvsdbTepInfo(updatedOvsdbNode.getAugmentation(OvsdbNodeAugmentation.class));
// get OVSDB TEP info from new ovsdb node
OvsdbTepInfo oldTepInfoObj = getOvsdbTepInfo(originalOvsdbNode.getAugmentation(OvsdbNodeAugmentation.class));
if (oldTepInfoObj == null && newTepInfoObj == null) {
LOG.trace("Tep Info is not received in old and new Ovsdb Nodes.");
return;
}
if (oldTepInfoObj != null && newTepInfoObj == null) {
isTepInfoDeleted = true;
LOG.trace("Tep Info is deleted from Ovsdb node: {}", originalOvsdbNode.getNodeId().getValue());
}
// store TEP info required parameters
if (newTepInfoObj != null) {
tzName = newTepInfoObj.getTzName();
newLocalIp = newTepInfoObj.getLocalIp();
newDpnBridgeName = newTepInfoObj.getBrName();
newOfTunnel = newTepInfoObj.getOfTunnel();
}
if (oldTepInfoObj != null) {
oldLocalIp = oldTepInfoObj.getLocalIp();
oldDpnBridgeName = oldTepInfoObj.getBrName();
oldTzName = oldTepInfoObj.getTzName();
}
// handle case when TEP parameters are not configured from switch side
if (newLocalIp == null && oldLocalIp == null) {
LOG.trace("TEP info Local IP parameters are not specified in old and new Ovsdb Nodes.");
return;
}
if (!isTepInfoDeleted) {
isLocalIpRemoved = isLocalIpRemoved(oldLocalIp, newLocalIp);
isLocalIpAdded = isLocalIpAdded(oldLocalIp, newLocalIp);
isLocalIpUpdated = isLocalIpUpdated(oldLocalIp, newLocalIp);
if (isLocalIpUpdated) {
LOG.info("Local IP cannot be updated. First delete the Local IP and then add again.");
return;
}
if (isLocalIpAdded || isLocalIpRemoved) {
isTepInfoUpdated = true;
}
if (isTzUpdated(oldTzName, tzName)) {
isTepInfoUpdated = true;
if (oldLocalIp != null && newLocalIp != null) {
isTzChanged = true;
LOG.trace("tzname is changed from {} to {} for Local IP: {}", oldTzName, tzName, newLocalIp);
}
}
if (isDpnUpdated(oldDpnBridgeName, newDpnBridgeName)) {
isTepInfoUpdated = true;
if (oldLocalIp != null && newLocalIp != null) {
isDpnBrChanged = true;
LOG.trace("dpn-br-name is changed from {} to {} for Local IP: {}", oldDpnBridgeName, newDpnBridgeName, newLocalIp);
}
}
if (!isTepInfoUpdated) {
LOG.trace("No updates in the TEP Info parameters. Nothing to do.");
return;
}
}
String strOldDpnId;
String strNewDpnId;
// handle TEP-remove in remove case, TZ change case, Bridge change case
if (isTepInfoDeleted || isLocalIpRemoved || isTzChanged || isDpnBrChanged) {
// if flag is OFF, then no need to add TEP into ITM config DS.
if (oldTzName == null || oldTzName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
boolean defTzEnabled = itmConfig.isDefTzEnabled();
if (!defTzEnabled) {
LOG.info("TEP ({}) cannot be removed from {} when def-tz-enabled flag is false.", oldLocalIp, ITMConstants.DEFAULT_TRANSPORT_ZONE);
return;
}
oldTzName = ITMConstants.DEFAULT_TRANSPORT_ZONE;
}
// TBD: Move this time taking operations into DataStoreJobCoordinator
strOldDpnId = ItmUtils.getBridgeDpid(updatedOvsdbNode, oldDpnBridgeName, dataBroker);
if (strOldDpnId == null || strOldDpnId.isEmpty()) {
LOG.error("TEP {} cannot be deleted. DPID for bridge {} is NULL.", oldLocalIp, oldDpnBridgeName);
return;
}
// remove TEP
LOG.trace("Update case: Removing TEP-IP: {}, TZ name: {}, Bridge Name: {}, Bridge DPID: {}", oldLocalIp, oldTzName, oldDpnBridgeName, strOldDpnId);
// Enqueue 'remove TEP from TZ' operation into DataStoreJobCoordinator
jobCoordinator.enqueueJob(oldLocalIp, new OvsdbTepRemoveWorker(oldLocalIp, strOldDpnId, oldTzName, dataBroker));
}
// handle TEP-add in add case, TZ change case, Bridge change case
if (isLocalIpAdded || isTzChanged || isDpnBrChanged) {
// if flag is OFF, then no need to add TEP into ITM config DS.
if (tzName == null || tzName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
boolean defTzEnabled = itmConfig.isDefTzEnabled();
if (!defTzEnabled) {
LOG.info("TEP ({}) cannot be added into {} when def-tz-enabled flag is false.", newLocalIp, ITMConstants.DEFAULT_TRANSPORT_ZONE);
return;
}
tzName = ITMConstants.DEFAULT_TRANSPORT_ZONE;
}
// TBD: Move this time taking operations into DataStoreJobCoordinator
// get Datapath ID for bridge
strNewDpnId = ItmUtils.getBridgeDpid(updatedOvsdbNode, newDpnBridgeName, dataBroker);
if (strNewDpnId == null || strNewDpnId.isEmpty()) {
LOG.error("TEP {} cannot be added. DPID for bridge {} is NULL.", newLocalIp, newDpnBridgeName);
return;
}
LOG.trace("Update case: Adding TEP-IP: {}, TZ name: {}, Bridge Name: {}, Bridge DPID: {}," + "of-tunnel: {}", newLocalIp, tzName, newDpnBridgeName, strNewDpnId, newOfTunnel);
// Enqueue 'add TEP into new TZ' operation into DataStoreJobCoordinator
jobCoordinator.enqueueJob(newLocalIp, new OvsdbTepAddWorker(newLocalIp, strNewDpnId, tzName, newOfTunnel, dataBroker));
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.Updates in project genius by opendaylight.
the class AlivenessMonitorUtils method handleTunnelMonitorUpdates.
public void handleTunnelMonitorUpdates(Interface interfaceOld, Interface interfaceNew) {
String interfaceName = interfaceNew.getName();
IfTunnel ifTunnelNew = interfaceNew.getAugmentation(IfTunnel.class);
if (!lldpMonitoringEnabled(ifTunnelNew)) {
return;
}
LOG.debug("handling tunnel monitoring updates for interface {}", interfaceName);
stopLLDPMonitoring(ifTunnelNew, interfaceOld.getName());
if (ifTunnelNew.isMonitorEnabled()) {
startLLDPMonitoring(ifTunnelNew, interfaceName);
// Delete old profile from Aliveness Manager
IfTunnel ifTunnelOld = interfaceOld.getAugmentation(IfTunnel.class);
if (!ifTunnelNew.getMonitorInterval().equals(ifTunnelOld.getMonitorInterval())) {
LOG.debug("deleting older monitor profile for interface {}", interfaceName);
long profileId = allocateProfile(FAILURE_THRESHOLD, ifTunnelOld.getMonitorInterval(), MONITORING_WINDOW, EtherTypes.Lldp);
MonitorProfileDeleteInput profileDeleteInput = new MonitorProfileDeleteInputBuilder().setProfileId(profileId).build();
Future<RpcResult<Void>> future = alivenessMonitorService.monitorProfileDelete(profileDeleteInput);
ListenableFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(future), LOG, "Delete monitor profile {}", interfaceName);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.Updates in project genius by opendaylight.
the class NodeConnectorStatsImpl method processFlowStatistics.
/**
* This method processes FlowStatistics RPC result.
* It performs:
* - fetches all flows of node
* - stores flows count per table in local map
* - creates/updates Flow table counters using Infrautils metrics API
* - set counter with values fetched from FlowStatistics
*/
private void processFlowStatistics(GetFlowStatisticsOutput flowStatsOutput, BigInteger dpid) {
Map<Short, AtomicInteger> flowTableMap = new HashMap<>();
// Get all flows for node from RPC result
List<FlowAndStatisticsMapList> flowTableAndStatisticsMapList = flowStatsOutput.getFlowAndStatisticsMapList();
for (FlowAndStatisticsMapList flowAndStatisticsMap : flowTableAndStatisticsMapList) {
short tableId = flowAndStatisticsMap.getTableId();
// populate map to maintain flow count per table
flowTableMap.computeIfAbsent(tableId, key -> new AtomicInteger(0)).incrementAndGet();
}
LOG.trace("FlowTableStatistics (tableId:counter): {} for node: {}", flowTableMap.entrySet(), dpid.toString());
for (Map.Entry<Short, AtomicInteger> flowTable : flowTableMap.entrySet()) {
Short tableId = flowTable.getKey();
AtomicInteger flowCount = flowTable.getValue();
Counter counter = getCounter(CounterConstants.IFM_FLOW_TBL_COUNTER_FLOWS_PER_TBL, dpid, null, null, tableId.toString());
// update counter value
updateCounter(counter, flowCount.longValue());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.Updates in project genius by opendaylight.
the class NodeConnectorStatsImpl method processNodeConnectorStatistics.
/**
* This method processes NodeConnectorStatistics RPC result.
* It performs:
* - fetches various OF Port counters values
* - creates/updates new OF Port counters using Infrautils metrics API
* - set counter with values fetched from NodeConnectorStatistics
*/
private void processNodeConnectorStatistics(GetNodeConnectorStatisticsOutput nodeConnectorStatisticsOutput, BigInteger dpid) {
String port = "";
String portUuid = "";
List<NodeConnectorStatisticsAndPortNumberMap> ncStatsAndPortMapList = nodeConnectorStatisticsOutput.getNodeConnectorStatisticsAndPortNumberMap();
// Parse NodeConnectorStatistics and create/update counters for them
for (NodeConnectorStatisticsAndPortNumberMap ncStatsAndPortMap : ncStatsAndPortMapList) {
NodeConnectorId nodeConnector = ncStatsAndPortMap.getNodeConnectorId();
LOG.trace("Create/update metric counter for NodeConnector: {} of node: {}", nodeConnector, dpid.toString());
port = nodeConnector.getValue();
// update port name as per port name maintained in portNameCache
String portNameInCache = "openflow" + ":" + dpid.toString() + ":" + port;
java.util.Optional<String> portName = portNameCache.get(portNameInCache);
if (portName.isPresent()) {
Optional<List<InterfaceChildEntry>> interfaceChildEntries = interfaceChildCache.getInterfaceChildEntries(portName.get());
if (interfaceChildEntries.isPresent()) {
if (!interfaceChildEntries.get().isEmpty()) {
portUuid = interfaceChildEntries.get().get(0).getChildInterface();
LOG.trace("Retrieved portUuid {} for portname {}", portUuid, portName.get());
} else {
LOG.trace("PortUuid is not found for portname {}. Skipping IFM counters publish for this port.", portName.get());
continue;
}
} else {
LOG.trace("PortUuid is not found for portname {}. Skipping IFM counters publish for this port.", portName.get());
continue;
}
}
Counter counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_DURATION, dpid, port, portUuid, null);
long ofPortDuration = ncStatsAndPortMap.getDuration().getSecond().getValue();
updateCounter(counter, ofPortDuration);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECVDROP, dpid, port, portUuid, null);
long packetsPerOFPortReceiveDrop = ncStatsAndPortMap.getReceiveDrops().longValue();
updateCounter(counter, packetsPerOFPortReceiveDrop);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECVERROR, dpid, port, portUuid, null);
long packetsPerOFPortReceiveError = ncStatsAndPortMap.getReceiveErrors().longValue();
updateCounter(counter, packetsPerOFPortReceiveError);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_SENT, dpid, port, portUuid, null);
long packetsPerOFPortSent = ncStatsAndPortMap.getPackets().getTransmitted().longValue();
updateCounter(counter, packetsPerOFPortSent);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECV, dpid, port, portUuid, null);
long packetsPerOFPortReceive = ncStatsAndPortMap.getPackets().getReceived().longValue();
updateCounter(counter, packetsPerOFPortReceive);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_BYTE_SENT, dpid, port, portUuid, null);
long bytesPerOFPortSent = ncStatsAndPortMap.getBytes().getTransmitted().longValue();
updateCounter(counter, bytesPerOFPortSent);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_BYTE_RECV, dpid, port, portUuid, null);
long bytesPerOFPortReceive = ncStatsAndPortMap.getBytes().getReceived().longValue();
updateCounter(counter, bytesPerOFPortReceive);
}
}
Aggregations