Search in sources :

Example 1 with MonitorIdInterfaceKey

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);
    }
}
Also used : MonitorIdInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterfaceBuilder) MonitorIdInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterface) MonitorIdInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterfaceKey)

Aggregations

MonitorIdInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterface)1 MonitorIdInterfaceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterfaceBuilder)1 MonitorIdInterfaceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.monitor.id._interface.map.MonitorIdInterfaceKey)1