WIFI-1247 OSGW needs to keep in sync the radio types reported by AP with the provisioned AP radio configuration -- add some logging and some checks in places where OSGW assumed to have values in equipments RadioMaps by default

This commit is contained in:
Mike Hansen
2021-01-07 21:53:47 -05:00
parent ab0061b582
commit 2cbe0b8b34
5 changed files with 237 additions and 222 deletions

View File

@@ -4,6 +4,7 @@ import java.net.Inet4Address;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -315,7 +316,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (apElementConfig == null) { if (apElementConfig == null) {
apElementConfig = ApElementConfiguration.createWithDefaults(); apElementConfig = ApElementConfiguration.createWithDefaults();
ce.setDetails(apElementConfig); ce.setDetails(apElementConfig);
needToUpdateEquipment = true; ce = equipmentServiceInterface.update(ce);
apElementConfig = (ApElementConfiguration) ce.getDetails();
} }
if (apElementConfig.getDeviceName() == null if (apElementConfig.getDeviceName() == null
@@ -333,76 +335,60 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
Map<RadioType, RadioConfiguration> advancedRadioMap = apElementConfig.getAdvancedRadioMap(); Map<RadioType, RadioConfiguration> advancedRadioMap = apElementConfig.getAdvancedRadioMap();
Map<RadioType, ElementRadioConfiguration> radioMap = apElementConfig.getRadioMap(); Map<RadioType, ElementRadioConfiguration> radioMap = apElementConfig.getRadioMap();
if (advancedRadioMap == null) { if (apElementConfig.getAdvancedRadioMap() == null) {
advancedRadioMap = new HashMap<>(); advancedRadioMap = new EnumMap<>(RadioType.class);
apElementConfig.setAdvancedRadioMap(advancedRadioMap); apElementConfig.setAdvancedRadioMap(advancedRadioMap);
needToUpdateEquipment = true; needToUpdateEquipment = true;
} }
if (radioMap == null) { if (radioMap == null) {
radioMap = new HashMap<>(); radioMap = new EnumMap<>(RadioType.class);
apElementConfig.setRadioMap(radioMap); apElementConfig.setRadioMap(radioMap);
needToUpdateEquipment = true; needToUpdateEquipment = true;
} }
Set<RadioType> radiosFromAp = new HashSet<>(); Set<RadioType> radiosFromAp = new HashSet<>();
connectNodeInfo.wifiRadioStates.keySet().forEach(k -> {
radiosFromAp.add(OvsdbToWlanCloudTypeMappingUtility.getRadioTypeForOvsdbRadioFreqBand(k));
});
// add missing radio configs from the AP into the DB // add missing radio configs from the AP into the DB
for (String radio : connectNodeInfo.wifiRadioStates.keySet()) { for (RadioType radio : radiosFromAp) {
RadioType radioType = RadioType.UNSUPPORTED; if (!advancedRadioMap.containsKey(radio) || advancedRadioMap.get(radio) == null) {
if (radio.equals("2.4G")) { advancedRadioMap.put(radio, RadioConfiguration.createWithDefaults(radio));
radioType = RadioType.is2dot4GHz; needToUpdateEquipment = true;
} else if (radio.equals("5G")) {
radioType = RadioType.is5GHz;
} else if (radio.equals("5GL")) {
radioType = RadioType.is5GHzL;
} else if (radio.equals("5GU")) {
radioType = RadioType.is5GHzU;
} }
if (!radioMap.containsKey(radio) || radioMap.get(radio) == null) {
if (!radioType.equals(RadioType.UNSUPPORTED)) { radioMap.putIfAbsent(radio, ElementRadioConfiguration.createWithDefaults(radio));
needToUpdateEquipment = true;
radiosFromAp.add(radioType);
RadioConfiguration advancedRadioConfiguration = advancedRadioMap.get(radioType);
ElementRadioConfiguration radioConfiguration = radioMap.get(radioType);
if (advancedRadioConfiguration == null) {
advancedRadioConfiguration = RadioConfiguration.createWithDefaults(radioType);
advancedRadioMap.put(radioType, advancedRadioConfiguration);
needToUpdateEquipment = true;
}
if (radioConfiguration == null) {
radioConfiguration = ElementRadioConfiguration.createWithDefaults(radioType);
radioMap.put(radioType, radioConfiguration);
needToUpdateEquipment = true;
}
} }
} }
// remove radio configs from the DB that are no longer // remove radio configs from the DB that are no longer
// present in the AP but still exist in DB // present in the AP but still exist in DB
for (RadioType radioType : RadioType.validValues()) { for (RadioType radio : advancedRadioMap.keySet()) {
if (!radiosFromAp.contains(radio)) {
RadioConfiguration advancedRadioConfiguration = advancedRadioMap.get(radioType); advancedRadioMap.remove(radio);
if (advancedRadioConfiguration != null || !radiosFromAp.contains(radioType)) {
advancedRadioMap.remove(radioType);
needToUpdateEquipment = true; needToUpdateEquipment = true;
} }
}
ElementRadioConfiguration radioConfiguration = radioMap.get(radioType); for (RadioType radio : radioMap.keySet()) {
if (radioConfiguration != null || !radiosFromAp.contains(radioType)) { if (!radiosFromAp.contains(radio)) {
radioMap.remove(radioType); radioMap.remove(radio);
needToUpdateEquipment = true; needToUpdateEquipment = true;
} }
} }
if (needToUpdateEquipment) { if (needToUpdateEquipment) {
apElementConfig.setAdvancedRadioMap(advancedRadioMap);
apElementConfig.setRadioMap(radioMap);
ce.setDetails(apElementConfig);
ce = equipmentServiceInterface.update(ce); ce = equipmentServiceInterface.update(ce);
apElementConfig = (ApElementConfiguration) ce.getDetails();
LOG.info("Equipment {} values for RadioMap {} AdvancedRadioMap {}", ce.getName(),
apElementConfig.getRadioMap(), apElementConfig.getAdvancedRadioMap());
} }
} }
@@ -947,7 +933,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
throw new IllegalStateException("AP is not connected " + apId); throw new IllegalStateException("AP is not connected " + apId);
} }
int customerId = ovsdbSession.getCustomerId(); int customerId = ovsdbSession.getCustomerId();
Equipment equipmentConfig = equipmentServiceInterface.getByInventoryIdOrNull(apId); Equipment equipmentConfig = equipmentServiceInterface.getByInventoryIdOrNull(apId);
if (equipmentConfig == null) { if (equipmentConfig == null) {
throw new IllegalStateException("Cannot retrieve configuration for " + apId); throw new IllegalStateException("Cannot retrieve configuration for " + apId);
@@ -1075,7 +1060,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return; return;
} }
Equipment apNode = equipmentServiceInterface.getByInventoryIdOrNull(apId); Equipment apNode = equipmentServiceInterface.getOrNull(equipmentId);
if (apNode == null) { if (apNode == null) {
LOG.debug("wifiVIFStateDbTableUpdate::Cannot get EquipmentId for AP {}", apId); LOG.debug("wifiVIFStateDbTableUpdate::Cannot get EquipmentId for AP {}", apId);
return; // we don't have the required info to get the return; // we don't have the required info to get the
@@ -1120,6 +1105,11 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
RadioType radioType = null; RadioType radioType = null;
Map<RadioType, RfElementConfiguration> rfElementMap = rfConfig.getRfConfigMap(); Map<RadioType, RfElementConfiguration> rfElementMap = rfConfig.getRfConfigMap();
Map<RadioType, ElementRadioConfiguration> elementRadioMap = apElementConfig.getRadioMap(); Map<RadioType, ElementRadioConfiguration> elementRadioMap = apElementConfig.getRadioMap();
if (apElementConfig.getAdvancedRadioMap().isEmpty()) {
LOG.warn("No AdvancedRadioMap for ap {} {}", apId, apElementConfig);
continue;
}
for (RadioType rType : elementRadioMap.keySet()) { for (RadioType rType : elementRadioMap.keySet()) {
boolean autoChannelSelection = rfElementMap.get(rType).getAutoChannelSelection(); boolean autoChannelSelection = rfElementMap.get(rType).getAutoChannelSelection();
if (elementRadioMap.get(rType).getActiveChannel(autoChannelSelection) == channel) { if (elementRadioMap.get(rType).getActiveChannel(autoChannelSelection) == channel) {
@@ -1134,11 +1124,12 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
Status activeBssidsStatus = statusServiceInterface.getOrNull(customerId, equipmentId, Status activeBssidsStatus = statusServiceInterface.getOrNull(customerId, equipmentId,
StatusDataType.ACTIVE_BSSIDS); StatusDataType.ACTIVE_BSSIDS);
if (activeBssidsStatus != null) {
ActiveBSSIDs bssidStatusDetails = (ActiveBSSIDs) activeBssidsStatus.getDetails();
ActiveBSSIDs bssidStatusDetails = (ActiveBSSIDs) activeBssidsStatus.getDetails(); if (bssidStatusDetails != null && bssidStatusDetails.getActiveBSSIDs() != null) {
updateClientDetailsStatus(customerId, equipmentId, bssidStatusDetails);
if (activeBssidsStatus != null && bssidStatusDetails != null && bssidStatusDetails.getActiveBSSIDs() != null) { }
updateClientDetailsStatus(customerId, equipmentId, bssidStatusDetails);
} }
LOG.info("Finished wifiVIFStateDbTableUpdate updated {}", activeBssidsStatus); LOG.info("Finished wifiVIFStateDbTableUpdate updated {}", activeBssidsStatus);
@@ -1167,7 +1158,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
Map<RadioType, Integer> clientsPerRadioType = new HashMap<>(); Map<RadioType, Integer> clientsPerRadioType = new HashMap<>();
for (ActiveBSSID bssid : statusDetails.getActiveBSSIDs()) { for (ActiveBSSID bssid : statusDetails.getActiveBSSIDs()) {
if (bssid.getRadioType() == null) {
LOG.info("No radio type for BSSID, ignore");
continue;
}
if (!clientsPerRadioType.containsKey(bssid.getRadioType())) { if (!clientsPerRadioType.containsKey(bssid.getRadioType())) {
clientsPerRadioType.put(bssid.getRadioType(), 0); clientsPerRadioType.put(bssid.getRadioType(), 0);
} }

View File

@@ -1805,16 +1805,10 @@ public class MqttStatsPublisher {
Status activeBssidsStatus = statusServiceInterface.getOrNull(customerId, equipmentId, Status activeBssidsStatus = statusServiceInterface.getOrNull(customerId, equipmentId,
StatusDataType.ACTIVE_BSSIDS); StatusDataType.ACTIVE_BSSIDS);
ActiveBSSIDs statusDetails = null; if (activeBssidsStatus != null && activeBssidsStatus.getDetails() != null && ((ActiveBSSIDs) activeBssidsStatus.getDetails()).getActiveBSSIDs() != null) {
if (activeBssidsStatus != null) {
statusDetails = (ActiveBSSIDs) activeBssidsStatus.getDetails();
for (ActiveBSSID activeBSSID : ((ActiveBSSIDs) activeBssidsStatus.getDetails()).getActiveBSSIDs()) { for (ActiveBSSID activeBSSID : ((ActiveBSSIDs) activeBssidsStatus.getDetails()).getActiveBSSIDs()) {
if (activeBSSID.getRadioType().equals(radioType)) { if (activeBSSID.getRadioType().equals(radioType)) {
ssidStatistics.setBssid(MacAddress.valueOf(activeBSSID.getBssid())); ssidStatistics.setBssid(MacAddress.valueOf(activeBSSID.getBssid()));
// ssid value, in case not in stats, else will take
// stats value after
ssid = activeBSSID.getSsid();
statusDetails.getActiveBSSIDs().indexOf(activeBSSID);
} }
} }
} }
@@ -1905,8 +1899,6 @@ public class MqttStatsPublisher {
} }
// we can only get Rssi as an unsigned int from opensync, so some
// shifting
ssidStatistics.setRxLastRssi(lastRssi); ssidStatistics.setRxLastRssi(lastRssi);
ssidStatistics.setNumRxData(Long.valueOf(rxFrames).intValue()); ssidStatistics.setNumRxData(Long.valueOf(rxFrames).intValue());
ssidStatistics.setRxBytes(rxBytes - rxErrors - rxRetries); ssidStatistics.setRxBytes(rxBytes - rxErrors - rxRetries);

View File

@@ -588,7 +588,7 @@ public class OpensyncExternalIntegrationCloudTest {
equipment.setProfileId(1); equipment.setProfileId(1);
equipment.setDetails(ApElementConfiguration.createWithDefaults()); equipment.setDetails(ApElementConfiguration.createWithDefaults());
Mockito.when(equipmentServiceInterface.getByInventoryIdOrNull(apId)).thenReturn(equipment); Mockito.when(equipmentServiceInterface.getOrNull(1L)).thenReturn(equipment);
Mockito.when(equipmentServiceInterface.get(equipment.getId())).thenReturn(equipment); Mockito.when(equipmentServiceInterface.get(equipment.getId())).thenReturn(equipment);
Mockito.when(equipmentServiceInterface.update(equipment)).thenReturn(equipment); Mockito.when(equipmentServiceInterface.update(equipment)).thenReturn(equipment);
@@ -620,7 +620,7 @@ public class OpensyncExternalIntegrationCloudTest {
Mockito.verify(session).getCustomerId(); Mockito.verify(session).getCustomerId();
Mockito.verify(session).getEquipmentId(); Mockito.verify(session).getEquipmentId();
Mockito.verify(ovsdbSessionMapInterface).getSession(apId); Mockito.verify(ovsdbSessionMapInterface).getSession(apId);
Mockito.verify(equipmentServiceInterface).getByInventoryIdOrNull(apId); Mockito.verify(equipmentServiceInterface).getOrNull(1L);
Mockito.verify(statusServiceInterface).getOrNull(2, 1L, StatusDataType.CLIENT_DETAILS); Mockito.verify(statusServiceInterface).getOrNull(2, 1L, StatusDataType.CLIENT_DETAILS);
Mockito.verify(statusServiceInterface).getOrNull(2, 1L, StatusDataType.ACTIVE_BSSIDS); Mockito.verify(statusServiceInterface).getOrNull(2, 1L, StatusDataType.ACTIVE_BSSIDS);

View File

@@ -133,17 +133,10 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
@Override @Override
public void disconnected(OvsdbClient ovsdbClient) { public void disconnected(OvsdbClient ovsdbClient) {
String remoteHost = ovsdbClient.getConnectionInfo().getRemoteAddress().getHostAddress();
int localPort = ovsdbClient.getConnectionInfo().getLocalPort();
String subjectDn = null;
try {
subjectDn = ((X509Certificate) ovsdbClient.getConnectionInfo().getRemoteCertificate())
.getSubjectDN().getName();
} catch (Exception e) {
// do nothing
}
String clientCn = SslUtil.extractCN(subjectDn); String remoteHost;
int localPort;
String clientCn;
// disconnected - deregister ovsdbClient from our // disconnected - deregister ovsdbClient from our
// connectedClients table // connectedClients table
@@ -153,22 +146,40 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
// so we are doing a reverse lookup here, and then if we find // so we are doing a reverse lookup here, and then if we find
// the key we will // the key we will
// remove the entry from the connectedClients. // remove the entry from the connectedClients.
String key = ovsdbSessionMapInterface.lookupClientId(ovsdbClient); String key;
if (key != null) { try {
remoteHost = ovsdbClient.getConnectionInfo().getRemoteAddress().getHostAddress();
localPort = ovsdbClient.getConnectionInfo().getLocalPort();
String subjectDn = null;
try { try {
extIntegrationInterface.apDisconnected(key); subjectDn = ((X509Certificate) ovsdbClient.getConnectionInfo().getRemoteCertificate())
ovsdbSessionMapInterface.removeSession(key); .getSubjectDN().getName();
} catch (Exception e) { } catch (Exception e) {
LOG.debug("Unable to process ap disconnect. {}", e.getMessage()); // do nothing
} finally { }
ovsdbClient.shutdown(); clientCn = SslUtil.extractCN(subjectDn);
key = ovsdbSessionMapInterface.lookupClientId(ovsdbClient);
if (key != null) {
try {
extIntegrationInterface.apDisconnected(key);
ovsdbSessionMapInterface.removeSession(key);
} catch (Exception e) {
LOG.debug("Unable to process ap disconnect. {}", e.getMessage());
}
}
LOG.info("ovsdbClient disconnected from {} on port {} clientCn {} AP {} ", remoteHost, localPort,
clientCn, key);
LOG.info("ovsdbClient connectedClients = {}", ovsdbSessionMapInterface.getNumSessions());
} finally {
try {
ovsdbClient.shutdown();
} catch (Exception e) {
LOG.info("Caught Exception shutting down ovsdb client, may have already been disconnected {}",
e);
} }
}
LOG.info("ovsdbClient disconnected from {} on port {} clientCn {} AP {} ", remoteHost, localPort, }
clientCn, key);
LOG.info("ovsdbClient connectedClients = {}", ovsdbSessionMapInterface.getNumSessions());
} }
@@ -191,36 +202,36 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
String apId = alterClientCnIfRequired(clientCn, connectNodeInfo); String apId = alterClientCnIfRequired(clientCn, connectNodeInfo);
LOG.debug("Client {} connect for AP {}", clientCn, apId); LOG.debug("Client {} connect for AP {}", clientCn, apId);
ovsdbDao.removeAllPasspointConfigs(ovsdbClient); ovsdbDao.removeAllPasspointConfigs(ovsdbClient);
ovsdbDao.removeAllSsids(ovsdbClient); // always ovsdbDao.removeAllSsids(ovsdbClient); // always
ovsdbDao.removeAllInetConfigs(ovsdbClient); ovsdbDao.removeAllInetConfigs(ovsdbClient);
ovsdbDao.removeWifiRrm(ovsdbClient); ovsdbDao.removeWifiRrm(ovsdbClient);
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
extIntegrationInterface.clearEquipmentStatus(apId); extIntegrationInterface.clearEquipmentStatus(apId);
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId); OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
if (opensyncAPConfig != null) { if (opensyncAPConfig != null) {
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig); ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig); ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureGreTunnels(ovsdbClient, opensyncAPConfig); ovsdbDao.configureGreTunnels(ovsdbClient, opensyncAPConfig);
ovsdbDao.createVlanNetworkInterfaces(ovsdbClient, opensyncAPConfig); ovsdbDao.createVlanNetworkInterfaces(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig); ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
if (opensyncAPConfig.getHotspotConfig() != null) { if (opensyncAPConfig.getHotspotConfig() != null) {
ovsdbDao.configureHotspots(ovsdbClient, opensyncAPConfig); ovsdbDao.configureHotspots(ovsdbClient, opensyncAPConfig);
} }
ovsdbDao.configureInterfaces(ovsdbClient); ovsdbDao.configureInterfaces(ovsdbClient);
ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig); ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig);
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) { if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats); ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
} }
} else { } else {
LOG.info("No Configuration available for {}", apId); LOG.info("No Configuration available for {}", apId);
} }
@@ -267,27 +278,25 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
LOG.warn("AP with id " + apId + " does not have a config to apply."); LOG.warn("AP with id " + apId + " does not have a config to apply.");
return; return;
} }
ovsdbDao.removeAllPasspointConfigs(ovsdbClient); ovsdbDao.removeAllPasspointConfigs(ovsdbClient);
ovsdbDao.removeAllSsids(ovsdbClient); // always ovsdbDao.removeAllSsids(ovsdbClient); // always
ovsdbDao.removeAllInetConfigs(ovsdbClient); ovsdbDao.removeAllInetConfigs(ovsdbClient);
ovsdbDao.removeWifiRrm(ovsdbClient); ovsdbDao.removeWifiRrm(ovsdbClient);
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
extIntegrationInterface.clearEquipmentStatus(apId); extIntegrationInterface.clearEquipmentStatus(apId);
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig); ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig); ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureGreTunnels(ovsdbClient, opensyncAPConfig); ovsdbDao.configureGreTunnels(ovsdbClient, opensyncAPConfig);
ovsdbDao.createVlanNetworkInterfaces(ovsdbClient, opensyncAPConfig); ovsdbDao.createVlanNetworkInterfaces(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig); ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
if (opensyncAPConfig.getHotspotConfig() != null) { if (opensyncAPConfig.getHotspotConfig() != null) {
ovsdbDao.configureHotspots(ovsdbClient, opensyncAPConfig); ovsdbDao.configureHotspots(ovsdbClient, opensyncAPConfig);
} }
ovsdbDao.configureInterfaces(ovsdbClient); ovsdbDao.configureInterfaces(ovsdbClient);
ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig); ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig);
@@ -425,16 +434,19 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
} }
if (!insert.isEmpty()) { if (!insert.isEmpty()) {
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(insert, key, RowUpdateOperation.INSERT); extIntegrationInterface.dhcpLeasedIpDbTableUpdate(insert, key,
RowUpdateOperation.INSERT);
} }
if (!delete.isEmpty()) { if (!delete.isEmpty()) {
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(delete, key, RowUpdateOperation.DELETE); extIntegrationInterface.dhcpLeasedIpDbTableUpdate(delete, key,
RowUpdateOperation.DELETE);
} }
if (!update.isEmpty()) { if (!update.isEmpty()) {
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(update, key, RowUpdateOperation.MODIFY); extIntegrationInterface.dhcpLeasedIpDbTableUpdate(update, key,
RowUpdateOperation.MODIFY);
} }
} catch (Exception e) { } catch (Exception e) {
@@ -504,16 +516,19 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
} }
if (!insert.isEmpty()) { if (!insert.isEmpty()) {
extIntegrationInterface.commandStateDbTableUpdate(insert, key, RowUpdateOperation.INSERT); extIntegrationInterface.commandStateDbTableUpdate(insert, key,
RowUpdateOperation.INSERT);
} }
if (!delete.isEmpty()) { if (!delete.isEmpty()) {
extIntegrationInterface.commandStateDbTableUpdate(delete, key, RowUpdateOperation.DELETE); extIntegrationInterface.commandStateDbTableUpdate(delete, key,
RowUpdateOperation.DELETE);
} }
if (!update.isEmpty()) { if (!update.isEmpty()) {
extIntegrationInterface.commandStateDbTableUpdate(update, key, RowUpdateOperation.MODIFY); extIntegrationInterface.commandStateDbTableUpdate(update, key,
RowUpdateOperation.MODIFY);
} }
} catch (Exception e) { } catch (Exception e) {
@@ -529,27 +544,28 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
} }
private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(OvsdbDao.ovsdbName, CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(
OvsdbDao.awlanNodeDbTable + "_" + key, OvsdbDao.ovsdbName, OvsdbDao.awlanNodeDbTable + "_" + key, new MonitorRequests(ImmutableMap
new MonitorRequests(ImmutableMap.of(OvsdbDao.awlanNodeDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))), .of(OvsdbDao.awlanNodeDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))),
new MonitorCallback() { new MonitorCallback() {
@Override @Override
public void update(TableUpdates tableUpdates) { public void update(TableUpdates tableUpdates) {
try { try {
LOG.info(OvsdbDao.awlanNodeDbTable + "_" + key + " monitor callback received {}", tableUpdates); LOG.info(OvsdbDao.awlanNodeDbTable + "_" + key + " monitor callback received {}",
tableUpdates);
extIntegrationInterface.awlanNodeDbTableUpdate( extIntegrationInterface.awlanNodeDbTableUpdate(
ovsdbDao.getOpensyncAWLANNode(tableUpdates, key, ovsdbClient), key); ovsdbDao.getOpensyncAWLANNode(tableUpdates, key, ovsdbClient), key);
} catch (Exception e) { } catch (Exception e) {
LOG.error("awlanNodeDbTableUpdate failed",e); LOG.error("awlanNodeDbTableUpdate failed", e);
} }
} }
}); });
extIntegrationInterface.awlanNodeDbTableUpdate( extIntegrationInterface.awlanNodeDbTableUpdate(ovsdbDao.getOpensyncAWLANNode(awCf.join(), key, ovsdbClient),
ovsdbDao.getOpensyncAWLANNode(awCf.join(), key, ovsdbClient), key); key);
} }
private void monitorWifiAssociatedClientsDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { private void monitorWifiAssociatedClientsDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
@@ -558,47 +574,49 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable, new MonitorRequest())), new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable, new MonitorRequest())),
new MonitorCallback() { new MonitorCallback() {
@Override @Override
public void update(TableUpdates tableUpdates) { public void update(TableUpdates tableUpdates) {
try { try {
LOG.info(OvsdbDao.wifiAssociatedClientsDbTable + "_" + key + " monitor callback received {}", LOG.info(
tableUpdates); OvsdbDao.wifiAssociatedClientsDbTable + "_" + key + " monitor callback received {}",
tableUpdates);
List<OpensyncWifiAssociatedClients> associatedClients = new ArrayList<>(); List<OpensyncWifiAssociatedClients> associatedClients = new ArrayList<>();
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
if ((rowUpdate.getOld() != null) && (rowUpdate.getNew() == null)) {
Row row = rowUpdate.getOld();
String deletedClientMac = row.getStringColumn("mac");
// take care of the deletes as we go
// through
// the updates, as we want to delete
// before
// adding anyway.
extIntegrationInterface.wifiAssociatedClientsDbTableDelete(deletedClientMac,
key);
} else {
associatedClients.addAll(
ovsdbDao.getOpensyncWifiAssociatedClients(rowUpdate, key, ovsdbClient));
}
}
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
if ((rowUpdate.getOld() != null) && (rowUpdate.getNew() == null)) {
Row row = rowUpdate.getOld();
String deletedClientMac = row.getStringColumn("mac");
// take care of the deletes as we go through
// the updates, as we want to delete before
// adding anyway.
extIntegrationInterface.wifiAssociatedClientsDbTableDelete(deletedClientMac, key);
} else {
associatedClients.addAll(
ovsdbDao.getOpensyncWifiAssociatedClients(rowUpdate, key, ovsdbClient));
} }
// now address the update/add
extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(associatedClients, key);
} catch (Exception e) {
LOG.error("wifiAssociatedClientsDbTableUpdate failed", e);
} }
} }
// now address the update/add });
extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(associatedClients, key);
} catch (Exception e) {
LOG.error("wifiAssociatedClientsDbTableUpdate failed", e);
}
}
});
extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(ovsdbDao.getInitialOpensyncWifiAssociatedClients(acCf.join(), key, ovsdbClient), key);
extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(
ovsdbDao.getInitialOpensyncWifiAssociatedClients(acCf.join(), key, ovsdbClient), key);
} }
@@ -624,11 +642,11 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) { for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
if (rowUpdate.getNew() == null) { if (rowUpdate.getNew() == null) {
inetStateDelete.addAll( inetStateDelete.addAll(ovsdbDao.getOpensyncApInetStateForRowUpdate(rowUpdate,
ovsdbDao.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient)); key, ovsdbClient));
} else { } else {
inetStateInsertOrUpdate.addAll( inetStateInsertOrUpdate.addAll(ovsdbDao
ovsdbDao.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient)); .getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
} }
} }
@@ -640,14 +658,15 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
// now process updates and mutations // now process updates and mutations
extIntegrationInterface.wifiInetStateDbTableUpdate(inetStateInsertOrUpdate, key); extIntegrationInterface.wifiInetStateDbTableUpdate(inetStateInsertOrUpdate, key);
} catch (Exception e) { } catch (Exception e) {
LOG.error("wifiInetStateDbTableUpdate failed",e); LOG.error("wifiInetStateDbTableUpdate failed", e);
} }
} }
}); });
extIntegrationInterface.wifiInetStateDbTableUpdate(ovsdbDao.getInitialOpensyncApInetStateForRowUpdate(isCf.join(), key, ovsdbClient), key); extIntegrationInterface.wifiInetStateDbTableUpdate(
ovsdbDao.getInitialOpensyncApInetStateForRowUpdate(isCf.join(), key, ovsdbClient), key);
} }
@@ -655,7 +674,8 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
CompletableFuture<TableUpdates> rsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName, CompletableFuture<TableUpdates> rsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
OvsdbDao.wifiRadioStateDbTable + "_" + key, OvsdbDao.wifiRadioStateDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))), new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable,
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
new MonitorCallback() { new MonitorCallback() {
@Override @Override
@@ -667,78 +687,82 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
extIntegrationInterface.wifiRadioStatusDbTableUpdate( extIntegrationInterface.wifiRadioStatusDbTableUpdate(
ovsdbDao.getOpensyncAPRadioState(tableUpdates, key, ovsdbClient), key); ovsdbDao.getOpensyncAPRadioState(tableUpdates, key, ovsdbClient), key);
} catch (Exception e) { } catch (Exception e) {
LOG.error("wifiRadioStatusDbTableUpdate failed",e); LOG.error("wifiRadioStatusDbTableUpdate failed", e);
} }
} }
}); });
extIntegrationInterface.wifiRadioStatusDbTableUpdate( extIntegrationInterface
ovsdbDao.getOpensyncAPRadioState(rsCf.join(), key, ovsdbClient), key); .wifiRadioStatusDbTableUpdate(ovsdbDao.getOpensyncAPRadioState(rsCf.join(), key, ovsdbClient), key);
} }
private void monitorWifiVifStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { private void monitorWifiVifStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
CompletableFuture<TableUpdates> vsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName, CompletableFuture<TableUpdates> vsCf = ovsdbClient
OvsdbDao.wifiVifStateDbTable + "_" + key, .monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiVifStateDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))), new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable,
new MonitorCallback() { new MonitorRequest(new MonitorSelect(false, true, true, true)))),
new MonitorCallback() {
@Override @Override
public void update(TableUpdates tableUpdates) { public void update(TableUpdates tableUpdates) {
try { try {
LOG.info(OvsdbDao.wifiVifStateDbTable + "_" + key + " monitor callback received {}", LOG.info(OvsdbDao.wifiVifStateDbTable + "_" + key + " monitor callback received {}",
tableUpdates); tableUpdates);
List<OpensyncAPVIFState> vifsToDelete = new ArrayList<>(); List<OpensyncAPVIFState> vifsToDelete = new ArrayList<>();
List<OpensyncAPVIFState> vifsToInsertOrUpdate = new ArrayList<>(); List<OpensyncAPVIFState> vifsToInsertOrUpdate = new ArrayList<>();
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) { for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
if (rowUpdate.getNew() == null) { if (rowUpdate.getNew() == null) {
// this is a deletion // this is a deletion
vifsToDelete.addAll( vifsToDelete.addAll(ovsdbDao.getOpensyncApVifStateForRowUpdate(
ovsdbDao.getOpensyncApVifStateForRowUpdate(rowUpdate, key, ovsdbClient)); rowUpdate, key, ovsdbClient));
} else { } else {
// either an insert or // either an insert or
// mutuate/update // mutuate/update
vifsToInsertOrUpdate.addAll( vifsToInsertOrUpdate.addAll(ovsdbDao.getOpensyncApVifStateForRowUpdate(
ovsdbDao.getOpensyncApVifStateForRowUpdate(rowUpdate, key, ovsdbClient)); rowUpdate, key, ovsdbClient));
}
}
// delete first, if required
if (!vifsToDelete.isEmpty()) {
extIntegrationInterface.wifiVIFStateDbTableDelete(vifsToDelete, key);
}
if (!vifsToInsertOrUpdate.isEmpty()) {
extIntegrationInterface.wifiVIFStateDbTableUpdate(vifsToInsertOrUpdate,
key);
}
}
} catch (Exception e) {
LOG.error("wifiVIFStateDbTableUpdate failed", e);
}
} }
} });
vsCf.join();
// delete first, if required
if (!vifsToDelete.isEmpty()) {
extIntegrationInterface.wifiVIFStateDbTableDelete(vifsToDelete, key);
}
if (!vifsToInsertOrUpdate.isEmpty()) {
extIntegrationInterface.wifiVIFStateDbTableUpdate(vifsToInsertOrUpdate, key);
}
}
} catch (Exception e) {
LOG.error("wifiVIFStateDbTableUpdate failed", e);
}
}
});
extIntegrationInterface.wifiVIFStateDbTableUpdate(ovsdbDao.getInitialOpensyncApVifStateForTableUpdates(vsCf.join(), key, ovsdbClient),key);
} }
@Override @Override
public String closeSession(String apId) { public String closeSession(String apId) {
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId); OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
try { if (session != null) {
session.getOvsdbClient().shutdown(); try {
} catch (Exception e) { session.getOvsdbClient().shutdown();
LOG.error("Failed to close session to " + apId + " " + e.getLocalizedMessage()); } catch (Exception e) {
return "Failed to close session to " + apId + " " + e.getLocalizedMessage(); LOG.error("Failed to close session to " + apId + " " + e.getLocalizedMessage());
return "Failed to close session to " + apId + " " + e.getLocalizedMessage();
}
} }
LOG.debug("Closed session to " + apId); LOG.debug("Closed session to " + apId);
return "Closed session to " + apId; return "Closed session to " + apId;
@@ -896,18 +920,21 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
return key; return key;
} }
public String processNewChannelsRequest(String apId, Map<RadioType, Integer> backupChannelMap, Map<RadioType,Integer> primaryChannelMap) { public String processNewChannelsRequest(String apId, Map<RadioType, Integer> backupChannelMap,
Map<RadioType, Integer> primaryChannelMap) {
LOG.info("TipWlanOvsdbClient::processNewChannelsRequest for AP {}", apId); LOG.info("TipWlanOvsdbClient::processNewChannelsRequest for AP {}", apId);
try { try {
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId); OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
OvsdbClient ovsdbClient = session.getOvsdbClient(); OvsdbClient ovsdbClient = session.getOvsdbClient();
ovsdbDao.processNewChannelsRequest(ovsdbClient, backupChannelMap, primaryChannelMap); ovsdbDao.processNewChannelsRequest(ovsdbClient, backupChannelMap, primaryChannelMap);
LOG.info("TipWlanOvsdbClient::processNewChannelsRequest change backup and/or primary channels for AP {}", apId); LOG.info("TipWlanOvsdbClient::processNewChannelsRequest change backup and/or primary channels for AP {}",
apId);
return " change backup and/or primary channels for AP " + apId; return " change backup and/or primary channels for AP " + apId;
} catch (Exception e) { } catch (Exception e) {
LOG.error("TipWlanOvsdbClient::processNewChannelsRequest failed to change backup and/or primary channels for AP {}", apId, LOG.error(
e); "TipWlanOvsdbClient::processNewChannelsRequest failed to change backup and/or primary channels for AP {}",
apId, e);
return "failed to change backup and/or primary channels for AP " + apId; return "failed to change backup and/or primary channels for AP " + apId;
} }
} }

