}
public LogicalSwitch getLogicalSwitch(UUID uuid) {
- return (LogicalSwitch) getDeviceOperData(LogicalSwitches.class, uuid);
+ DeviceData deviceData = getDeviceOperData(LogicalSwitches.class, uuid);
+ if (deviceData != null && deviceData.getData() != null) {
+ return (LogicalSwitch) deviceData.getData();
+ }
+ return null;
}
public Map<UUID, LogicalSwitch> getLogicalSwitches() {
}
public PhysicalLocator getPhysicalLocator(UUID uuid) {
- return (PhysicalLocator) getDeviceOperData(TerminationPoint.class, uuid);
+ DeviceData deviceData = getDeviceOperData(TerminationPoint.class, uuid);
+ if (deviceData != null && deviceData.getData() != null) {
+ return (PhysicalLocator) deviceData.getData();
+ }
+ return null;
}
public Map<UUID, PhysicalLocator> getPhysicalLocators() {
}
}
- public Object getDeviceOperData(Class<? extends Identifiable> cls, UUID uuid) {
- return HwvtepSouthboundUtil.getData(uuidVsData, cls, uuid).getData();
+ public DeviceData getDeviceOperData(Class<? extends Identifiable> cls, UUID uuid) {
+ return HwvtepSouthboundUtil.getData(uuidVsData, cls, uuid);
}
public DeviceData getDeviceOperData(Class<? extends Identifiable> cls, InstanceIdentifier key) {
public static <K, D> void updateData(Map<Class<? extends Identifiable>, Map<K, D>> map,
Class<? extends Identifiable> cls, K key, D data) {
+ LOG.debug("Updating data {} {} {}", cls, key, data);
if (key == null) {
return;
}
public static <K, D> void clearData(Map<Class<? extends Identifiable>, Map<K, D>> map,
Class<? extends Identifiable> cls, K key) {
+ LOG.debug("Clearing data {} {}", cls, key);
if (key == null) {
return;
}
Map inTransitDependencies = new HashMap<>();
Map configDependencies = new HashMap<>();
- if (!isRemoveCommand() && unMetDependencyGetter != null) {
+ if (!isDeleteCmd() && unMetDependencyGetter != null) {
inTransitDependencies = unMetDependencyGetter.getInTransitDependencies(getOperationalState(), data);
configDependencies = unMetDependencyGetter.getUnMetConfigDependencies(getOperationalState(), data);
//we can skip the config termination point dependency as we can create them in device as part of this tx
if (HwvtepSouthboundUtil.isEmptyMap(configDependencies) && HwvtepSouthboundUtil.isEmptyMap(
inTransitDependencies)) {
doDeviceTransaction(transaction, nodeIid, data, key, extraData);
- if (isRemoveCommand()) {
+ if (isDeleteCmd()) {
getDeviceInfo().clearConfigData((Class<? extends Identifiable>) classType, key);
} else {
getDeviceInfo().updateConfigData((Class<? extends Identifiable>) classType, key, data);
return false;
}
- protected boolean isRemoveCommand() {
+ protected boolean isDeleteCmd() {
return false;
}
--- /dev/null
+/*
+ * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.hwvtepsouthbound.transact;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public final class EmptyDependencyGetter extends UnMetDependencyGetter {
+
+ public static final EmptyDependencyGetter INSTANCE = new EmptyDependencyGetter();
+
+ private EmptyDependencyGetter() {
+ }
+
+ @Override
+ public List<InstanceIdentifier<?>> getLogicalSwitchDependencies(Identifiable data) {
+ return Collections.EMPTY_LIST;
+ }
+
+ @Override
+ public List<InstanceIdentifier<?>> getTerminationPointDependencies(Identifiable data) {
+ return Collections.EMPTY_LIST;
+ }
+}
protected boolean areEqual(final LogicalRouters routers1, final LogicalRouters routers2) {
return routers1.key().equals(routers2.key());
}
+
+ @Override
+ public boolean isDeleteCmd() {
+ return true;
+ }
}
}
@Override
- protected boolean isRemoveCommand() {
+ protected boolean isDeleteCmd() {
return true;
}
final LogicalSwitches lswitch,
final InstanceIdentifier lsKey,
final Object... extraData) {
- processDependencies(null, transaction, nodeIid, lsKey, lswitch);
+ processDependencies(EmptyDependencyGetter.INSTANCE, transaction, nodeIid, lsKey, lswitch);
}
@Override
}
@Override
- protected boolean isRemoveCommand() {
+ protected boolean isDeleteCmd() {
return true;
}
}
final RemoteMcastMacs remoteMcastMac,
final InstanceIdentifier macKey,
final Object... extraData) {
- processDependencies(null, transaction, nodeIid, macKey, remoteMcastMac);
+ processDependencies(EmptyDependencyGetter.INSTANCE, transaction, nodeIid, macKey, remoteMcastMac);
}
@Override
}
@Override
- protected boolean isRemoveCommand() {
+ protected boolean isDeleteCmd() {
return true;
}
}
@Override
- protected boolean isRemoveCommand() {
+ protected boolean isDeleteCmd() {
return true;
}
}
}
@Override
- protected boolean isRemoveCommand() {
+ protected boolean isDeleteCmd() {
return true;
}
final InstanceIdentifier<Node> connectionIId = getOvsdbConnectionInstance().getInstanceIdentifier();
Node connectionNode = buildConnectionNode(macRemote);
transaction.merge(LogicalDatastoreType.OPERATIONAL, connectionIId, connectionNode);
- InstanceIdentifier<RemoteMcastMacs> macIid = getMacIid(connectionIId, connectionNode);
- getOvsdbConnectionInstance().getDeviceInfo().updateDeviceOperData(RemoteMcastMacs.class,
- macIid, macRemote.getUuid(), macRemote);
}
InstanceIdentifier<RemoteMcastMacs> getMacIid(InstanceIdentifier<Node> connectionIId, Node connectionNode) {
setLogicalSwitch(macRemoteBuilder, macRemote);
List<RemoteMcastMacs> macRemoteList = new ArrayList<>();
- macRemoteList.add(macRemoteBuilder.build());
+ RemoteMcastMacs mac = macRemoteBuilder.build();
+ macRemoteList.add(mac);
HwvtepGlobalAugmentationBuilder hgAugmentationBuilder = new HwvtepGlobalAugmentationBuilder();
hgAugmentationBuilder.setRemoteMcastMacs(macRemoteList);
connectionNode.addAugmentation(HwvtepGlobalAugmentation.class, hgAugmentationBuilder.build());
+ InstanceIdentifier<RemoteMcastMacs> macIid = getOvsdbConnectionInstance().getInstanceIdentifier()
+ .augmentation(HwvtepGlobalAugmentation.class).child(RemoteMcastMacs.class, mac.key());
+ getOvsdbConnectionInstance().getDeviceInfo().updateDeviceOperData(RemoteMcastMacs.class,
+ macIid, macRemote.getUuid(), macRemote);
return connectionNode.build();
}
PhysicalLocator locator = updatedPLocRows.get(locUUID);
if (locator == null) {
locator = (PhysicalLocator) getOvsdbConnectionInstance()
- .getDeviceInfo().getDeviceOperData(TerminationPoint.class, locUUID);
+ .getDeviceInfo().getPhysicalLocator(locUUID);
}
InstanceIdentifier<TerminationPoint> tpIid = HwvtepSouthboundMapper.createInstanceIdentifier(
getOvsdbConnectionInstance().getInstanceIdentifier(), locator);