use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches in project netvirt by opendaylight.
the class AssociateHwvtepToElanJob method createLogicalSwitch.
private ListenableFuture<Void> createLogicalSwitch() {
final String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(elanInstance.getElanInstanceName());
String segmentationId = ElanUtils.getVxlanSegmentationId(elanInstance).toString();
String replicationMode = "";
LOG.trace("logical switch {} is created on {} with VNI {}", logicalSwitchName, l2GatewayDevice.getHwvtepNodeId(), segmentationId);
NodeId hwvtepNodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
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, replicationMode);
ListenableFuture<Void> lsCreateFuture = HwvtepUtils.addLogicalSwitch(broker, hwvtepNodeId, logicalSwitch);
Futures.addCallback(lsCreateFuture, new FutureCallback<Void>() {
@Override
public void onSuccess(Void noarg) {
// Listener will be closed after all configuration completed
// on hwvtep by
// listener itself
LOG.trace("Successful in initiating logical switch {} creation", logicalSwitchName);
}
@Override
public void onFailure(Throwable error) {
LOG.error("Failed logical switch {} creation", logicalSwitchName, error);
}
}, MoreExecutors.directExecutor());
return lsCreateFuture;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches in project netvirt by opendaylight.
the class DeleteLogicalSwitchJob method call.
@Override
public List<ListenableFuture<Void>> call() {
if (cancelled) {
LOG.info("Delete logical switch job cancelled ");
return Collections.emptyList();
}
LOG.debug("running logical switch deleted job for {} in {}", logicalSwitchName, hwvtepNodeId);
elanL2GatewayUtils.deleteElanMacsFromL2GatewayDevice(hwvtepNodeId.getValue(), logicalSwitchName);
InstanceIdentifier<LogicalSwitches> logicalSwitch = HwvtepSouthboundUtils.createLogicalSwitchesInstanceIdentifier(hwvtepNodeId, new HwvtepNodeName(logicalSwitchName));
RemoteMcastMacsKey remoteMcastMacsKey = new RemoteMcastMacsKey(new HwvtepLogicalSwitchRef(logicalSwitch), new MacAddress(ElanConstants.UNKNOWN_DMAC));
HwvtepUtils.deleteRemoteMcastMac(broker, hwvtepNodeId, remoteMcastMacsKey);
L2GatewayDevice l2GatewayDevice = new L2GatewayDevice("");
l2GatewayDevice.setHwvtepNodeId(hwvtepNodeId.getValue());
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(HwvtepUtils.deleteLogicalSwitch(broker, hwvtepNodeId, logicalSwitchName));
if (clearUcast) {
LOG.trace("Clearing the local ucast macs of device {} macs ", hwvtepNodeId.getValue());
elanL2GatewayUtils.deleteL2GwDeviceUcastLocalMacsFromElan(l2GatewayDevice, logicalSwitchName);
}
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches in project netvirt by opendaylight.
the class TestComparators method compareLogicalSwitches.
public static void compareLogicalSwitches(Node d1, Node d2, Node ha, InstanceIdentifier<Node> nodePath) {
LogicalSwitchesCmd cmd = new LogicalSwitchesCmd();
HwvtepGlobalAugmentation d1Aug = d1.getAugmentation(HwvtepGlobalAugmentation.class);
HwvtepGlobalAugmentation d2Aug = d2.getAugmentation(HwvtepGlobalAugmentation.class);
HwvtepGlobalAugmentation haAug = ha.getAugmentation(HwvtepGlobalAugmentation.class);
List<LogicalSwitches> d1Values = d1Aug.getLogicalSwitches() != null ? d1Aug.getLogicalSwitches() : new ArrayList<>();
List<LogicalSwitches> result1 = cmd.transform(nodePath, d1Values);
List<LogicalSwitches> d2Values = d2Aug.getLogicalSwitches() != null ? d2Aug.getLogicalSwitches() : new ArrayList<>();
List<LogicalSwitches> result2 = cmd.transform(nodePath, d2Values);
// Merge data of both d1 and d2 logical switch info should be same as ha
Set<LogicalSwitches> set1 = new HashSet<>();
set1.addAll(result1);
set1.addAll(result2);
List<LogicalSwitches> result = cmd.transform(nodePath, haAug.getLogicalSwitches());
Set<LogicalSwitches> set2 = Sets.newHashSet(result);
assertEquals("should have equal logical switches", 0, Sets.symmetricDifference(set1, set2).size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches in project genius by opendaylight.
the class HwvtepSouthboundUtils method createLogicalSwitch.
/**
* Create logical switch.
*
* @param name
* the name
* @param desc
* the desc
* @param tunnelKey
* the tunnel key
* @return the logical switches
*/
public static LogicalSwitches createLogicalSwitch(String name, String desc, String tunnelKey, String replicationMode) {
HwvtepNodeName hwvtepName = new HwvtepNodeName(name);
LogicalSwitchesBuilder lsBuilder = new LogicalSwitchesBuilder().setHwvtepNodeDescription(desc).setHwvtepNodeName(hwvtepName).setKey(new LogicalSwitchesKey(hwvtepName)).setTunnelKey(tunnelKey);
if (replicationMode != null && !replicationMode.isEmpty()) {
lsBuilder.setReplicationMode(replicationMode);
}
return lsBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.LogicalSwitches in project genius by opendaylight.
the class HwvtepSouthboundUtils method createVlanBinding.
/**
* Create vlan binding.
*
* @param nodeId
* the node id
* @param vlanId
* the vlan id
* @param logicalSwitchName
* the logical switch name
* @return the vlan bindings
*/
public static VlanBindings createVlanBinding(NodeId nodeId, int vlanId, String logicalSwitchName) {
VlanBindingsBuilder vbBuilder = new VlanBindingsBuilder();
VlanBindingsKey vbKey = new VlanBindingsKey(new VlanId(vlanId));
vbBuilder.setKey(vbKey);
vbBuilder.setVlanIdKey(vbKey.getVlanIdKey());
final InstanceIdentifier<LogicalSwitches> lSwitchIid = createLogicalSwitchesInstanceIdentifier(nodeId, new HwvtepNodeName(logicalSwitchName));
HwvtepLogicalSwitchRef lsRef = new HwvtepLogicalSwitchRef(lSwitchIid);
vbBuilder.setLogicalSwitchRef(lsRef);
return vbBuilder.build();
}
Aggregations