use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation in project genius by opendaylight.
the class OvsdbTestUtil method updateNode.
public static CheckedFuture<Void, TransactionCommitFailedException> updateNode(ConnectionInfo connectionInfo, String tepIp, String tzName, String brName, DataBroker dataBroker) throws Exception {
final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
Node oldOvsdbNode = dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.OPERATIONAL, iid).checkedGet().get();
// build Node using its builder class
NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setNodeId(oldOvsdbNode.getNodeId());
// build OvsdbNodeAugmentation for Node
OvsdbNodeAugmentationBuilder ovsdbNodeAugBuilder = new OvsdbNodeAugmentationBuilder();
ovsdbNodeAugBuilder.setConnectionInfo(connectionInfo);
// create map of key-val pairs
Map<String, String> externalIds = new HashMap<>();
Map<String, String> otherConfigs = new HashMap<>();
if (tepIp != null && !tepIp.isEmpty()) {
otherConfigs.put(ItmTestConstants.OTHER_CFG_TEP_IP_KEY, tepIp);
}
if (tzName != null) {
externalIds.put(ItmTestConstants.EXTERNAL_ID_TZNAME_KEY, tzName);
}
if (brName != null && !brName.isEmpty()) {
externalIds.put(ItmTestConstants.EXTERNAL_ID_BR_NAME_KEY, brName);
}
// get map-keys into set.
Set<String> externalIdKeys = externalIds.keySet();
Set<String> otherConfigKeys = otherConfigs.keySet();
List<OpenvswitchExternalIds> externalIdsList = new ArrayList<>();
String externalIdValue = null;
for (String externalIdKey : externalIdKeys) {
externalIdValue = externalIds.get(externalIdKey);
if (externalIdKey != null && externalIdValue != null) {
externalIdsList.add(new OpenvswitchExternalIdsBuilder().setExternalIdKey(externalIdKey).setExternalIdValue(externalIdValue).build());
}
}
List<OpenvswitchOtherConfigs> otherConfigsList = new ArrayList<>();
String otherConfigsValue = null;
for (String otherConfigKey : otherConfigKeys) {
otherConfigsValue = otherConfigs.get(otherConfigKey);
if (otherConfigKey != null && otherConfigsValue != null) {
otherConfigsList.add(new OpenvswitchOtherConfigsBuilder().setOtherConfigKey(otherConfigKey).setOtherConfigValue(otherConfigsValue).build());
}
}
// set ExternalIds list into Node
ovsdbNodeAugBuilder.setOpenvswitchExternalIds(externalIdsList);
// set OtherConfigs list into Node
ovsdbNodeAugBuilder.setOpenvswitchOtherConfigs(otherConfigsList);
// add OvsdbNodeAugmentation into Node
nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, ovsdbNodeAugBuilder.build());
Node ovsdbNode = nodeBuilder.build();
// ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
transaction.put(LogicalDatastoreType.OPERATIONAL, iid, ovsdbNode, true);
return transaction.submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation in project genius by opendaylight.
the class OvsdbNodeListener method add.
@Override
public void add(@Nonnull Node ovsdbNodeNew) {
String bridgeName = null;
String strDpnId = "";
OvsdbNodeAugmentation ovsdbNewNodeAugmentation = null;
LOG.trace("OvsdbNodeListener called for Ovsdb Node ({}) Add.", ovsdbNodeNew.getNodeId().getValue());
// check for OVS bridge node
OvsdbBridgeAugmentation ovsdbNewBridgeAugmentation = ovsdbNodeNew.getAugmentation(OvsdbBridgeAugmentation.class);
if (ovsdbNewBridgeAugmentation != null) {
processBridgeUpdate(ovsdbNewBridgeAugmentation);
}
}
Aggregations