use of org.opendaylight.netvirt.elan.l2gw.jobs.AssociateHwvtepToElanJob in project netvirt by opendaylight.
the class L2GatewayConnectionUtils method associateHwvtepsToElan.
private void associateHwvtepsToElan(ElanInstance elanInstance, L2gateway l2Gateway, L2gatewayConnection input, String l2GwDeviceName) {
String elanName = elanInstance.getElanInstanceName();
Integer defaultVlan = input.getSegmentId();
Uuid l2GwConnId = input.getKey().getUuid();
List<Devices> l2Devices = l2Gateway.getDevices();
LOG.trace("Associating ELAN {} with L2Gw Conn Id {} having below L2Gw devices {}", elanName, l2GwConnId, l2Devices);
for (Devices l2Device : l2Devices) {
String l2DeviceName = l2Device.getDeviceName();
// preprovisioning/re-provisioning
if (l2GwDeviceName != null && !l2GwDeviceName.equals(l2DeviceName)) {
LOG.debug("Associating Hwvtep to ELAN is not been processed for {}; as only {} got connected now!", l2DeviceName, l2GwDeviceName);
continue;
}
L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(l2DeviceName);
if (isL2GwDeviceConnected(l2GatewayDevice)) {
NodeId hwvtepNodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
// Delete pending delete logical switch task if scheduled
elanL2GatewayUtils.cancelDeleteLogicalSwitch(hwvtepNodeId, ElanL2GatewayUtils.getLogicalSwitchFromElan(elanName));
// Add L2 Gateway device to 'ElanL2GwDevice' cache
boolean createLogicalSwitch;
LogicalSwitches logicalSwitch = HwvtepUtils.getLogicalSwitch(broker, LogicalDatastoreType.CONFIGURATION, hwvtepNodeId, elanName);
if (logicalSwitch == null) {
HwvtepLogicalSwitchListener hwVTEPLogicalSwitchListener = new HwvtepLogicalSwitchListener(elanInstanceCache, elanL2GatewayUtils, elanClusterUtils, elanL2GatewayMulticastUtils, this, l2GatewayDevice, elanName, l2Device, defaultVlan, l2GwConnId);
hwVTEPLogicalSwitchListener.registerListener(LogicalDatastoreType.OPERATIONAL, broker);
closeables.add(hwVTEPLogicalSwitchListener);
createLogicalSwitch = true;
} else {
addL2DeviceToElanL2GwCache(elanName, l2GatewayDevice, l2GwConnId, l2Device);
createLogicalSwitch = false;
}
AssociateHwvtepToElanJob associateHwvtepToElanJob = new AssociateHwvtepToElanJob(broker, elanL2GatewayUtils, elanL2GatewayMulticastUtils, elanInstanceCache, l2GatewayDevice, elanInstance, l2Device, defaultVlan, createLogicalSwitch);
elanClusterUtils.runOnlyInOwnerNode(associateHwvtepToElanJob.getJobKey(), "create logical switch in hwvtep topo", associateHwvtepToElanJob);
} else {
LOG.info("L2GwConn create is not handled for device with id {} as it's not connected", l2DeviceName);
}
}
}
Aggregations