+ private void updateConnectionAttributes() {
+ LOG.debug("Update attributes of ovsdb node ip: {} port: {}",
+ this.initialCreateData.getConnectionInfo().getRemoteIp(),
+ this.initialCreateData.getConnectionInfo().getRemotePort());
+ for ( Map.Entry<DatabaseSchema,TransactInvoker> entry: transactInvokers.entrySet()) {
+
+ TransactionBuilder transaction = new TransactionBuilder(this, entry.getKey());
+
+ // OpenVSwitchPart
+ OpenVSwitch ovs = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), OpenVSwitch.class);
+ Map<String, String> externalIdsMap = new HashMap<String, String>();
+
+ List<OpenvswitchExternalIds> externalIds = this.initialCreateData.getOpenvswitchExternalIds();
+
+ if (externalIds != null) {
+ for (OpenvswitchExternalIds externalId : externalIds) {
+ externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
+ }
+ }
+
+ stampInstanceIdentifier(transaction,this.instanceIdentifier.firstIdentifierOf(Node.class));
+
+ try {
+ ovs.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+ Mutate<GenericTableSchema> mutate = op.mutate(ovs)
+ .addMutation(ovs.getExternalIdsColumn().getSchema(),
+ Mutator.INSERT,
+ ovs.getExternalIdsColumn().getData());
+ transaction.add(mutate);
+ } catch (NullPointerException e) {
+ LOG.warn("Incomplete OVSDB Node external IDs");
+ }
+
+
+
+ List<OpenvswitchOtherConfigs> otherConfigs = this.initialCreateData.getOpenvswitchOtherConfigs();
+ if (otherConfigs != null) {
+ Map<String, String> otherConfigsMap = new HashMap<String, String>();
+ for (OpenvswitchOtherConfigs otherConfig : otherConfigs) {
+ otherConfigsMap.put(otherConfig.getOtherConfigKey(), otherConfig.getOtherConfigValue());
+ }
+ try {
+ ovs.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
+ transaction.add(op.mutate(ovs).addMutation(ovs.getOtherConfigColumn().getSchema(),
+ Mutator.INSERT,
+ ovs.getOtherConfigColumn().getData()));
+ } catch (NullPointerException e) {
+ LOG.warn("Incomplete OVSDB Node other_config", e);
+ }
+ }
+
+ invoke(transaction);
+ }
+ }
+
+ private void stampInstanceIdentifier(TransactionBuilder transaction,InstanceIdentifier<Node> iid) {
+ OpenVSwitch ovs = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), OpenVSwitch.class);
+ ovs.setExternalIds(Collections.<String,String>emptyMap());
+ TransactUtils.stampInstanceIdentifier(transaction,
+ iid,
+ ovs.getSchema(),
+ ovs.getExternalIdsColumn().getSchema());
+ }
+
+ private void invoke(TransactionBuilder txBuilder) {
+ ListenableFuture<List<OperationResult>> result = txBuilder.execute();
+ LOG.debug("invoke: tb: {}", txBuilder);
+ if (txBuilder.getOperations().size() > 0) {
+ try {
+ List<OperationResult> got = result.get();
+ LOG.debug("OVSDB transaction result: {}", got);
+ } catch (Exception e) {
+ LOG.warn("Transact execution exception: ", e);
+ }
+ LOG.trace("invoke exit tb: {}", txBuilder);
+ }
+ }
+
+