Robustness for ActiveBSSIDs, state change handling cleanup

This commit is contained in:
Mike Hansen
2020-08-04 18:45:44 -04:00
parent 2f4be3f6c7
commit a39432fdf0
5 changed files with 253 additions and 233 deletions

View File

@@ -111,7 +111,6 @@ import com.telecominfraproject.wlan.status.equipment.report.models.ActiveBSSID;
import com.telecominfraproject.wlan.status.equipment.report.models.ActiveBSSIDs;
import com.telecominfraproject.wlan.status.equipment.report.models.ClientConnectionDetails;
import com.telecominfraproject.wlan.status.equipment.report.models.EquipmentCapacityDetails;
import com.telecominfraproject.wlan.status.equipment.report.models.EquipmentPerRadioUtilizationDetails;
import com.telecominfraproject.wlan.status.equipment.report.models.OperatingSystemPerformance;
import com.telecominfraproject.wlan.status.equipment.report.models.RadioUtilizationReport;
import com.telecominfraproject.wlan.status.models.Status;
@@ -1121,7 +1120,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
// private Integer nonWifi;
// private Integer timestampSeconds;
Map<RadioType, Integer> avgNoiseFloor = new HashMap<>();
Map<RadioType, EquipmentPerRadioUtilizationDetails> radioUtilization = new HashMap<>();
new HashMap<>();
Map<RadioType, EquipmentCapacityDetails> capacityDetails = new HashMap<>();
RadioUtilizationReport radioUtilizationReport = new RadioUtilizationReport();
@@ -1149,7 +1148,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
radioUtil.setTimestampSeconds((int) ((survey.getTimestampMs() + surveySample.getOffsetMs()) / 1000));
radioUtil.setAssocClientTx((100 * surveySample.getBusyTx()) / surveySample.getDurationMs());
radioUtil.setAssocClientRx((100 * surveySample.getBusyRx()) / surveySample.getDurationMs());
//TODO not totally correct, NonWifi = totalBusy - iBSS - oBSS
// TODO not totally correct, NonWifi = totalBusy - iBSS - oBSS
radioUtil.setNonWifi(
(100 * (surveySample.getBusy() - surveySample.getBusyTx() - surveySample.getBusyRx()))
/ surveySample.getDurationMs());
@@ -1181,10 +1180,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
}
if (survey.getSurveyListCount() > 0 && radioType != RadioType.UNSUPPORTED) {
int noiseAvg = (int) Math.round(DecibelUtils.getAverageDecibel(toIntArray(noiseList)));
avgNoiseFloor.put(radioType, noiseAvg);
apNodeMetrics.setNoiseFloor(radioType, noiseAvg);
if ((survey.getSurveyListCount() > 0) && (radioType != RadioType.UNSUPPORTED)) {
int noiseAvg = (int) Math.round(DecibelUtils.getAverageDecibel(toIntArray(noiseList)));
avgNoiseFloor.put(radioType, noiseAvg);
apNodeMetrics.setNoiseFloor(radioType, noiseAvg);
}
Double totalUtilization = (100D * totalBusy) / durationMs;
Double totalNonWifi = (100D * (totalBusy - iBSS - oBSS)) / durationMs;
@@ -1197,8 +1196,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
cap.setUnusedCapacity(avaiCapacity - totalUtilization.intValue());
if (radioType != RadioType.UNSUPPORTED) {
apNodeMetrics.setChannelUtilization(radioType, totalUtilization.intValue());
capacityDetails.put(radioType, cap);
apNodeMetrics.setChannelUtilization(radioType, totalUtilization.intValue());
capacityDetails.put(radioType, cap);
}
}
@@ -1212,23 +1211,26 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
updateDeviceStatusRadioUtilizationReport(customerId, equipmentId, radioUtilizationReport);
}
private void updateDeviceStatusRadioUtilizationReport(int customerId, long equipmentId, RadioUtilizationReport radioUtilizationReport) {
LOG.debug("Processing updateDeviceStatusRadioUtilizationReport for equipmentId {} with RadioUtilizationReport {}",
equipmentId, radioUtilizationReport);
private void updateDeviceStatusRadioUtilizationReport(int customerId, long equipmentId,
RadioUtilizationReport radioUtilizationReport) {
LOG.debug(
"Processing updateDeviceStatusRadioUtilizationReport for equipmentId {} with RadioUtilizationReport {}",
equipmentId, radioUtilizationReport);
Status radioUtilizationStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.RADIO_UTILIZATION);
Status radioUtilizationStatus = statusServiceInterface.getOrNull(customerId, equipmentId,
StatusDataType.RADIO_UTILIZATION);
if (radioUtilizationStatus == null) {
LOG.debug("Create new radioUtilizationStatus");
radioUtilizationStatus = new Status();
radioUtilizationStatus.setCustomerId(customerId);
radioUtilizationStatus.setEquipmentId(equipmentId);
radioUtilizationStatus.setStatusDataType(StatusDataType.RADIO_UTILIZATION);
}
if (radioUtilizationStatus == null) {
LOG.debug("Create new radioUtilizationStatus");
radioUtilizationStatus = new Status();
radioUtilizationStatus.setCustomerId(customerId);
radioUtilizationStatus.setEquipmentId(equipmentId);
radioUtilizationStatus.setStatusDataType(StatusDataType.RADIO_UTILIZATION);
}
radioUtilizationStatus.setDetails(radioUtilizationReport);
radioUtilizationStatus.setDetails(radioUtilizationReport);
statusServiceInterface.update(radioUtilizationStatus);
statusServiceInterface.update(radioUtilizationStatus);
}
void populateNetworkProbeMetrics(Report report, ApNodeMetrics apNodeMetrics) {
@@ -1238,51 +1240,62 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
NetworkProbeMetrics networkProbeMetrics = new NetworkProbeMetrics();
List<DnsProbeMetric> dnsProbeResults = new ArrayList<>();
if (networkProbe.hasDnsProbe()) {
DNSProbeMetric dnsProbeMetricStats = networkProbe.getDnsProbe();
DNSProbeMetric dnsProbeMetricFromAp = networkProbe.getDnsProbe();
LOG.debug("DNSProbeMetric from AP {}", dnsProbeMetricFromAp);
DnsProbeMetric dnsProbeMetric = new DnsProbeMetric();
networkProbeMetrics.setDnsLatencyMs(dnsProbeMetricStats.getLatency());
dnsProbeMetric.setDnsLatencyMs(dnsProbeMetricStats.getLatency());
switch (dnsProbeMetricStats.getState()) {
case SUD_down:
networkProbeMetrics.setDnsState(StateUpDownError.disabled);
dnsProbeMetric.setDnsState(StateUpDownError.disabled);
break;
case SUD_up:
networkProbeMetrics.setDnsState(StateUpDownError.enabled);
dnsProbeMetric.setDnsState(StateUpDownError.enabled);
break;
case SUD_error:
networkProbeMetrics.setDnsState(StateUpDownError.error);
dnsProbeMetric.setDnsState(StateUpDownError.error);
break;
default:
networkProbeMetrics.setDnsState(StateUpDownError.UNSUPPORTED);
dnsProbeMetric.setDnsState(StateUpDownError.UNSUPPORTED);
if (dnsProbeMetricFromAp.hasLatency()) {
networkProbeMetrics.setDnsLatencyMs(dnsProbeMetricFromAp.getLatency());
dnsProbeMetric.setDnsLatencyMs(dnsProbeMetricFromAp.getLatency());
}
try {
InetAddress ipAddress = InetAddress.getByName(dnsProbeMetricStats.getServerIP());
dnsProbeMetric.setDnsServerIp(ipAddress);
} catch (Exception e) {
LOG.error("Unable to get the DNS server IP.", e);
if (dnsProbeMetricFromAp.hasState()) {
switch (dnsProbeMetricFromAp.getState()) {
case SUD_down:
networkProbeMetrics.setDnsState(StateUpDownError.disabled);
dnsProbeMetric.setDnsState(StateUpDownError.disabled);
break;
case SUD_up:
networkProbeMetrics.setDnsState(StateUpDownError.enabled);
dnsProbeMetric.setDnsState(StateUpDownError.enabled);
break;
case SUD_error:
networkProbeMetrics.setDnsState(StateUpDownError.error);
dnsProbeMetric.setDnsState(StateUpDownError.error);
break;
default:
networkProbeMetrics.setDnsState(StateUpDownError.UNSUPPORTED);
dnsProbeMetric.setDnsState(StateUpDownError.UNSUPPORTED);
}
}
if (networkProbeMetrics.getDnsProbeResults() == null) {
List<DnsProbeMetric> dnsProbeMetricList = new ArrayList<>();
dnsProbeMetricList.add(dnsProbeMetric);
networkProbeMetrics.setDnsProbeResults(dnsProbeMetricList);
} else {
networkProbeMetrics.getDnsProbeResults().add(dnsProbeMetric);
if (dnsProbeMetricFromAp.hasServerIP()) {
InetAddress ipAddress;
try {
ipAddress = InetAddress.getByName(dnsProbeMetricFromAp.getServerIP());
dnsProbeMetric.setDnsServerIp(ipAddress);
} catch (UnknownHostException e) {
LOG.error("Could not get DNS Server IP from network_probe metrics", e);
}
}
dnsProbeResults.add(dnsProbeMetric);
}
networkProbeMetrics.setDnsProbeResults(dnsProbeResults);
if (networkProbe.hasRadiusProbe()) {
RADIUSMetrics radiusMetrics = networkProbe.getRadiusProbe();
LOG.debug("Network Probe Radius Metrics {}", radiusMetrics);
if (networkProbe.hasVlanProbe()) {
if (networkProbe.getVlanProbe().hasObsV200RadiusLatency()) {
networkProbeMetrics.setRadiusLatencyInMs(networkProbe.getVlanProbe().getObsV200RadiusLatency());
@@ -1305,27 +1318,36 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
} else {
// take the average if we don't have from the VLAN Probe
networkProbeMetrics.setRadiusLatencyInMs(radiusMetrics.getLatencyAve());
if (radiusMetrics.hasLatencyAve()) {
networkProbeMetrics.setRadiusLatencyInMs(radiusMetrics.getLatencyAve());
}
}
}
if (networkProbe.hasVlanProbe()) {
VLANMetrics vlanMetrics = networkProbe.getVlanProbe();
networkProbeMetrics.setVlanIF(vlanMetrics.getVlanIF());
networkProbeMetrics.setDhcpLatencyMs(vlanMetrics.getDhcpLatency());
switch (vlanMetrics.getDhcpState()) {
case SUD_down:
networkProbeMetrics.setDhcpState(StateUpDownError.disabled);
break;
case SUD_up:
networkProbeMetrics.setDhcpState(StateUpDownError.enabled);
break;
case SUD_error:
networkProbeMetrics.setDhcpState(StateUpDownError.error);
break;
default:
networkProbeMetrics.setDhcpState(StateUpDownError.UNSUPPORTED);
LOG.debug("NetworkProbe Vlan Metrics {}", vlanMetrics);
if (vlanMetrics.hasVlanIF()) {
networkProbeMetrics.setVlanIF(vlanMetrics.getVlanIF());
}
if (vlanMetrics.hasDhcpLatency()) {
networkProbeMetrics.setDhcpLatencyMs(vlanMetrics.getDhcpLatency());
}
if (vlanMetrics.hasDhcpState()) {
switch (vlanMetrics.getDhcpState()) {
case SUD_down:
networkProbeMetrics.setDhcpState(StateUpDownError.disabled);
break;
case SUD_up:
networkProbeMetrics.setDhcpState(StateUpDownError.enabled);
break;
case SUD_error:
networkProbeMetrics.setDhcpState(StateUpDownError.error);
break;
default:
networkProbeMetrics.setDhcpState(StateUpDownError.UNSUPPORTED);
}
}
}
@@ -1799,7 +1821,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
//TODO replace this with getNegativeSignedIntFrom8BitUnsigned
// TODO replace this with getNegativeSignedIntFrom8BitUnsigned
int getNegativeSignedIntFromUnsigned(int unsignedValue) {
int negSignedValue = (unsignedValue << 1) >> 1;
return negSignedValue;
@@ -1887,7 +1909,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
channelInfoList = new ArrayList<>();
}
channelInfoList.add(channelInfo);
Map<RadioType,List<ChannelInfo>> channelInfoMap = channelInfoReports.getChannelInformationReportsPerRadio();
Map<RadioType, List<ChannelInfo>> channelInfoMap = channelInfoReports
.getChannelInformationReportsPerRadio();
channelInfoMap.put(radioType, channelInfoList);
channelInfoReports.setChannelInformationReportsPerRadio(channelInfoMap);
}
@@ -1903,7 +1926,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
channelInfoList = new ArrayList<>();
}
channelInfoList.add(channelInfo);
Map<RadioType,List<ChannelInfo>> channelInfoMap = channelInfoReports.getChannelInformationReportsPerRadio();
Map<RadioType, List<ChannelInfo>> channelInfoMap = channelInfoReports
.getChannelInformationReportsPerRadio();
channelInfoMap.put(radioType, channelInfoList);
channelInfoReports.setChannelInformationReportsPerRadio(channelInfoMap);
}
@@ -1929,7 +1953,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
busySelf += sample.getBusySelf();
busy += sample.getBusy();
channelInfo.setChanNumber(sample.getChannel());
noiseArray[index++] = getNegativeSignedIntFrom8BitUnsigned(sample.getNoise()); }
noiseArray[index++] = getNegativeSignedIntFrom8BitUnsigned(sample.getNoise());
}
int iBSS = busyTx + busySelf;
@@ -1939,7 +1964,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
channelInfo.setWifiUtilization(totalWifi);
channelInfo.setBandwidth(channelBandwidth);
if (surveySampleList.size() > 0) {
channelInfo.setNoiseFloor((int) Math.round(DecibelUtils.getAverageDecibel(noiseArray)));
channelInfo.setNoiseFloor((int) Math.round(DecibelUtils.getAverageDecibel(noiseArray)));
}
return channelInfo;
}
@@ -2254,13 +2279,22 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
apId, currentActiveBSSIDs);
}
for (OpensyncAPVIFState vifState : radioState.getVifStates()) {
ActiveBSSID activeBssid = new ActiveBSSID();
activeBssid.setBssid(vifState.getMac());
activeBssid.setSsid(vifState.getSsid());
activeBssid.setNumDevicesConnected(vifState.getAssociatedClients().size());
activeBssid.setRadioType(radioState.getFreqBand());
currentActiveBSSIDs.add(activeBssid);
ProfileContainer profileContainer = new ProfileContainer(
profileServiceInterface.getProfileWithChildren(ce.getProfileId()));
List<Profile> ssidProfiles = profileContainer.getChildrenOfType(ce.getProfileId(), ProfileType.ssid);
for (Profile ssidProfile : ssidProfiles) {
SsidConfiguration ssidConfig = (SsidConfiguration) ssidProfile.getDetails();
if (ssidConfig.getAppliedRadios().contains(radioState.freqBand)) {
ActiveBSSID activeBssid = new ActiveBSSID();
activeBssid.setBssid(radioState.getMac());
activeBssid.setSsid(ssidConfig.getSsid());
activeBssid.setRadioType(radioState.getFreqBand());
currentActiveBSSIDs.add(activeBssid);
}
}
statusDetails.setActiveBSSIDs(currentActiveBSSIDs);
@@ -2605,6 +2639,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
Equipment ce = getCustomerEquipment(apId);
if (ce != null) {
ce.getDetails();
if (fwUpgradeState.equals(EquipmentUpgradeState.up_to_date)) {
LOG.info("Firmware load is up to date.");
@@ -2614,7 +2650,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (!firmwareStatusData.getActiveSwVersion().equals(reportedFwImageName)
|| !firmwareStatusData.getUpgradeState().equals(fwUpgradeState)) {
firmwareStatusData.setActiveSwVersion(reportedFwImageName);
firmwareStatusData.setUpgradeState(fwUpgradeState);
firmwareStatusData.setUpgradeState(fwUpgradeState, fwUpgradeFailureReason);
firmwareStatus.setDetails(firmwareStatusData);
updates.add(firmwareStatus);
}
@@ -2643,7 +2679,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (!firmwareStatusData.getActiveSwVersion().equals(reportedFwImageName)
|| !firmwareStatusData.getUpgradeState().equals(fwUpgradeState)) {
firmwareStatusData.setActiveSwVersion(reportedFwImageName);
firmwareStatusData.setUpgradeState(fwUpgradeState);
firmwareStatusData.setUpgradeState(fwUpgradeState, fwUpgradeFailureReason);
if (fwUpgradeState.equals(EquipmentUpgradeState.apply_initiated)) {
firmwareStatusData.setUpgradeStartTime(System.currentTimeMillis());
} else if (fwUpgradeState.equals(EquipmentUpgradeState.reboot_initiated)
@@ -2678,6 +2714,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
firmwareStatus.setDetails(firmwareStatusData);
updates.add(firmwareStatus);
updates = statusServiceInterface.update(updates);
reconcileFwVersionToTrack(ce, reportedFwImageName, opensyncAPState.getModel());
} else {
if (!updates.isEmpty()) {
@@ -2701,7 +2738,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (!firmwareStatusData.getActiveSwVersion().equals(reportedFwImageName)
|| !firmwareStatusData.getUpgradeState().equals(fwUpgradeState)) {
firmwareStatusData.setActiveSwVersion(reportedFwImageName);
firmwareStatusData.setUpgradeState(fwUpgradeState);
firmwareStatusData.setUpgradeState(fwUpgradeState, fwUpgradeFailureReason);
firmwareStatus.setDetails(firmwareStatusData);
updates.add(firmwareStatus);
updates = statusServiceInterface.update(updates);
@@ -2728,6 +2765,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
@Override
public void wifiVIFStateDbTableDelete(List<OpensyncAPVIFState> vifStateTables, String apId) {
LOG.info("wifiVIFStateDbTableDelete for AP {} rows {}", apId, vifStateTables);
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
if (ovsdbSession == null) {
@@ -2760,8 +2798,20 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ActiveBSSIDs statusDetails = (ActiveBSSIDs) activeBssidsStatus.getDetails();
List<ActiveBSSID> bssidList = statusDetails.getActiveBSSIDs();
List<ActiveBSSID> toBeDeleted = new ArrayList<>();
for (OpensyncAPVIFState vifState : vifStateTables) {
bssidList.clear();
if (bssidList != null) {
for (ActiveBSSID activeBSSID : bssidList) {
if (activeBSSID.getBssid().equals(vifState.getMac())
&& activeBSSID.getSsid().equals(vifState.getSsid())) {
toBeDeleted.add(activeBSSID);
}
}
}
}
bssidList.removeAll(toBeDeleted);
statusDetails.setActiveBSSIDs(bssidList);
@@ -2792,16 +2842,16 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
private static int[] toIntArray(List<Integer> values) {
if (values != null) {
int returnValue[] = new int[values.size()];
int index = 0;
if (values != null) {
int returnValue[] = new int[values.size()];
int index = 0;
for (Integer value : values) {
returnValue[index++] = value;
}
for (Integer value : values) {
returnValue[index++] = value;
}
return returnValue;
}
return returnValue;
}
return null;
}

View File

@@ -645,48 +645,27 @@ public class OpensyncExternalIntegrationCloudTest {
public void testWifiRadioStatusDbTableUpdate() {
String apId = "Test_Client_21P10C68818122";
OpensyncAPVIFState vifState1 = new OpensyncAPVIFState();
vifState1.setMac("24:f5:a2:ef:2e:54");
vifState1.setSsid("ssid-1");
Uuid uuid1 = Uuid.of(UUID.randomUUID());
vifState1.setAssociatedClients(ImmutableList.of(uuid1));
OpensyncAPRadioState radioState1 = new OpensyncAPRadioState();
radioState1.setChannel(6);
radioState1.setVifStates(ImmutableList.of(vifState1));
radioState1.setVifStates(ImmutableSet.of(new Uuid(UUID.randomUUID())));
radioState1.setFreqBand(RadioType.is5GHzL);
radioState1.setAllowedChannels(ImmutableSet.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));
radioState1.setTxPower(32);
radioState1.setEnabled(true);
radioState1.setCountry("CA");
OpensyncAPVIFState vifState2 = new OpensyncAPVIFState();
vifState2.setMac("24:f5:a2:ef:2e:55");
vifState2.setSsid("ssid-2");
Uuid uuid2 = Uuid.of(UUID.randomUUID());
vifState2.setAssociatedClients(ImmutableList.of(uuid2));
OpensyncAPRadioState radioState2 = new OpensyncAPRadioState();
radioState2.setChannel(36);
radioState2.setVifStates(ImmutableList.of(vifState2));
radioState2.setVifStates(ImmutableSet.of(new Uuid(UUID.randomUUID())));
radioState2.setFreqBand(RadioType.is5GHzL);
radioState2.setAllowedChannels(ImmutableSet.of(36, 40, 44, 48, 52, 56, 60, 64));
radioState2.setTxPower(32);
radioState2.setEnabled(true);
radioState2.setCountry("CA");
OpensyncAPVIFState vifState3 = new OpensyncAPVIFState();
vifState3.setMac("24:f5:a2:ef:2e:56");
vifState3.setSsid("ssid-3");
Uuid uuid3 = Uuid.of(UUID.randomUUID());
vifState3.setAssociatedClients(ImmutableList.of(uuid3));
OpensyncAPRadioState radioState3 = new OpensyncAPRadioState();
radioState3.setChannel(149);
radioState3.setVifStates(ImmutableList.of(vifState3));
radioState3.setVifStates(ImmutableSet.of(new Uuid(UUID.randomUUID())));
radioState3.setFreqBand(RadioType.is5GHzL);
radioState3.setAllowedChannels(
ImmutableSet.of(00, 104, 108, 112, 116, 132, 136, 140, 144, 149, 153, 157, 161, 165));

View File

@@ -48,7 +48,7 @@ public class OpensyncAPRadioState extends BaseJsonModel {
public Map<String, String> hwParams;
public RadioType freqBand;
public int thermalIntegration;
public List<OpensyncAPVIFState> vifStates;
public Set<Uuid> vifStates;
public OpensyncAPRadioState() {
super();
@@ -56,7 +56,7 @@ public class OpensyncAPRadioState extends BaseJsonModel {
hwConfig = new HashMap<>();
channels = new HashMap<>();
hwParams = new HashMap<>();
vifStates = new ArrayList<>();
vifStates = new HashSet<>();
}
public String channelMode;
@@ -103,11 +103,11 @@ public class OpensyncAPRadioState extends BaseJsonModel {
this.mac = mac;
}
public List<OpensyncAPVIFState> getVifStates() {
public Set<Uuid> getVifStates() {
return vifStates;
}
public void setVifStates(List<OpensyncAPVIFState> vifStates) {
public void setVifStates(Set<Uuid> vifStates) {
this.vifStates = vifStates;
}

View File

@@ -2,7 +2,6 @@ package com.telecominfraproject.wlan.opensync.ovsdb;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
@@ -352,12 +351,13 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
CompletableFuture<TableUpdates> awCf = ovsdbClient
.monitor(OvsdbDao.ovsdbName, OvsdbDao.awlanNodeDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.awlanNodeDbTable,
new MonitorRequest(new MonitorSelect(true, false, false, true)))),
new MonitorRequest(new MonitorSelect(false, false, false, true)))),
new MonitorCallback() {
@Override
public void update(TableUpdates tableUpdates) {
LOG.info("Monitor callback received {}", tableUpdates);
LOG.info(OvsdbDao.awlanNodeDbTable + "_" + key + " monitor callback received {}",
tableUpdates);
extIntegrationInterface.awlanNodeDbTableUpdate(
ovsdbDao.getOpensyncAWLANNode(tableUpdates, key, ovsdbClient), key);
@@ -365,8 +365,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
});
extIntegrationInterface.awlanNodeDbTableUpdate(ovsdbDao.getOpensyncAWLANNode(awCf.join(), key, ovsdbClient),
key);
awCf.join();
}
@@ -374,80 +373,81 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
CompletableFuture<TableUpdates> acCf = ovsdbClient
.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiAssociatedClientsDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable,
new MonitorRequest(new MonitorSelect(true, true, false, true)))),
new MonitorRequest(new MonitorSelect(false, true, false, true)))),
new MonitorCallback() {
@Override
public void update(TableUpdates tableUpdates) {
LOG.info("Monitor callback received {}", tableUpdates);
LOG.info(OvsdbDao.wifiAssociatedClientsDbTable + "_" + key
+ " monitor callback received {}", tableUpdates);
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(
ovsdbDao.getOpensyncWifiAssociatedClients(tableUpdates, key, ovsdbClient), key);
extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(
ovsdbDao.getOpensyncWifiAssociatedClients(tableUpdates, key, ovsdbClient),
key);
}
}
});
extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(
ovsdbDao.getOpensyncWifiAssociatedClients(acCf.join(), key, ovsdbClient), key);
acCf.join();
}
private void monitorWifiInetStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
CompletableFuture<TableUpdates> isCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
OvsdbDao.wifiInetStateDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiInetStateDbTable,
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
new MonitorCallback() {
CompletableFuture<TableUpdates> isCf = ovsdbClient
.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiInetStateDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiInetStateDbTable,
new MonitorRequest(new MonitorSelect(false, true, true, true)))),
new MonitorCallback() {
@Override
public void update(TableUpdates tableUpdates) {
LOG.info("Monitor callback received {}", tableUpdates);
@Override
public void update(TableUpdates tableUpdates) {
LOG.info(OvsdbDao.ovsdbName,
OvsdbDao.wifiInetStateDbTable + "_" + key + " monitor callback received {}",
tableUpdates);
extIntegrationInterface.wifiInetStateDbTableUpdate(
ovsdbDao.getOpensyncAPInetState(tableUpdates, key, ovsdbClient), key);
extIntegrationInterface.wifiInetStateDbTableUpdate(
ovsdbDao.getOpensyncAPInetState(tableUpdates, key, ovsdbClient), key);
}
}
});
});
isCf.join();
extIntegrationInterface
.wifiInetStateDbTableUpdate(ovsdbDao.getOpensyncAPInetState(isCf.join(), key, ovsdbClient), key);
}
private void monitorWifiRadioStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
CompletableFuture<TableUpdates> rsCf = ovsdbClient
.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiRadioStateDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable,
new MonitorRequest(new MonitorSelect(true, false, false, true)))),
new MonitorRequest(new MonitorSelect(false, false, false, true)))),
new MonitorCallback() {
@Override
public void update(TableUpdates tableUpdates) {
LOG.info("Monitor callback received {}", tableUpdates);
LOG.info(OvsdbDao.wifiRadioStateDbTable + "_" + key + " monitor callback received {}",
tableUpdates);
extIntegrationInterface.wifiRadioStatusDbTableUpdate(
ovsdbDao.getOpensyncAPRadioState(tableUpdates, key, ovsdbClient), key);
}
});
extIntegrationInterface
.wifiRadioStatusDbTableUpdate(ovsdbDao.getOpensyncAPRadioState(rsCf.join(), key, ovsdbClient), key);
rsCf.join();
}
private void monitorWifiVifStateDbTableDeletion(OvsdbClient ovsdbClient, String key) throws OvsdbClientException {
CompletableFuture<TableUpdates> vsdCf = ovsdbClient
.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiVifStateDbTable + "_delete_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable,
new MonitorRequest(new MonitorSelect(true, false, true, false)))),
new MonitorRequest(new MonitorSelect(false, false, true, false)))),
new MonitorCallback() {
@Override
public void update(TableUpdates tableUpdates) {
LOG.info("Monitor callback received {}", tableUpdates);
LOG.info(OvsdbDao.wifiVifStateDbTable + "_delete_" + key
+ " monitor callback received {}", tableUpdates);
// extIntegrationInterface.wifiVIFStateDbTableUpdate(
// ovsdbDao.getOpensyncAPVIFState(tableUpdates,
@@ -458,8 +458,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
for (Entry<UUID, RowUpdate> rowUpdate : tableUpdate.getValue().getRowUpdates()
.entrySet()) {
if ((rowUpdate.getValue().getOld() != null)
&& (rowUpdate.getValue().getNew() == null)) {
if ((rowUpdate.getValue().getOld() != null)) {
Row row = rowUpdate.getValue().getOld();
String ifName = null;
String ssid = null;
@@ -506,12 +505,13 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
CompletableFuture<TableUpdates> acdCf = ovsdbClient
.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiAssociatedClientsDbTable + "_delete_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable,
new MonitorRequest(new MonitorSelect(true, false, true, false)))),
new MonitorRequest(new MonitorSelect(false, false, true, false)))),
new MonitorCallback() {
@Override
public void update(TableUpdates tableUpdates) {
LOG.info("Monitor callback received {}", tableUpdates);
LOG.info(OvsdbDao.wifiAssociatedClientsDbTable + "_delete_" + key
+ " monitor callback received {}", tableUpdates);
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
@@ -536,11 +536,13 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
CompletableFuture<TableUpdates> vsCf = ovsdbClient
.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiVifStateDbTable + "_" + key,
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable,
new MonitorRequest(new MonitorSelect(true, true, false, true)))),
new MonitorRequest(new MonitorSelect(false, true, false, true)))),
new MonitorCallback() {
@Override
public void update(TableUpdates tableUpdates) {
LOG.info("Monitor callback received {}", tableUpdates);
LOG.info(OvsdbDao.wifiVifStateDbTable + "_" + key + " monitor callback received {}",
tableUpdates);
List<OpensyncAPVIFState> vifStates = ovsdbDao.getOpensyncAPVIFState(tableUpdates, key,
ovsdbClient);
LOG.info("Calling wifiVIFStateDbTableUpdate for {}, {}", vifStates, key);
@@ -550,8 +552,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
});
extIntegrationInterface.wifiVIFStateDbTableUpdate(ovsdbDao.getOpensyncAPVIFState(vsCf.join(), key, ovsdbClient),
key);
vsCf.join();
}

