Merge "Bug 5174: Support for AutoAttach Table in OVSDB"
authorSam Hague <shague@redhat.com>
Fri, 11 Mar 2016 20:56:27 +0000 (20:56 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 11 Mar 2016 20:56:27 +0000 (20:56 +0000)
46 files changed:
hwvtepsouthbound/hwvtepsouthbound-api/src/main/yang/hwvtep.yang
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepDataChangeListener.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/LogicalSwitchUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsLocalUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/McastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalPortUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/PhysicalSwitchUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsLocalUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteRemoveCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transact/UcastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/McastMacsLocalUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/McastMacsRemoteUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/PhysicalSwitchUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/UcastMacsLocalUpdateCommand.java
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/transactions/md/UcastMacsRemoteUpdateCommand.java
netvirt/renderers/hwgw/src/main/config/default-config.xml
netvirt/renderers/neutron/pom.xml [new file with mode: 0644]
netvirt/renderers/neutron/src/main/config/default-config.xml [new file with mode: 0644]
netvirt/renderers/neutron/src/main/java/org/opendaylight/ovsdb/netvirt/renderers/neutron/NeutronProvider.java [new file with mode: 0644]
netvirt/renderers/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModule.java [new file with mode: 0644]
netvirt/renderers/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleFactory.java [new file with mode: 0644]
netvirt/renderers/neutron/src/main/yang/neutron.yang [new file with mode: 0644]
netvirt/renderers/neutron/src/test/java/org/opendaylight/ovsdb/netvirt/renderers/neutron/NeutronProviderTest.java [new file with mode: 0644]
netvirt/renderers/neutron/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleFactoryTest.java [new file with mode: 0644]
netvirt/renderers/neutron/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleTest.java [new file with mode: 0644]
netvirt/renderers/pom.xml
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/NetvirtProvider.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/OvsdbInventoryServiceImpl.java
southbound/southbound-api/src/main/yang/ovsdb.yang
southbound/southbound-features/src/main/features/features.xml
southbound/southbound-impl/pom.xml
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/OvsdbConnectionInstance.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/BridgeUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/OvsdbNodeUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QosUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/QueueUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointCreateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/ovsdb/transact/TerminationPointUpdateCommand.java
southbound/southbound-impl/src/main/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommand.java
southbound/southbound-impl/src/test/java/org/opendaylight/ovsdb/southbound/transactions/md/OvsdbPortUpdateCommandTest.java
utils/pom.xml
utils/yang-utils/pom.xml [new file with mode: 0644]
utils/yang-utils/src/main/java/org/opendaylight/ovsdb/utils/yang/YangUtils.java [new file with mode: 0644]

index 4496ae3baa43b950722c491112aadb3d85d50c9b..766588ad88f83497ddc3b361bec27532a00df113 100644 (file)
@@ -53,6 +53,10 @@ module hwvtep {
             description "MAC address entry";
             type yang:mac-address;
         }
+        leaf mac-entry-uuid {
+            description "The unique identifier of the mac-entry";
+            type yang:uuid;
+        }
         leaf logical-switch-ref {
             description "The logical switch to which this mapping applies";
             type hwvtep-logical-switch-ref;
index 08106386991967598a203afb5cf8a28b067e2434..0da5f37cb26f28be55e74f35d26712f89b6098f5 100644 (file)
@@ -153,7 +153,8 @@ public class HwvtepDataChangeListener implements ClusteredDataTreeChangeListener
                 HwvtepGlobalAugmentation hgUpdated = updated.getAugmentation(HwvtepGlobalAugmentation.class);
                 HwvtepGlobalAugmentation hgOriginal = original.getAugmentation(HwvtepGlobalAugmentation.class);
                 // Check if user has updated connection information
-                if (hgUpdated != null && hgOriginal != null && hgUpdated.getConnectionInfo() != null) {
+                if (hgUpdated != null && hgOriginal != null && hgUpdated.getConnectionInfo() != null
+                                && !hgUpdated.getConnectionInfo().equals(hgOriginal.getConnectionInfo())) {
                     OvsdbClient client = hcm.getClient(hgUpdated.getConnectionInfo());
                     if (client == null) {
                         try {
index 2ae002d6ce472a3b4997ab7fe2e3835b0ebe3b3a..905a788dcf3a8147ed40fe7d220ecaf2dab60dc9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -71,16 +71,20 @@ public class LogicalSwitchUpdateCommand extends AbstractTransactCommand {
             setTunnelKey(logicalSwitch, lswitch);
             if (!operationalSwitchOptional.isPresent()) {
                 setName(logicalSwitch, lswitch, operationalSwitchOptional);
+                LOG.trace("execute: creating LogicalSwitch entry: {}", logicalSwitch);
                 transaction.add(op.insert(logicalSwitch));
+                transaction.add(op.comment("Logical Switch: Creating " + lswitch.getHwvtepNodeName().getValue()));
             } else {
                 LogicalSwitches updatedLSwitch = operationalSwitchOptional.get();
                 String existingLogicalSwitchName = updatedLSwitch.getHwvtepNodeName().getValue();
                 // Name is immutable, and so we *can't* update it.  So we use extraBridge for the schema stuff
                 LogicalSwitch extraLogicalSwitch = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), LogicalSwitch.class);
                 extraLogicalSwitch.setName("");
+                LOG.trace("execute: updating LogicalSwitch entry: {}", logicalSwitch);
                 transaction.add(op.update(logicalSwitch)
                         .where(extraLogicalSwitch.getNameColumn().getSchema().opEqual(existingLogicalSwitchName))
                         .build());
+                transaction.add(op.comment("Logical Switch: Updating " + existingLogicalSwitchName));
             }
         }
     }
index fd5d5030fcdaee2047a6a61fd47df2d89793eaf0..25e04a31abb09016535a37bd24c158e1cfc5ea67 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -20,6 +20,7 @@ import java.util.Map.Entry;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundConstants;
+import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.hardwarevtep.McastMacsLocal;
@@ -33,7 +34,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 
 public class McastMacsLocalRemoveCommand extends AbstractTransactCommand {
-    private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+    private static final Logger LOG = LoggerFactory.getLogger(McastMacsLocalRemoveCommand.class);
 
     public McastMacsLocalRemoveCommand(HwvtepOperationalState state,
             Collection<DataTreeModification<Node>> changes) {
@@ -60,18 +61,13 @@ public class McastMacsLocalRemoveCommand extends AbstractTransactCommand {
                     getOperationalState().getLocalMcastMacs(instanceIdentifier, mac.getKey());
             McastMacsLocal mcastMacsLocal = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
                     McastMacsLocal.class, null);
-            if (operationalMacOptional.isPresent()) {
+            if (operationalMacOptional.isPresent() && operationalMacOptional.get().getMacEntryUuid() != null) {
                 //when mac entry is deleted, its referenced locator set and locators are deleted automatically.
                 //TODO: locator in config DS is not deleted
-                String macString = null;
-                if (mac.getMacEntryKey().equals(HwvtepSouthboundConstants.UNKNOWN_DST_MAC)) {
-                    macString = HwvtepSouthboundConstants.UNKNOWN_DST_STRING;
-                } else {
-                    macString = mac.getMacEntryKey().getValue();
-                }
-                transaction.add(op.delete(mcastMacsLocal.getSchema())
-                        .where(mcastMacsLocal.getMacColumn().getSchema().opEqual(macString)).build());
-                transaction.add(op.comment("Local McastMacLocal: Deleting " + mac.getMacEntryKey().getValue()));
+                UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                transaction.add(op.delete(mcastMacsLocal.getSchema()).
+                        where(mcastMacsLocal.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
+                transaction.add(op.comment("McastMacLocal: Deleting " + mac.getMacEntryKey().getValue()));
             } else {
                 LOG.warn("Unable to delete localMcastMacs {} because it was not found in the operational store",
                         mac.getMacEntryKey().getValue());
index f735ae0e1a3cdcece5719db4d6c25f0257e4b0c5..f9b2871d8271399728cab1376deefd850b28ed6b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 
 public class McastMacsLocalUpdateCommand extends AbstractTransactCommand {
-    private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+    private static final Logger LOG = LoggerFactory.getLogger(McastMacsLocalUpdateCommand.class);
 
     public McastMacsLocalUpdateCommand(HwvtepOperationalState state,
             Collection<DataTreeModification<Node>> changes) {
@@ -74,15 +74,19 @@ public class McastMacsLocalUpdateCommand extends AbstractTransactCommand {
             setLogicalSwitch(mcastMacsLocal, localMcastMac);
             if (!operationalMacOptional.isPresent()) {
                 setMac(mcastMacsLocal, localMcastMac, operationalMacOptional);
+                LOG.trace("execute: create LocalMcastMac entry: {}", mcastMacsLocal);
                 transaction.add(op.insert(mcastMacsLocal));
+                transaction.add(op.comment("McastMacLocal: Creating " + localMcastMac.getMacEntryKey().getValue()));
             } else {
                 LocalMcastMacs updatedMac = operationalMacOptional.get();
                 String existingMac = updatedMac.getMacEntryKey().getValue();
                 McastMacsLocal extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), McastMacsLocal.class);
-                extraMac.setMac("");;
+                extraMac.setMac("");
+                LOG.trace("execute: update LocalMcastMac entry: {}", mcastMacsLocal);
                 transaction.add(op.update(mcastMacsLocal)
                         .where(extraMac.getMacColumn().getSchema().opEqual(existingMac))
                         .build());
+                transaction.add(op.comment("McastMacLocal: Updating " + localMcastMac.getMacEntryKey().getValue()));
             }
         }
     }
index 2c0e8d55de7f23a589ba3a1e0bbc5426be20796b..65dc3ee5fc00538e1d41cf780c0f5d4a0e21b45e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -20,6 +20,7 @@ import java.util.Map.Entry;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundConstants;
+import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.hardwarevtep.McastMacsRemote;
@@ -33,7 +34,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 
 public class McastMacsRemoteRemoveCommand extends AbstractTransactCommand {
-    private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+    private static final Logger LOG = LoggerFactory.getLogger(McastMacsRemoteRemoveCommand.class);
 
     public McastMacsRemoteRemoveCommand(HwvtepOperationalState state,
             Collection<DataTreeModification<Node>> changes) {
@@ -60,18 +61,13 @@ public class McastMacsRemoteRemoveCommand extends AbstractTransactCommand {
                     getOperationalState().getRemoteMcastMacs(instanceIdentifier, mac.getKey());
             McastMacsRemote mcastMacsRemote = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
                     McastMacsRemote.class, null);
-            if (operationalMacOptional.isPresent()) {
+            if (operationalMacOptional.isPresent() && operationalMacOptional.get().getMacEntryUuid() != null) {
                 //when mac entry is deleted, its referenced locator set and locators are deleted automatically.
                 //TODO: locator in config DS is not deleted
-                String macString = null;
-                if (mac.getMacEntryKey().equals(HwvtepSouthboundConstants.UNKNOWN_DST_MAC)) {
-                    macString = HwvtepSouthboundConstants.UNKNOWN_DST_STRING;
-                } else {
-                    macString = mac.getMacEntryKey().getValue();
-                }
-                transaction.add(op.delete(mcastMacsRemote.getSchema())
-                        .where(mcastMacsRemote.getMacColumn().getSchema().opEqual(macString)).build());
-                transaction.add(op.comment("Remote McastMacRemote: Deleting " + mac.getMacEntryKey().getValue()));
+                UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                transaction.add(op.delete(mcastMacsRemote.getSchema()).
+                        where(mcastMacsRemote.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
+                transaction.add(op.comment("McastMacRemote: Deleting " + mac.getMacEntryKey().getValue()));
             } else {
                 LOG.warn("Unable to delete remoteMcastMacs {} because it was not found in the operational store",
                         mac.getMacEntryKey().getValue());
index 23938eaffd41ff9c7190312a87bc990a9468df76..fdeab3d0ec6cf623e3410d179d778f6aa6f14aa7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 
 public class McastMacsRemoteUpdateCommand extends AbstractTransactCommand {
-    private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+    private static final Logger LOG = LoggerFactory.getLogger(McastMacsRemoteUpdateCommand.class);
 
     public McastMacsRemoteUpdateCommand(HwvtepOperationalState state,
             Collection<DataTreeModification<Node>> changes) {
@@ -74,15 +74,19 @@ public class McastMacsRemoteUpdateCommand extends AbstractTransactCommand {
             setLogicalSwitch(mcastMacsRemote, mac);
             if (!operationalMacOptional.isPresent()) {
                 setMac(mcastMacsRemote, mac, operationalMacOptional);
+                LOG.trace("execute: create RemoteMcastMac entry: {}", mcastMacsRemote);
                 transaction.add(op.insert(mcastMacsRemote));
+                transaction.add(op.comment("McastMacRemote: Creating " + mac.getMacEntryKey().getValue()));
             } else {
                 RemoteMcastMacs updatedMac = operationalMacOptional.get();
                 String existingMac = updatedMac.getMacEntryKey().getValue();
                 McastMacsRemote extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), McastMacsRemote.class);
-                extraMac.setMac("");;
+                extraMac.setMac("");
+                LOG.trace("execute: update RemoteMcastMac entry: {}", mcastMacsRemote);
                 transaction.add(op.update(mcastMacsRemote)
                         .where(extraMac.getMacColumn().getSchema().opEqual(existingMac))
                         .build());
+                transaction.add(op.comment("McastMacRemote: Updating " + mac.getMacEntryKey().getValue()));
             }
         }
     }
index 00376a46bf11f35d0dfe2de8890870ba902fc928..053c5cfc588142d44815a22a892e9bb0b8647460 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -89,17 +89,21 @@ public class PhysicalPortUpdateCommand extends AbstractTransactCommand {
                 //create a physical port
                 setName(physicalPort, port, operationalPhysicalPortOptional);
                 String portUuid = "PhysicalPort_" + HwvtepSouthboundMapper.getRandomUUID();
+                LOG.trace("execute: creating physical port: {}", physicalPort);
                 transaction.add(op.insert(physicalPort).withId(portUuid));
+                transaction.add(op.comment("Physical Port: Creating " + port.getHwvtepNodeName().getValue()));
                 //update physical switch table
                 PhysicalSwitch physicalSwitch = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), PhysicalSwitch.class);
                 physicalSwitch.setName(physicalSwitchBelong.getHwvtepNodeName().getValue());
                 physicalSwitch.setPorts(Sets.newHashSet(new UUID(portUuid)));
-                LOG.info("execute: physical switch: {}", physicalSwitch);
+                LOG.trace("execute: mutating physical switch: {}", physicalSwitch);
                 transaction.add(op.mutate(physicalSwitch)
                         .addMutation(physicalSwitch.getPortsColumn().getSchema(), Mutator.INSERT,
                                 physicalSwitch.getPortsColumn().getData())
                         .where(physicalSwitch.getNameColumn().getSchema().opEqual(physicalSwitch.getNameColumn().getData()))
                         .build());
+                transaction.add(op.comment("Physical Switch: Mutating " +
+                                port.getHwvtepNodeName().getValue() + " " + portUuid));
             } else {
                 //updated physical port only
                 HwvtepPhysicalPortAugmentation updatedPhysicalPort = operationalPhysicalPortOptional.get();
@@ -107,9 +111,11 @@ public class PhysicalPortUpdateCommand extends AbstractTransactCommand {
                 PhysicalPort extraPhyscialPort =
                         TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), PhysicalPort.class);
                 extraPhyscialPort.setName("");
+                LOG.trace("execute: updating physical port: {}", physicalPort);
                 transaction.add(op.update(physicalPort)
                         .where(extraPhyscialPort.getNameColumn().getSchema().opEqual(existingPhysicalPortName))
                         .build());
+                transaction.add(op.comment("Physical Port: Updating " + existingPhysicalPortName));
             }
         }
     }
index c639ec1ad4d984328929082c712326539666ec23..838ae9c8dac610a3cddd4b24fa0ce681bc894b26 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -84,29 +84,44 @@ public class PhysicalSwitchUpdateCommand extends AbstractTransactCommand {
         setDescription(physicalSwitch, physicalSwitchAugmentation);
         setManagementIps(physicalSwitch, physicalSwitchAugmentation);
         setTunnuleIps(physicalSwitch, physicalSwitchAugmentation);
-        setTunnels(transaction, iid, physicalSwitch, physicalSwitchAugmentation);
+        setTunnels(transaction, iid, physicalSwitch, physicalSwitchAugmentation,
+                        operationalPhysicalSwitchOptional.isPresent());
         if (!operationalPhysicalSwitchOptional.isPresent()) {
             //create a physical switch
             setName(physicalSwitch, physicalSwitchAugmentation, operationalPhysicalSwitchOptional);
             String pswitchUuid = "PhysicalSwitch_" + HwvtepSouthboundMapper.getRandomUUID();
             transaction.add(op.insert(physicalSwitch).withId(pswitchUuid));
+            transaction.add(op.comment("Physical Switch: Creating " +
+                            physicalSwitchAugmentation.getHwvtepNodeName().getValue()));
             //update global table
             Global global = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Global.class);
             global.setSwitches(Sets.newHashSet(new UUID(pswitchUuid)));
 
-            LOG.debug("execute: physical switch: {}", physicalSwitch);
+            LOG.trace("execute: create physical switch: {}", physicalSwitch);
             transaction.add(op.mutate(global)
                     .addMutation(global.getSwitchesColumn().getSchema(), Mutator.INSERT,
                             global.getSwitchesColumn().getData()));
+            transaction.add(op.comment("Global: Mutating " +
+                            physicalSwitchAugmentation.getHwvtepNodeName().getValue() + " " + pswitchUuid));
         } else {
             PhysicalSwitchAugmentation updatedPhysicalSwitch = operationalPhysicalSwitchOptional.get();
             String existingPhysicalSwitchName = updatedPhysicalSwitch.getHwvtepNodeName().getValue();
+            /* In case TOR devices don't allow creation of PhysicalSwitch name might be null
+             * as user is only adding configurable parameters to MDSAL like BFD params
+             * 
+             * TODO Note: Consider handling tunnel udpate/remove in separate command
+             */
+            if(existingPhysicalSwitchName == null) {
+                existingPhysicalSwitchName = operationalPhysicalSwitchOptional.get().getHwvtepNodeName().getValue();
+            }
             // Name is immutable, and so we *can't* update it.  So we use extraPhysicalSwitch for the schema stuff
             PhysicalSwitch extraPhysicalSwitch = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), PhysicalSwitch.class);
             extraPhysicalSwitch.setName("");
+            LOG.trace("execute: updating physical switch: {}", physicalSwitch);
             transaction.add(op.update(physicalSwitch)
                     .where(extraPhysicalSwitch.getNameColumn().getSchema().opEqual(existingPhysicalSwitchName))
                     .build());
+            transaction.add(op.comment("Physical Switch: Updating " + existingPhysicalSwitchName));
         }
     }
 
@@ -147,36 +162,62 @@ public class PhysicalSwitchUpdateCommand extends AbstractTransactCommand {
 
     @SuppressWarnings("unchecked")
     private void setTunnels(TransactionBuilder transaction, InstanceIdentifier<Node> iid,
-                    PhysicalSwitch physicalSwitch, PhysicalSwitchAugmentation physicalSwitchAugmentation) {
+                    PhysicalSwitch physicalSwitch, PhysicalSwitchAugmentation physicalSwitchAugmentation,
+                    boolean pSwitchExists) {
         //TODO: revisit this code for optimizations
         //TODO: needs more testing
         if(physicalSwitchAugmentation.getTunnels() != null) {
-            Set<UUID> tunnels = Sets.newHashSet();
             for(Tunnels tunnel: physicalSwitchAugmentation.getTunnels()) {
                 Optional<Tunnels> opTunnelOpt = getOperationalState().getTunnels(iid, tunnel.getKey());
                 Tunnel newTunnel = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Tunnel.class);
-                String tunnelUuid = null;
-                if(!opTunnelOpt.isPresent()) {
-                    tunnelUuid = "Tunnel_" + HwvtepSouthboundMapper.getRandomUUID();
-                } else {
-                    tunnelUuid = opTunnelOpt.get().getTunnelUuid().getValue();
-                }
+
                 UUID localUUID = getLocatorUUID(transaction,
                                 (InstanceIdentifier<TerminationPoint>) tunnel.getLocalLocatorRef().getValue());
                 UUID remoteUUID = getLocatorUUID(transaction,
                                 (InstanceIdentifier<TerminationPoint>) tunnel.getRemoteLocatorRef().getValue());
                 if(localUUID != null && remoteUUID != null) {
+                    UUID uuid;
                     // local and remote must exist
                     newTunnel.setLocal(localUUID);
                     newTunnel.setRemote(remoteUUID);
                     setBfdParams(newTunnel, tunnel);
                     setBfdLocalConfigs(newTunnel, tunnel);
                     setBfdRemoteConfigs(newTunnel, tunnel);
-                    transaction.add(op.insert(newTunnel).withId(tunnelUuid));
-                    tunnels.add(new UUID(tunnelUuid));
+                    if(!opTunnelOpt.isPresent()) {
+                        String tunnelUuid = "Tunnel_" + HwvtepSouthboundMapper.getRandomUUID();
+                        transaction.add(op.insert(newTunnel).withId(tunnelUuid));
+                        transaction.add(op.comment("Tunnel: Creating " + tunnelUuid));
+                        if(!pSwitchExists) {
+                            //TODO: Figure out a way to handle this
+                            LOG.warn("Tunnel configuration requires pre-existing physicalSwitch");
+                        } else {
+                            // TODO: Can we reuse physicalSwitch instead?
+                            PhysicalSwitch pSwitch =
+                                            TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
+                                                            PhysicalSwitch.class);
+                            pSwitch.setTunnels(Sets.newHashSet(new UUID(tunnelUuid)));
+                            pSwitch.setName(physicalSwitchAugmentation.getHwvtepNodeName().getValue());
+                            transaction.add(op.mutate(pSwitch)
+                                            .addMutation(pSwitch.getTunnels().getSchema(), Mutator.INSERT,
+                                                    pSwitch.getTunnels().getData())
+                                            .where(pSwitch.getNameColumn().getSchema().
+                                                            opEqual(pSwitch.getNameColumn().getData()))
+                                            .build());
+                            transaction.add(op.comment("PhysicalSwitch: Mutating " + tunnelUuid));
+                        }
+                        uuid = new UUID(tunnelUuid);
+                    } else {
+                        uuid = new UUID (opTunnelOpt.get().getTunnelUuid().getValue());
+                        Tunnel extraTunnel =
+                                TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Tunnel.class, null);
+                        extraTunnel.getUuidColumn().setData(uuid);
+                        transaction.add(op.update(newTunnel)
+                                        .where(extraTunnel.getUuidColumn().getSchema().opEqual(uuid))
+                                        .build());
+                        transaction.add(op.comment("Tunnel: Updating " + uuid));
+                    }
                 }
             }
-            physicalSwitch.setTunnels(tunnels);
         }
     }
 
index fb6f7d244d220a545df92032df7b4a9bc37fd329..a333450bc5a8b808948ce7d5560e48c623a1952c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -19,6 +19,7 @@ import java.util.Map.Entry;
 
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsLocal;
@@ -32,7 +33,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 
 public class UcastMacsLocalRemoveCommand extends AbstractTransactCommand {
-    private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+    private static final Logger LOG = LoggerFactory.getLogger(UcastMacsLocalRemoveCommand.class);
 
     public UcastMacsLocalRemoveCommand(HwvtepOperationalState state,
             Collection<DataTreeModification<Node>> changes) {
@@ -57,14 +58,15 @@ public class UcastMacsLocalRemoveCommand extends AbstractTransactCommand {
             LOG.debug("Removing remoteUcastMacs, mac address: {}", mac.getMacEntryKey().getValue());
             Optional<LocalUcastMacs> operationalMacOptional =
                     getOperationalState().getLocalUcastMacs(instanceIdentifier, mac.getKey());
-            UcastMacsLocal mcastMacsLocal = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
+            UcastMacsLocal ucastMacsLocal = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
                     UcastMacsLocal.class, null);
-            if (operationalMacOptional.isPresent()) {
+            if (operationalMacOptional.isPresent() && operationalMacOptional.get().getMacEntryUuid() != null) {
                 //when mac entry is deleted, its referenced locators are deleted automatically.
                 //locators in config DS is not deleted and user need to be removed explicitly by user.
-                transaction.add(op.delete(mcastMacsLocal.getSchema())
-                        .where(mcastMacsLocal.getMacColumn().getSchema().opEqual(mac.getMacEntryKey().getValue())).build());
-                transaction.add(op.comment("Local UcastMacLocal: Deleting " + mac.getMacEntryKey().getValue()));
+                UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                transaction.add(op.delete(ucastMacsLocal.getSchema()).
+                        where(ucastMacsLocal.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
+                transaction.add(op.comment("UcastMacLocal: Deleting " + mac.getMacEntryKey().getValue()));
             } else {
                 LOG.warn("Unable to delete remoteUcastMacs {} because it was not found in the operational store",
                         mac.getMacEntryKey().getValue());
index 52d212c21d02db9e08aea7e41c3f8439c2e885bc..bd9ba06413b81014acb3c54a2e62e688e24bb2f7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 
 public class UcastMacsLocalUpdateCommand extends AbstractTransactCommand {
-    private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+    private static final Logger LOG = LoggerFactory.getLogger(UcastMacsLocalUpdateCommand.class);
 
     public UcastMacsLocalUpdateCommand(HwvtepOperationalState state,
             Collection<DataTreeModification<Node>> changes) {
@@ -77,15 +77,19 @@ public class UcastMacsLocalUpdateCommand extends AbstractTransactCommand {
             setLogicalSwitch(ucastMacsLocal, localUcastMac);
             if (!operationalMacOptional.isPresent()) {
                 setMac(ucastMacsLocal, localUcastMac, operationalMacOptional);
+                LOG.trace("execute: creating LocalUcastMac entry: {}", ucastMacsLocal);
                 transaction.add(op.insert(ucastMacsLocal));
+                transaction.add(op.comment("UcastMacLocal: Creating " + localUcastMac.getMacEntryKey().getValue()));
             } else {
                 LocalUcastMacs updatedMac = operationalMacOptional.get();
                 String existingMac = updatedMac.getMacEntryKey().getValue();
                 UcastMacsLocal extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), UcastMacsLocal.class);
-                extraMac.setMac("");;
+                extraMac.setMac("");
+                LOG.trace("execute: updating LocalUcastMac entry: {}", ucastMacsLocal);
                 transaction.add(op.update(ucastMacsLocal)
                         .where(extraMac.getMacColumn().getSchema().opEqual(existingMac))
                         .build());
+                transaction.add(op.comment("UcastMacLocal: Updating " + localUcastMac.getMacEntryKey().getValue()));
             }
         }
     }
index e9a43c7344b2145cc4c8b37a263b39cded1a2919..fed83dc72cad2fd1fdf520add06612109049f5fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -19,6 +19,7 @@ import java.util.Map.Entry;
 
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsRemote;
@@ -32,7 +33,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 
 public class UcastMacsRemoteRemoveCommand extends AbstractTransactCommand {
-    private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+    private static final Logger LOG = LoggerFactory.getLogger(UcastMacsRemoteRemoveCommand.class);
 
     public UcastMacsRemoteRemoveCommand(HwvtepOperationalState state,
             Collection<DataTreeModification<Node>> changes) {
@@ -57,14 +58,15 @@ public class UcastMacsRemoteRemoveCommand extends AbstractTransactCommand {
             LOG.debug("Removing remoteUcastMacs, mac address: {}", mac.getMacEntryKey().getValue());
             Optional<RemoteUcastMacs> operationalMacOptional =
                     getOperationalState().getRemoteUcastMacs(instanceIdentifier, mac.getKey());
-            UcastMacsRemote mcastMacsRemote = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
+            UcastMacsRemote ucastMacsRemote = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(),
                     UcastMacsRemote.class, null);
-            if (operationalMacOptional.isPresent()) {
+            if (operationalMacOptional.isPresent() && operationalMacOptional.get().getMacEntryUuid() != null) {
                 //when mac entry is deleted, its referenced locators are deleted automatically.
                 //locators in config DS is not deleted and need to be removed explicitly by user.
-                transaction.add(op.delete(mcastMacsRemote.getSchema())
-                        .where(mcastMacsRemote.getMacColumn().getSchema().opEqual(mac.getMacEntryKey().getValue())).build());
-                transaction.add(op.comment("Remote UcastMacRemote: Deleting " + mac.getMacEntryKey().getValue()));
+                UUID macEntryUUID = new UUID(operationalMacOptional.get().getMacEntryUuid().getValue());
+                transaction.add(op.delete(ucastMacsRemote.getSchema()).
+                        where(ucastMacsRemote.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
+                transaction.add(op.comment("UcastMacRemote: Deleting " + mac.getMacEntryKey().getValue()));
             } else {
                 LOG.warn("Unable to delete remoteUcastMacs {} because it was not found in the operational store",
                         mac.getMacEntryKey().getValue());
index 227608c2c6c6f395cb42856371688eacd573344d..de841c184d5e73b6cb2220cbe213e6361a3488d0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 China Telecom Beijing Research Institute and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 China Telecom Beijing Research Institute and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -24,10 +24,8 @@ import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsRemote;
 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.HwvtepNodeName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation;
 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.LogicalSwitchesKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
@@ -38,7 +36,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 
 public class UcastMacsRemoteUpdateCommand extends AbstractTransactCommand {
-    private static final Logger LOG = LoggerFactory.getLogger(PhysicalPortRemoveCommand.class);
+    private static final Logger LOG = LoggerFactory.getLogger(UcastMacsRemoteUpdateCommand.class);
 
     public UcastMacsRemoteUpdateCommand(HwvtepOperationalState state,
             Collection<DataTreeModification<Node>> changes) {
@@ -77,15 +75,19 @@ public class UcastMacsRemoteUpdateCommand extends AbstractTransactCommand {
             setLogicalSwitch(ucastMacsRemote, remoteUcastMac);
             if (!operationalMacOptional.isPresent()) {
                 setMac(ucastMacsRemote, remoteUcastMac, operationalMacOptional);
+                LOG.trace("execute: creating RemotUcastMac entry: {}", ucastMacsRemote);
                 transaction.add(op.insert(ucastMacsRemote));
+                transaction.add(op.comment("UcastMacRemote: Creating " + remoteUcastMac.getMacEntryKey().getValue()));
             } else {
                 RemoteUcastMacs updatedMac = operationalMacOptional.get();
                 String existingMac = updatedMac.getMacEntryKey().getValue();
                 UcastMacsRemote extraMac = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), UcastMacsRemote.class);
-                extraMac.setMac("");;
+                extraMac.setMac("");
+                LOG.trace("execute: updating RemotUcastMac entry: {}", ucastMacsRemote);
                 transaction.add(op.update(ucastMacsRemote)
                         .where(extraMac.getMacColumn().getSchema().opEqual(existingMac))
                         .build());
+                transaction.add(op.comment("UcastMacRemote: Updating " + remoteUcastMac.getMacEntryKey().getValue()));
             }
         }
     }
index 252047ba05eeadd067723ea28a3b61b3c065b71e..4ff016658a2780a61c46a05ab521ec9473ac8e00 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -31,6 +31,7 @@ import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocator;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocatorSet;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+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.HwvtepGlobalAugmentationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
@@ -88,6 +89,7 @@ public class McastMacsLocalUpdateCommand extends AbstractTransactionCommand {
         } else {
             mMacLocalBuilder.setMacEntryKey(new MacAddress(mMacLocal.getMac()));
         }
+        mMacLocalBuilder.setMacEntryUuid(new Uuid(mMacLocal.getUuid().toString()));
         setIpAddress(mMacLocalBuilder, mMacLocal);
         setLocatorSet(mMacLocalBuilder, mMacLocal);
         setLogicalSwitch(mMacLocalBuilder, mMacLocal);
index 631f1c7be509e8a5fcf94349dd4e650d5b71bbd6..ed5ed5cd83a4fcccd4035da696350ce5101a316c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -31,6 +31,7 @@ import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocator;
 import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocatorSet;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+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.HwvtepGlobalAugmentationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
@@ -88,6 +89,7 @@ public class McastMacsRemoteUpdateCommand extends AbstractTransactionCommand {
         } else {
             mMacRemoteBuilder.setMacEntryKey(new MacAddress(mMacRemote.getMac()));
         }
+        mMacRemoteBuilder.setMacEntryUuid(new Uuid(mMacRemote.getUuid().toString()));
         setIpAddress(mMacRemoteBuilder, mMacRemote);
         setLocatorSet(mMacRemoteBuilder, mMacRemote);
         setLogicalSwitch(mMacRemoteBuilder, mMacRemote);
index 696bc8a737d8322e7800b86880e5d89f25c4d4b2..f474c8131093829498f51bb13921b2ca6f350d9e 100644 (file)
@@ -138,7 +138,7 @@ public class PhysicalSwitchUpdateCommand extends AbstractTransactionCommand {
                                     HwvtepSouthboundMapper.createInstanceIdentifier(node.getNodeId()), pLoc);
                     tBuilder.setLocalLocatorRef(new HwvtepPhysicalLocatorRef(tpPath));
                 }
-
+                tBuilder.setTunnelUuid(new Uuid(uuid.toString()));
                 setBfdLocalConfigs(tBuilder, tunnel);
                 setBfdRemoteConfigs(tBuilder, tunnel);
                 setBfdParams(tBuilder, tunnel);
index 73dbfdc05ab726953f9ad3e4f87cde3950833d20..cc4ae95048e787c333c9a1d68d4e7a9103c8b43e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -9,9 +9,11 @@
 package org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md;
 
 import com.google.common.base.Optional;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
@@ -26,6 +28,7 @@ import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocator;
 import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsLocal;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+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.HwvtepGlobalAugmentationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
@@ -80,6 +83,7 @@ public class UcastMacsLocalUpdateCommand extends AbstractTransactionCommand {
             ucmlBuilder.setIpaddr(new IpAddress(ucml.getIpAddr().toCharArray()));
         }
         ucmlBuilder.setMacEntryKey(new MacAddress(ucml.getMac()));
+        ucmlBuilder.setMacEntryUuid(new Uuid(ucml.getUuid().toString()));
         if (ucml.getLocatorColumn() != null && ucml.getLocatorColumn().getData() != null) {
             UUID plocUUID = ucml.getLocatorColumn().getData();
             PhysicalLocator physicalLocator = updatedPLocRows.get(plocUUID);
index 7ebe81a2e471954db211a982373308059e618fb7..e26d6670f153d7b6c50a38ece5d87c27f98d2007 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -26,6 +26,7 @@ import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocator;
 import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsRemote;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+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.HwvtepGlobalAugmentationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
@@ -78,6 +79,7 @@ public class UcastMacsRemoteUpdateCommand extends AbstractTransactionCommand {
         List<RemoteUcastMacs> remoteUMacs = new ArrayList<>();
         RemoteUcastMacsBuilder rumBuilder = new RemoteUcastMacsBuilder();
         rumBuilder.setMacEntryKey(new MacAddress(uMacRemote.getMac()));
+        rumBuilder.setMacEntryUuid(new Uuid(uMacRemote.getUuid().toString()));
         if (uMacRemote.getIpAddr() != null && !uMacRemote.getIpAddr().isEmpty()) {
             rumBuilder.setIpaddr(new IpAddress(uMacRemote.getIpAddr().toCharArray()));
         }
index 09926d96a8c096737130540577feaf9fa17627cd..c60959c15adc4f80e86f4d42fb8d8ff2197afabd 100644 (file)
@@ -9,7 +9,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
 -->
 <snapshot>
   <required-capabilities>
-      <capability>urn:opendaylight:params:xml:ns:yang:hwgw?module=hwgw&amp;revision=2015-12-27</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:netvirt:hwgw?module=hwgw&amp;revision=2015-12-27</capability>
       <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
   </required-capabilities>
   <configuration>
@@ -17,7 +17,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
         <module>
-          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:hwgw">prefix:hwgw</type>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:netvirt:hwgw">prefix:hwgw</type>
           <name>hwgw-default</name>
           <broker>
             <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
diff --git a/netvirt/renderers/neutron/pom.xml b/netvirt/renderers/neutron/pom.xml
new file mode 100644 (file)
index 0000000..95e93bb
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+Copyright (c) 2016 Red Hat, Inc. and others. All rights reserved.
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.5.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.ovsdb</groupId>
+  <artifactId>neutron</artifactId>
+  <version>1.3.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+  <dependencies>
+    <!-- Testing Dependencies -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/netvirt/renderers/neutron/src/main/config/default-config.xml b/netvirt/renderers/neutron/src/main/config/default-config.xml
new file mode 100644 (file)
index 0000000..4d91221
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2016 Red Hat, Inc. and others.  All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<snapshot>
+  <required-capabilities>
+      <capability>urn:opendaylight:params:xml:ns:yang:netvirt:neutron?module=neutron&amp;revision=2016-03-08</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+  </required-capabilities>
+  <configuration>
+
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+        <module>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:netvirt:neutron">prefix:neutron</type>
+          <name>neutron-default</name>
+          <broker>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+            <name>binding-osgi-broker</name>
+          </broker>
+        </module>
+      </modules>
+    </data>
+  </configuration>
+</snapshot>
diff --git a/netvirt/renderers/neutron/src/main/java/org/opendaylight/ovsdb/netvirt/renderers/neutron/NeutronProvider.java b/netvirt/renderers/neutron/src/main/java/org/opendaylight/ovsdb/netvirt/renderers/neutron/NeutronProvider.java
new file mode 100644 (file)
index 0000000..4ad26a0
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.ovsdb.netvirt.renderers.neutron;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NeutronProvider implements BindingAwareProvider, AutoCloseable {
+
+    private static final Logger LOG = LoggerFactory.getLogger(NeutronProvider.class);
+
+    @Override
+    public void onSessionInitiated(ProviderContext session) {
+        LOG.info("NeutronProvider Session Initiated");
+    }
+
+    @Override
+    public void close() throws Exception {
+        LOG.info("NeutronProvider Closed");
+    }
+
+}
diff --git a/netvirt/renderers/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModule.java b/netvirt/renderers/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModule.java
new file mode 100644 (file)
index 0000000..874803e
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308;
+
+import org.opendaylight.ovsdb.netvirt.renderers.neutron.NeutronProvider;
+
+public class NeutronModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308.AbstractNeutronModule {
+    public NeutronModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public NeutronModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308.NeutronModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        NeutronProvider provider = new NeutronProvider();
+        getBrokerDependency().registerProvider(provider);
+        return provider;
+    }
+
+}
diff --git a/netvirt/renderers/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleFactory.java b/netvirt/renderers/neutron/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleFactory.java
new file mode 100644 (file)
index 0000000..98cd54a
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2016 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+/*
+* Generated file
+*
+* Generated from: yang module name: neutron yang module local name: neutron
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308;
+public class NeutronModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308.AbstractNeutronModuleFactory {
+
+}
diff --git a/netvirt/renderers/neutron/src/main/yang/neutron.yang b/netvirt/renderers/neutron/src/main/yang/neutron.yang
new file mode 100644 (file)
index 0000000..63c0cd2
--- /dev/null
@@ -0,0 +1,35 @@
+module neutron {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:netvirt:neutron";
+    prefix "neutron";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+
+    description
+        "Service definition for NetVirt Neutron renderer";
+
+    revision "2016-03-08" {
+        description
+            "Initial revision";
+    }
+
+    identity neutron {
+        base config:module-type;
+        config:java-name-prefix Neutron;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case neutron {
+            when "/config:modules/config:module/config:type = 'neutron'";
+            container broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/netvirt/renderers/neutron/src/test/java/org/opendaylight/ovsdb/netvirt/renderers/neutron/NeutronProviderTest.java b/netvirt/renderers/neutron/src/test/java/org/opendaylight/ovsdb/netvirt/renderers/neutron/NeutronProviderTest.java
new file mode 100644 (file)
index 0000000..722664b
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2016 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.ovsdb.netvirt.renderers.neutron;
+
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+
+import static org.mockito.Mockito.mock;
+
+public class NeutronProviderTest {
+    @Test
+    public void testOnSessionInitiated() {
+        NeutronProvider provider = new NeutronProvider();
+
+        // ensure no exceptions
+        // currently this method is empty
+        provider.onSessionInitiated(mock(BindingAwareBroker.ProviderContext.class));
+    }
+
+    @Test
+    public void testClose() throws Exception {
+        NeutronProvider provider = new NeutronProvider();
+
+        // ensure no exceptions
+        // currently this method is empty
+        provider.close();
+    }
+}
diff --git a/netvirt/renderers/neutron/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleFactoryTest.java b/netvirt/renderers/neutron/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleFactoryTest.java
new file mode 100644 (file)
index 0000000..76bf797
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2016 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308;
+
+import org.junit.Test;
+
+public class NeutronModuleFactoryTest {
+    @Test
+    public void testFactoryConstructor() {
+        // ensure no exceptions on construction
+        new NeutronModuleFactory();
+    }
+}
diff --git a/netvirt/renderers/neutron/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleTest.java b/netvirt/renderers/neutron/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/netvirt/neutron/rev160308/NeutronModuleTest.java
new file mode 100644 (file)
index 0000000..1e5ca5e
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2016 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.neutron.rev160308;
+
+import org.junit.Test;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.JmxAttribute;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.ovsdb.netvirt.renderers.neutron.NeutronProvider;
+
+import javax.management.ObjectName;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class NeutronModuleTest {
+    @Test
+    public void testCustomValidation() {
+        NeutronModule module = new NeutronModule(mock(ModuleIdentifier.class), mock(DependencyResolver.class));
+
+        // ensure no exceptions on validation
+        // currently this method is empty
+        module.customValidation();
+    }
+
+    @Test
+    public void testCreateInstance() throws Exception {
+        // configure mocks
+        DependencyResolver dependencyResolver = mock(DependencyResolver.class);
+        BindingAwareBroker broker = mock(BindingAwareBroker.class);
+        when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
+
+        // create instance of module with injected mocks
+        NeutronModule module = new NeutronModule(mock(ModuleIdentifier.class), dependencyResolver);
+
+        // getInstance calls resolveInstance to get the broker dependency and then calls createInstance
+        AutoCloseable closeable = module.getInstance();
+
+        // verify that the module registered the returned provider with the broker
+        verify(broker).registerProvider((NeutronProvider)closeable);
+
+        // ensure no exceptions on close
+        closeable.close();
+    }
+}
index ebaeb6ebba1ff347a06d927c0a1a413e43703e51..7fa0a20362323517d642f9c7d86f13b89e5a8775 100644 (file)
@@ -24,6 +24,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
   </prerequisites>
   <modules>
     <module>hwgw</module>
+    <module>neutron</module>
   </modules>
   <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
   <build>
index 1542cec28c794e51ad38161daeeb443c2061c53f..9d068337099d0e929aa902047cfae90c4837394f 100644 (file)
@@ -47,6 +47,14 @@ public class NetvirtProvider implements BindingAwareProvider, AutoCloseable {
         return false;
     }
 
+    public static boolean isMasterElected(){
+        if (entityOwnershipService != null) {
+            Optional<EntityOwnershipState> state = entityOwnershipService.getOwnershipState(ownerInstanceEntity);
+            return state.isPresent() && state.get().hasOwner();
+        }
+        return false;
+    }
+
     @Override
     public void close() throws Exception {
         LOG.info("NetvirtProvider closed");
index 120e3ce938ddd46ada19f0c78e944fb6d2f15f93..0ce75a5600a4f0e88d461247ca0c898ea5fdff19 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.ovsdb.openstack.netvirt.ClusterAwareMdsalUtils;
 import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.NetvirtProvider;
 import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
 import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbInventoryService;
 import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbInventoryListener;
@@ -87,6 +88,13 @@ public class OvsdbInventoryServiceImpl implements ConfigInterface, OvsdbInventor
     public void setDependencies(Object impl) {}
 
     private void initializeNetvirtTopology() {
+        while(!NetvirtProvider.isMasterElected()){
+            try {
+                Thread.sleep(100);
+            } catch (InterruptedException e) {
+                LOG.warn("Netvirt thread waiting on Netvirt Ownership Election is interrupted");
+            }
+        }
         final TopologyId topologyId = new TopologyId(new Uri(Constants.NETVIRT_TOPOLOGY_ID));
         InstanceIdentifier<Topology> path =
                 InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyId));
index cc4b4920ad366892b65bdb82def59ac9e0ac3950..cc276199803b713129dbbcd3d27958a313b0bc94 100755 (executable)
@@ -1096,6 +1096,143 @@ module ovsdb {
             }
         }
 
+        list interface-bfd {
+            description "BFD configuration for a particular interface.
+                BFD, defined in RFC 5880 and RFC 5881, allows point-to-point
+                detection of connectivity failures by occasional transmission of
+                BFD control messages.
+
+                bfd : enable: optional string, either true or false
+                       True to enable BFD on this Interface. If not specified, BFD
+                       will be disabled by default.
+
+                bfd : min_rx: optional string
+                       containing an integer, at least 1.
+                       The shortest interval, in milliseconds, at which this BFD session
+                       offers to receive BFD control messages.  The remote endpoint may
+                       choose to send messages at a slower rate.  Defaults to 1000.
+
+                bfd : min_tx: optional string
+                       containing an integer, at least 1.
+                       The shortest interval, in milliseconds, at which this BFD session is
+                       willing to transmit BFD control messages.  Messages will actually be
+                       transmitted at a slower rate if the remote endpoint is not willing to
+                       receive as quickly as specified.  Defaults to 100.
+
+                bfd : decay_min_rx: optional string
+                       containing an integer
+                       An alternate receive interval, in milliseconds, that must be greater
+                       than or equal to bfd:min_rx.  The implementation switches from
+                       bfd:min_rx to bfd:decay_min_rx when there is no obvious incoming
+                       data traffic at the interface, to reduce the CPU and bandwidth cost
+                       of monitoring an idle interface.  This feature may be disabled by
+                       setting a value of 0. This feature is reset whenever bfd:decay_min_rx
+                       bfd:min_rx changes.
+
+                bfd : forwarding_if_rx: optional string, either true or false
+                       When true, traffic received on the Interface is used to
+                       indicate the capability of packet I/O. BFD control packets are
+                       still transmitted and received.  At least one BFD control
+                       packet must be received every 100 * bfd:min_rx amount of time.
+                       Otherwise, even if traffic are received, the bfd-status:forwarding
+                       will be false.
+
+                bfd : cpath_down: optional string, either true or false
+                       Set to true to notify the remote endpoint that traffic should not be
+                       forwarded to this system for some reason other than a connectivity
+                       failure on the interface being monitored.  The typical underlying
+                       reason is concatenated path down, that is, that connectivity
+                       beyond the local system is down.  Defaults to false.
+
+                bfd : cpath_down: optional string, either true or false
+                       Set to true to notify the remote endpoint that traffic should not be
+                       forwarded to this system for some reason other than a connectivity
+                       failure on the interface being monitored.  The typical underlying
+                       reason is concatenated path down, that is, that connectivity
+                       beyond the local system is down.  Defaults to false.
+
+                bfd : check_tnl_key: optional string, either true or false
+                       Set to true to make BFD accept only control messages with a tunnel
+                       key of zero.  By default, BFD accepts control messages with any
+                       tunnel key.
+
+                bfd : bfd_local_dst_mac: optional string, mac address
+                       Set to an Ethernet address in the form xx:xx:xx:xx:xx:xx
+                       to set the MAC used as destination for transmitted BFD packets. The
+                       default is 00:23:20:00:00:01
+
+                bfd : bfd_remote_dst_mac: optional string, mac address
+                       Set to an Ethernet address in the form xx:xx:xx:xx:xx:xx
+                       to set the MAC used for checking the destination of received BFD packets.
+                       Packets with different destination MAC will not be considered as BFD packets.
+                       If not specified the destination MAC address of received BFD packets
+                       are not checked.
+
+                bfd : bfd_src_ip: optional string, ip address
+                       Set to an IPv4 address to set the IP address used as source
+                       for transmitted BFD packets.  The default is 169.254.1.1
+
+                bfd : bfd_dst_ip: optional string, ip address
+                       Set to an IPv4 address to set the IP address used as destination
+                       for transmitted BFD packets.  The default is 169.254.1.0";
+
+            key "bfd-key";
+            leaf bfd-key {
+                description "bfd name/key";
+                type string;
+            }
+            leaf bfd-value {
+                description "bfd value";
+                type string;
+            }
+        }
+
+        list interface-bfd-status {
+            description "BFD status for a particular interface.
+                The switch sets key-value pairs in the bfd_status column to
+                report the status of BFD on this interface.  When BFD is not
+                enabled, with bfd:enable, the switch clears all key-value
+                pairs from bfd_status.
+
+                bfd_status : state: optional string, one of [admin_down, down, init, up]
+                       Reports the state of the BFD session.  The BFD session is fully
+                       healthy and negotiated if UP.
+
+                bfd_status : forwarding: optional string, true or false
+                       Reports whether the BFD session believes this Interface
+                       may be used to forward traffic.  Typically this means
+                       the local session is signaling UP, and the remote
+                       system isn't signaling a problem such as concatenated path down.
+
+                bfd_status : diagnostic: optional string
+                       A diagnostic code specifying the local system's reason for the
+                       last change in session state. The error messages are defined in
+                       section 4.1 of [RFC 5880].
+
+                bfd_status : remote_state: optional string, one of [admin_down, down, init, up]
+                       Reports the state of the remote endpoint's BFD session.
+
+                bfd_status : remote_diagnostic: optional string
+                       A diagnostic code specifying the remote system's reason for the
+                       last change in session state. The error messages are defined in
+                       section 4.1 of [RFC 5880].
+
+                bfd_status : flap_count: optional string, 
+                       containing an integer, minimum 0
+                       Counts the number of bfd_status:forwarding flaps since start.
+                       A flap is considered as a change of the bfd_status:forwarding value.";
+
+            key "bfd-status-key";
+            leaf bfd-status-key {
+                description "bfd-status name/key";
+                type string;
+            }
+            leaf bfd-status-value {
+                description "bfd-status value";
+                type string;
+            }
+        }
+
         leaf qos {
             description "The unique identifier of the QoS entry for this port.";
             type yang:uuid;
index 0fbba27f2d06675e04500b8b70751d4d691384cb..d7b8c7dd0ed8ebd9353c9547ab9a5181dda43384 100644 (file)
@@ -24,6 +24,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <feature version='${project.version}'>odl-ovsdb-southbound-api</feature>
     <bundle>mvn:org.opendaylight.ovsdb/southbound-impl/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.ovsdb/library/{{VERSION}}</bundle>
+    <bundle>mvn:org.opendaylight.ovsdb/utils.yang-utils/{{VERSION}}</bundle>
     <bundle>mvn:com.fasterxml.jackson.core/jackson-annotations/{{VERSION}}</bundle>
     <bundle>mvn:com.fasterxml.jackson.core/jackson-core/{{VERSION}}</bundle>
     <bundle>mvn:com.fasterxml.jackson.core/jackson-databind/{{VERSION}}</bundle>
index ac63bf2c1cb4c6580adac1b3d3aaa357f39364c3..062bf28e41655e6f3cb694d6fc7d1abbbc316ddd 100644 (file)
@@ -63,6 +63,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <artifactId>schema.openvswitch</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.ovsdb</groupId>
+      <artifactId>utils.yang-utils</artifactId>
+      <version>${project.version}</version>
+    </dependency>
     <dependency>
       <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
index 33184082ca1860ea717c42682a2eaea425fd3d4c..d2565bb41d0a37fb28797e89d9dfe0ffba69a9a5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -48,6 +48,7 @@ import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactInvoker;
 import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactInvokerImpl;
 import org.opendaylight.ovsdb.southbound.ovsdb.transact.TransactUtils;
 import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
 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.ConnectionInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchExternalIds;
@@ -59,7 +60,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.ListenableFuture;
 
@@ -160,20 +160,15 @@ public class OvsdbConnectionInstance implements OvsdbClient {
 
             // OpenVSwitchPart
             OpenVSwitch ovs = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), OpenVSwitch.class);
-            Map<String, String> externalIdsMap = new HashMap<>();
 
             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));
+                ovs.setExternalIds(
+                        YangUtils.convertYangKeyValueListToMap(externalIds, OpenvswitchExternalIds::getExternalIdKey,
+                                OpenvswitchExternalIds::getExternalIdValue));
                 Mutate<GenericTableSchema> mutate = op.mutate(ovs)
                             .addMutation(ovs.getExternalIdsColumn().getSchema(),
                                 Mutator.INSERT,
@@ -187,12 +182,10 @@ public class OvsdbConnectionInstance implements OvsdbClient {
 
             List<OpenvswitchOtherConfigs> otherConfigs = this.initialCreateData.getOpenvswitchOtherConfigs();
             if (otherConfigs != null) {
-                Map<String, String> otherConfigsMap = new HashMap<>();
-                for (OpenvswitchOtherConfigs otherConfig : otherConfigs) {
-                    otherConfigsMap.put(otherConfig.getOtherConfigKey(), otherConfig.getOtherConfigValue());
-                }
                 try {
-                    ovs.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
+                    ovs.setOtherConfig(YangUtils.convertYangKeyValueListToMap(otherConfigs,
+                            OpenvswitchOtherConfigs::getOtherConfigKey,
+                            OpenvswitchOtherConfigs::getOtherConfigValue));
                     transaction.add(op.mutate(ovs).addMutation(ovs.getOtherConfigColumn().getSchema(),
                         Mutator.INSERT,
                         ovs.getOtherConfigColumn().getData()));
index 6fe618438047d404c65d929e6f51db672c91f54f..96adcb39520dd76bc1f4fd32eb889dd044f865fe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -11,10 +11,11 @@ import static org.opendaylight.ovsdb.lib.operations.Operations.op;
 
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import javax.annotation.Nonnull;
+
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.ovsdb.lib.notation.UUID;
 import org.opendaylight.ovsdb.lib.operations.Insert;
@@ -28,6 +29,7 @@ import org.opendaylight.ovsdb.schema.openvswitch.Port;
 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 import org.opendaylight.ovsdb.southbound.SouthboundUtil;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeInternal;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.BridgeExternalIds;
@@ -39,7 +41,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Sets;
 
 public class BridgeUpdateCommand extends AbstractTransactCommand {
@@ -127,33 +128,23 @@ public class BridgeUpdateCommand extends AbstractTransactCommand {
         Map<String, String> externalIdMap = new HashMap<>();
         externalIdMap.put(SouthboundConstants.IID_EXTERNAL_ID_KEY, SouthboundUtil.serializeInstanceIdentifier(iid));
         // Set user provided external ids
-        List<BridgeExternalIds> bridgeExternalId = ovsdbManagedNode.getBridgeExternalIds();
-        if (bridgeExternalId != null) {
-            for (BridgeExternalIds externalId : bridgeExternalId) {
-                externalIdMap.put(externalId.getBridgeExternalIdKey(), externalId.getBridgeExternalIdValue());
-            }
-        }
         try {
-            bridge.setExternalIds(ImmutableMap.copyOf(externalIdMap));
+            YangUtils.copyYangKeyValueListToMap(externalIdMap, ovsdbManagedNode.getBridgeExternalIds(),
+                    BridgeExternalIds::getBridgeExternalIdKey, BridgeExternalIds::getBridgeExternalIdValue);
         } catch (NullPointerException e) {
             LOG.warn("Incomplete bridge external Id", e);
         }
+        bridge.setExternalIds(externalIdMap);
     }
 
 
 
-    private void setOpenDaylightOtherConfig(Bridge bridge, OvsdbBridgeAugmentation ovsdbManagedNode) {
-        List<BridgeOtherConfigs> bridgeOtherConfig = ovsdbManagedNode.getBridgeOtherConfigs();
-        if (bridgeOtherConfig != null) {
-            Map<String, String> otherConfigMap = new HashMap<>();
-            for (BridgeOtherConfigs otherConf : bridgeOtherConfig) {
-                otherConfigMap.put(otherConf.getBridgeOtherConfigKey(), otherConf.getBridgeOtherConfigValue());
-            }
-            try {
-                bridge.setOtherConfig(ImmutableMap.copyOf(otherConfigMap));
-            } catch (NullPointerException e) {
-                LOG.warn("Incomplete bridge other config", e);
-            }
+    private void setOpenDaylightOtherConfig(@Nonnull Bridge bridge, @Nonnull OvsdbBridgeAugmentation ovsdbManagedNode) {
+        try {
+            bridge.setOtherConfig(YangUtils.convertYangKeyValueListToMap(ovsdbManagedNode.getBridgeOtherConfigs(),
+                    BridgeOtherConfigs::getBridgeOtherConfigKey, BridgeOtherConfigs::getBridgeOtherConfigValue));
+        } catch (NullPointerException e) {
+            LOG.warn("Incomplete bridge other config", e);
         }
     }
 
index a36060cf246ad9b04328d9b78a8507482d5b6be6..f675b6b4462f31638e362c3f34d0eda20b897113 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Intel Corporation and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 Intel Corporation and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -10,7 +10,6 @@ package org.opendaylight.ovsdb.southbound.ovsdb.transact;
 import static org.opendaylight.ovsdb.lib.operations.Operations.op;
 
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -22,6 +21,7 @@ import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.OpenvswitchOtherConfigs;
@@ -31,8 +31,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.ImmutableMap;
-
 public class OvsdbNodeUpdateCommand implements TransactCommand {
     private AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes;
     private static final Logger LOG = LoggerFactory.getLogger(OvsdbNodeUpdateCommand.class);
@@ -55,20 +53,12 @@ public class OvsdbNodeUpdateCommand implements TransactCommand {
 
             // OpenVSwitchPart
             OpenVSwitch ovs = TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), OpenVSwitch.class);
-            Map<String, String> externalIdsMap = new HashMap<>();
-
-            List<OpenvswitchExternalIds> externalIds = ovsdbNode.getOpenvswitchExternalIds();
-
-            if (externalIds != null) {
-                for (OpenvswitchExternalIds externalId : externalIds) {
-                    externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
-                }
-            }
 
             stampInstanceIdentifier(transaction,ovsdbNodeEntry.getKey().firstIdentifierOf(Node.class));
 
             try {
-                ovs.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+                ovs.setExternalIds(YangUtils.convertYangKeyValueListToMap(ovsdbNode.getOpenvswitchExternalIds(),
+                        OpenvswitchExternalIds::getExternalIdKey, OpenvswitchExternalIds::getExternalIdValue));
                 Mutate<GenericTableSchema> mutate = op.mutate(ovs)
                             .addMutation(ovs.getExternalIdsColumn().getSchema(),
                                 Mutator.INSERT,
@@ -82,12 +72,9 @@ public class OvsdbNodeUpdateCommand implements TransactCommand {
 
             List<OpenvswitchOtherConfigs> otherConfigs = ovsdbNode.getOpenvswitchOtherConfigs();
             if (otherConfigs != null) {
-                Map<String, String> otherConfigsMap = new HashMap<>();
-                for (OpenvswitchOtherConfigs otherConfig : otherConfigs) {
-                    otherConfigsMap.put(otherConfig.getOtherConfigKey(), otherConfig.getOtherConfigValue());
-                }
                 try {
-                    ovs.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
+                    ovs.setOtherConfig(YangUtils.convertYangKeyValueListToMap(otherConfigs,
+                            OpenvswitchOtherConfigs::getOtherConfigKey, OpenvswitchOtherConfigs::getOtherConfigValue));
                     transaction.add(op.mutate(ovs).addMutation(ovs.getOtherConfigColumn().getSchema(),
                         Mutator.INSERT,
                         ovs.getOtherConfigColumn().getData()));
index 9f895600a1dd0b8ae943a2a95bf61d8e0261d32b..8cf3c77d9092d2760c9f5bdda1ad691d8912c8a3 100644 (file)
@@ -10,27 +10,21 @@ package org.opendaylight.ovsdb.southbound.ovsdb.transact;
 import static org.opendaylight.ovsdb.lib.operations.Operations.op;
 
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.ovsdb.lib.notation.Condition;
-import org.opendaylight.ovsdb.lib.notation.Mutator;
 import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.operations.Mutate;
 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
-import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
-import org.opendaylight.ovsdb.schema.openvswitch.Port;
 import org.opendaylight.ovsdb.schema.openvswitch.Qos;
 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
 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.rev150105.OvsdbNodeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.QosEntries;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QosExternalIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.qos.entries.QosOtherConfig;
@@ -40,8 +34,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.ImmutableMap;
-
 public class QosUpdateCommand extends AbstractTransactCommand {
     private static final Logger LOG = LoggerFactory.getLogger(QosUpdateCommand.class);
 
@@ -101,31 +93,21 @@ public class QosUpdateCommand extends AbstractTransactCommand {
                 }
                 qos.setQueues(newQueueList);
 
-                List<QosExternalIds> externalIds = qosEntry.getQosExternalIds();
                 Map<String, String> externalIdsMap = new HashMap<>();
-                if (externalIds != null) {
-                    for (QosExternalIds externalId : externalIds) {
-                        externalIdsMap.put(externalId.getQosExternalIdKey(), externalId.getQosExternalIdValue());
-                    }
-                }
-                externalIdsMap.put(SouthboundConstants.QOS_ID_EXTERNAL_ID_KEY, qosEntry.getQosId().getValue());
                 try {
-                    qos.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+                    YangUtils.copyYangKeyValueListToMap(externalIdsMap, qosEntry.getQosExternalIds(),
+                            QosExternalIds::getQosExternalIdKey, QosExternalIds::getQosExternalIdValue);
                 } catch (NullPointerException e) {
                     LOG.warn("Incomplete Qos external IDs", e);
                 }
+                externalIdsMap.put(SouthboundConstants.QOS_ID_EXTERNAL_ID_KEY, qosEntry.getQosId().getValue());
+                qos.setExternalIds(externalIdsMap);
 
-                List<QosOtherConfig> otherConfigs = qosEntry.getQosOtherConfig();
-                if (otherConfigs != null) {
-                    Map<String, String> otherConfigsMap = new HashMap<>();
-                    for (QosOtherConfig otherConfig : otherConfigs) {
-                        otherConfigsMap.put(otherConfig.getOtherConfigKey(), otherConfig.getOtherConfigValue());
-                    }
-                    try {
-                        qos.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
-                    } catch (NullPointerException e) {
-                        LOG.warn("Incomplete Qos other_config", e);
-                    }
+                try {
+                    qos.setOtherConfig(YangUtils.convertYangKeyValueListToMap(qosEntry.getQosOtherConfig(),
+                            QosOtherConfig::getOtherConfigKey, QosOtherConfig::getOtherConfigValue));
+                } catch (NullPointerException e) {
+                    LOG.warn("Incomplete Qos other_config", e);
                 }
                 if (uuid == null) {
                     transaction.add(op.insert(qos)).build();
index 1b991bbf16165c59b97130cec9fc8a9411c6c30c..cd6d768555ea1e925d1fd847ecb2c6f1cc170126 100644 (file)
@@ -17,20 +17,15 @@ import java.util.Map.Entry;
 import java.util.Set;
 
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.ovsdb.lib.notation.Mutator;
 import org.opendaylight.ovsdb.lib.notation.UUID;
-import org.opendaylight.ovsdb.lib.operations.Mutate;
 import org.opendaylight.ovsdb.lib.operations.TransactionBuilder;
-import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
 import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
-import org.opendaylight.ovsdb.schema.openvswitch.Qos;
 import org.opendaylight.ovsdb.schema.openvswitch.Queue;
 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
-import org.opendaylight.ovsdb.southbound.SouthboundMapper;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
 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.rev150105.OvsdbNodeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.QosEntries;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.Queues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.queues.QueuesExternalIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.queues.QueuesOtherConfig;
@@ -39,8 +34,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.ImmutableMap;
-
 public class QueueUpdateCommand extends AbstractTransactCommand {
     private static final Logger LOG = LoggerFactory.getLogger(QueueUpdateCommand.class);
 
@@ -98,31 +91,21 @@ public class QueueUpdateCommand extends AbstractTransactCommand {
                     uuid = new UUID(queueUuid.getValue());
                 }
 
-                List<QueuesExternalIds> externalIds = queueEntry.getQueuesExternalIds();
                 Map<String, String> externalIdsMap = new HashMap<>();
-                if (externalIds != null) {
-                    for (QueuesExternalIds externalId : externalIds) {
-                        externalIdsMap.put(externalId.getQueuesExternalIdKey(), externalId.getQueuesExternalIdValue());
-                    }
-                }
-                externalIdsMap.put(SouthboundConstants.QUEUE_ID_EXTERNAL_ID_KEY, queueEntry.getQueueId().getValue());
                 try {
-                    queue.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+                    YangUtils.copyYangKeyValueListToMap(externalIdsMap, queueEntry.getQueuesExternalIds(),
+                            QueuesExternalIds::getQueuesExternalIdKey, QueuesExternalIds::getQueuesExternalIdValue);
                 } catch (NullPointerException e) {
                     LOG.warn("Incomplete Queue external IDs", e);
                 }
+                externalIdsMap.put(SouthboundConstants.QUEUE_ID_EXTERNAL_ID_KEY, queueEntry.getQueueId().getValue());
+                queue.setExternalIds(externalIdsMap);
 
-                List<QueuesOtherConfig> otherConfigs = queueEntry.getQueuesOtherConfig();
-                if (otherConfigs != null) {
-                    Map<String, String> otherConfigsMap = new HashMap<>();
-                    for (QueuesOtherConfig otherConfig : otherConfigs) {
-                        otherConfigsMap.put(otherConfig.getQueueOtherConfigKey(), otherConfig.getQueueOtherConfigValue());
-                    }
-                    try {
-                        queue.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
-                    } catch (NullPointerException e) {
-                        LOG.warn("Incomplete Queue other_config", e);
-                    }
+                try {
+                    queue.setOtherConfig(YangUtils.convertYangKeyValueListToMap(queueEntry.getQueuesOtherConfig(),
+                            QueuesOtherConfig::getQueueOtherConfigKey, QueuesOtherConfig::getQueueOtherConfigValue));
+                } catch (NullPointerException e) {
+                    LOG.warn("Incomplete Queue other_config", e);
                 }
                 if (uuid == null) {
                     transaction.add(op.insert(queue)).build();
index ce3a1464376fac82265bd62b89080aa8cf4efd4b..21214949c97b87a338fcbcc5a9f1c55bda5e2999 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -34,10 +34,12 @@ import org.opendaylight.ovsdb.schema.openvswitch.Port;
 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundMapper;
 import org.opendaylight.ovsdb.southbound.SouthboundProvider;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbPortInterfaceAttributes.VlanMode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfd;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceOtherConfigs;
@@ -53,7 +55,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.CheckedFuture;
 
@@ -124,6 +125,7 @@ public class TerminationPointCreateCommand extends AbstractTransactCommand {
         createInterfaceOtherConfig(terminationPoint, ovsInterface);
         createInterfaceExternalIds(terminationPoint, ovsInterface);
         createInterfaceLldp(terminationPoint, ovsInterface);
+        createInterfaceBfd(terminationPoint, ovsInterface);
     }
 
     private void createInterfaceType(final OvsdbTerminationPointAugmentation terminationPoint,
@@ -174,12 +176,9 @@ public class TerminationPointCreateCommand extends AbstractTransactCommand {
 
         //Configure optional input
         if (terminationPoint.getOptions() != null) {
-            Map<String, String> optionsMap = new HashMap<>();
-            for (Options option : terminationPoint.getOptions()) {
-                optionsMap.put(option.getOption(), option.getValue());
-            }
             try {
-                ovsInterface.setOptions(ImmutableMap.copyOf(optionsMap));
+                ovsInterface.setOptions(YangUtils.convertYangKeyValueListToMap(terminationPoint.getOptions(),
+                        Options::getOption, Options::getValue));
             } catch (NullPointerException e) {
                 LOG.warn("Incomplete OVSDB interface options", e);
             }
@@ -193,12 +192,9 @@ public class TerminationPointCreateCommand extends AbstractTransactCommand {
         List<InterfaceExternalIds> interfaceExternalIds =
                 terminationPoint.getInterfaceExternalIds();
         if (interfaceExternalIds != null && !interfaceExternalIds.isEmpty()) {
-            Map<String, String> externalIdsMap = new HashMap<>();
-            for (InterfaceExternalIds externalId: interfaceExternalIds) {
-                externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
-            }
             try {
-                ovsInterface.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+                ovsInterface.setExternalIds(YangUtils.convertYangKeyValueListToMap(interfaceExternalIds,
+                        InterfaceExternalIds::getExternalIdKey, InterfaceExternalIds::getExternalIdValue));
             } catch (NullPointerException e) {
                 LOG.warn("Incomplete OVSDB interface external_ids", e);
             }
@@ -233,12 +229,9 @@ public class TerminationPointCreateCommand extends AbstractTransactCommand {
             List<InterfaceLldp> interfaceLldpList =
                     terminationPoint.getInterfaceLldp();
             if (interfaceLldpList != null && !interfaceLldpList.isEmpty()) {
-                Map<String, String> interfaceLldpMap = new HashMap<>();
-                for (InterfaceLldp interfaceLldp : interfaceLldpList) {
-                    interfaceLldpMap.put(interfaceLldp.getLldpKey(), interfaceLldp.getLldpValue());
-                }
                 try {
-                    ovsInterface.setLldp(ImmutableMap.copyOf(interfaceLldpMap));
+                    ovsInterface.setLldp(YangUtils.convertYangKeyValueListToMap(interfaceLldpList,
+                            InterfaceLldp::getLldpKey, InterfaceLldp::getLldpValue));
                 } catch (NullPointerException e) {
                     LOG.warn("Incomplete OVSDB interface lldp", e);
                 }
@@ -248,18 +241,33 @@ public class TerminationPointCreateCommand extends AbstractTransactCommand {
         }
     }
 
+    private void createInterfaceBfd(final OvsdbTerminationPointAugmentation terminationPoint,
+                    final Interface ovsInterface) {
+
+        try {
+            List<InterfaceBfd> interfaceBfdList = terminationPoint.getInterfaceBfd();
+            if (interfaceBfdList != null && !interfaceBfdList.isEmpty()) {
+                try {
+                    ovsInterface.setBfd(YangUtils.convertYangKeyValueListToMap(interfaceBfdList,
+                                    InterfaceBfd::getBfdKey, InterfaceBfd::getBfdValue));
+                } catch (NullPointerException e) {
+                    LOG.warn("Incomplete OVSDB interface bfd", e);
+                }
+            }
+        } catch (SchemaVersionMismatchException e) {
+            LOG.debug("bfd column for Interface Table unsupported for this version of ovsdb schema", e);
+        }
+    }
+
     private void createPortExternalIds(
             final OvsdbTerminationPointAugmentation terminationPoint,
             final Port port) {
 
         List<PortExternalIds> portExternalIds = terminationPoint.getPortExternalIds();
         if (portExternalIds != null && !portExternalIds.isEmpty()) {
-            Map<String, String> externalIdsMap = new HashMap<>();
-            for (PortExternalIds externalId: portExternalIds) {
-                externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
-            }
             try {
-                port.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+                port.setExternalIds(YangUtils.convertYangKeyValueListToMap(portExternalIds,
+                        PortExternalIds::getExternalIdKey, PortExternalIds::getExternalIdValue));
             } catch (NullPointerException e) {
                 LOG.warn("Incomplete OVSDB port external_ids", e);
             }
@@ -310,13 +318,9 @@ public class TerminationPointCreateCommand extends AbstractTransactCommand {
         List<PortOtherConfigs> portOtherConfigs =
                 terminationPoint.getPortOtherConfigs();
         if (portOtherConfigs != null && !portOtherConfigs.isEmpty()) {
-            Map<String, String> otherConfigsMap = new HashMap<>();
-            for (PortOtherConfigs portOtherConfig : portOtherConfigs) {
-                otherConfigsMap.put(portOtherConfig.getOtherConfigKey(),
-                        portOtherConfig.getOtherConfigValue());
-            }
             try {
-                ovsPort.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
+                ovsPort.setOtherConfig(YangUtils.convertYangKeyValueListToMap(portOtherConfigs,
+                        PortOtherConfigs::getOtherConfigKey, PortOtherConfigs::getOtherConfigValue));
             } catch (NullPointerException e) {
                 LOG.warn("Incomplete OVSDB port other_config", e);
             }
index 159161905fd26f9bfa851df82d9df96fced078ba..f59183cbce548f9d79cbda02de4e936750bf22b7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2015, 2016 Brocade Communications Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -24,9 +24,11 @@ import org.opendaylight.ovsdb.lib.schema.typed.TyperUtils;
 import org.opendaylight.ovsdb.schema.openvswitch.Interface;
 import org.opendaylight.ovsdb.schema.openvswitch.Port;
 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
+import org.opendaylight.ovsdb.utils.yang.YangUtils;
 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.rev150105.OvsdbPortInterfaceAttributes.VlanMode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfd;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceOtherConfigs;
@@ -40,7 +42,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Sets;
 
 public class TerminationPointUpdateCommand extends AbstractTransactCommand {
@@ -113,6 +114,7 @@ public class TerminationPointUpdateCommand extends AbstractTransactCommand {
         updateInterfaceOtherConfig(terminationPoint, ovsInterface);
         updateInterfaceExternalIds(terminationPoint, ovsInterface);
         updateInterfaceLldp(terminationPoint, ovsInterface);
+        updateInterfaceBfd(terminationPoint, ovsInterface);
     }
 
     private void updatePort(
@@ -166,12 +168,9 @@ public class TerminationPointUpdateCommand extends AbstractTransactCommand {
 
         //Configure optional input
         if (terminationPoint.getOptions() != null) {
-            Map<String, String> optionsMap = new HashMap<>();
-            for (Options option : terminationPoint.getOptions()) {
-                optionsMap.put(option.getOption(), option.getValue());
-            }
             try {
-                ovsInterface.setOptions(ImmutableMap.copyOf(optionsMap));
+                ovsInterface.setOptions(YangUtils.convertYangKeyValueListToMap(terminationPoint.getOptions(),
+                        Options::getOption, Options::getValue));
             } catch (NullPointerException e) {
                 LOG.warn("Incomplete OVSDB interface options", e);
             }
@@ -185,12 +184,9 @@ public class TerminationPointUpdateCommand extends AbstractTransactCommand {
         List<InterfaceExternalIds> interfaceExternalIds =
                 terminationPoint.getInterfaceExternalIds();
         if (interfaceExternalIds != null && !interfaceExternalIds.isEmpty()) {
-            Map<String, String> externalIdsMap = new HashMap<>();
-            for (InterfaceExternalIds externalId: interfaceExternalIds) {
-                externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
-            }
             try {
-                ovsInterface.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+                ovsInterface.setExternalIds(YangUtils.convertYangKeyValueListToMap(interfaceExternalIds,
+                        InterfaceExternalIds::getExternalIdKey, InterfaceExternalIds::getExternalIdValue));
             } catch (NullPointerException e) {
                 LOG.warn("Incomplete OVSDB interface external_ids", e);
             }
@@ -205,12 +201,9 @@ public class TerminationPointUpdateCommand extends AbstractTransactCommand {
             List<InterfaceLldp> interfaceLldpList =
                     terminationPoint.getInterfaceLldp();
             if (interfaceLldpList != null && !interfaceLldpList.isEmpty()) {
-                Map<String, String> interfaceLldpMap = new HashMap<>();
-                for (InterfaceLldp interfaceLldp : interfaceLldpList) {
-                    interfaceLldpMap.put(interfaceLldp.getLldpKey(), interfaceLldp.getLldpValue());
-                }
                 try {
-                    ovsInterface.setLldp(ImmutableMap.copyOf(interfaceLldpMap));
+                    ovsInterface.setLldp(YangUtils.convertYangKeyValueListToMap(interfaceLldpList,
+                            InterfaceLldp::getLldpKey, InterfaceLldp::getLldpValue));
                 } catch (NullPointerException e) {
                     LOG.warn("Incomplete OVSDB interface lldp", e);
                 }
@@ -240,18 +233,35 @@ public class TerminationPointUpdateCommand extends AbstractTransactCommand {
         }
     }
 
+    private void updateInterfaceBfd(
+            final OvsdbTerminationPointAugmentation terminationPoint,
+            final Interface ovsInterface) {
+
+        try {
+            List<InterfaceBfd> interfaceBfdList =
+                    terminationPoint.getInterfaceBfd();
+            if (interfaceBfdList != null && !interfaceBfdList.isEmpty()) {
+                try {
+                    ovsInterface.setBfd(YangUtils.convertYangKeyValueListToMap(interfaceBfdList,
+                            InterfaceBfd::getBfdKey, InterfaceBfd::getBfdValue));
+                } catch (NullPointerException e) {
+                    LOG.warn("Incomplete OVSDB interface bfd", e);
+                }
+            }
+        } catch (SchemaVersionMismatchException e) {
+            LOG.debug("bfd column for Interface Table unsupported for this version of ovsdb schema", e);
+        }
+    }
+
     private void updatePortExternalIds(
             final OvsdbTerminationPointAugmentation terminationPoint,
             final Port port) {
 
         List<PortExternalIds> portExternalIds = terminationPoint.getPortExternalIds();
         if (portExternalIds != null && !portExternalIds.isEmpty()) {
-            Map<String, String> externalIdsMap = new HashMap<>();
-            for (PortExternalIds externalId: portExternalIds) {
-                externalIdsMap.put(externalId.getExternalIdKey(), externalId.getExternalIdValue());
-            }
             try {
-                port.setExternalIds(ImmutableMap.copyOf(externalIdsMap));
+                port.setExternalIds(YangUtils.convertYangKeyValueListToMap(portExternalIds,
+                        PortExternalIds::getExternalIdKey, PortExternalIds::getExternalIdValue));
             } catch (NullPointerException e) {
                 LOG.warn("Incomplete OVSDB port external_ids", e);
             }
@@ -302,13 +312,9 @@ public class TerminationPointUpdateCommand extends AbstractTransactCommand {
         List<PortOtherConfigs> portOtherConfigs =
                 terminationPoint.getPortOtherConfigs();
         if (portOtherConfigs != null && !portOtherConfigs.isEmpty()) {
-            Map<String, String> otherConfigsMap = new HashMap<>();
-            for (PortOtherConfigs portOtherConfig : portOtherConfigs) {
-                otherConfigsMap.put(portOtherConfig.getOtherConfigKey(),
-                        portOtherConfig.getOtherConfigValue());
-            }
             try {
-                ovsPort.setOtherConfig(ImmutableMap.copyOf(otherConfigsMap));
+                ovsPort.setOtherConfig(YangUtils.convertYangKeyValueListToMap(portOtherConfigs,
+                        PortOtherConfigs::getOtherConfigKey, PortOtherConfigs::getOtherConfigValue));
             } catch (NullPointerException e) {
                 LOG.warn("Incomplete OVSDB port other_config", e);
             }
index 120ef5e6a5a60840174a4e1dc7e39517dae4410d..0bfb3e22cecd573f850e7a5ffbf25d00985b1f14 100644 (file)
@@ -42,6 +42,12 @@ 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.OvsdbTerminationPointAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfd;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdStatusBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceBfdStatusKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceExternalIdsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.port._interface.attributes.InterfaceLldp;
@@ -259,6 +265,8 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
         updateOptions(interf, ovsdbTerminationPointBuilder);
         updateInterfaceOtherConfig(interf, ovsdbTerminationPointBuilder);
         updateInterfaceLldp(interf, ovsdbTerminationPointBuilder);
+        updateInterfaceBfd(interf, ovsdbTerminationPointBuilder);
+        updateInterfaceBfdStatus(interf, ovsdbTerminationPointBuilder);
     }
 
     private void updateVlan(final Port port,
@@ -492,6 +500,56 @@ public class OvsdbPortUpdateCommand extends AbstractTransactionCommand {
         }
     }
 
+    private void updateInterfaceBfdStatus(final Interface interf,
+            final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) {
+
+        try {
+            Map<String, String> interfaceBfdStatusMap = interf.getBfdStatusColumn().getData();
+            if (interfaceBfdStatusMap != null && !interfaceBfdStatusMap.isEmpty()) {
+                List<InterfaceBfdStatus> interfaceBfdStatusList = new ArrayList<>();
+                for (String interfaceBfdStatusKeyString : interfaceBfdStatusMap.keySet()) {
+                    String interfaceBfdStatusValueString = interfaceBfdStatusMap.get(interfaceBfdStatusKeyString);
+                    if (interfaceBfdStatusKeyString != null && interfaceBfdStatusValueString!=null) {
+                        interfaceBfdStatusList.add(new InterfaceBfdStatusBuilder()
+                                .setKey(new InterfaceBfdStatusKey(interfaceBfdStatusKeyString))
+                                .setBfdStatusKey(interfaceBfdStatusKeyString)
+                                .setBfdStatusValue(interfaceBfdStatusValueString)
+                                .build());
+                    }
+                }
+                ovsdbTerminationPointBuilder.setInterfaceBfdStatus(interfaceBfdStatusList);
+            }
+        } catch (SchemaVersionMismatchException e) {
+            // We don't care about the exception stack trace here
+            LOG.debug("bfd-status column for Interface Table unsupported for this version of ovsdb schema. {}", e.getMessage());
+        }
+    }
+
+    private void updateInterfaceBfd(final Interface interf,
+            final OvsdbTerminationPointAugmentationBuilder ovsdbTerminationPointBuilder) {
+
+        try {
+            Map<String, String> interfaceBfdMap = interf.getBfdColumn().getData();
+            if (interfaceBfdMap != null && !interfaceBfdMap.isEmpty()) {
+                List<InterfaceBfd> interfaceBfdList = new ArrayList<>();
+                for (String interfaceBfdKeyString : interfaceBfdMap.keySet()) {
+                    String interfaceBfdValueString = interfaceBfdMap.get(interfaceBfdKeyString);
+                    if (interfaceBfdKeyString != null && interfaceBfdValueString!=null) {
+                        interfaceBfdList.add(new InterfaceBfdBuilder()
+                                .setKey(new InterfaceBfdKey(interfaceBfdKeyString))
+                                .setBfdKey(interfaceBfdKeyString)
+                                .setBfdValue(interfaceBfdValueString)
+                                .build());
+                    }
+                }
+                ovsdbTerminationPointBuilder.setInterfaceBfd(interfaceBfdList);
+            }
+        } catch (SchemaVersionMismatchException e) {
+            // We don't care about the exception stack trace here
+            LOG.debug("bfd column for Interface Table unsupported for this version of ovsdb schema. {}", e.getMessage());
+        }
+    }
+
     private boolean portQosCleared(Entry<UUID, Port> portUpdate) {
         if (portUpdate.getValue().getQosColumn() == null) {
             return false;
index f85fd02df53509c0ff788d7cc26bf8ed9fa45390..2f26fd3dc05e06a9dcd4a9e539a70d63bd8d98eb 100644 (file)
@@ -386,6 +386,8 @@ import com.google.common.util.concurrent.CheckedFuture;
         MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateOptions", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
         MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceOtherConfig", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
         MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceLldp", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
+        MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceBfd", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
+        MemberModifier.suppress(MemberMatcher.method(OvsdbPortUpdateCommand.class, "updateInterfaceBfdStatus", Interface.class, OvsdbTerminationPointAugmentationBuilder.class));
 
         Whitebox.invokeMethod(ovsdbPortUpdateCommand, "updateInterface", interf, OVSDB_INTERFACE_TYPE, ovsdbTerminationPointBuilder);
         verify(ovsdbTerminationPointBuilder).setInterfaceUuid(any(Uuid.class));
index 90ac03ae9e867cb9560d23ac4ddc495b46c59309..ce6acfb639c57d4a44cf088b366ffc2bd4eefd14 100644 (file)
@@ -57,6 +57,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <module>servicehelper</module>
     <module>southbound-utils</module>
     <module>hwvtepsouthbound-utils</module>
+    <module>yang-utils</module>
   </modules>
 
 <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
diff --git a/utils/yang-utils/pom.xml b/utils/yang-utils/pom.xml
new file mode 100644 (file)
index 0000000..b8a502d
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.opendaylight.odlparent</groupId>
+    <artifactId>bundle-parent</artifactId>
+    <version>1.7.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.ovsdb</groupId>
+  <artifactId>utils.yang-utils</artifactId>
+  <version>1.3.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.google.code.findbugs</groupId>
+      <artifactId>jsr305</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>
+              org.opendaylight.ovsdb.utils.yang
+            </Export-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/utils/yang-utils/src/main/java/org/opendaylight/ovsdb/utils/yang/YangUtils.java b/utils/yang-utils/src/main/java/org/opendaylight/ovsdb/utils/yang/YangUtils.java
new file mode 100644 (file)
index 0000000..6470e6f
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright © 2016 Red Hat, Inc. and others.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.ovsdb.utils.yang;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.Function;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * YANG utility functions.
+ */
+public final class YangUtils {
+    /**
+     * Prevent instantiation.
+     */
+    private YangUtils() {
+        // Nothing to do
+    }
+
+    /**
+     * Copies a list of YANG key-value items to the given map. Any {@code null} key or value will cause an error.
+     *
+     * @param map The map to fill.
+     * @param yangList The list of YANG key-value items.
+     * @param keyExtractor The key extractor function to use.
+     * @param valueExtractor The value extractor function to use.
+     * @param <T> The YANG item type.
+     * @param <K> The key type.
+     * @param <V> The value type.
+     * @return The map.
+     */
+    @Nonnull
+    public static <T, K, V> Map<K, V> copyYangKeyValueListToMap(@Nonnull Map<K, V> map, @Nullable Iterable<T> yangList,
+                                                                @Nonnull Function<T, K> keyExtractor,
+                                                                @Nonnull Function<T, V> valueExtractor) {
+        if (yangList != null) {
+            for (T yangValue : yangList) {
+                K key = keyExtractor.apply(yangValue);
+                V value = valueExtractor.apply(yangValue);
+                Preconditions.checkNotNull(key);
+                Preconditions.checkNotNull(value);
+                map.put(key, value);
+            }
+        }
+        return map;
+    }
+
+    /**
+     * Converts a list of YANG key-value items to a map.
+     *
+     * @param yangList The list of YANG key-value items.
+     * @param keyExtractor The key extractor function to use.
+     * @param valueExtractor The value extractor function to use.
+     * @param <T> The YANG item type.
+     * @param <K> The key type.
+     * @param <V> The value type.
+     * @return The map.
+     */
+    @Nonnull
+    public static <T, K, V> Map<K, V> convertYangKeyValueListToMap(@Nullable Iterable<T> yangList,
+                                                                   @Nonnull Function<T, K> keyExtractor,
+                                                                   @Nonnull Function<T, V> valueExtractor) {
+        return copyYangKeyValueListToMap(new HashMap<>(), yangList, keyExtractor, valueExtractor);
+    }
+}