use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project netvirt by opendaylight.
the class ElanL2GatewayUtils method installElanMacsInL2GatewayDevice.
/**
* Install ELAN macs in L2 Gateway device.<br>
* This includes installing ELAN mac table entries plus external device
* UcastLocalMacs which are part of the same ELAN.
*
* @param elanName
* the elan name
* @param l2GatewayDevice
* the l2 gateway device which has to be configured
* @return the listenable future
*/
public FluentFuture<? extends CommitInfo> installElanMacsInL2GatewayDevice(String elanName, L2GatewayDevice l2GatewayDevice) {
String logicalSwitchName = getLogicalSwitchFromElan(elanName);
NodeId hwVtepNodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
List<RemoteUcastMacs> lstL2GatewayDevicesMacs = getOtherDevicesMacs(elanName, l2GatewayDevice, hwVtepNodeId, logicalSwitchName);
List<RemoteUcastMacs> lstElanMacTableEntries = getElanMacTableEntriesMacs(elanName, hwVtepNodeId, logicalSwitchName);
List<RemoteUcastMacs> lstRemoteUcastMacs = new ArrayList<>(lstL2GatewayDevicesMacs);
lstRemoteUcastMacs.addAll(lstElanMacTableEntries);
FluentFuture<? extends CommitInfo> future = HwvtepUtils.addRemoteUcastMacs(broker, hwVtepNodeId, lstRemoteUcastMacs);
LOG.info("Added RemoteUcastMacs entries [{}] in config DS. NodeID: {}, LogicalSwitch: {}", lstRemoteUcastMacs.size(), hwVtepNodeId.getValue(), logicalSwitchName);
return future;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project netvirt by opendaylight.
the class ElanL2GatewayUtils method deleteL2GwDeviceUcastLocalMacsFromElan.
/**
* Delete l2 gateway device ucast local macs from elan.<br>
* Deletes macs from internal ELAN nodes and also on rest of external l2
* gateway devices which are part of the ELAN.
*
* @param l2GatewayDevice
* the l2 gateway device whose ucast local macs to be deleted
* from elan
* @param elanName
* the elan name
*/
public void deleteL2GwDeviceUcastLocalMacsFromElan(L2GatewayDevice l2GatewayDevice, String elanName) {
LOG.info("Deleting L2GatewayDevice [{}] UcastLocalMacs from elan [{}]", l2GatewayDevice.getHwvtepNodeId(), elanName);
ElanInstance elan = elanInstanceCache.get(elanName).orElse(null);
if (elan == null) {
LOG.error("Could not find Elan by name: {}", elanName);
return;
}
Collection<MacAddress> localMacs = getL2GwDeviceLocalMacs(elanName, l2GatewayDevice);
unInstallL2GwUcastMacFromL2gwDevices(elanName, l2GatewayDevice, localMacs);
unInstallL2GwUcastMacFromElanDpns(elan, l2GatewayDevice, localMacs);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project netvirt by opendaylight.
the class L2GatewayConnectionUtils method disAssociateHwvtepsFromElan.
private void disAssociateHwvtepsFromElan(String elanName, L2gatewayConnection input) {
Integer defaultVlan = input.getSegmentId();
List<L2GatewayDevice> l2Devices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
List<Devices> l2gwDevicesToBeDeleted = new ArrayList<>();
for (L2GatewayDevice elanL2gwDevice : l2Devices) {
if (elanL2gwDevice.getL2GatewayIds().contains(input.key().getUuid())) {
l2gwDevicesToBeDeleted.addAll(elanL2gwDevice.getDevicesForL2gwConnectionId(input.key().getUuid()));
}
}
if (l2gwDevicesToBeDeleted.isEmpty()) {
// delete logical switch
Uuid l2GatewayId = input.getL2gatewayId();
L2gateway l2Gateway = L2GatewayConnectionUtils.getNeutronL2gateway(broker, l2GatewayId);
if (l2Gateway == null) {
LOG.error("Failed to find the l2gateway for the connection {}", input.getUuid());
return;
} else if (l2Gateway.nonnullDevices() != null) {
l2gwDevicesToBeDeleted.addAll(l2Gateway.nonnullDevices().values());
}
}
for (Devices l2Device : l2gwDevicesToBeDeleted) {
String l2DeviceName = l2Device.getDeviceName();
L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(l2DeviceName);
String hwvtepNodeId = l2GatewayDevice.getHwvtepNodeId();
if (hwvtepNodeId == null) {
LOG.error("Could not disassociate failed to get node id {}", l2DeviceName);
continue;
}
boolean isLastL2GwConnDeleted = false;
L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
if (elanL2GwDevice != null && isLastL2GwConnBeingDeleted(elanL2GwDevice)) {
// Delete L2 Gateway device from 'ElanL2GwDevice' cache
LOG.debug("Elan L2Gw Conn cache removed for id {}", hwvtepNodeId);
ElanL2GwCacheUtils.removeL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
isLastL2GwConnDeleted = true;
} else {
Uuid l2GwConnId = input.key().getUuid();
LOG.debug("Elan L2Gw Conn cache with id {} is being referred by other L2Gw Conns; so only " + "L2 Gw Conn {} reference is removed", hwvtepNodeId, l2GwConnId);
if (elanL2GwDevice != null) {
elanL2GwDevice.removeL2GatewayId(l2GwConnId);
} else {
isLastL2GwConnDeleted = true;
}
}
DisAssociateHwvtepFromElanJob disAssociateHwvtepToElanJob = new DisAssociateHwvtepFromElanJob(elanL2GatewayUtils, elanL2GatewayMulticastUtils, elanL2GatewayBcGroupUtils, elanClusterUtils, scheduler, jobCoordinator, elanL2GwDevice, elanName, l2Device, defaultVlan, hwvtepNodeId, isLastL2GwConnDeleted);
elanClusterUtils.runOnlyInOwnerNode(disAssociateHwvtepToElanJob.getJobKey(), "remove l2gw connection job", disAssociateHwvtepToElanJob);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project netvirt by opendaylight.
the class L2GatewayConnectionUtils method addL2GatewayConnection.
public void addL2GatewayConnection(final L2gatewayConnection input, @Nullable final String l2GwDeviceName, @Nullable L2gateway l2Gateway) {
LOG.info("Adding L2gateway Connection:{} vlan: {} device name {}", input.key().getUuid(), input.getSegmentId(), l2GwDeviceName);
Uuid networkUuid = input.getNetworkId();
// Taking cluster reboot scenario , if Elan instance is not available when l2GatewayConnection add events
// comes we need to wait for elaninstance to resolve. Hence updating the map with the runnable .
// When elanInstance add comes , it look in to the map and run the associated runnable associated with it.
ElanInstance elanInstance = elanInstanceCache.get(networkUuid.getValue(), () -> addL2GatewayConnection(input, l2GwDeviceName)).orElse(null);
if (elanInstance == null) {
return;
}
if (!isVxlanNetworkOrVxlanSegment(elanInstance)) {
LOG.error("Neutron network with id {} is not VxlanNetwork", networkUuid.getValue());
} else {
Uuid l2GatewayId = input.getL2gatewayId();
if (l2Gateway == null) {
l2Gateway = getNeutronL2gateway(broker, l2GatewayId);
}
if (l2Gateway == null) {
LOG.error("L2Gateway with id {} is not present", l2GatewayId);
} else {
associateHwvtepsToElan(elanInstance, l2Gateway, input, l2GwDeviceName);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project netvirt by opendaylight.
the class ElanL2GatewayMulticastUtils method preapareRemoteMcastMacEntry.
/**
* Update remote mcast mac.
*
* @param elanName
* the elan name
* @param device
* the device
* @param dpnsTepIps
* the dpns tep ips
* @param l2GwDevicesTepIps
* the l2 gw devices tep ips
* @return the write transaction
*/
private ListenableFuture<Void> preapareRemoteMcastMacEntry(String elanName, L2GatewayDevice device, List<IpAddress> dpnsTepIps, List<IpAddress> l2GwDevicesTepIps, boolean addCase) {
ArrayList<IpAddress> remoteTepIps = new ArrayList<>(l2GwDevicesTepIps);
remoteTepIps.remove(device.getTunnelIp());
remoteTepIps.addAll(dpnsTepIps);
IpAddress dhcpDesignatedSwitchTepIp = getTepIpOfDesignatedSwitchForExternalTunnel(device, elanName);
if (dhcpDesignatedSwitchTepIp != null && !remoteTepIps.contains(dhcpDesignatedSwitchTepIp)) {
remoteTepIps.add(dhcpDesignatedSwitchTepIp);
}
return putRemoteMcastMac(new NodeId(device.getHwvtepNodeId()), elanName, remoteTepIps, addCase);
}
Aggregations