use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.
the class L2GatewayConnectionUtils method addL2GatewayConnection.
public void addL2GatewayConnection(final L2gatewayConnection input, final String l2GwDeviceName, L2gateway l2Gateway) {
LOG.info("Adding L2gateway Connection with ID: {}", input.getKey().getUuid());
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)).orNull();
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.getValue());
} else {
associateHwvtepsToElan(elanInstance, l2Gateway, input, l2GwDeviceName);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method removed.
@Override
protected void removed(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchDeleted) {
NodeId nodeId = getNodeId(identifier);
String psName = phySwitchDeleted.getHwvtepNodeName().getValue();
LOG.info("Received physical switch {} removed event for node {}", psName, nodeId.getValue());
L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
if (l2GwDevice != null) {
if (!L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
l2GatewayCache.remove(psName);
LOG.debug("{} details removed from L2Gateway Cache", psName);
MDSALUtil.syncDelete(this.dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
} else {
LOG.debug("{} details are not removed from L2Gateway Cache as it has L2Gateway reference", psName);
}
l2GwDevice.setConnected(false);
// ElanL2GwCacheUtils.removeL2GatewayDeviceFromAllElanCache(psName);
} else {
LOG.error("Unable to find L2 Gateway details for {}", psName);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method handleAdd.
/**
* Handle add.
*
* @param l2GwDevice
* the l2 gw device
*/
private void handleAdd(L2GatewayDevice l2GwDevice) {
final String psName = l2GwDevice.getDeviceName();
final String hwvtepNodeId = l2GwDevice.getHwvtepNodeId();
Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
for (final IpAddress tunnelIpAddr : tunnelIps) {
if (L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
LOG.debug("L2Gateway {} associated for {} physical switch; creating ITM tunnels for {}", l2GwDevice.getL2GatewayIds(), psName, tunnelIpAddr);
l2gwServiceProvider.provisionItmAndL2gwConnection(l2GwDevice, psName, hwvtepNodeId, tunnelIpAddr);
} else {
LOG.info("l2gw.provision.skip {}:{}", hwvtepNodeId, psName);
}
}
elanClusterUtils.runOnlyInOwnerNode("Stale entry cleanup", () -> {
InstanceIdentifier<Node> globalNodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(hwvtepNodeId));
InstanceIdentifier<Node> psIid = HwvtepSouthboundUtils.createInstanceIdentifier(HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepNodeId), psName));
staleVlanBindingsCleaner.scheduleStaleCleanup(psName, globalNodeIid, psIid);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.
the class L2GatewayListener method removeL2Device.
private void removeL2Device(Devices l2Device, L2gateway input) {
final String l2DeviceName = l2Device.getDeviceName();
L2GatewayDevice l2GwDevice = l2GatewayCache.get(l2DeviceName);
if (l2GwDevice != null) {
// Also, do not delete device from cache if it's connected
if (L2GatewayUtils.isLastL2GatewayBeingDeleted(l2GwDevice)) {
if (l2GwDevice.isConnected()) {
l2GwDevice.removeL2GatewayId(input.getUuid());
// Delete ITM tunnels
final String hwvtepId = l2GwDevice.getHwvtepNodeId();
final Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
jobCoordinator.enqueueJob(hwvtepId, () -> {
if (entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
LOG.info("Deleting ITM Tunnels for {} connected to cluster node owner", l2DeviceName);
for (IpAddress tunnelIp : tunnelIps) {
L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId, l2DeviceName, tunnelIp);
}
} else {
LOG.info("ITM Tunnels are not deleted on the cluster node as this is not owner for {}", l2DeviceName);
}
return null;
});
} else {
l2GatewayCache.remove(l2DeviceName);
// Cleaning up the config DS
NodeId nodeId = new NodeId(l2GwDevice.getHwvtepNodeId());
NodeId psNodeId = HwvtepSouthboundUtils.createManagedNodeId(nodeId, l2DeviceName);
// FIXME: These should be removed
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(nodeId));
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, HwvtepSouthboundUtils.createInstanceIdentifier(psNodeId));
}
} else {
l2GwDevice.removeL2GatewayId(input.getUuid());
LOG.trace("ITM tunnels are not deleted for {} as this device has other L2gateway associations", l2DeviceName);
}
} else {
LOG.error("Unable to find L2 Gateway details for {}", l2DeviceName);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway in project netvirt by opendaylight.
the class L2GatewayListener method add.
@Override
protected void add(final InstanceIdentifier<L2gateway> identifier, final L2gateway input) {
LOG.info("Adding L2gateway with ID: {}", input.getUuid());
List<Devices> l2Devices = input.getDevices();
for (Devices l2Device : l2Devices) {
LOG.trace("Adding L2gateway device: {}", l2Device);
addL2Device(l2Device, input);
}
}
Aggregations