View File

@@ -608,10 +608,7 @@ public class OvsdbDao {
/**
* @param ovsdbClient
* @param value
* of reporting_interval column for the stats_type=device from
* the Wifi_Stats_Config table. If value is not provisioned then
* return -1.
*
*/
public void enableNetworkProbeForSyntheticClient(OvsdbClient ovsdbClient) {
LOG.debug("Enable network_probe metrics for synthetic client");
@@ -735,35 +732,6 @@ public class OvsdbDao {
return ret;
}
public void getWifiVIFsForRadioByUuid(OvsdbClient ovsdbClient, List<OpensyncAPVIFState> vifList, Uuid uuid) {
List<Operation> operations = new ArrayList<>();
List<Condition> conditions = new ArrayList<>();
conditions.add(new Condition("_uuid", Function.EQUALS, new Atom<>(uuid)));
operations.add(new Select(wifiVifStateDbTable, conditions));
try {
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
if ((result != null) && (result.length > 0) && result[0] instanceof SelectResult
&& !((SelectResult) result[0]).getRows().isEmpty()) {
Row row = ((SelectResult) result[0]).getRows().iterator().next();
OpensyncAPVIFState tableState = processWifiVIFStateColumn(ovsdbClient, row, false);
vifList.add(tableState);
}
} catch (Exception e) {
LOG.info("Could not get Wifi_VIF_State for UUID {}. {}", uuid, e.getMessage());
}
}
private OpensyncAPVIFState processWifiVIFStateColumn(OvsdbClient ovsdbClient, Row row, boolean update) {
OpensyncAPVIFState tableState = new OpensyncAPVIFState();
@@ -1201,7 +1169,7 @@ public class OvsdbDao {
wifiVifConfigInfo.macList = row.getSetColumn("mac_list");
if (row.getColumns().get("mac_list_type") != null && row.getColumns().get("mac_list_type").getClass()
if ((row.getColumns().get("mac_list_type") != null) && row.getColumns().get("mac_list_type").getClass()
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
wifiVifConfigInfo.macListType = row.getStringColumn("mac_list_type");
}
@@ -1640,7 +1608,6 @@ public class OvsdbDao {
}
}
// Now clean up references in the vif_configs columns
operations = new ArrayList<>();
Map<String, Value> updateColumns = new HashMap<>();
@@ -1770,14 +1737,20 @@ public class OvsdbDao {
enabled, ht_mode, txPower);
} catch (OvsdbClientException e) {
LOG.error("ConfigureWifiRadios failed with OvsdbClient exception.", e);
throw new RuntimeException(e);
} catch (TimeoutException e) {
LOG.error("ConfigureWifiRadios failed with Timeout.", e);
throw new RuntimeException(e);
} catch (ExecutionException e) {
LOG.error("ConfigureWifiRadios excecution failed.", e);
throw new RuntimeException(e);
} catch (InterruptedException e) {
LOG.error("ConfigureWifiRadios interrupted.", e);
throw new RuntimeException(e);
}
}
@@ -1882,14 +1855,7 @@ public class OvsdbDao {
}
Set<Uuid> vifStates = row.getSetColumn("vif_states");
List<OpensyncAPVIFState> vifStatesList = new ArrayList<>();
if (vifStates != null) {
for (Uuid uuid : vifStates) {
getWifiVIFsForRadioByUuid(ovsdbClient, vifStatesList, uuid);
}
}
tableState.setVifStates(vifStatesList);
tableState.setVifStates(vifStates);
ret.add(tableState);
}
@@ -1905,6 +1871,8 @@ public class OvsdbDao {
} catch (Exception e) {
LOG.error("Could not parse update for Wifi_Radio_State", e);
throw new RuntimeException(e);
}
return ret;
@@ -1979,6 +1947,8 @@ public class OvsdbDao {
} catch (Exception e) {
LOG.error("Could not parse update for Wifi_Inet_State", e);
throw new RuntimeException(e);
}
return ret;
}
@@ -2014,6 +1984,7 @@ public class OvsdbDao {
} catch (Exception e) {
LOG.error("Could not parse update for Wifi_VIF_State", e);
throw new RuntimeException(e);
}
return ret;
@@ -2069,6 +2040,8 @@ public class OvsdbDao {
});
} catch (Exception e) {
LOG.error("Could not get Wifi_Associated_Clients list from table update", e);
throw new RuntimeException(e);
}
return ret;
@@ -2194,6 +2167,8 @@ public class OvsdbDao {
}
} catch (Exception e) {
LOG.error("Failed to handle AWLAN_Node update", e);
throw new RuntimeException(e);
}
return tableState;
@@ -2357,7 +2332,7 @@ public class OvsdbDao {
private void updateBlockList(Map<String, Value> updateColumns, List<MacAddress> macBlockList) {
if (macBlockList != null && !macBlockList.isEmpty()) {
if ((macBlockList != null) && !macBlockList.isEmpty()) {
updateColumns.put("mac_list_type", new Atom<>("blacklist"));
Set<Atom<String>> atomMacList = new HashSet<>();
for (MacAddress mac : macBlockList) {
@@ -2495,8 +2470,8 @@ public class OvsdbDao {
int clientDlLimit = 0;
int clientUlLimit = 0;
if ((ssidConfig.getBandwidthLimitDown() != null && ssidConfig.getBandwidthLimitUp() > 0)
|| (ssidConfig.getBandwidthLimitUp() != null && ssidConfig.getBandwidthLimitUp() > 0)) {
if (((ssidConfig.getBandwidthLimitDown() != null) && (ssidConfig.getBandwidthLimitUp() > 0))
|| ((ssidConfig.getBandwidthLimitUp() != null) && (ssidConfig.getBandwidthLimitUp() > 0))) {
rateLimitEnable = true;
ssidUlLimit = ssidConfig.getBandwidthLimitUp();
ssidDlLimit = ssidConfig.getBandwidthLimitDown();
@@ -2509,25 +2484,25 @@ public class OvsdbDao {
String ifName = null;
String radioName = null;
for (Entry<String, WifiRadioConfigInfo> entry : provisionedRadioConfigs.entrySet()) {
if (radioType == RadioType.is2dot4GHz && entry.getValue().freqBand.equals("2.4G")) {
if ((radioType == RadioType.is2dot4GHz) && entry.getValue().freqBand.equals("2.4G")) {
freqBand = "2.4G";
radioName = entry.getKey();
break;
} else if (radioType == RadioType.is5GHzL && entry.getValue().freqBand.equals("5GL")) {
} else if ((radioType == RadioType.is5GHzL) && entry.getValue().freqBand.equals("5GL")) {
freqBand = "5GL";
radioName = entry.getKey();
break;
} else if (radioType == RadioType.is5GHzU && entry.getValue().freqBand.equals("5GU")) {
} else if ((radioType == RadioType.is5GHzU) && entry.getValue().freqBand.equals("5GU")) {
freqBand = "5GU";
radioName = entry.getKey();
break;
} else if (radioType == RadioType.is5GHz && entry.getValue().freqBand.equals("5G")) {
} else if ((radioType == RadioType.is5GHz) && entry.getValue().freqBand.equals("5G")) {
freqBand = "5G";
radioName = entry.getKey();
break;
}
}
if (radioName == null || freqBand == null) {
if ((radioName == null) || (freqBand == null)) {
LOG.debug("Cannot provision SSID with radio if_name {} and freqBand {}", radioName, freqBand);
continue;
}
@@ -2726,9 +2701,10 @@ public class OvsdbDao {
private void getCaptiveConfiguration(OpensyncAPConfig opensyncApConfig, SsidConfiguration ssidConfig,
Map<String, String> captiveMap, List<String> walledGardenAllowlist) {
if (ssidConfig.getCaptivePortalId() != null && opensyncApConfig.getCaptiveProfiles() != null) {
if ((ssidConfig.getCaptivePortalId() != null) && (opensyncApConfig.getCaptiveProfiles() != null)) {
for (Profile profileCaptive : opensyncApConfig.getCaptiveProfiles()) {
if (ssidConfig.getCaptivePortalId() == profileCaptive.getId() && profileCaptive.getDetails() != null) {
if ((ssidConfig.getCaptivePortalId() == profileCaptive.getId())
&& (profileCaptive.getDetails() != null)) {
CaptivePortalConfiguration captiveProfileDetails = ((CaptivePortalConfiguration) profileCaptive
.getDetails());
captiveMap.put("sessionTimeoutInMinutes",
@@ -2755,7 +2731,7 @@ public class OvsdbDao {
}
private String getCaptiveManagedFileUrl(String fileDesc, ManagedFileInfo fileInfo) {
if (fileInfo == null || fileInfo.getApExportUrl() == null) {
if ((fileInfo == null) || (fileInfo.getApExportUrl() == null)) {
return "";
}
if (fileInfo.getApExportUrl().startsWith(HTTP)) {
@@ -3158,6 +3134,8 @@ public class OvsdbDao {
} catch (Exception e) {
LOG.error("Could not download firmware {} to AP {}", firmwareVersion, apId, e);
throw new RuntimeException(e);
}
}
@@ -3183,6 +3161,8 @@ public class OvsdbDao {
} catch (Exception e) {
LOG.error("Could not configure timer for flashing firmware {} on AP {}", firmwareVersion, apId, e);
throw new RuntimeException(e);
}
}
@@ -3217,7 +3197,12 @@ public class OvsdbDao {
Map<String, WifiRadioConfigInfo> radioConfigs = getProvisionedWifiRadioConfigs(ovsdbClient);
Map<String, String> radioIfNameMap = new HashMap<>();
radioConfigs.entrySet().stream().forEach(e -> radioIfNameMap.put(e.getValue().freqBand, e.getKey()));
radioConfigs.entrySet().stream().forEach(new Consumer<Entry<String, WifiRadioConfigInfo>>() {
@Override
public void accept(Entry<String, WifiRadioConfigInfo> e) {
radioIfNameMap.put(e.getValue().freqBand, e.getKey());
}
});
ApElementConfiguration apElementConfig = (ApElementConfiguration) opensyncApConfig.getCustomerEquipment()
.getDetails();
@@ -3265,14 +3250,19 @@ public class OvsdbDao {
managementRate);
} catch (OvsdbClientException e) {
LOG.error("configureRrm failed with OvsdbClient exception.", e);
throw new RuntimeException(e);
} catch (TimeoutException e) {
LOG.error("configureRrm failed with Timeout.", e);
throw new RuntimeException(e);
} catch (ExecutionException e) {
LOG.error("configureRrm excecution failed.", e);
throw new RuntimeException(e);
} catch (InterruptedException e) {
LOG.error("configureRrm interrupted.", e);
throw new RuntimeException(e);
}
}