JIRA: OVSDB-481
The change in this review is to improve the format of the Hwvtep TransctionHistory hwvtep:txlog command
1. The hwvtep:txlog output is not logging/printing the date correctly. The date that is getting
printed is the date at which the command is executed , not the date at the transaction is looged.
Change has the fix for date issue.
2. The hwvtep:txlog output format is printing the complete instance identifier information of the nodes.
making the command output clumsy and hard to read.
ex :
Printing for iid KeyedInstanceIdentifier{targetType=interface org.opendaylight.yang.gen.v1.urn.tbd.
params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node, path=
org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology,
org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.
Topology[key=TopologyKey{_topologyId=Uri{_value=hwvtep:1}}],org.opendaylight.yang.gen.v1.urn.tbd.
params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node[key=NodeKey{_nodeId=
Uri{_value=hwvtep://uuid/
3b0fb1b3-6449-4fa7-b6ac-
0db437fe144e}}]]}
Update the output format only to print the node id : "hwvtep://uuid/
3b0fb1b3-6449-4fa7-b6ac-
0db437fe144e"
3. Update the TransctionHistory for the missing tables/objects like LogicalSwitch and Physical Port etc.
4. Added more logging of Transctions.
Change-Id: Ia5e8984fb414944820140acae69dd64104ee9619
Signed-off-by: Chandra Shekar S <chandra.shekar.s@ericsson.com>
ConnectionInfo key = HwvtepSouthboundMapper.createConnectionInfo(client);
HwvtepConnectionInstance hwvtepConnectionInstance = getConnectionInstance(key);
if (hwvtepConnectionInstance != null) {
- deviceUpdateHistory.get(hwvtepConnectionInstance.getInstanceIdentifier()).addToHistory(
- TransactionType.DELETE, new ClientConnected(client.getConnectionInfo().getRemotePort()));
+ if (hwvtepConnectionInstance.getInstanceIdentifier() != null) {
+ deviceUpdateHistory.get(hwvtepConnectionInstance.getInstanceIdentifier()).addToHistory(
+ TransactionType.DELETE, new ClientConnected(client.getConnectionInfo().getRemotePort()));
+ }
+
// Unregister Entity ownership as soon as possible ,so this instance should
// not be used as a candidate in Entity election (given that this instance is
package org.opendaylight.ovsdb.hwvtepsouthbound;
import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionElement;
-import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
public class HwvtepTransactionLogElement extends TransactionElement {
private final boolean isDeviceLog;
-
- public HwvtepTransactionLogElement(TransactionType transactionType,
- Object data,
- boolean isDeviceLog) {
- super(transactionType, data);
- this.isDeviceLog = isDeviceLog;
- }
+ private long date;
public HwvtepTransactionLogElement(TransactionElement element,
boolean isDeviceLog) {
super(element.getTransactionType(), element.getData());
this.isDeviceLog = isDeviceLog;
+ this.date = element.getDate();
+ }
+
+ @Override
+ public long getDate() {
+ return date;
}
@Override
@Option(name = "-nodeid", description = "Node Id",
required = false, multiValued = false)
String nodeid;
+ private static final String SEPERATOR = "#######################################################";
private final HwvtepSouthboundProvider hwvtepProvider;
private void printLogs(Map<InstanceIdentifier<Node>, TransactionHistory> controllerTxLogs,
Map<InstanceIdentifier<Node>, TransactionHistory> deviceUpdateLogs,
InstanceIdentifier<Node> iid) {
- session.getConsole().println("Printing for iid " + iid);
- session.getConsole().println("======================================");
- session.getConsole().println("======================================");
- session.getConsole().print("printing logs for node ");
- session.getConsole().println(iid);
-
+ session.getConsole().println(SEPERATOR + " START " + SEPERATOR);
List<HwvtepTransactionLogElement> controllerTxLog = controllerTxLogs.get(iid).getElements()
.stream().map(ele -> new HwvtepTransactionLogElement(ele, false)).collect(Collectors.toList());
List<HwvtepTransactionLogElement> deviceUpdateLog = deviceUpdateLogs.get(iid).getElements()
- .stream().map(ele -> new HwvtepTransactionLogElement(ele, false)).collect(Collectors.toList());
- //deviceUpdateLog.forEach( (log) -> log.setDeviceLog(true));
- printLogs(mergeLogsByDate(controllerTxLog, deviceUpdateLog));
+ .stream().map(ele -> new HwvtepTransactionLogElement(ele, true)).collect(Collectors.toList());
+ List<Pair<HwvtepTransactionLogElement, Boolean>> allLogs = mergeLogsByDate(controllerTxLog, deviceUpdateLog);
+ session.getConsole().print("Printing for Node : ");
+ session.getConsole().println(iid.firstKeyOf(Node.class).getNodeId().getValue());
+ printLogs(allLogs);
+ session.getConsole().println(SEPERATOR + " END " + SEPERATOR);
+ session.getConsole().println();
}
private void printLogs(List<Pair<HwvtepTransactionLogElement, Boolean>> logs) {
import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalRouter;
+import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
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.LogicalRouters;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
transaction.add(op.delete(logicalRouter.getSchema())
.where(logicalRouter.getUuidColumn().getSchema().opEqual(logicalRouterUuid)).build());
transaction.add(op.comment("Logical Router: Deleting " + lrouter.getHwvtepNodeName().getValue()));
+ updateControllerTxHistory(TransactionType.DELETE, logicalRouter);
} else {
LOG.warn("Unable to delete logical router {} because it was not found in the operational data store",
lrouter.getHwvtepNodeName().getValue());
import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalRouter;
+import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
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.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.Acls;
transaction.add(op.comment("Logical Router: Creating " + lrouter.getHwvtepNodeName().getValue()));
UUID lrUuid = new UUID(TransactUtils.getLogicalRouterId(lrouter));
updateCurrentTxData(LogicalRouters.class, routerKey, lrUuid, lrouter);
+ updateControllerTxHistory(TransactionType.ADD, logicalRouter);
} else {
LogicalRouters updatedLRouter = operationalRouterOptional.get();
String existingLogicalRouterName = updatedLRouter.getHwvtepNodeName().getValue();
.where(extraLogicalRouter.getNameColumn().getSchema().opEqual(existingLogicalRouterName))
.build());
transaction.add(op.comment("Logical Router: Updating " + existingLogicalRouterName));
+ updateControllerTxHistory(TransactionType.UPDATE, logicalRouter);
}
}
transaction.add(op.comment("Logical Switch: Creating " + lswitch.getHwvtepNodeName().getValue()));
UUID lsUuid = new UUID(TransactUtils.getLogicalSwitchId(lswitch));
updateCurrentTxData(LogicalSwitches.class, lsKey, lsUuid, lswitch);
- updateControllerTxHistory(TransactionType.ADD, lswitch);
+ updateControllerTxHistory(TransactionType.ADD, logicalSwitch);
} else {
String existingLogicalSwitchName = lswitch.getHwvtepNodeName().getValue();
// Name is immutable, and so we *can't* update it. So we use extraBridge for the schema stuff
.where(extraLogicalSwitch.getNameColumn().getSchema().opEqual(existingLogicalSwitchName))
.build());
transaction.add(op.comment("Logical Switch: Updating " + existingLogicalSwitchName));
- updateControllerTxHistory(TransactionType.UPDATE, lswitch);
+ updateControllerTxHistory(TransactionType.UPDATE, logicalSwitch);
}
}
import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
import org.opendaylight.ovsdb.schema.hardwarevtep.McastMacsRemote;
+import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
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;
.where(mcastMacsRemote.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
transaction.add(op.comment("McastMacRemote: Deleting " + mac.getMacEntryKey().getValue()));
updateCurrentTxDeleteData(RemoteMcastMacs.class, macIid, mac);
+ updateControllerTxHistory(TransactionType.DELETE, mcastMacsRemote);
} else {
LOG.warn("Unable to delete remoteMcastMacs {} because it was not found in the operational store",
mac.getMacEntryKey().getValue());
import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
import org.opendaylight.ovsdb.schema.hardwarevtep.McastMacsRemote;
+import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
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;
transaction.add(op.insert(mcastMacsRemote));
transaction.add(op.comment("McastMacRemote: Creating " + mac.getMacEntryKey().getValue()));
updateCurrentTxData(RemoteMcastMacs.class, macKey, TXUUID, mac);
+ updateControllerTxHistory(TransactionType.ADD, mcastMacsRemote);
} else if (operationalMacOptional.getUuid() != null) {
UUID macEntryUUID = operationalMacOptional.getUuid();
McastMacsRemote extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
.where(extraMac.getUuidColumn().getSchema().opEqual(macEntryUUID))
.build());
transaction.add(op.comment("McastMacRemote: Updating " + macEntryUUID));
+ updateControllerTxHistory(TransactionType.UPDATE, mcastMacsRemote);
//add to updates so that tep ref counts can be updated upon success
addToUpdates(macKey, mac);
} else {
import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocator;
import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocatorSet;
import org.opendaylight.ovsdb.utils.mdsal.utils.ControllerMdsalUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.EncapsulationTypeVxlanOverIpv4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepNodeName;
public static UUID createPhysicalLocatorSet(HwvtepOperationalState hwvtepOperationalState,
TransactionBuilder transaction, List<LocatorSet> locatorList) {
Set<UUID> locators = new HashSet<>();
+ Set<String> locatorsInfo = new HashSet<String>();
for (LocatorSet locator: locatorList) {
@SuppressWarnings("unchecked")
InstanceIdentifier<TerminationPoint> iid =
UUID locatorUuid = createPhysicalLocator(transaction, hwvtepOperationalState, iid);
if (locatorUuid != null) {
locators.add(locatorUuid);
+ addLocatorToTransactionHistory(hwvtepOperationalState, locatorsInfo, iid);
}
}
PhysicalLocatorSet physicalLocatorSet = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
physicalLocatorSet.setLocators(locators);
String locatorSetUuid = "PhysicalLocatorSet_" + HwvtepSouthboundMapper.getRandomUUID();
transaction.add(op.insert(physicalLocatorSet).withId(locatorSetUuid));
+ hwvtepOperationalState.getDeviceInfo().addToControllerTx(TransactionType.ADD,
+ new StringBuilder(physicalLocatorSet.toString()).append(" Uuid ").append(locatorSetUuid)
+ .append(" ").append(locatorsInfo.toString()));
return new UUID(locatorSetUuid);
}
String ip = tepKey.substring(tepKey.indexOf(":") + 1);
builder.setDstIp(IpAddressBuilder.getDefaultInstance(ip));
locatorAugmentation = builder.build();
- locatorUuid = TransactUtils.createPhysicalLocator(transaction, locatorAugmentation);
+ locatorUuid = TransactUtils.createPhysicalLocator(transaction, locatorAugmentation, operationalState);
operationalState.updateCurrentTxData(TerminationPoint.class, iid, locatorUuid);
operationalState.getDeviceInfo().markKeyAsInTransit(TerminationPoint.class, iid);
return locatorUuid;
}
public static UUID createPhysicalLocator(TransactionBuilder transaction,
- HwvtepPhysicalLocatorAugmentation inputLocator) {
+ HwvtepPhysicalLocatorAugmentation inputLocator,
+ HwvtepOperationalState hwvtepOperationalState) {
LOG.debug("Creating a physical locator: {}", inputLocator.getDstIp());
PhysicalLocator physicalLocator = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
PhysicalLocator.class);
setDstIp(physicalLocator, inputLocator);
String locatorUuid = "PhysicalLocator_" + HwvtepSouthboundMapper.getRandomUUID();
transaction.add(op.insert(physicalLocator).withId(locatorUuid));
+ hwvtepOperationalState.getDeviceInfo().addToControllerTx(TransactionType.ADD,
+ new StringBuilder(physicalLocator.toString()).append(" Uuid ").append(locatorUuid));
return new UUID(locatorUuid);
}
return new UUID(HwvtepSouthboundConstants.ACL_UUID_PREFIX
+ sanitizeUUID(aclIid.firstKeyOf(Acls.class).getAclName()));
}
+
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ private static void addLocatorToTransactionHistory(HwvtepOperationalState hwvtepOperationalState,
+ Set<String> locatorsInfo, InstanceIdentifier<TerminationPoint> iid) {
+ try {
+ HwvtepDeviceInfo.DeviceData deviceData = hwvtepOperationalState.getDeviceInfo().getDeviceOperData(
+ TerminationPoint.class, iid);
+ if (deviceData != null) {
+ PhysicalLocator locator = (PhysicalLocator) deviceData.getData();
+ locatorsInfo.add(new StringBuilder(locator.getUuid().toString()).append(" ")
+ .append(locator.getDstIpColumn().getData()).toString());
+ }
+ }
+ catch (Exception exp) {
+ LOG.warn("Failed to add to Transaction Histroy ",exp);
+ }
+ }
}
if (configLocatorOptional.isPresent()) {
HwvtepPhysicalLocatorAugmentation locatorAugmentation =
configLocatorOptional.get().augmentation(HwvtepPhysicalLocatorAugmentation.class);
- locatorUuid = TransactUtils.createPhysicalLocator(transaction, locatorAugmentation);
+ locatorUuid = TransactUtils.createPhysicalLocator(transaction, locatorAugmentation,
+ getOperationalState());
} else {
LOG.warn("Create or update localUcastMac: No physical locator found in operational datastore!"
+ "Its indentifier is {}", inputMac.getLocatorRef().getValue());
LOG.trace("doDeviceTransaction: creating RemotUcastMac entry: {}", ucastMacsRemote);
transaction.add(op.insert(ucastMacsRemote));
getOperationalState().getDeviceInfo().markKeyAsInTransit(RemoteUcastMacs.class, macKey);
+ updateCurrentTxData(RemoteUcastMacs.class, macKey, new UUID("uuid"), remoteUcastMac);
} else if (deviceData.getUuid() != null) {
UUID macEntryUUID = deviceData.getUuid();
UcastMacsRemote extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),