package org.opendaylight.ovsdb.hwvtepsouthbound.transact;
-import static org.opendaylight.ovsdb.lib.operations.Operations.op;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
+import com.google.common.base.Optional;
+import com.google.common.collect.Lists;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundConstants;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundUtil;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSet;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Optional;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import static org.opendaylight.ovsdb.lib.operations.Operations.op;
-public class McastMacsRemoteUpdateCommand extends AbstractTransactCommand {
+public class McastMacsRemoteUpdateCommand extends AbstractTransactCommand<RemoteMcastMacs> {
private static final Logger LOG = LoggerFactory.getLogger(McastMacsRemoteUpdateCommand.class);
+ private static final McastMacUnMetDependencyGetter MCAST_MAC_DATA_VALIDATOR = new McastMacUnMetDependencyGetter();
public McastMacsRemoteUpdateCommand(HwvtepOperationalState state,
Collection<DataTreeModification<Node>> changes) {
private void updateMcastMacRemote(TransactionBuilder transaction,
InstanceIdentifier<Node> instanceIdentifier, List<RemoteMcastMacs> macList) {
for (RemoteMcastMacs mac: macList) {
+ onConfigUpdate(transaction, instanceIdentifier, mac, null);
+ }
+ }
+
+ @Override
+ public void onConfigUpdate(TransactionBuilder transaction,
+ InstanceIdentifier<Node> nodeIid,
+ RemoteMcastMacs remoteMcastMac,
+ InstanceIdentifier macKey,
+ Object... extraData) {
+ InstanceIdentifier<RemoteMcastMacs> macIid = nodeIid.augmentation(HwvtepGlobalAugmentation.class).
+ child(RemoteMcastMacs.class, remoteMcastMac.getKey());
+ processDependencies(MCAST_MAC_DATA_VALIDATOR, transaction, nodeIid, macIid, remoteMcastMac);
+ }
+
+ @Override
+ public void doDeviceTransaction(TransactionBuilder transaction,
+ InstanceIdentifier<Node> instanceIdentifier,
+ RemoteMcastMacs mac,
+ InstanceIdentifier macKey,
+ Object... extraData) {
LOG.debug("Creating remoteMcastMacs, mac address: {}", mac.getMacEntryKey().getValue());
Optional<RemoteMcastMacs> operationalMacOptional =
getOperationalState().getRemoteMcastMacs(instanceIdentifier, mac.getKey());
LOG.warn("Unable to update remoteMcastMacs {} because uuid not found in the operational store",
mac.getMacEntryKey().getValue());
}
- }
}
private void setLogicalSwitch(McastMacsRemote mcastMacsRemote, RemoteMcastMacs inputMac) {
}
return result;
}
+
+ static class McastMacUnMetDependencyGetter extends UnMetDependencyGetter<RemoteMcastMacs> {
+
+ public List<InstanceIdentifier<?>> getLogicalSwitchDependencies(RemoteMcastMacs data) {
+ if (data == null) {
+ return Collections.EMPTY_LIST;
+ }
+ return Lists.newArrayList(data.getLogicalSwitchRef().getValue());
+ }
+
+ public List<InstanceIdentifier<?>> getTerminationPointDependencies(RemoteMcastMacs data) {
+ if (data == null || HwvtepSouthboundUtil.isEmpty(data.getLocatorSet())) {
+ return Collections.EMPTY_LIST;
+ }
+ List<InstanceIdentifier<?>> locators = new ArrayList<>();
+ for (LocatorSet locator: data.getLocatorSet()) {
+ locators.add(locator.getLocatorRef().getValue());
+ }
+ return locators;
+ }
+ }
}