Merged in NETEXP-3230 (pull request #21)

[NETEXP-3230] fix for not populating Node_Config table

Approved-by: Ralph.lee
This commit is contained in:
Thomas Leung
2021-10-20 15:31:27 +00:00
committed by Thomas-Leung2021
parent 3647fd6bec
commit 551db33074

View File

@@ -145,8 +145,24 @@ public class OvsdbNodeConfig extends OvsdbDaoBase {
List.of(new Condition("module", Function.EQUALS, new Atom<>("led"))), new Row(columns)));
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
long numUpdates = 0;
for (OperationResult res : result) {
LOG.debug("processLedControlEnabled result {}", res);
if (res instanceof UpdateResult) {
numUpdates += ((UpdateResult) res).getCount();
LOG.debug("processLedControlEnabled update result {}", res);
}
}
if (numUpdates == 0) {
// no records existed, insert the row instead
operations.clear();
operations.add(new Insert(nodeConfigTable, new Row(columns)));
fResult = ovsdbClient.transact(ovsdbName, operations);
result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
for (OperationResult res : result) {
if (res instanceof InsertResult) {
LOG.debug("processLedControlEnabled insert result {}", res);
}
}
}
} catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) {
throw new RuntimeException(e);