use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterfaceKey in project genius by opendaylight.
the class AlivenessMonitorUtils method createOrUpdateMonitorIdInterfaceMap.
private static void createOrUpdateMonitorIdInterfaceMap(ReadWriteTransaction tx, String infName, long monitorId) throws ReadFailedException {
MonitorIdInterface monitorIdInterfaceInstance;
String existinginterfaceName;
MonitorIdInterfaceBuilder monitorIdInterfaceBuilder = new MonitorIdInterfaceBuilder();
InstanceIdentifier<MonitorIdInterface> id = InstanceIdentifier.builder(MonitorIdInterfaceMap.class).child(MonitorIdInterface.class, new MonitorIdInterfaceKey(monitorId)).build();
Optional<MonitorIdInterface> monitorIdInterfaceMap = tx.read(LogicalDatastoreType.OPERATIONAL, id).checkedGet();
if (monitorIdInterfaceMap.isPresent()) {
monitorIdInterfaceInstance = monitorIdInterfaceMap.get();
existinginterfaceName = monitorIdInterfaceInstance.getInterfaceName();
if (!existinginterfaceName.equals(infName)) {
monitorIdInterfaceInstance = monitorIdInterfaceBuilder.setKey(new MonitorIdInterfaceKey(monitorId)).setInterfaceName(infName).build();
tx.merge(LogicalDatastoreType.OPERATIONAL, id, monitorIdInterfaceInstance, WriteTransaction.CREATE_MISSING_PARENTS);
}
} else {
monitorIdInterfaceInstance = monitorIdInterfaceBuilder.setMonitorId(monitorId).setKey(new MonitorIdInterfaceKey(monitorId)).setInterfaceName(infName).build();
tx.merge(LogicalDatastoreType.OPERATIONAL, id, monitorIdInterfaceInstance, WriteTransaction.CREATE_MISSING_PARENTS);
}
}
Aggregations