View File

@@ -3089,13 +3089,13 @@ public class OvsdbDao {
rrmEnabled = opensyncApConfig.getEquipmentLocation().getDetails().isRrmEnabled(); rrmEnabled = opensyncApConfig.getEquipmentLocation().getDetails().isRrmEnabled();
} }
List<MacAddress> macBlockList = opensyncApConfig.getBlockedClients(); List<MacAddress> macBlockList = opensyncApConfig.getBlockedClients();
LOG.debug("configureSsids with blockList {}", macBlockList); LOG.debug("configureSsids {} with blockList {}", opensyncApConfig.getSsidProfile(), macBlockList);
List<RadioType> enabledRadiosFromAp = new ArrayList<>(); List<RadioType> enabledRadiosFromAp = new ArrayList<>();
getEnabledRadios(ovsdbClient, enabledRadiosFromAp); getEnabledRadios(ovsdbClient, enabledRadiosFromAp);
for (Profile ssidProfile : opensyncApConfig.getSsidProfile()) { for (Profile ssidProfile : opensyncApConfig.getSsidProfile()) {
SsidConfiguration ssidConfig = (SsidConfiguration) ssidProfile.getDetails(); SsidConfiguration ssidConfig = (SsidConfiguration) ssidProfile.getDetails();
ApElementConfiguration apElementConfig = (ApElementConfiguration) opensyncApConfig.getCustomerEquipment() ApElementConfiguration apElementConfig = (ApElementConfiguration) opensyncApConfig.getCustomerEquipment()
.getDetails(); .getDetails();
@@ -3198,15 +3198,21 @@ public class OvsdbDao {
} }
} }
RadioConfiguration radioConfiguration = apElementConfig.getAdvancedRadioMap().get(radioType);
if (radioConfiguration == null) {
continue; // don't have a radio of this kind in the map
}
RfElementConfiguration rfElementConfig = rfConfig.getRfConfig(radioType); RfElementConfiguration rfElementConfig = rfConfig.getRfConfig(radioType);
int dtimPeriod = radioConfiguration.getDtimPeriod();
int rtsCtsThreshold = rfElementConfig.getRtsCtsThreshold(); int rtsCtsThreshold = rfElementConfig.getRtsCtsThreshold();
int fragThresholdBytes = radioConfiguration.getFragmentationThresholdBytes();
RadioMode radioMode = rfElementConfig.getRadioMode(); RadioMode radioMode = rfElementConfig.getRadioMode();
int dtimPeriod = 2;
int fragThresholdBytes = 2346;
boolean uapsdEnabled = true;
boolean apBridge = true;
RadioConfiguration radioConfiguration = apElementConfig.getAdvancedRadioMap().get(radioType);
if (radioConfiguration != null) {
dtimPeriod = radioConfiguration.getDtimPeriod();
uapsdEnabled = radioConfiguration.getUapsdState() == StateSetting.enabled;
apBridge = radioConfiguration.getStationIsolation() == StateSetting.disabled; // stationIsolation
fragThresholdBytes = radioConfiguration.getFragmentationThresholdBytes();
}
String minHwMode = "11n"; // min_hw_mode is 11ac, wifi 5, we can String minHwMode = "11n"; // min_hw_mode is 11ac, wifi 5, we can
// also take ++ (11ax) but 2.4GHz only // also take ++ (11ax) but 2.4GHz only
// Wifi4 -- // Wifi4 --
@@ -3217,9 +3223,7 @@ public class OvsdbDao {
minHwMode = "11x"; minHwMode = "11x";
} }
boolean uapsdEnabled = radioConfiguration.getUapsdState() == StateSetting.enabled;
boolean apBridge = radioConfiguration.getStationIsolation() == StateSetting.disabled; // stationIsolation
// off by default // off by default
boolean enable80211r = false; boolean enable80211r = false;
int mobilityDomain = 0; int mobilityDomain = 0;
@@ -5656,7 +5660,8 @@ public class OvsdbDao {
} }
} }
public void processNewChannelsRequest(OvsdbClient ovsdbClient, Map<RadioType, Integer> backupChannelMap, Map<RadioType, Integer> primaryChannelMap) { public void processNewChannelsRequest(OvsdbClient ovsdbClient, Map<RadioType, Integer> backupChannelMap,
Map<RadioType, Integer> primaryChannelMap) {
LOG.info("OvsdbDao::processNewChannelsRequest backup {} primary {}", backupChannelMap, primaryChannelMap); LOG.info("OvsdbDao::processNewChannelsRequest backup {} primary {}", backupChannelMap, primaryChannelMap);
try { try {
@@ -5689,7 +5694,6 @@ public class OvsdbDao {
LOG.info("Op Result {}", res); LOG.info("Op Result {}", res);
} }
LOG.info("Updated ovsdb config for primary and backup channels."); LOG.info("Updated ovsdb config for primary and backup channels.");
} catch (ExecutionException e) { } catch (ExecutionException e) {
LOG.error("Error in processNewChannelsRequest", e); LOG.error("Error in processNewChannelsRequest", e);
@@ -5699,8 +5703,6 @@ public class OvsdbDao {
} }
} }
public AutoOrManualValue getSourcedValue(SourceType source, int profileValue, int equipmentValue) { public AutoOrManualValue getSourcedValue(SourceType source, int profileValue, int equipmentValue) {
if (source == SourceType.profile) { if (source == SourceType.profile) {