import org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice;
+import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices;
-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.hwvtep.global.attributes.LogicalSwitches;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
ListenableFuture<Void> lsCreateFuture = createLogicalSwitch(l2GatewayDevice, elanInstance);
futures.add(lsCreateFuture);
} else {
+ createLogicalSwitch(l2GatewayDevice, elanInstance);
String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(elanInstanceName);
LOG.info("{} is already created in {}; adding remaining configurations", logicalSwitchName, hwvtepNodeId);
private ListenableFuture<Void> createLogicalSwitch(L2GatewayDevice l2GatewayDevice, ElanInstance elanInstance) {
final String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(
elanInstance.getElanInstanceName());
- String segmentationId = elanInstance.getSegmentationId().toString();
+ String segmentationId = ElanUtils.getVxlanSegmentationId(elanInstance).toString();
+ String replicationMode = "";
- if (LOG.isTraceEnabled()) {
- LOG.trace("logical switch {} is created on {} with VNI {}", logicalSwitchName,
- l2GatewayDevice.getHwvtepNodeId(), segmentationId);
- }
+ LOG.trace("logical switch {} is created on {} with VNI {}", logicalSwitchName,
+ l2GatewayDevice.getHwvtepNodeId(), segmentationId);
NodeId hwvtepNodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
- InstanceIdentifier<LogicalSwitches> path = HwvtepSouthboundUtils
- .createLogicalSwitchesInstanceIdentifier(hwvtepNodeId, new HwvtepNodeName(logicalSwitchName));
+ String dbVersion = HwvtepUtils.getDbVersion(broker,hwvtepNodeId);
+ if (SouthboundUtils.compareDbVersionToMinVersion(dbVersion, "1.6.0")) {
+ replicationMode = "source_node";
+ }
+
+ LOG.trace("logical switch {} has schema version {}, replication mode set to {}", logicalSwitchName,
+ dbVersion, replicationMode);
+
LogicalSwitches logicalSwitch = HwvtepSouthboundUtils.createLogicalSwitch(logicalSwitchName,
- elanInstance.getDescription(), segmentationId);
+ elanInstance.getDescription(), segmentationId, replicationMode);
ListenableFuture<Void> lsCreateFuture = HwvtepUtils.addLogicalSwitch(broker, hwvtepNodeId, logicalSwitch);
Futures.addCallback(lsCreateFuture, new FutureCallback<Void>() {
// Listener will be closed after all configuration completed
// on hwvtep by
// listener itself
- if (LOG.isTraceEnabled()) {
- LOG.trace("Successful in initiating logical switch {} creation", logicalSwitchName);
- }
+ LOG.trace("Successful in initiating logical switch {} creation", logicalSwitchName);
}
@Override