From 79fd2fe2360d30762486fd8425d482188870b492 Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Wed, 8 Apr 2015 08:20:22 -0700 Subject: [PATCH] Support other_config for OVSDB Nodes Add support to set other_config via MDSAL config and update operational MDSAL from the Open_vSwitch table on the OVS host. v2 - add NPE to the LOG warning. v3 - rebase v4 - fix logging of exception v5 - remove whitespace Change-Id: If684e89185fe5660263c3e7ff8b1f5c7087764ee Signed-off-by: Eric Multanen --- .../southbound-api/src/main/yang/ovsdb.yang | 29 +++++++++---------- .../transact/OvsdbNodeUpdateCommand.java | 17 +++++++++++ .../md/OpenVSwitchUpdateCommand.java | 19 ++++++++++++ 3 files changed, 49 insertions(+), 16 deletions(-) diff --git a/southbound/southbound-api/src/main/yang/ovsdb.yang b/southbound/southbound-api/src/main/yang/ovsdb.yang index 07e368efb..db2860272 100755 --- a/southbound/southbound-api/src/main/yang/ovsdb.yang +++ b/southbound/southbound-api/src/main/yang/ovsdb.yang @@ -242,6 +242,19 @@ module ovsdb { } } + list openvswitch-other-configs { + description "Open_vSwitch table other configs"; + key "other-config-key"; + leaf other-config-key { + description "other-config name/key"; + type string; + } + leaf other-config-value { + description "other-config value"; + type string; + } + } + } identity interface-type-base { @@ -440,21 +453,6 @@ module ovsdb { } } - grouping ovsdb-other-config-attributes { - list other-configs { - description "Other config attributes for OVSDB tables"; - key "other-config-key"; - leaf other-config-key { - description "other-config name/key"; - type string; - } - leaf other-config-value { - description "other-config value"; - type string; - } - } - } - augment "/topo:network-topology/topo:topology/topo:node" { description "Augmentation for bridge nodes managed by ovsdb"; ext:augment-identifier "ovsdb-bridge-augmentation"; @@ -465,7 +463,6 @@ module ovsdb { description "Augment topology node for an ovsdb node"; ext:augment-identifier "ovsdb-node-augmentation"; uses ovsdb-node-attributes; - uses ovsdb-other-config-attributes; } augment "/topo:network-topology/topo:topology/topo:node/topo:termination-point" { diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommand.java index fc83e8b68..fa028fb25 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommand.java @@ -22,6 +22,7 @@ import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIds; import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigs; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,6 +67,22 @@ public class OvsdbNodeUpdateCommand implements TransactCommand { LOG.warn("Incomplete OVSDB Node external IDs"); } } + + List otherConfigs = ovsdbNode.getOpenvswitchOtherConfigs(); + if (otherConfigs != null) { + HashMap otherConfigsMap = new HashMap(); + 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); + } + } } } } diff --git a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java index 187a67ced..380a180b2 100644 --- a/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java +++ b/southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OpenVSwitchUpdateCommand.java @@ -32,6 +32,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.re import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.DatapathTypeEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.InterfaceTypeEntry; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.InterfaceTypeEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigs; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigsBuilder; 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.NodeBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -121,6 +123,23 @@ public class OpenVSwitchUpdateCommand extends AbstractTransactionCommand { ovsdbNodeBuilder.setOpenvswitchExternalIds(externalIdsList); } + Map otherConfigs = openVSwitch.getOtherConfigColumn().getData(); + if (otherConfigs != null && !otherConfigs.isEmpty()) { + Set otherConfigKeys = otherConfigs.keySet(); + List otherConfigsList = new ArrayList(); + String otherConfigValue; + for (String otherConfigKey : otherConfigKeys) { + otherConfigValue = otherConfigs.get(otherConfigKey); + if (otherConfigKey != null && otherConfigValue != null) { + otherConfigsList.add(new OpenvswitchOtherConfigsBuilder() + .setOtherConfigKey(otherConfigKey) + .setOtherConfigValue(otherConfigValue) + .build()); + } + } + ovsdbNodeBuilder.setOpenvswitchOtherConfigs(otherConfigsList); + } + NodeBuilder nodeBuilder = new NodeBuilder(); nodeBuilder.setNodeId(SouthboundMapper.createNodeId( ovsdbNode.getIp(), ovsdbNode.getPort())); -- 2.36.6