diff --git a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java index 7ded2b5..aa44b0c 100644 --- a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java +++ b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java @@ -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 avgNoiseFloor = new HashMap<>(); - Map radioUtilization = new HashMap<>(); + new HashMap<>(); Map 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,55 +1180,58 @@ 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; - + EquipmentCapacityDetails cap = new EquipmentCapacityDetails(); cap.setUnavailableCapacity(totalNonWifi.intValue()); int avaiCapacity = 100 - totalNonWifi.intValue(); cap.setAvailableCapacity(avaiCapacity); cap.setUsedCapacity(totalUtilization.intValue()); 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); } } new RadioStatistics(); populateNetworkProbeMetrics(report, apNodeMetrics); - + radioUtilizationReport.setAvgNoiseFloor(avgNoiseFloor); radioUtilizationReport.setCapacityDetails(capacityDetails); - + updateDeviceStatusRadioUtilizationReport(customerId, 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); - - 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); - - statusServiceInterface.update(radioUtilizationStatus); - } + + 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); + + 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); + + statusServiceInterface.update(radioUtilizationStatus); + } void populateNetworkProbeMetrics(Report report, ApNodeMetrics apNodeMetrics) { List networkProbeMetricsList = new ArrayList<>(); @@ -1238,51 +1240,62 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra NetworkProbeMetrics networkProbeMetrics = new NetworkProbeMetrics(); + List 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 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); + } } } @@ -1601,7 +1623,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra if (client.getDurationMs() > 0) { clientSessionDetails.setMetricDetails(calculateClientSessionMetricDetails(client, timestamp)); - + } clientSession.getDetails().mergeSession(clientSessionDetails); clientSession = clientServiceInterface.updateSession(clientSession); @@ -1639,9 +1661,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra private ClientSessionMetricDetails calculateClientSessionMetricDetails(sts.OpensyncStats.Client client, long timestamp) { - + LOG.debug("calculateClientSessionMetricDetails for Client {} at timestamp {}", client, timestamp); - + ClientSessionMetricDetails metricDetails = new ClientSessionMetricDetails(); metricDetails.setRssi(getNegativeSignedIntFromUnsigned(client.getStats().getRssi())); metricDetails.setRxBytes(client.getStats().getRxBytes()); @@ -1799,12 +1821,12 @@ 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; } - + int getNegativeSignedIntFrom8BitUnsigned(int unsignedValue) { byte b = (byte) Integer.parseInt(Integer.toHexString(unsignedValue), 16); return b; @@ -1887,7 +1909,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra channelInfoList = new ArrayList<>(); } channelInfoList.add(channelInfo); - Map> channelInfoMap = channelInfoReports.getChannelInformationReportsPerRadio(); + Map> 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> channelInfoMap = channelInfoReports.getChannelInformationReportsPerRadio(); + Map> channelInfoMap = channelInfoReports + .getChannelInformationReportsPerRadio(); channelInfoMap.put(radioType, channelInfoList); channelInfoReports.setChannelInformationReportsPerRadio(channelInfoMap); } @@ -1924,12 +1948,13 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra int[] noiseArray = new int[surveySampleList.size()]; int index = 0; for (SurveySample sample : surveySampleList) { - + busyTx += sample.getBusyTx(); 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 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 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 bssidList = statusDetails.getActiveBSSIDs(); + List 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); @@ -2790,18 +2840,18 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra } } - + private static int[] toIntArray(List 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; } diff --git a/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloudTest.java b/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloudTest.java index 352cb9d..3a3a589 100644 --- a/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloudTest.java +++ b/opensync-ext-cloud/src/test/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloudTest.java @@ -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)); diff --git a/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/models/OpensyncAPRadioState.java b/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/models/OpensyncAPRadioState.java index c3ee39d..f96a315 100644 --- a/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/models/OpensyncAPRadioState.java +++ b/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/models/OpensyncAPRadioState.java @@ -48,7 +48,7 @@ public class OpensyncAPRadioState extends BaseJsonModel { public Map hwParams; public RadioType freqBand; public int thermalIntegration; - public List vifStates; + public Set 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 getVifStates() { + public Set getVifStates() { return vifStates; } - public void setVifStates(List vifStates) { + public void setVifStates(Set vifStates) { this.vifStates = vifStates; } diff --git a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/TipWlanOvsdbClient.java b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/TipWlanOvsdbClient.java index 0004ea3..c16f0a7 100644 --- a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/TipWlanOvsdbClient.java +++ b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/TipWlanOvsdbClient.java @@ -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 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 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 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 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 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 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 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 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 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 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(); } diff --git a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDao.java b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDao.java index 55d64ec..59d024b 100644 --- a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDao.java +++ b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/dao/OvsdbDao.java @@ -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 vifList, Uuid uuid) { - List operations = new ArrayList<>(); - List conditions = new ArrayList<>(); - - conditions.add(new Condition("_uuid", Function.EQUALS, new Atom<>(uuid))); - operations.add(new Select(wifiVifStateDbTable, conditions)); - - try { - CompletableFuture 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"); } @@ -1623,7 +1591,7 @@ public class OvsdbDao { LOG.debug("Op Result {}", res); } } - + operations = new ArrayList<>(); List conditions = new ArrayList<>(); conditions.add(new Condition("if_type", Function.EQUALS, new Atom<>("vif"))); @@ -1640,7 +1608,6 @@ public class OvsdbDao { } } - // Now clean up references in the vif_configs columns operations = new ArrayList<>(); Map 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 vifStates = row.getSetColumn("vif_states"); - List 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 updateColumns, List macBlockList) { - if (macBlockList != null && !macBlockList.isEmpty()) { + if ((macBlockList != null) && !macBlockList.isEmpty()) { updateColumns.put("mac_list_type", new Atom<>("blacklist")); Set> 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 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 captiveMap, List 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 radioConfigs = getProvisionedWifiRadioConfigs(ovsdbClient); Map radioIfNameMap = new HashMap<>(); - radioConfigs.entrySet().stream().forEach(e -> radioIfNameMap.put(e.getValue().freqBand, e.getKey())); + radioConfigs.entrySet().stream().forEach(new Consumer>() { + @Override + public void accept(Entry 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); + } }