use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.
the class DhcpNeutronPortListener method processArpResponderForElanDpns.
/**
* Handle(Add/Remove) ARP Responder for DHCP IP on all the DPNs when DHCP is
* enabled/disabled on subnet add or update or delete.
*
* @param port
* DHCP port for which ARP Responder flow to be added when dhcp
* flag is enabled on the subnet or DHCP port for which ARP
* Responder flow to be removed when dhcp flag is disabled on the
* Subnet
* @param arpResponderAction
* ARP Responder Action to be performed i.e., add or remove flow
*/
private void processArpResponderForElanDpns(Port port, Consumer<ArpResponderInput> arpResponderAction) {
java.util.Optional<String> ip4Address = DhcpServiceUtils.getIpV4Address(port);
if (!ip4Address.isPresent()) {
LOG.warn("There is no IPv4Address for port {}, not performing ARP responder add/remove flow operation", port.getName());
return;
}
ElanHelper.getDpnInterfacesInElanInstance(broker, port.getNetworkId().getValue()).stream().map(ifName -> DhcpServiceUtils.getInterfaceInfo(interfaceManager, ifName)).forEach(interfaceInfo -> {
ArpResponderInput arpResponderInput = new ArpResponderInput.ArpReponderInputBuilder().setDpId(interfaceInfo.getDpId().toJava()).setInterfaceName(interfaceInfo.getInterfaceName()).setLportTag(interfaceInfo.getInterfaceTag()).setSha(port.getMacAddress().getValue()).setSpa(ip4Address.get()).build();
arpResponderAction.accept(arpResponderInput);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.
the class DhcpNeutronPortListener method update.
@Override
public void update(InstanceIdentifier<Port> identifier, Port original, Port update) {
if (!config.isControllerDhcpEnabled()) {
return;
}
LOG.trace("Port changed to {}", update);
// With Ipv6 changes we can get ipv4 subnets later. The below check is to support such scenario.
if (original.nonnullFixedIps().size() < update.nonnullFixedIps().size()) {
final String interfaceName = update.getUuid().getValue();
List<FixedIps> updatedFixedIps = new ArrayList<>(update.nonnullFixedIps().values());
// Need to check only the newly added fixed ip.
updatedFixedIps.removeAll(original.nonnullFixedIps().values());
Subnet subnet = dhcpManager.getNeutronSubnet(updatedFixedIps);
if (null == subnet || !subnet.isEnableDhcp()) {
LOG.trace("Subnet is null/not ipv4 or not enabled {}", subnet);
return;
}
// Binding the DHCP service for an existing port because of subnet change.
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
LOG.debug("Binding DHCP service for interface {}", interfaceName);
DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx);
})), DhcpMConstants.RETRY_COUNT);
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), () -> {
Uint64 dpnId = interfaceManager.getDpnForInterface(interfaceName);
if (dpnId == null || dpnId.equals(DhcpMConstants.INVALID_DPID)) {
LOG.trace("Unable to install the DHCP flow since dpn is not available");
return Collections.emptyList();
}
String vmMacAddress = txRunner.applyWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> DhcpServiceUtils.getAndUpdateVmMacAddress(tx, interfaceName, dhcpManager)).get();
return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> dhcpManager.installDhcpEntries(dpnId, vmMacAddress, tx)));
}, DhcpMConstants.RETRY_COUNT);
}
if (!isVnicTypeDirectOrMacVtap(update)) {
LOG.trace("Port updated is normal {}", update.getUuid());
if (isVnicTypeDirectOrMacVtap(original)) {
LOG.trace("Original Port was direct/macvtap {} so removing flows and cache entry if any", update.getUuid());
removePort(original);
}
return;
}
if (!isVnicTypeDirectOrMacVtap(original)) {
LOG.trace("Original port was normal and updated is direct. Calling addPort()");
addPort(update);
return;
}
String macOriginal = getMacAddress(original);
String macUpdated = getMacAddress(update);
String segmentationIdOriginal = DhcpServiceUtils.getSegmentationId(original.getNetworkId(), broker);
String segmentationIdUpdated = DhcpServiceUtils.getSegmentationId(update.getNetworkId(), broker);
if (macOriginal != null && !macOriginal.equalsIgnoreCase(macUpdated) && segmentationIdOriginal != null && !segmentationIdOriginal.equalsIgnoreCase(segmentationIdUpdated)) {
LOG.trace("Mac/segment id has changed");
dhcpExternalTunnelManager.removeVniMacToPortCache(Uint64.valueOf(segmentationIdOriginal), macOriginal);
dhcpExternalTunnelManager.updateVniMacToPortCache(Uint64.valueOf(segmentationIdUpdated), macUpdated, update);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.
the class ElanGroupListener method update.
@Override
public void update(InstanceIdentifier<Group> identifier, @Nullable Group original, Group update) {
LOG.trace("received group updated {}", update.key().getGroupId());
final Uint64 dpnId = getDpnId(identifier.firstKeyOf(Node.class).getId().getValue());
if (dpnId == null) {
return;
}
List<L2GatewayDevice> allDevices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
if (allDevices.isEmpty()) {
LOG.trace("no elan devices present in cache {}", update.key().getGroupId());
return;
}
int expectedElanFootprint = 0;
final ElanInstance elanInstance = getElanInstanceFromGroupId(update);
if (elanInstance == null) {
LOG.trace("no elan instance is null {}", update.key().getGroupId());
return;
}
final int devicesSize = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanInstance.getElanInstanceName()).size();
if (devicesSize == 0) {
LOG.trace("no elan devices in elan cache {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
return;
}
boolean updateGroup = false;
List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
if (dpns.size() > 0) {
expectedElanFootprint += dpns.size();
} else {
updateGroup = true;
}
expectedElanFootprint += devicesSize;
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.key().getGroupId());
}
}
if (updateGroup) {
List<Bucket> bucketList = elanL2GatewayMulticastUtils.getRemoteBCGroupBuckets(elanInstance, null, dpnId, 0, elanInstance.getElanTag().toJava());
// 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.key().getGroupId());
elanClusterUtils.runOnlyInOwnerNode(elanInstance.getElanInstanceName(), "updating broadcast group", () -> {
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInstance, dpnId, confTx)), LOG, "Error setting up ELAN BGs");
return null;
});
} else {
LOG.trace("no buckets in the update {} {}", elanInstance.getElanInstanceName(), update.key().getGroupId());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.
the class ElanL2GatewayMulticastUtils method putRemoteMcastMac.
/**
* Put remote mcast mac in config DS.
*
* @param nodeId
* the node id
* @param logicalSwitchName
* the logical switch name
* @param tepIps
* the tep ips
*/
private ListenableFuture<Void> putRemoteMcastMac(NodeId nodeId, String logicalSwitchName, ArrayList<IpAddress> tepIps, boolean addCase) {
List<LocatorSet> locators = new ArrayList<>();
for (IpAddress tepIp : tepIps) {
locators.add(buildLocatorSet(nodeId, tepIp));
}
HwvtepLogicalSwitchRef lsRef = new HwvtepLogicalSwitchRef(HwvtepSouthboundUtils.createLogicalSwitchesInstanceIdentifier(nodeId, new HwvtepNodeName(logicalSwitchName)));
RemoteMcastMacs newMac = new RemoteMcastMacsBuilder().setMacEntryKey(new MacAddress(ElanConstants.UNKNOWN_DMAC)).setLogicalSwitchRef(lsRef).setLocatorSet(locators).build();
InstanceIdentifier<RemoteMcastMacs> iid = HwvtepSouthboundUtils.createRemoteMcastMacsInstanceIdentifier(nodeId, newMac.key());
RemoteMcastMacs existingMac = configMcastCache.getMac(newMac.getLogicalSwitchRef().getValue());
if (!addCase) {
// proactively update the cache for delete cases do not wait for batch manager to delete from cache
// while the delete is in progress from the batch manager the below skip may trigger
// by updating the cache upfront the skip wont be triggered
configMcastCache.added(iid, newMac);
}
if (addCase && existingMac != null && existingMac.getLocatorSet() != null) {
Set existingLocators = new HashSet<>(existingMac.getLocatorSet());
List newLocators = newMac.getLocatorSet();
if (existingLocators.containsAll(newLocators)) {
return Futures.immediateFuture(null);
}
}
return ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, iid, newMac);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method handleAdd.
/**
* Handle add.
*
* @param l2GwDevice
* the l2 gw device
*/
private void handleAdd(L2GatewayDevice l2GwDevice, InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchAdded) {
LOG.info("PhysicalSwitchListener Handle add of tunnel ips {} psNode {} device {}", phySwitchAdded.getTunnelIps(), identifier.firstKeyOf(Node.class).getNodeId(), l2GwDevice);
final String psName = l2GwDevice.getDeviceName();
final String hwvtepNodeId = l2GwDevice.getHwvtepNodeId();
Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
if (tunnelIps != null) {
// TODO add logical switch and mcast put itm tep event and update mcast
hwvtepHACache.addDebugEvent(new MdsalEvent("ps add provision", l2GwDevice.getHwvtepNodeId()));
for (final IpAddress tunnelIpAddr : tunnelIps) {
if (L2GatewayConnectionUtils.isGatewayAssociatedToL2Device(l2GwDevice)) {
LOG.info("PhysicalSwitchListener 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 : {}", hwvtepNodeId, psName);
}
}
InstanceIdentifier<Node> globalNodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(hwvtepNodeId));
HwvtepHACache.getInstance().setTepIpOfNode(globalNodeIid, tunnelIps.iterator().next());
elanClusterUtils.runOnlyInOwnerNode(psName, "Stale entry cleanup", () -> {
InstanceIdentifier<Node> psIid = HwvtepSouthboundUtils.createInstanceIdentifier(HwvtepSouthboundUtils.createManagedNodeId(new NodeId(hwvtepNodeId), psName));
staleVlanBindingsCleaner.scheduleStaleCleanup(psName, globalNodeIid, psIid);
transportZoneListener.createL2gwZeroDayConfig();
return Collections.emptyList();
});
}
}
Aggregations