LOG.trace("Connection Change Map: {}", result);
return result;
}
-}
\ No newline at end of file
+}
return tpKey;
}
+ public static String getRandomUUID() {
+ return "Random_" + java.util.UUID.randomUUID().toString().replace("-", "");
+ }
}
return result;
}
- private static Optional<HwvtepGlobalAugmentation> getManagingNode(DataBroker db, HwvtepGlobalRef ref) {
+ public static Optional<HwvtepGlobalAugmentation> getManagingNode(DataBroker db, HwvtepGlobalRef ref) {
try {
ReadOnlyTransaction transaction = db.newReadOnlyTransaction();
@SuppressWarnings("unchecked")
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.EncapsulationTypeBase;
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.HwvtepNodeName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
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.LogicalSwitchesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Switches;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.base.Preconditions;
public class HwvtepOperationalState {
private static final Logger LOG = LoggerFactory.getLogger(HwvtepOperationalState.class);
private Map<InstanceIdentifier<Node>, Node> operationalNodes = new HashMap<>();
public HwvtepOperationalState(DataBroker db, Collection<DataTreeModification<Node>> changes) {
- ReadOnlyTransaction transaction = db.newReadOnlyTransaction();
Map<InstanceIdentifier<Node>, Node> nodeCreateOrUpdate =
TransactUtils.extractCreatedOrUpdatedOrRemoved(changes, Node.class);
if (nodeCreateOrUpdate != null) {
+ final ReadWriteTransaction transaction = db.newReadWriteTransaction();
for (Entry<InstanceIdentifier<Node>, Node> entry: nodeCreateOrUpdate.entrySet()) {
- CheckedFuture<Optional<Node>, ReadFailedException> nodeFuture =
- transaction.read(LogicalDatastoreType.OPERATIONAL, entry.getKey());
- try {
- Optional<Node> nodeOptional = nodeFuture.get();
- if (nodeOptional.isPresent()) {
- operationalNodes.put(entry.getKey(), nodeOptional.get());
+ Optional<Node> readNode = HwvtepSouthboundUtil.readNode(transaction, entry.getKey());
+ //add related globalNode or physicalSwitchNode to operationalNodes map
+ //for example, when creating physical port, logical switch is needed
+ //but logical switch is in HwvtepGlobalAugmentation rather than PhysicalSwitchAugmentation
+ if (readNode.isPresent()) {
+ operationalNodes.put(entry.getKey(), readNode.get());
+ HwvtepGlobalAugmentation hgAugmentation = readNode.get().getAugmentation(HwvtepGlobalAugmentation.class);
+ PhysicalSwitchAugmentation psAugmentation = readNode.get().getAugmentation(PhysicalSwitchAugmentation.class);
+ if (hgAugmentation != null) {
+ for (Switches pswitch : hgAugmentation.getSwitches()) {
+ @SuppressWarnings("unchecked")
+ InstanceIdentifier<Node> psNodeIid = (InstanceIdentifier<Node>) pswitch.getSwitchRef().getValue();
+ Optional<Node> psNode = HwvtepSouthboundUtil.readNode(transaction, psNodeIid);
+ if (psNode.isPresent()) {
+ operationalNodes.put(psNodeIid, psNode.get());
+ }
+ }
+ }
+ if (psAugmentation != null) {
+ @SuppressWarnings("unchecked")
+ InstanceIdentifier<Node> hgNodeIid = (InstanceIdentifier<Node>) psAugmentation.getManagedBy().getValue();
+ Optional<Node> hgNode = HwvtepSouthboundUtil.readNode(transaction, hgNodeIid);
+ if (hgNode.isPresent()) {
+ operationalNodes.put(hgNodeIid, hgNode.get());
+ }
}
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("Error reading from datastore",e);
}
}
}
- transaction.close();
}
- public Optional<Node> getGlobalNode(InstanceIdentifier<?> iid) {
+ private Optional<Node> getGlobalNode(InstanceIdentifier<?> iid) {
InstanceIdentifier<Node> nodeIid = iid.firstIdentifierOf(Node.class);
return Optional.fromNullable(operationalNodes.get(nodeIid));
}
- public Optional<LogicalSwitches> getLogicalSwitches(InstanceIdentifier<?> iid, LogicalSwitchesKey lswitchKey) {
+ public Optional<HwvtepGlobalAugmentation> getHwvtepGlobalAugmentation(InstanceIdentifier<?> iid) {
+ Preconditions.checkNotNull(iid);
Optional<Node> nodeOptional = getGlobalNode(iid);
if (nodeOptional.isPresent()) {
- List<LogicalSwitches> lswitchList = nodeOptional.get().getAugmentation(HwvtepGlobalAugmentation.class).getLogicalSwitches();
- if (lswitchList != null) {
- for (LogicalSwitches lswitch: lswitchList) {
- if (lswitch.getKey().equals(lswitchKey)) {
- return Optional.fromNullable(lswitch);
- }
- }
- }
+ return Optional.fromNullable(nodeOptional.get().getAugmentation(HwvtepGlobalAugmentation.class));
}
return Optional.absent();
}
public Optional<PhysicalSwitchAugmentation> getPhysicalSwitchAugmentation(InstanceIdentifier<?> iid) {
+ Preconditions.checkNotNull(iid);
Optional<Node> nodeOptional = getGlobalNode(iid);
if (nodeOptional.isPresent()) {
return Optional.fromNullable(nodeOptional.get().getAugmentation(PhysicalSwitchAugmentation.class));
return Optional.absent();
}
- public Optional<TerminationPoint> getHwvtepTerminationPoint(InstanceIdentifier<?> iid) {
- if (iid != null) {
- Optional<Node> nodeOptional = getGlobalNode(iid);
- if (nodeOptional.isPresent() && nodeOptional.get().getTerminationPoint() != null) {
- TerminationPointKey key = iid.firstKeyOf(TerminationPoint.class, TerminationPointKey.class);
- if (key != null) {
- for (TerminationPoint tp:nodeOptional.get().getTerminationPoint()) {
- if (tp.getKey().equals(key)) {
- return Optional.of(tp);
- }
+ public Optional<List<TerminationPoint>> getTerminationPointList(InstanceIdentifier<?> iid) {
+ Preconditions.checkNotNull(iid);
+ Optional<Node> nodeOptional = getGlobalNode(iid);
+ if (nodeOptional.isPresent() && nodeOptional.get().getTerminationPoint() != null) {
+ return Optional.fromNullable(nodeOptional.get().getTerminationPoint());
+ }
+ return Optional.absent();
+ }
+
+ public Optional<LogicalSwitches> getLogicalSwitches(InstanceIdentifier<?> iid, LogicalSwitchesKey logicalSwitchesKey) {
+ Preconditions.checkNotNull(iid);
+ Optional<HwvtepGlobalAugmentation> nodeOptional = getHwvtepGlobalAugmentation(iid);
+ if (nodeOptional.isPresent()) {
+ HwvtepGlobalAugmentation hgAugmentation = nodeOptional.get();
+ List<LogicalSwitches> lswitchList = null;
+ if (hgAugmentation != null) {
+ lswitchList = hgAugmentation.getLogicalSwitches();
+ }
+ if (lswitchList != null) {
+ for (LogicalSwitches lswitch: lswitchList) {
+ if (lswitch.getKey().equals(logicalSwitchesKey)) {
+ return Optional.fromNullable(lswitch);
}
}
}
return Optional.absent();
}
- public Optional<HwvtepPhysicalLocatorAugmentation> getPhysicalLocatorAugmentation(InstanceIdentifier<?> iid) {
- Optional<TerminationPoint> nodeOptional = getHwvtepTerminationPoint(iid);
+ public Optional<HwvtepPhysicalPortAugmentation> getPhysicalPortAugmentation(InstanceIdentifier<?> iid,
+ HwvtepNodeName hwvtepNodeName) {
+ Preconditions.checkNotNull(iid);
+ Optional<List<TerminationPoint>> nodeOptional = getTerminationPointList(iid);
if (nodeOptional.isPresent()) {
- return Optional.fromNullable(nodeOptional.get().getAugmentation(HwvtepPhysicalLocatorAugmentation.class));
+ List<TerminationPoint> tpList = nodeOptional.get();
+ for (TerminationPoint tp : tpList) {
+ HwvtepPhysicalPortAugmentation hppAugmentation = tp.getAugmentation(HwvtepPhysicalPortAugmentation.class);
+ if (hppAugmentation.getHwvtepNodeName().equals(hwvtepNodeName)) {
+ return Optional.fromNullable(hppAugmentation);
+ }
+ }
}
return Optional.absent();
}
- public Optional<HwvtepPhysicalPortAugmentation> getPhysycalPortAugmentation(InstanceIdentifier<?> iid) {
- Optional<TerminationPoint> tpOptional = getHwvtepTerminationPoint(iid);
- if (tpOptional.isPresent()) {
- return Optional.fromNullable(tpOptional.get().getAugmentation(HwvtepPhysicalPortAugmentation.class));
+ public Optional<HwvtepPhysicalLocatorAugmentation> getPhysicalLocatorAugmentation(InstanceIdentifier<?> iid,
+ IpAddress dstIp, Class<? extends EncapsulationTypeBase> encapType) {
+ Preconditions.checkNotNull(iid);
+ Optional<List<TerminationPoint>> nodeOptional = getTerminationPointList(iid);
+ if (nodeOptional.isPresent()) {
+ List<TerminationPoint> tpList = nodeOptional.get();
+ for (TerminationPoint tp : tpList) {
+ HwvtepPhysicalLocatorAugmentation hppAugmentation = tp.getAugmentation(HwvtepPhysicalLocatorAugmentation.class);
+ if (hppAugmentation.getDstIp().equals(dstIp)
+ && hppAugmentation.getEncapsulationType().equals(encapType)) {
+ return Optional.fromNullable(hppAugmentation);
+ }
+ }
}
return Optional.absent();
}
final DataObjectModification<Node> mod = change.getRootNode();
Node created = TransactUtils.getCreated(mod);
if (created != null) {
- List<LogicalSwitches> lswitchListUpdated = created.getAugmentation(HwvtepGlobalAugmentation.class).getLogicalSwitches();
+ List<LogicalSwitches> lswitchListUpdated = null;
+ if (created.getAugmentation(HwvtepGlobalAugmentation.class) != null) {
+ lswitchListUpdated = created.getAugmentation(HwvtepGlobalAugmentation.class).getLogicalSwitches();
+ }
if (lswitchListUpdated != null) {
result.put(key, lswitchListUpdated);
}
Node updated = TransactUtils.getUpdated(mod);
Node before = mod.getDataBefore();
if (updated != null && before != null) {
- List<LogicalSwitches> lswitchListUpdated = updated.getAugmentation(HwvtepGlobalAugmentation.class).getLogicalSwitches();
- List<LogicalSwitches> lswitchListBefore = before.getAugmentation(HwvtepGlobalAugmentation.class).getLogicalSwitches();
+ List<LogicalSwitches> lswitchListUpdated = null;
+ List<LogicalSwitches> lswitchListBefore = null;
+ if (updated.getAugmentation(HwvtepGlobalAugmentation.class) != null) {
+ lswitchListUpdated = updated.getAugmentation(HwvtepGlobalAugmentation.class).getLogicalSwitches();
+ }
+ if (before.getAugmentation(HwvtepGlobalAugmentation.class) != null) {
+ lswitchListBefore = before.getAugmentation(HwvtepGlobalAugmentation.class).getLogicalSwitches();
+ }
if (lswitchListUpdated != null) {
if (lswitchListBefore != null) {
lswitchListUpdated.removeAll(lswitchListBefore);
package org.opendaylight.ovsdb.hwvtepsouthbound.transact;
+import static org.opendaylight.ovsdb.lib.operations.Operations.op;
+
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundMapper;
+import org.opendaylight.ovsdb.lib.notation.Mutator;
+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.ovsdb.schema.hardwarevtep.PhysicalPort;
+import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalSwitch;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalPortAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.PhysicalSwitchAugmentation;
+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.LogicalSwitchesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.port.attributes.VlanBindings;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Optional;
+import com.google.common.collect.Sets;
+
public class PhysicalPortUpdateCommand extends AbstractTransactCommand {
private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortUpdateCommand.class);
@Override
public void execute(TransactionBuilder transaction) {
- //TODO
+ Map<InstanceIdentifier<Node>, List<HwvtepPhysicalPortAugmentation>> createds =
+ extractCreated(getChanges(),HwvtepPhysicalPortAugmentation.class);
+ Map<InstanceIdentifier<Node>, PhysicalSwitchAugmentation> createdPhysicalSwitches =
+ extractCreatedPhyscialSwitch(getChanges(),PhysicalSwitchAugmentation.class);
+ if (!createds.isEmpty()) {
+ for (Entry<InstanceIdentifier<Node>, List<HwvtepPhysicalPortAugmentation>> created:
+ createds.entrySet()) {
+ updatePhysicalPort(transaction, created.getKey(), created.getValue(), createdPhysicalSwitches);
+ }
+ }
+ Map<InstanceIdentifier<Node>, List<HwvtepPhysicalPortAugmentation>> updateds =
+ extractUpdated(getChanges(),HwvtepPhysicalPortAugmentation.class);
+ if (!updateds.isEmpty()) {
+ for (Entry<InstanceIdentifier<Node>, List<HwvtepPhysicalPortAugmentation>> updated:
+ updateds.entrySet()) {
+ updatePhysicalPort(transaction, updated.getKey(), updated.getValue(), createdPhysicalSwitches);
+ }
+ }
}
-}
+ private void updatePhysicalPort(TransactionBuilder transaction,
+ InstanceIdentifier<Node> psNodeiid,
+ List<HwvtepPhysicalPortAugmentation> listPort,
+ Map<InstanceIdentifier<Node>, PhysicalSwitchAugmentation> createdPhysicalSwitches ) {
+ //Get physical switch which the port belong to: in operation DS or new created
+ PhysicalSwitchAugmentation physicalSwitchBelong = getPhysicalSwitchBelong(psNodeiid, createdPhysicalSwitches);
+ for (HwvtepPhysicalPortAugmentation port : listPort) {
+ LOG.debug("Creating a physical port named: {}", port.getHwvtepNodeName().getValue());
+ Optional<HwvtepPhysicalPortAugmentation> operationalPhysicalPortOptional =
+ getOperationalState().getPhysicalPortAugmentation(psNodeiid, port.getHwvtepNodeName());
+ PhysicalPort physicalPort = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), PhysicalPort.class);
+ //get managing global node of physicalSwitchBelong
+ InstanceIdentifier<?> globalNodeIid = physicalSwitchBelong.getManagedBy().getValue();
+ setVlanBindings(globalNodeIid, physicalPort, port);
+ setDescription(physicalPort, port);
+ if (!operationalPhysicalPortOptional.isPresent()) {
+ //create a physical port
+ setName(physicalPort, port, operationalPhysicalPortOptional);
+ String portUuid = "PhysicalPort_" + HwvtepSouthboundMapper.getRandomUUID();
+ transaction.add(op.insert(physicalPort).withId(portUuid));
+ //update physical switch table
+ PhysicalSwitch physicalSwitch = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), PhysicalSwitch.class);
+ physicalSwitch.setName(physicalSwitchBelong.getHwvtepNodeName().getValue());
+ physicalSwitch.setPorts(Sets.newHashSet(new UUID(portUuid)));
+ LOG.info("execute: physical switch: {}", physicalSwitch);
+ transaction.add(op.mutate(physicalSwitch)
+ .addMutation(physicalSwitch.getPortsColumn().getSchema(), Mutator.INSERT,
+ physicalSwitch.getPortsColumn().getData())
+ .where(physicalSwitch.getNameColumn().getSchema().opEqual(physicalSwitch.getNameColumn().getData()))
+ .build());
+ } else {
+ //updated physical port only
+ HwvtepPhysicalPortAugmentation updatedPhysicalPort = operationalPhysicalPortOptional.get();
+ String existingPhysicalPortName = updatedPhysicalPort.getHwvtepNodeName().getValue();
+ PhysicalPort extraPhyscialPort =
+ TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), PhysicalPort.class);
+ extraPhyscialPort.setName("");
+ transaction.add(op.update(physicalPort)
+ .where(extraPhyscialPort.getNameColumn().getSchema().opEqual(existingPhysicalPortName))
+ .build());
+ }
+ }
+ }
+
+ private PhysicalSwitchAugmentation getPhysicalSwitchBelong(InstanceIdentifier<Node> psNodeiid,
+ Map<InstanceIdentifier<Node>, PhysicalSwitchAugmentation> createdPhysicalSwitches) {
+ Optional<PhysicalSwitchAugmentation> physicalSwitchOptional =
+ getOperationalState().getPhysicalSwitchAugmentation(psNodeiid);
+ PhysicalSwitchAugmentation physicalSwitchAugmentation = null;
+ if (physicalSwitchOptional.isPresent()) {
+ physicalSwitchAugmentation = physicalSwitchOptional.get();
+ } else {
+ physicalSwitchAugmentation = createdPhysicalSwitches.get(psNodeiid);
+ }
+ return physicalSwitchAugmentation;
+ }
+
+ private void setName(PhysicalPort physicalPort, HwvtepPhysicalPortAugmentation inputPhysicalPort,
+ Optional<HwvtepPhysicalPortAugmentation> operationalLogicalSwitchOptional) {
+ if (inputPhysicalPort.getHwvtepNodeName() != null) {
+ physicalPort.setName(inputPhysicalPort.getHwvtepNodeName().getValue());
+ } else if (operationalLogicalSwitchOptional.isPresent()
+ && operationalLogicalSwitchOptional.get().getHwvtepNodeName() != null) {
+ physicalPort.setName(operationalLogicalSwitchOptional.get().getHwvtepNodeName().getValue());
+ }
+ }
+
+ private void setDescription(PhysicalPort physicalPort, HwvtepPhysicalPortAugmentation inputPhysicalPort) {
+ if (inputPhysicalPort.getHwvtepNodeDescription() != null) {
+ physicalPort.setDescription(inputPhysicalPort.getHwvtepNodeDescription().toString());
+ }
+ }
+
+ private void setVlanBindings(InstanceIdentifier<?> globalNodeIid, PhysicalPort physicalPort,
+ HwvtepPhysicalPortAugmentation inputPhysicalPort) {
+ if (inputPhysicalPort.getVlanBindings() != null) {
+ //get UUID by LogicalSwitchRef
+ Map<Long, UUID> bindingMap = new HashMap<Long, UUID>();
+ for (VlanBindings vlanBinding: inputPhysicalPort.getVlanBindings()) {
+ HwvtepNodeName lswitchName = new HwvtepNodeName(vlanBinding.getLogicalSwitchRef().getValue());
+ Optional<LogicalSwitches> operationalSwitchOptional =
+ getOperationalState().getLogicalSwitches(globalNodeIid, new LogicalSwitchesKey(lswitchName));
+ if (operationalSwitchOptional.isPresent()) {
+ Uuid logicalSwitchUuid = operationalSwitchOptional.get().getLogicalSwitchUuid();
+ bindingMap.put(vlanBinding.getVlanIdKey().getValue().longValue(), new UUID(logicalSwitchUuid.getValue()));
+ }
+ }
+ physicalPort.setVlanBindings(bindingMap);
+ }
+ }
+
+ private Map<InstanceIdentifier<Node>, List<HwvtepPhysicalPortAugmentation>> extractCreated(
+ Collection<DataTreeModification<Node>> changes, Class<HwvtepPhysicalPortAugmentation> class1) {
+ Map<InstanceIdentifier<Node>, List<HwvtepPhysicalPortAugmentation>> result
+ = new HashMap<InstanceIdentifier<Node>, List<HwvtepPhysicalPortAugmentation>>();
+ if (changes != null && !changes.isEmpty()) {
+ for (DataTreeModification<Node> change : changes) {
+ final InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier();
+ final DataObjectModification<Node> mod = change.getRootNode();
+ Node created = TransactUtils.getCreated(mod);
+ if (created != null) {
+ List<HwvtepPhysicalPortAugmentation> portListUpdated = new ArrayList<HwvtepPhysicalPortAugmentation>();
+ if (created.getTerminationPoint() != null) {
+ for (TerminationPoint tp : created.getTerminationPoint()) {
+ HwvtepPhysicalPortAugmentation hppAugmentation = tp.getAugmentation(HwvtepPhysicalPortAugmentation.class);
+ if (hppAugmentation != null) {
+ portListUpdated.add(hppAugmentation);
+ }
+ }
+ }
+ result.put(key, portListUpdated);
+ }
+ }
+ }
+ return result;
+ }
+
+ private Map<InstanceIdentifier<Node>, PhysicalSwitchAugmentation> extractCreatedPhyscialSwitch(
+ Collection<DataTreeModification<Node>> changes, Class<PhysicalSwitchAugmentation> class1) {
+ Map<InstanceIdentifier<Node>, PhysicalSwitchAugmentation> result
+ = new HashMap<InstanceIdentifier<Node>, PhysicalSwitchAugmentation>();
+ if (changes != null && !changes.isEmpty()) {
+ for (DataTreeModification<Node> change : changes) {
+ final InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier();
+ final DataObjectModification<Node> mod = change.getRootNode();
+ Node created = TransactUtils.getCreated(mod);
+ if (created != null) {
+ PhysicalSwitchAugmentation physicalSwitch = created.getAugmentation(PhysicalSwitchAugmentation.class);
+ if (physicalSwitch != null) {
+ result.put(key, physicalSwitch);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ private Map<InstanceIdentifier<Node>, List<HwvtepPhysicalPortAugmentation>> extractUpdated(
+ Collection<DataTreeModification<Node>> changes, Class<HwvtepPhysicalPortAugmentation> class1) {
+ Map<InstanceIdentifier<Node>, List<HwvtepPhysicalPortAugmentation>> result
+ = new HashMap<InstanceIdentifier<Node>, List<HwvtepPhysicalPortAugmentation>>();
+ if (changes != null && !changes.isEmpty()) {
+ for (DataTreeModification<Node> change : changes) {
+ final InstanceIdentifier<Node> key = change.getRootPath().getRootIdentifier();
+ final DataObjectModification<Node> mod = change.getRootNode();
+ Node updated = TransactUtils.getUpdated(mod);
+ Node before = mod.getDataBefore();
+ if (updated != null && before != null) {
+ List<HwvtepPhysicalPortAugmentation> portListUpdated = new ArrayList<HwvtepPhysicalPortAugmentation>();
+ List<HwvtepPhysicalPortAugmentation> portListBefore = new ArrayList<HwvtepPhysicalPortAugmentation>();
+ if (updated.getTerminationPoint() != null) {
+ for (TerminationPoint tp : updated.getTerminationPoint()) {
+ HwvtepPhysicalPortAugmentation hppAugmentation = tp.getAugmentation(HwvtepPhysicalPortAugmentation.class);
+ if (hppAugmentation != null) {
+ portListUpdated.add(hppAugmentation);
+ }
+ }
+ }
+ if (before.getTerminationPoint() != null) {
+ for (TerminationPoint tp : before.getTerminationPoint()) {
+ HwvtepPhysicalPortAugmentation hppAugmentation = tp.getAugmentation(HwvtepPhysicalPortAugmentation.class);
+ if (hppAugmentation != null) {
+ portListBefore.add(hppAugmentation);
+ }
+ }
+ }
+ portListUpdated.removeAll(portListBefore);
+ result.put(key, portListUpdated);
+ }
+ }
+ }
+ return result;
+ }
+}
\ No newline at end of file
"e25f67e4-3a3f-5da7-f7c8-41b371156719",
"f7d33d50-7c8e-69e2-6d60-5c6155c5d210",
"233b5ab5-8177-4416-6912-2477520a0654",
+ "567d7827-628d-07a4-3b95-5a208a244c43",
+ "f906c48b-ba3c-a3da-36e8-34c453538e2e",
+ "5d0c4d49-44f7-4165-ca5f-00cf2a9fca8b",
+ "34167a78-7de4-91a9-ef40-7592b28ead5c",
"9bc22ca7-049c-af51-7c12-6bf71044b2ec",
"f6d300f7-380a-d090-0d4a-2b2ddefe5104",
"f9f71d74-a49d-b190-d929-b6772ce0ba73",
"c8e8f3fd-3bfb-aafa-e3ec-a671a942f426",
"d362ddc4-1c5f-67d5-e354-c2a8d2ba9d79",
"538c71b3-e3e6-f01b-cc4c-d2b686686aa8",
- "a13e6877-997e-84e1-c8e8-e83ef5e9a002"
+ "a13e6877-997e-84e1-c8e8-e83ef5e9a002",
+ "3c86ab7c-a7ee-6b71-3ec1-da7d20f97d1a"
],
"owner":0,
"sharedWithTeam":false,
"preRequestScript": "",
"tests": "",
"rawModeData": ""
+ },
+ {
+ "collectionId": "19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id": "567d7827-628d-07a4-3b95-5a208a244c43",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
+ "url": "http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Fphysicalswitch%2Fbr0",
+ "preRequestScript": "",
+ "pathVariables": {},
+ "method": "POST",
+ "data": [],
+ "dataMode": "raw",
+ "version": 2,
+ "tests": "",
+ "currentHelper": "normal",
+ "helperAttributes": {},
+ "time": 1448641495086,
+ "name": "Create Specific Config Physical Port",
+ "description": "",
+ "rawModeData": "{\n \"network-topology:termination-point\": [\n {\n \"tp-id\": \"port0\",\n \t\"hwvtep-node-name\": \"port0\",\n \"hwvtep-node-description\": \"\",\n \"vlan-bindings\": [\n \t\t{\n \"vlan-id-key\": \"100\",\n \"logical-switch-ref\": \"ls0\"\n \t}\n \t]\n\t\t}\n ]\n}"
+ },
+ {
+ "collectionId": "19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id": "f906c48b-ba3c-a3da-36e8-34c453538e2e",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
+ "url": "http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Fphysicalswitch%2Fbr0/termination-point/port0",
+ "preRequestScript": "",
+ "pathVariables": {},
+ "method": "PUT",
+ "data": [],
+ "dataMode": "raw",
+ "version": 2,
+ "tests": "",
+ "currentHelper": "normal",
+ "helperAttributes": {},
+ "time": 1448643757985,
+ "name": "Update Specific Config Physical Port",
+ "description": "",
+ "rawModeData": "{\n \"network-topology:termination-point\": [\n {\n \"tp-id\": \"port0\",\n \t\"hwvtep-node-name\": \"port0\",\n \"hwvtep-node-description\": \"\",\n \"vlan-bindings\": [\n \t\t{\n \"vlan-id-key\": \"100\",\n \"logical-switch-ref\": \"ls0\"\n \t}\n \t]\n\t\t}\n ]\n}"
+ },
+ {
+ "collectionId": "19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id": "5d0c4d49-44f7-4165-ca5f-00cf2a9fca8b",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
+ "url": "http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Fphysicalswitch%2Fbr0/termination-point/port0",
+ "preRequestScript": "",
+ "pathVariables": {},
+ "method": "GET",
+ "data": [],
+ "dataMode": "params",
+ "version": 2,
+ "tests": "",
+ "currentHelper": "normal",
+ "helperAttributes": {},
+ "time": 1448643846609,
+ "name": "Get Specific Config Physical Port",
+ "description": ""
+ },
+ {
+ "collectionId": "19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id": "34167a78-7de4-91a9-ef40-7592b28ead5c",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
+ "url": "http://{{controllerHost}}:8181/restconf/config/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Fphysicalswitch%2Fbr0/termination-point/port0",
+ "preRequestScript": "",
+ "pathVariables": {},
+ "method": "DELETE",
+ "data": [],
+ "dataMode": "raw",
+ "version": 2,
+ "tests": "",
+ "currentHelper": "normal",
+ "helperAttributes": {},
+ "time": 1448643860663,
+ "name": "Delete Specific Config Physical Port",
+ "description": "",
+ "rawModeData": ""
+ },
+ {
+ "collectionId": "19f6b1a8-4d54-62f8-6bd6-f52e0b6e40b8",
+ "id": "3c86ab7c-a7ee-6b71-3ec1-da7d20f97d1a",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\n",
+ "url": "http://{{controllerHost}}:8181/restconf/operational/network-topology:network-topology/topology/hwvtep:1/node/hwvtep:%2F%2F{{hwvtepNodeIp}}:6640%2Fphysicalswitch%2Fbr0/termination-point/port0",
+ "preRequestScript": "",
+ "pathVariables": {},
+ "method": "GET",
+ "data": [],
+ "dataMode": "params",
+ "version": 2,
+ "tests": "",
+ "currentHelper": "normal",
+ "helperAttributes": {},
+ "time": 1448718837283,
+ "name": "Get Specific Operational Physical Port",
+ "description": ""
}
]
}