use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.
the class L2GwValidateCli method verifyL2GatewayConnections.
private void verifyL2GatewayConnections() {
boolean isValid = true;
for (L2gatewayConnection l2gatewayConnection : l2gatewayConnections) {
L2gateway l2gateway = uuidToL2Gateway.get(l2gatewayConnection.getL2gatewayId());
String logicalSwitchName = l2gatewayConnection.getNetworkId().getValue();
List<Devices> devices = l2gateway.getDevices();
for (Devices device : devices) {
L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(device.getDeviceName());
isValid = verifyL2GatewayDevice(l2gateway, device, l2GatewayDevice);
if (!isValid) {
continue;
}
NodeId nodeId = new NodeId(l2GatewayDevice.getHwvtepNodeId());
InstanceIdentifier<Node> nodeIid = topoIid.child(Node.class, new NodeKey(nodeId));
isValid = verfiyLogicalSwitch(logicalSwitchName, nodeIid);
if (isValid) {
isValid = verifyMcastMac(logicalSwitchName, nodeIid);
verifyVlanBindings(nodeIid, logicalSwitchName, device, l2gatewayConnection.getSegmentId());
L2GatewayDevice elanL2gatewayDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(logicalSwitchName, nodeId.getValue());
if (elanL2gatewayDevice == null) {
pw.println("Failed elan l2gateway device not found for network " + logicalSwitchName + " and device " + device.getDeviceName() + " " + l2GatewayDevice.getHwvtepNodeId() + " l2gw connection id " + l2gatewayConnection.getUuid());
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.
the class ElanGroupListener method update.
@Override
protected void update(InstanceIdentifier<Group> identifier, Group original, Group update) {
LOG.trace("received group updated {}", update.getKey().getGroupId());
final BigInteger dpnId = getDpnId(identifier.firstKeyOf(Node.class).getId().getValue());
if (dpnId == null) {
return;
}
List<L2GatewayDevice> allDevices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
if (allDevices == null || allDevices.isEmpty()) {
LOG.trace("no elan devices present in cache {}", update.getKey().getGroupId());
return;
}
int expectedElanFootprint = 0;
final ElanInstance elanInstance = getElanInstanceFromGroupId(update);
if (elanInstance == null) {
LOG.trace("no elan instance is null {}", update.getKey().getGroupId());
return;
}
ConcurrentMap<String, L2GatewayDevice> devices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanInstance.getElanInstanceName());
if (devices == null || devices.isEmpty()) {
LOG.trace("no elan devices in elan cache {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
return;
}
boolean updateGroup = false;
List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
if (dpns.size() > 0) {
expectedElanFootprint += dpns.size();
} else {
updateGroup = true;
}
expectedElanFootprint += devices.size();
if (update.getBuckets() != null && update.getBuckets().getBucket() != null) {
if (update.getBuckets().getBucket().size() != expectedElanFootprint) {
updateGroup = true;
} else {
LOG.trace("no of buckets matched perfectly {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
}
}
if (updateGroup) {
List<Bucket> bucketList = elanL2GatewayMulticastUtils.getRemoteBCGroupBuckets(elanInstance, null, dpnId, 0, elanInstance.getElanTag());
// remove local bcgroup bucket
expectedElanFootprint--;
if (bucketList.size() != expectedElanFootprint) {
// no point in retrying if not able to meet expected foot print
return;
}
LOG.trace("no of buckets mismatched {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
elanClusterUtils.runOnlyInOwnerNode(elanInstance.getElanInstanceName(), "updating broadcast group", () -> {
elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInstance, dpnId);
return null;
});
} else {
LOG.trace("no buckets in the update {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.
the class HwvtepTerminationPointListener method getVlanBindings.
private List<VlanBindings> getVlanBindings(List<L2gatewayConnection> l2GwConns, NodeId hwvtepNodeId, String psName, String newPortId) {
List<VlanBindings> vlanBindings = new ArrayList<>();
for (L2gatewayConnection l2GwConn : l2GwConns) {
L2gateway l2Gateway = L2GatewayConnectionUtils.getNeutronL2gateway(broker, l2GwConn.getL2gatewayId());
if (l2Gateway == null) {
LOG.error("L2Gateway with id {} is not present", l2GwConn.getL2gatewayId().getValue());
} else {
String logicalSwitchName = ElanL2GatewayUtils.getLogicalSwitchFromElan(l2GwConn.getNetworkId().getValue());
List<Devices> l2Devices = l2Gateway.getDevices();
for (Devices l2Device : l2Devices) {
String l2DeviceName = l2Device.getDeviceName();
if (l2DeviceName != null && l2DeviceName.equals(psName)) {
for (Interfaces deviceInterface : l2Device.getInterfaces()) {
if (deviceInterface.getInterfaceName().equals(newPortId)) {
if (deviceInterface.getSegmentationIds() != null && !deviceInterface.getSegmentationIds().isEmpty()) {
for (Integer vlanId : deviceInterface.getSegmentationIds()) {
vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(hwvtepNodeId, vlanId, logicalSwitchName));
}
} else {
// Use defaultVlanId (specified in L2GatewayConnection) if Vlan
// ID not specified at interface level.
Integer segmentationId = l2GwConn.getSegmentId();
int defaultVlanId = segmentationId != null ? segmentationId : 0;
vlanBindings.add(HwvtepSouthboundUtils.createVlanBinding(hwvtepNodeId, defaultVlanId, logicalSwitchName));
}
}
}
}
}
}
}
return vlanBindings;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.
the class ElanDpnInterfaceClusteredListener method add.
@Override
protected void add(InstanceIdentifier<DpnInterfaces> identifier, final DpnInterfaces dpnInterfaces) {
final String elanName = getElanName(identifier);
jobCoordinator.enqueueJob(elanName + ":l2gw", () -> {
elanInstanceDpnsCache.add(getElanName(identifier), dpnInterfaces);
if (entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
if (elanInstance != null) {
elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpnInterfaces.getDpId(), elanInstance, dpnInterfaces.getInterfaces().get(0));
// updating remote mcast mac on l2gw devices
elanL2GatewayMulticastUtils.updateRemoteMcastMacOnElanL2GwDevices(elanName);
}
}
return null;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices in project netvirt by opendaylight.
the class ElanL2GatewayMulticastUtils method updateMcastMacsForAllElanDevices.
/**
* Update mcast macs for this elan.
* for all dpns in this elan recompute and update broadcast group
* for all l2gw devices in this elan recompute and update remote mcast mac entry
*
* @param elanName
* the elan name
* @param device
* the device
* @param updateThisDevice
* the update this device
* @return the listenable future
*/
private ListenableFuture<Void> updateMcastMacsForAllElanDevices(String elanName, L2GatewayDevice device, boolean updateThisDevice) {
SettableFuture<Void> ft = SettableFuture.create();
ft.set(null);
List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanName);
ConcurrentMap<String, L2GatewayDevice> devices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanName);
List<IpAddress> dpnsTepIps = getAllTepIpsOfDpns(device, dpns);
List<IpAddress> l2GwDevicesTepIps = getAllTepIpsOfL2GwDevices(devices);
return txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
if (updateThisDevice) {
preapareRemoteMcastMacEntry(elanName, device, dpnsTepIps, l2GwDevicesTepIps);
}
// present to configure RemoteMcastMac entry
for (L2GatewayDevice otherDevice : devices.values()) {
if (!otherDevice.getDeviceName().equals(device.getDeviceName())) {
preapareRemoteMcastMacEntry(elanName, otherDevice, dpnsTepIps, l2GwDevicesTepIps);
}
}
});
}
Aggregations