From 82332611ce3aa48070bab869d298a9e3d17beb3c Mon Sep 17 00:00:00 2001 From: Mike Hansen Date: Tue, 23 Jun 2020 17:46:31 -0400 Subject: [PATCH] Retrieve Radio State information on initial AP connect --- .../OpensyncExternalIntegrationCloud.java | 270 +++--- .../OpensyncCloudGatewayController.java | 147 +-- .../integration/models/ConnectNodeInfo.java | 31 +- .../opensync/mqtt/OpensyncMqttClient.java | 343 +++---- .../opensync/ovsdb/ConnectusOvsdbClient.java | 36 +- .../wlan/opensync/ovsdb/dao/OvsdbDao.java | 856 ++++++++++-------- 6 files changed, 911 insertions(+), 772 deletions(-) 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 4c649d0..36a9faf 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 @@ -9,6 +9,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.Callable; +import java.util.function.Consumer; import javax.annotation.PostConstruct; @@ -39,7 +40,6 @@ import com.telecominfraproject.wlan.core.model.equipment.RadioType; import com.telecominfraproject.wlan.customer.models.Customer; import com.telecominfraproject.wlan.customer.service.CustomerServiceInterface; import com.telecominfraproject.wlan.datastore.exceptions.DsConcurrentModificationException; -import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException; import com.telecominfraproject.wlan.equipment.EquipmentServiceInterface; import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration; import com.telecominfraproject.wlan.equipment.models.Equipment; @@ -48,7 +48,6 @@ import com.telecominfraproject.wlan.firmware.FirmwareServiceInterface; import com.telecominfraproject.wlan.firmware.models.CustomerFirmwareTrackRecord; import com.telecominfraproject.wlan.firmware.models.CustomerFirmwareTrackSettings; import com.telecominfraproject.wlan.firmware.models.CustomerFirmwareTrackSettings.TrackFlag; -import com.telecominfraproject.wlan.firmware.models.FirmwareVersion; import com.telecominfraproject.wlan.location.models.Location; import com.telecominfraproject.wlan.location.service.LocationServiceInterface; import com.telecominfraproject.wlan.opensync.external.integration.controller.OpensyncCloudGatewayController; @@ -115,10 +114,6 @@ import sts.OpensyncStats.Neighbor; import sts.OpensyncStats.Neighbor.NeighborBss; import sts.OpensyncStats.RadioBandType; import sts.OpensyncStats.Report; -import sts.OpensyncStats.RssiPeer; -import sts.OpensyncStats.RssiPeer.RssiSample; -import sts.OpensyncStats.RssiPeer.RssiSource; -import sts.OpensyncStats.RssiReport; import sts.OpensyncStats.Survey; import sts.OpensyncStats.Survey.SurveySample; import sts.OpensyncStats.SurveyType; @@ -129,7 +124,7 @@ import wc.stats.IpDnsTelemetry.WCStatsReport; @Component public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegrationInterface { - private static final Logger LOG = LoggerFactory.getLogger(OpensyncExternalIntegrationCloud.class); + private static Logger LOG = LoggerFactory.getLogger(OpensyncExternalIntegrationCloud.class); @Autowired private AlarmServiceInterface alarmServiceInterface; @@ -197,6 +192,41 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra return ce; } + private RadioType opensyncFreqBandToRadioType(String osFreqBand) { + + switch (osFreqBand) { + case "2.4G": + return RadioType.is2dot4GHz; + case "5G": + return RadioType.is5GHz; + case "5GL": + return RadioType.is5GHzL; + case "5GU": + return RadioType.is5GHzU; + default: + return RadioType.UNSUPPORTED; + } + + } + + private String radioTypeToOpensyncFrequencyBand(RadioType radioType) { + + switch (radioType) { + case is2dot4GHz: + return "2.4G"; + case is5GHz: + return "5G"; + case is5GHzL: + return "5GL"; + case is5GHzU: + return "5GU"; + default: + return null; + + } + + } + @Override public void apConnected(String apId, ConnectNodeInfo connectNodeInfo) { @@ -208,9 +238,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra CustomerFirmwareTrackRecord custFwTrackRecord = firmwareServiceInterface .getCustomerFirmwareTrackRecord(autoProvisionedCustomerId); if (custFwTrackRecord != null) { - trackSettings = custFwTrackRecord.getSettings(); + trackSettings = CustomerFirmwareTrackSettings.combine(custFwTrackRecord.getSettings(), trackSettings); } - // determine if AP requires FW upgrade before cloud connection/provision + // determine if AP requires FW upgrade before cloud + // connection/provision if (trackSettings.getAutoUpgradeDeprecatedOnBind().equals(TrackFlag.ALWAYS) || trackSettings.getAutoUpgradeUnknownOnBind().equals(TrackFlag.ALWAYS)) { @@ -232,90 +263,69 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra try { if (ce == null) { + + Customer customer = customerServiceInterface.getOrNull(autoProvisionedCustomerId); + if (customer == null) { + customer = new Customer(); + customer.setName("DefaultCustomer"); + customer.setEmail("DefaulCustomer@DefaultEmail.com"); + customer = customerServiceInterface.create(customer); + } + ce = new Equipment(); ce.setEquipmentType(EquipmentType.AP); + ce.setCustomerId(customer.getId()); ce.setInventoryId(apId); ce.setSerial(connectNodeInfo.serialNumber); ce.setDetails(ApElementConfiguration.createWithDefaults()); + ce.setName(apId); + ce.setLocationId(autoProvisionedLocationId); + ce = equipmentServiceInterface.create(ce); ce.setCustomerId(autoProvisionedCustomerId); - ce.setName(apId); - ce.setLocationId(autoProvisionedLocationId); ApElementConfiguration apElementConfig = (ApElementConfiguration) ce.getDetails(); - apElementConfig.setEquipmentModel(connectNodeInfo.model); - apElementConfig.getAdvancedRadioMap().get(RadioType.is2dot4GHz) - .setAutoChannelSelection(StateSetting.disabled); - apElementConfig.getAdvancedRadioMap().get(RadioType.is5GHzL) - .setAutoChannelSelection(StateSetting.disabled); - apElementConfig.getAdvancedRadioMap().get(RadioType.is5GHzU) - .setAutoChannelSelection(StateSetting.disabled); - - apElementConfig.getRadioMap().get(RadioType.is2dot4GHz).setAutoChannelSelection(false); - apElementConfig.getRadioMap().get(RadioType.is5GHzL).setAutoChannelSelection(false); - apElementConfig.getRadioMap().get(RadioType.is5GHzU).setAutoChannelSelection(false); + for (RadioType key : apElementConfig.getRadioMap().keySet()) { + String ovsdbKey = radioTypeToOpensyncFrequencyBand(key); + if (connectNodeInfo.wifiRadioStates.containsKey(ovsdbKey)) { + apElementConfig.getAdvancedRadioMap().get(key) + .setAutoChannelSelection(StateSetting.disabled); + apElementConfig.getRadioMap().get(key).setAutoChannelSelection(false); + } else { + apElementConfig.getAdvancedRadioMap().remove(key); + apElementConfig.getRadioMap().remove(key); + } + } ce.setDetails(apElementConfig); ce = equipmentServiceInterface.update(ce); + Profile ssidProfile = new Profile(); + ssidProfile.setCustomerId(ce.getCustomerId()); + ssidProfile.setName("DefaultSsidApConnected"); + SsidConfiguration ssidConfig = SsidConfiguration.createWithDefaults(); + ssidConfig.setSsid("DefaultSsidApConnected"); + ssidConfig.setSecureMode(SecureMode.wpa2PSK); + ssidConfig.setKeyStr("12345678"); + Set appliedRadios = new HashSet<>(); + appliedRadios.addAll(((ApElementConfiguration) ce.getDetails()).getRadioMap().keySet()); + ssidConfig.setAppliedRadios(appliedRadios); + ssidProfile.setDetails(ssidConfig); + ssidProfile = profileServiceInterface.create(ssidProfile); + Profile apProfile = new Profile(); apProfile.setCustomerId(ce.getCustomerId()); apProfile.setName("DefaultApProfile"); apProfile.setDetails(ApNetworkConfiguration.createWithDefaults()); - apProfile = profileServiceInterface.create(apProfile); - - Profile ssidProfile = new Profile(); - ssidProfile.setCustomerId(ce.getCustomerId()); - ssidProfile.setName("DefaultSsid-2g"); - SsidConfiguration ssidConfig = SsidConfiguration.createWithDefaults(); - ssidConfig.setSsid("DefaultSsid-2g"); - ssidConfig.setSecureMode(SecureMode.wpa2PSK); - ssidConfig.setKeyStr("12345678"); - - Set appliedRadios = new HashSet<>(); - appliedRadios.add(RadioType.is2dot4GHz); - // ssidConfig.getRadioBasedConfigs().get(RadioType.is2dot4GHz).setEnable80211r(true); - - ssidConfig.setAppliedRadios(appliedRadios); - ssidProfile.setDetails(ssidConfig); - ssidProfile = profileServiceInterface.create(ssidProfile); - - Profile ssidProfile5g = new Profile(); - ssidProfile5g.setCustomerId(ce.getCustomerId()); - ssidProfile5g.setName("DefaultSsid-5g"); - SsidConfiguration ssidConfig5g = SsidConfiguration.createWithDefaults(); - ssidConfig5g.setSecureMode(SecureMode.wpa2PSK); - ssidConfig5g.setSsid("DefaultSsid-5g"); - ssidConfig5g.setKeyStr("12345678"); - Set appliedRadios5g = new HashSet<>(); - appliedRadios5g.add(RadioType.is5GHzL); - appliedRadios5g.add(RadioType.is5GHzU); - ssidConfig5g.setAppliedRadios(appliedRadios5g); - // ssidConfig5g.getRadioBasedConfigs().get(RadioType.is5GHzL).setEnable80211r(true); - // ssidConfig5g.getRadioBasedConfigs().get(RadioType.is5GHzU).setEnable80211r(true); - - ssidProfile5g.setDetails(ssidConfig5g); - ssidProfile5g = profileServiceInterface.create(ssidProfile5g); Set childProfileIds = new HashSet<>(); childProfileIds.add(ssidProfile.getId()); - childProfileIds.add(ssidProfile5g.getId()); - apProfile.setChildProfileIds(childProfileIds); + apProfile = profileServiceInterface.create(apProfile); - apProfile = profileServiceInterface.update(apProfile); ce.setProfileId(apProfile.getId()); - ce = equipmentServiceInterface.update(ce); - Customer customer = customerServiceInterface.getOrNull(ce.getCustomerId()); - if (customer == null) { - customer = new Customer(); - customer.setId(autoProvisionedCustomerId); - customerServiceInterface.create(customer); - ce.setCustomerId(customer.getId()); - equipmentServiceInterface.update(ce); - } } EquipmentRoutingRecord equipmentRoutingRecord = gatewayController @@ -405,7 +415,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra } catch (UnknownHostException e) { // do nothing here } - if (connectNodeInfo.macAddress != null && MacAddress.valueOf(connectNodeInfo.macAddress) != null) { + if ((connectNodeInfo.macAddress != null) && (MacAddress.valueOf(connectNodeInfo.macAddress) != null)) { protocolStatusData.setReportedMacAddr(MacAddress.valueOf(connectNodeInfo.macAddress)); } protocolStatusData.setReportedSku(connectNodeInfo.skuNumber); @@ -633,7 +643,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra int customerId = extractCustomerIdFromTopic(topic); long equipmentId = extractEquipmentIdFromTopic(topic); - if (equipmentId <= 0 || customerId <= 0) { + if ((equipmentId <= 0) || (customerId <= 0)) { LOG.warn("Cannot determine equipment ids from topic {} - customerId {} equipmentId {}", topic, customerId, equipmentId); return; @@ -647,13 +657,12 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra populateApNodeMetrics(metricRecordList, report, customerId, equipmentId); populateNeighbourScanReports(metricRecordList, report, customerId, equipmentId); try { - // TODO: depends on survey - // populateChannelInfoReports(metricRecordList, report, customerId, - // equipmentId); + populateChannelInfoReports(metricRecordList, report, customerId, equipmentId); populateApSsidMetrics(metricRecordList, report, customerId, equipmentId, extractApIdFromTopic(topic)); - // handleRssiMetrics(metricRecordList, report, customerId, - // equipmentId); - + /* + * TODO: add when available handleRssiMetrics(metricRecordList, + * report, customerId, equipmentId); + */ } catch (Exception e) { LOG.error("Exception when processing populateApSsidMetrics", e); } @@ -664,31 +673,32 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra } - private void handleRssiMetrics(List metricRecordList, Report report, int customerId, - long equipmentId) { - LOG.debug("handleRssiMetrics for Customer {} Equipment {}", customerId, equipmentId); - - for (RssiReport rssiReport : report.getRssiReportList()) { - - for (RssiPeer peer : rssiReport.getPeerListList()) { - if (peer.getRssiSource().equals(RssiSource.CLIENT)) { - int rssi = 0; - - for (RssiSample sample : peer.getRssiListList()) { - rssi += getNegativeSignedIntFromUnsigned(sample.getRssi()); - LOG.debug("RSSI Sample: unsignedValue {} signedValue {}", sample.getRssi(), - getNegativeSignedIntFromUnsigned(sample.getRssi())); - } - - rssi = rssi / peer.getRssiListCount(); - - LOG.debug("RssiReport::RssiPeer::Band {} RssiPeer MAC {} RssiSamples Avg {} RxPpdus {} TxPpdus {}", - rssiReport.getBand(), peer.getMacAddress(), rssi, peer.getRxPpdus(), peer.getTxPpdus()); - } - } - - } - } + /* + * TODO: when available handle RSSI metric processing private void + * handleRssiMetrics(List metricRecordList, Report report, + * int customerId, long equipmentId) { + * LOG.debug("handleRssiMetrics for Customer {} Equipment {}", customerId, + * equipmentId); + * + * for (RssiReport rssiReport : report.getRssiReportList()) { + * + * for (RssiPeer peer : rssiReport.getPeerListList()) { if + * (peer.getRssiSource().equals(RssiSource.CLIENT)) { int rssi = 0; + * + * for (RssiSample sample : peer.getRssiListList()) { rssi += + * getNegativeSignedIntFromUnsigned(sample.getRssi()); + * LOG.debug("RSSI Sample: unsignedValue {} signedValue {}", + * sample.getRssi(), getNegativeSignedIntFromUnsigned(sample.getRssi())); } + * + * rssi = rssi / peer.getRssiListCount(); + * + * LOG. + * debug("RssiReport::RssiPeer::Band {} RssiPeer MAC {} RssiSamples Avg {} RxPpdus {} TxPpdus {}" + * , rssiReport.getBand(), peer.getMacAddress(), rssi, peer.getRxPpdus(), + * peer.getTxPpdus()); } } + * + * } } + */ private void populateApNodeMetrics(List metricRecordList, Report report, int customerId, long equipmentId) { @@ -890,7 +900,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra ClientMetrics cMetrics = new ClientMetrics(); smr.setDetails(cMetrics); - Integer periodLengthSec = 60; // matches what's configured by + Integer periodLengthSec = 60; // matches what's configured + // by // OvsdbDao.configureStats(OvsdbClient) cMetrics.setPeriodLengthSec(periodLengthSec); @@ -934,7 +945,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra } if (cl.getStats().hasTxRate()) { - cMetrics.setAverageTxRate(Double.valueOf(cl.getStats().getTxRate() / 1000)); + cMetrics.setAverageTxRate(cl.getStats().getTxRate() / 1000); } if (cl.getStats().hasTxRate() && cl.getStats().hasRxRate()) { @@ -1010,7 +1021,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra nr.setMacAddress(new MacAddress(nBss.getBssid())); nr.setNetworkType(NetworkType.AP); nr.setPacketType(NeighborScanPacketType.BEACON); - nr.setPrivacy((nBss.getSsid() == null || nBss.getSsid().isEmpty()) ? true : false); + nr.setPrivacy(((nBss.getSsid() == null) || nBss.getSsid().isEmpty()) ? true : false); // nr.setRate(rate); // we can only get Rssi as an unsigned int from opensync, so // some shifting @@ -1120,8 +1131,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra metricDetails.setTxDataFrames((int) ((int) client.getStats().getTxFrames() - client.getStats().getTxRetries())); metricDetails.setRxDataFrames((int) ((int) client.getStats().getRxFrames() - client.getStats().getRxRetries())); // values reported in Kbps, convert to Mbps - metricDetails.setRxMbps(Float.valueOf((float) (client.getStats().getRxRate() / 1000))); - metricDetails.setTxMbps(Float.valueOf((float) (client.getStats().getTxRate() / 1000))); + metricDetails.setRxMbps((float) (client.getStats().getRxRate() / 1000)); + metricDetails.setTxMbps((float) (client.getStats().getTxRate() / 1000)); metricDetails.setRxRateKbps((long) client.getStats().getRxRate()); metricDetails.setTxRateKbps((long) client.getStats().getTxRate()); return metricDetails; @@ -1187,7 +1198,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra for (Client client : clientReport.getClientListList()) { - if (client.hasSsid() && client.getSsid() != null && !client.getSsid().equals("")) { + if (client.hasSsid() && (client.getSsid() != null) && !client.getSsid().equals("")) { ssid = client.getSsid(); } @@ -1319,15 +1330,18 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra // ChannelInfo entries per surveyed channel Map> sampleByChannelMap = new HashMap<>(); - survey.getSurveyListList().stream().forEach(s -> { - List surveySampleList; - if (sampleByChannelMap.get(s.getChannel()) == null) { - surveySampleList = new ArrayList<>(); - } else { - surveySampleList = sampleByChannelMap.get(s.getChannel()); + survey.getSurveyListList().stream().forEach(new Consumer() { + @Override + public void accept(SurveySample s) { + List surveySampleList; + if (sampleByChannelMap.get(s.getChannel()) == null) { + surveySampleList = new ArrayList<>(); + } else { + surveySampleList = sampleByChannelMap.get(s.getChannel()); + } + surveySampleList.add(s); + sampleByChannelMap.put(s.getChannel(), surveySampleList); } - surveySampleList.add(s); - sampleByChannelMap.put(s.getChannel(), surveySampleList); }); for (List surveySampleList : sampleByChannelMap.values()) { @@ -1383,9 +1397,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra channelInfo.setWifiUtilization(totalWifi); channelInfo.setBandwidth(((ApElementConfiguration) equipmentServiceInterface.get(equipmentId).getDetails()) .getRadioMap().get(radioType).getChannelBandwidth()); - channelInfo.setNoiseFloor(Integer.valueOf(-84)); // TODO: when this - // becomes available - // add + channelInfo.setNoiseFloor(-84); // TODO: when this + // becomes available + // add return channelInfo; } @@ -1396,7 +1410,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra int customerId = extractCustomerIdFromTopic(topic); long equipmentId = extractEquipmentIdFromTopic(topic); - if (equipmentId <= 0 || customerId <= 0) { + if ((equipmentId <= 0) || (customerId <= 0)) { LOG.warn("Cannot determine equipment ids from topic {} - customerId {} equipmentId {}", topic, customerId, equipmentId); return; @@ -1420,7 +1434,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra int customerId = extractCustomerIdFromTopic(topic); long equipmentId = extractEquipmentIdFromTopic(topic); - if (equipmentId <= 0 || customerId <= 0) { + if ((equipmentId <= 0) || (customerId <= 0)) { LOG.warn("Cannot determine equipment ids from topic {} - customerId {} equipmentId {}", topic, customerId, equipmentId); return; @@ -1453,13 +1467,13 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra return; } - if (vifStateTables == null || vifStateTables.isEmpty() || apId == null) { + if ((vifStateTables == null) || vifStateTables.isEmpty() || (apId == null)) { return; } for (OpensyncAPVIFState vifState : vifStateTables) { - if (vifState.getMac() != null && vifState.getSsid() != null && vifState.getChannel() > 0) { + if ((vifState.getMac() != null) && (vifState.getSsid() != null) && (vifState.getChannel() > 0)) { String bssid = vifState.getMac(); String ssid = vifState.getSsid(); @@ -1550,7 +1564,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra int customerId = ovsdbSession.getCustomerId(); long equipmentId = ovsdbSession.getEquipmentId(); - if (customerId < 0 || equipmentId < 0) { + if ((customerId < 0) || (equipmentId < 0)) { LOG.debug("wifiRadioStatusDbTableUpdate::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", customerId, equipmentId, apId); return; @@ -1704,14 +1718,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra return; } - if (inetStateTables == null || inetStateTables.isEmpty() || apId == null) { + if ((inetStateTables == null) || inetStateTables.isEmpty() || (apId == null)) { return; } - for (OpensyncAPInetState inetState : inetStateTables) { - // TODO: implement me - } - } @Override @@ -1738,7 +1748,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra return; } - if (wifiAssociatedClients == null || wifiAssociatedClients.isEmpty() || apId == null) { + if ((wifiAssociatedClients == null) || wifiAssociatedClients.isEmpty() || (apId == null)) { return; } @@ -1757,7 +1767,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra int customerId = ovsdbSession.getCustomerId(); long equipmentId = ovsdbSession.getEquipmentId(); - if (customerId < 0 || equipmentId < 0) { + if ((customerId < 0) || (equipmentId < 0)) { LOG.debug("awlanNodeDbTableUpdate::Cannot get valid CustomerId {} or EquipmentId {} for AP {}", customerId, equipmentId, apId); return; diff --git a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/controller/OpensyncCloudGatewayController.java b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/controller/OpensyncCloudGatewayController.java index 582329b..016264e 100644 --- a/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/controller/OpensyncCloudGatewayController.java +++ b/opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/controller/OpensyncCloudGatewayController.java @@ -10,6 +10,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.function.BiFunction; +import java.util.function.Consumer; import javax.servlet.http.HttpServletRequest; @@ -122,62 +123,66 @@ public class OpensyncCloudGatewayController { return ret; } - commands.stream().forEach(command -> { - LOG.debug("sendCommands - processing {}", command); + commands.stream().forEach(new Consumer() { + @Override + public void accept(CEGWBaseCommand command) { + LOG.debug("sendCommands - processing {}", command); - String inventoryId = command.getInventoryId(); + String inventoryId = command.getInventoryId(); + + if (com.telecominfraproject.wlan.core.model.json.BaseJsonModel.hasUnsupportedValue(command)) { + LOG.error("[{}] Failed to deliver command {}, command contains unsupported value", inventoryId, + command); + ret.add(new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand, + "Unsupported value in command for " + inventoryId, command, registeredGateway.getHostname(), + registeredGateway.getPort())); + return; + } + OvsdbSession session = ovsdbSessionMapInterface.getSession(inventoryId); + if (session == null) { + LOG.warn("[{}] Failed to deliver command {}, equipment session not found", inventoryId, command); + ret.add(new EquipmentCommandResponse(CEGWCommandResultCode.NoRouteToCE, + "No session found for " + inventoryId, command, registeredGateway.getHostname(), + registeredGateway.getPort())); + return; + } + + switch (command.getCommandType()) { + + case ConfigChangeNotification: + ret.add(sendConfigChangeNotification(session, (CEGWConfigChangeNotification) command)); + break; + case CloseSessionRequest: + ret.add(closeSession(session, (CEGWCloseSessionRequest) command)); + break; + case CheckRouting: + ret.add(checkEquipmentRouting(session, (CEGWRouteCheck) command)); + break; + case BlinkRequest: + ret.add(processBlinkRequest(session, (CEGWBlinkRequest) command)); + break; + case StartDebugEngine: + ret.add(processChangeRedirector(session, (CEGWStartDebugEngine) command)); + break; + case FirmwareDownloadRequest: + ret.add(processFirmwareDownload(session, (CEGWFirmwareDownloadRequest) command)); + break; + case FirmwareFlashRequest: + ret.add(processFirmwareFlash(session, (CEGWFirmwareFlashRequest) command)); + break; + case RadioReset: + ret.add(processRadioReset(session, (CEGWRadioResetRequest) command)); + break; + + default: + LOG.warn("[{}] Failed to deliver command {}, unsupported command type", inventoryId, command); + ret.add(new EquipmentCommandResponse( + CEGWCommandResultCode.UnsupportedCommand, "Invalid command type (" + + command.getCommandType() + ") for equipment (" + inventoryId + ")", + command, registeredGateway.getHostname(), registeredGateway.getPort())); + } - if (com.telecominfraproject.wlan.core.model.json.BaseJsonModel.hasUnsupportedValue(command)) { - LOG.error("[{}] Failed to deliver command {}, command contains unsupported value", inventoryId, - command); - ret.add(new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand, - "Unsupported value in command for " + inventoryId, command, registeredGateway.getHostname(), - registeredGateway.getPort())); - return; } - OvsdbSession session = ovsdbSessionMapInterface.getSession(inventoryId); - if (session == null) { - LOG.warn("[{}] Failed to deliver command {}, equipment session not found", inventoryId, command); - ret.add(new EquipmentCommandResponse(CEGWCommandResultCode.NoRouteToCE, - "No session found for " + inventoryId, command, registeredGateway.getHostname(), - registeredGateway.getPort())); - return; - } - - switch (command.getCommandType()) { - - case ConfigChangeNotification: - ret.add(sendConfigChangeNotification(session, (CEGWConfigChangeNotification) command)); - break; - case CloseSessionRequest: - ret.add(closeSession(session, (CEGWCloseSessionRequest) command)); - break; - case CheckRouting: - ret.add(checkEquipmentRouting(session, (CEGWRouteCheck) command)); - break; - case BlinkRequest: - ret.add(processBlinkRequest(session, (CEGWBlinkRequest) command)); - break; - case StartDebugEngine: - ret.add(processChangeRedirector(session, (CEGWStartDebugEngine) command)); - break; - case FirmwareDownloadRequest: - ret.add(processFirmwareDownload(session, (CEGWFirmwareDownloadRequest) command)); - break; - case FirmwareFlashRequest: - ret.add(processFirmwareFlash(session, (CEGWFirmwareFlashRequest) command)); - break; - case RadioReset: - ret.add(processRadioReset(session, (CEGWRadioResetRequest) command)); - break; - - default: - LOG.warn("[{}] Failed to deliver command {}, unsupported command type", inventoryId, command); - ret.add(new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand, - "Invalid command type (" + command.getCommandType() + ") for equipment (" + inventoryId + ")", - command, registeredGateway.getHostname(), registeredGateway.getPort())); - } - }); return ret; @@ -352,9 +357,9 @@ public class OpensyncCloudGatewayController { try { - EquipmentGatewayRecord result = this.eqRoutingSvc.registerGateway(gwRecord); - this.registeredGwId = result.getId(); - this.registeredGateway = result; + EquipmentGatewayRecord result = eqRoutingSvc.registerGateway(gwRecord); + registeredGwId = result.getId(); + registeredGateway = result; LOG.info("Successfully registered (name={}, id={}) with Routing Service", result.getHostname(), registeredGwId); registeredWithRoutingService = true; @@ -383,20 +388,20 @@ public class OpensyncCloudGatewayController { try { eqRoutingSvc.deleteGateway(registeredGwId); LOG.info("Deregistered Customer Equipment Gateway (name={},id={}) with Routing Service", - getGatewayName(), this.registeredGwId); - this.registeredGwId = -1; - this.registeredGateway = null; + getGatewayName(), registeredGwId); + registeredGwId = -1; + registeredGateway = null; } catch (Exception e) { // failed LOG.error("Failed to deregister Customer Equipment Gateway (name={},id={}) with Routing Service: {}", - getGatewayName(), this.registeredGwId, e.getLocalizedMessage()); + getGatewayName(), registeredGwId, e.getLocalizedMessage()); } registeredWithRoutingService = false; } } public long getRegisteredGwId() { - return this.registeredGwId; + return registeredGwId; } /** @@ -418,7 +423,7 @@ public class OpensyncCloudGatewayController { EquipmentRoutingRecord routingRecord = new EquipmentRoutingRecord(); routingRecord.setCustomerId(customerId); routingRecord.setEquipmentId(equipmentId); - routingRecord.setGatewayId(this.registeredGwId); + routingRecord.setGatewayId(registeredGwId); try { routingRecord = eqRoutingSvc.create(routingRecord); @@ -456,7 +461,7 @@ public class OpensyncCloudGatewayController { @Scheduled(initialDelay = 5 * 60 * 1000, fixedRate = 5 * 60 * 1000) public void updateActiveCustomer() { try { - Map activeMap = this.getActiveCustomerMapForUpdate(); + Map activeMap = getActiveCustomerMapForUpdate(); if (null != activeMap) { LOG.info("Updating active customer records, total record size {}", activeMap.size()); // this.eqRoutingSvc.updateActiveCustomer(activeMap, @@ -482,11 +487,11 @@ public class OpensyncCloudGatewayController { * @param customerId */ public void updateActiveCustomer(int customerId) { - this.activeCustomerReadLock.lock(); + activeCustomerReadLock.lock(); try { - this.activeCustomerMap.merge(customerId, System.currentTimeMillis(), latestTimestamp); + activeCustomerMap.merge(customerId, System.currentTimeMillis(), latestTimestamp); } finally { - this.activeCustomerReadLock.unlock(); + activeCustomerReadLock.unlock(); } } @@ -496,17 +501,17 @@ public class OpensyncCloudGatewayController { * @return null if no records. */ protected Map getActiveCustomerMapForUpdate() { - this.activeCustomerWriteLock.lock(); + activeCustomerWriteLock.lock(); try { Map map = null; - if (!this.activeCustomerMap.isEmpty()) { - map = this.activeCustomerMap; - this.activeCustomerMap = new ConcurrentHashMap<>(); + if (!activeCustomerMap.isEmpty()) { + map = activeCustomerMap; + activeCustomerMap = new ConcurrentHashMap<>(); } return map; } finally { - this.activeCustomerWriteLock.unlock(); + activeCustomerWriteLock.unlock(); } } } diff --git a/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/models/ConnectNodeInfo.java b/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/models/ConnectNodeInfo.java index 4ab8ea2..7f12e09 100644 --- a/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/models/ConnectNodeInfo.java +++ b/opensync-ext-interface/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/models/ConnectNodeInfo.java @@ -3,8 +3,9 @@ package com.telecominfraproject.wlan.opensync.external.integration.models; import java.util.HashMap; import java.util.Map; -public class ConnectNodeInfo implements Cloneable{ - public Map mqttSettings; +public class ConnectNodeInfo implements Cloneable { + public Map mqttSettings; + public Map> wifiRadioStates; public String redirectorAddr; public String managerAddr; public String skuNumber; @@ -15,29 +16,35 @@ public class ConnectNodeInfo implements Cloneable{ public String firmwareVersion; public String revision; public String model; - - + public String ifName; + public String ifType; + public String country; + + + @Override public ConnectNodeInfo clone() { try { - ConnectNodeInfo ret = (ConnectNodeInfo)super.clone(); - if (this.mqttSettings!=null) { + ConnectNodeInfo ret = (ConnectNodeInfo) super.clone(); + if (this.mqttSettings != null) { ret.mqttSettings = new HashMap<>(this.mqttSettings); } + if (this.wifiRadioStates != null) { + ret.wifiRadioStates = new HashMap<>(this.wifiRadioStates); + } return ret; - }catch(CloneNotSupportedException e) { + } catch (CloneNotSupportedException e) { throw new IllegalStateException("Cannot clone ", e); - } + } } - @Override public String toString() { return String.format( "ConnectNodeInfo [mqttSettings=%s, redirectorAddr=%s, managerAddr=%s, skuNumber=%s, serialNumber=%s, " - + "macAddress=%s, ipV4Address=%s, platformVersion=%s, firmwareVersion=%s, revision=%s, model=%s]", + + "macAddress=%s, ipV4Address=%s, platformVersion=%s, firmwareVersion=%s, revision=%s, model=%s ifName=%s ifType=%s, wifiRadioStates=%s]", mqttSettings, redirectorAddr, managerAddr, skuNumber, serialNumber, macAddress, ipV4Address, - platformVersion, firmwareVersion, revision, model); + platformVersion, firmwareVersion, revision, model, ifName, ifType, wifiRadioStates); } -} \ No newline at end of file +} diff --git a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/mqtt/OpensyncMqttClient.java b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/mqtt/OpensyncMqttClient.java index b6820b8..a9b4cdf 100644 --- a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/mqtt/OpensyncMqttClient.java +++ b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/mqtt/OpensyncMqttClient.java @@ -38,196 +38,221 @@ import wc.stats.IpDnsTelemetry.WCStatsReport; @Component public class OpensyncMqttClient implements ApplicationListener { - private static final Logger LOG = LoggerFactory.getLogger(OpensyncMqttClient.class); + private static final Logger LOG = LoggerFactory.getLogger(OpensyncMqttClient.class); - private static final Logger MQTT_LOG = LoggerFactory.getLogger("MQTT_DATA"); + private static final Logger MQTT_LOG = LoggerFactory.getLogger("MQTT_DATA"); - public static Charset utf8 = Charset.forName("UTF-8"); + public static Charset utf8 = Charset.forName("UTF-8"); - @Autowired - private OpensyncExternalIntegrationInterface extIntegrationInterface; + @Autowired + private OpensyncExternalIntegrationInterface extIntegrationInterface; - // - // See https://github.com/fusesource/mqtt-client for the docs - // + // + // See https://github.com/fusesource/mqtt-client for the docs + // - private boolean keepReconnecting = true; - private Thread mqttClientThread; + private boolean keepReconnecting = true; + private Thread mqttClientThread; - public OpensyncMqttClient(@Autowired io.netty.handler.ssl.SslContext sslContext, - @Value("${connectus.mqttBroker.address:testportal.123wlan.com}") String mqttBrokerAddress, - @Value("${connectus.mqttBroker.listenPort:1883}") int mqttBrokerListenPort, - @Value("${connectus.mqttBroker.user:admin}") String username, - @Value("${connectus.mqttBroker.password:admin}") String password, - @Value("${mqtt.javax.net.ssl.keyStore:/opt/tip-wlan/certs/client_keystore.jks}") String jdkKeyStoreLocation, - @Value("${mqtt.javax.net.ssl.keyStorePassword:mypassword}") String jdkKeyStorePassword, - @Value("${mqtt.javax.net.ssl.trustStore:/opt/tip-wlan/certs/truststore.jks}") String jdkTrustStoreLocation, - @Value("${mqtt.javax.net.ssl.trustStorePassword:mypassword}") String jdkTrustStorePassword) { + public OpensyncMqttClient(@Autowired io.netty.handler.ssl.SslContext sslContext, + @Value("${connectus.mqttBroker.address:testportal.123wlan.com}") String mqttBrokerAddress, + @Value("${connectus.mqttBroker.listenPort:1883}") int mqttBrokerListenPort, + @Value("${connectus.mqttBroker.user:admin}") String username, + @Value("${connectus.mqttBroker.password:admin}") String password, + @Value("${mqtt.javax.net.ssl.keyStore:/opt/tip-wlan/certs/client_keystore.jks}") String jdkKeyStoreLocation, + @Value("${mqtt.javax.net.ssl.keyStorePassword:mypassword}") String jdkKeyStorePassword, + @Value("${mqtt.javax.net.ssl.trustStore:/opt/tip-wlan/certs/truststore.jks}") String jdkTrustStoreLocation, + @Value("${mqtt.javax.net.ssl.trustStorePassword:mypassword}") String jdkTrustStorePassword) { - if (System.getProperty("javax.net.ssl.keyStore") == null) { - System.setProperty("javax.net.ssl.keyStore", jdkKeyStoreLocation); - } + if (System.getProperty("javax.net.ssl.keyStore") == null) { + System.setProperty("javax.net.ssl.keyStore", jdkKeyStoreLocation); + } - if (System.getProperty("javax.net.ssl.keyStorePassword") == null) { - System.setProperty("javax.net.ssl.keyStorePassword", jdkKeyStorePassword); - } + if (System.getProperty("javax.net.ssl.keyStorePassword") == null) { + System.setProperty("javax.net.ssl.keyStorePassword", jdkKeyStorePassword); + } - if (System.getProperty("javax.net.ssl.trustStore") == null) { - System.setProperty("javax.net.ssl.trustStore", jdkTrustStoreLocation); - } + if (System.getProperty("javax.net.ssl.trustStore") == null) { + System.setProperty("javax.net.ssl.trustStore", jdkTrustStoreLocation); + } - if (System.getProperty("javax.net.ssl.trustStorePassword") == null) { - System.setProperty("javax.net.ssl.trustStorePassword", jdkTrustStorePassword); - } + if (System.getProperty("javax.net.ssl.trustStorePassword") == null) { + System.setProperty("javax.net.ssl.trustStorePassword", jdkTrustStorePassword); + } - Runnable mqttClientRunnable = () -> { - while (keepReconnecting) { - BlockingConnection connection = null; - try { - Thread.sleep(5000); + Runnable mqttClientRunnable = new Runnable() { + @Override + public void run() { + while (keepReconnecting) { + BlockingConnection connection = null; + try { + Thread.sleep(5000); - // Create a new MQTT connection to the broker. - /* - * Using SSL connections If you want to connect over SSL/TLS instead of TCP, use - * an "ssl://" or "tls://" URI prefix instead of "tcp://" for the host field. - * Supported protocol values are: - * - * ssl:// - Use the JVM default version of the SSL algorithm. sslv*:// - Use a - * specific SSL version where * is a version supported by your JVM. Example: - * sslv3 tls:// - Use the JVM default version of the TLS algorithm. tlsv*:// - - * Use a specific TLS version where * is a version supported by your JVM. - * Example: tlsv1.1 The client will use the default JVM SSLContext which is - * configured via JVM system properties unless you configure the MQTT instance - * using the setSslContext method. - * - * SSL connections perform blocking operations against internal thread pool - * unless you call the setBlockingExecutor method to configure that executor - * they will use instead. - * - */ + // Create a new MQTT connection to the broker. + /* + * Using SSL connections If you want to connect over + * SSL/TLS instead of TCP, use an "ssl://" or "tls://" + * URI prefix instead of "tcp://" for the host field. + * Supported protocol values are: + * + * ssl:// - Use the JVM default version of the SSL + * algorithm. sslv*:// - Use a specific SSL version + * where * is a version supported by your JVM. Example: + * sslv3 tls:// - Use the JVM default version of the TLS + * algorithm. tlsv*:// - Use a specific TLS version + * where * is a version supported by your JVM. Example: + * tlsv1.1 The client will use the default JVM + * SSLContext which is configured via JVM system + * properties unless you configure the MQTT instance + * using the setSslContext method. + * + * SSL connections perform blocking operations against + * internal thread pool unless you call the + * setBlockingExecutor method to configure that executor + * they will use instead. + * + */ - MQTT mqtt = new MQTT(); - // mqtt.setHost("tcp://192.168.0.137:61616"); - mqtt.setHost("tls://" + mqttBrokerAddress + ":" + mqttBrokerListenPort); - LOG.info("Connecting to MQTT broker at {}", mqtt.getHost()); - mqtt.setClientId("opensync_mqtt"); - mqtt.setUserName(username); - mqtt.setPassword(password); - // Note: the following does not work with the serverContext, it has to be the - // clientContext - // mqtt.setSslContext(((JdkSslContext) sslContext).context()); - // For now we'll rely on regular SSLContext from the JDK + MQTT mqtt = new MQTT(); + // mqtt.setHost("tcp://192.168.0.137:61616"); + mqtt.setHost("tls://" + mqttBrokerAddress + ":" + mqttBrokerListenPort); + LOG.info("Connecting to MQTT broker at {}", mqtt.getHost()); + mqtt.setClientId("opensync_mqtt"); + mqtt.setUserName(username); + mqtt.setPassword(password); + // Note: the following does not work with the + // serverContext, + // it has to be the + // clientContext + // mqtt.setSslContext(((JdkSslContext) + // sslContext).context()); + // For now we'll rely on regular SSLContext from the JDK - // TODO: revisit this blocking connection, change it to futureConnection - connection = mqtt.blockingConnection(); - connection.connect(); - LOG.info("Connected to MQTT broker at {}", mqtt.getHost()); + // TODO: revisit this blocking connection, change it to + // futureConnection + connection = mqtt.blockingConnection(); + connection.connect(); + LOG.info("Connected to MQTT broker at {}", mqtt.getHost()); - // Subscribe to topics: - // - // new Topic("mqtt/example/publish", QoS.AT_LEAST_ONCE), - // new Topic("#", QoS.AT_LEAST_ONCE), - // new Topic("test/#", QoS.EXACTLY_ONCE), - // new Topic("foo/+/bar", QoS.AT_LEAST_ONCE) - Topic[] topics = { new Topic("#", QoS.AT_LEAST_ONCE), }; + // Subscribe to topics: + // + // new Topic("mqtt/example/publish", QoS.AT_LEAST_ONCE), + // new Topic("#", QoS.AT_LEAST_ONCE), + // new Topic("test/#", QoS.EXACTLY_ONCE), + // new Topic("foo/+/bar", QoS.AT_LEAST_ONCE) + Topic[] topics = { new Topic("#", QoS.AT_LEAST_ONCE), }; - connection.subscribe(topics); - LOG.info("Subscribed to mqtt topics {}", Arrays.asList(topics)); + connection.subscribe(topics); + LOG.info("Subscribed to mqtt topics {}", Arrays.asList(topics)); - // prepare a JSONPrinter to format protobuf messages as json - List protobufDescriptors = new ArrayList<>(); - protobufDescriptors.addAll(OpensyncStats.getDescriptor().getMessageTypes()); - protobufDescriptors.addAll(IpDnsTelemetry.getDescriptor().getMessageTypes()); - protobufDescriptors.addAll(NetworkMetadata.getDescriptor().getMessageTypes()); - TypeRegistry oldRegistry = TypeRegistry.newBuilder().add(protobufDescriptors).build(); - JsonFormat.Printer jsonPrinter = JsonFormat.printer().includingDefaultValueFields() - .omittingInsignificantWhitespace().usingTypeRegistry(oldRegistry); + // prepare a JSONPrinter to format protobuf messages as + // json + List protobufDescriptors = new ArrayList<>(); + protobufDescriptors.addAll(OpensyncStats.getDescriptor().getMessageTypes()); + protobufDescriptors.addAll(IpDnsTelemetry.getDescriptor().getMessageTypes()); + protobufDescriptors.addAll(NetworkMetadata.getDescriptor().getMessageTypes()); + TypeRegistry oldRegistry = TypeRegistry.newBuilder().add(protobufDescriptors).build(); + JsonFormat.Printer jsonPrinter = JsonFormat.printer().includingDefaultValueFields() + .omittingInsignificantWhitespace().usingTypeRegistry(oldRegistry); - // main loop - receive messages - while (true) { - Message mqttMsg = connection.receive(5, TimeUnit.SECONDS); + // main loop - receive messages + while (true) { + Message mqttMsg = connection.receive(5, TimeUnit.SECONDS); - if (mqttMsg == null) { - continue; - } + if (mqttMsg == null) { + continue; + } - byte payload[] = mqttMsg.getPayload(); - // we acknowledge right after receive because: - // a. none of the stats messages are so important that we cannot skip one - // b. if there's some kind of problem with the message (decoding or processing) - // - we want to move on as quickly as possible and not let it get stuck in the - // queue - mqttMsg.ack(); + byte payload[] = mqttMsg.getPayload(); + // we acknowledge right after receive because: + // a. none of the stats messages are so important + // that + // we cannot skip one + // b. if there's some kind of problem with the + // message + // (decoding or processing) + // - we want to move on as quickly as possible and + // not + // let it get stuck in the + // queue + mqttMsg.ack(); - LOG.trace("received message on topic {} size {}", mqttMsg.getTopic(), payload.length); + LOG.trace("received message on topic {} size {}", mqttMsg.getTopic(), payload.length); - if (payload[0] == 0x78) { - // looks like zlib-compressed data, let's decompress it before deserializing - payload = ZlibUtil.decompress(payload); - } + if (payload[0] == 0x78) { + // looks like zlib-compressed data, let's + // decompress + // it before deserializing + payload = ZlibUtil.decompress(payload); + } - // attempt to parse the message as protobuf - MessageOrBuilder encodedMsg = null; - try { + // attempt to parse the message as protobuf + MessageOrBuilder encodedMsg = null; + try { - encodedMsg = Report.parseFrom(payload); - MQTT_LOG.info("topic = {} Report = {}", mqttMsg.getTopic(), jsonPrinter.print(encodedMsg)); - extIntegrationInterface.processMqttMessage(mqttMsg.getTopic(), (Report) encodedMsg); + encodedMsg = Report.parseFrom(payload); + MQTT_LOG.info("topic = {} Report = {}", mqttMsg.getTopic(), + jsonPrinter.print(encodedMsg)); + extIntegrationInterface.processMqttMessage(mqttMsg.getTopic(), (Report) encodedMsg); - } catch (Exception e) { - try { - // not a plume_stats report, attempt to deserialize as network_metadata - encodedMsg = FlowReport.parseFrom(payload); - MQTT_LOG.info("topic = {} FlowReport = {}", mqttMsg.getTopic(), - jsonPrinter.print(encodedMsg)); - extIntegrationInterface.processMqttMessage(mqttMsg.getTopic(), (FlowReport) encodedMsg); - } catch (Exception e1) { + } catch (Exception e) { + try { + // not a plume_stats report, attempt to + // deserialize as network_metadata + encodedMsg = FlowReport.parseFrom(payload); + MQTT_LOG.info("topic = {} FlowReport = {}", mqttMsg.getTopic(), + jsonPrinter.print(encodedMsg)); + extIntegrationInterface.processMqttMessage(mqttMsg.getTopic(), + (FlowReport) encodedMsg); + } catch (Exception e1) { - try { - // not a plume_stats report and not network_metadata report, attempt to - // deserialize as WCStatsReport - encodedMsg = WCStatsReport.parseFrom(payload); - MQTT_LOG.info("topic = {} IpDnsTelemetry = {}", mqttMsg.getTopic(), - jsonPrinter.print(encodedMsg)); - extIntegrationInterface.processMqttMessage(mqttMsg.getTopic(), - (WCStatsReport) encodedMsg); - } catch (Exception e2) { - String msgStr = new String(mqttMsg.getPayload(), utf8); - MQTT_LOG.info("topic = {} message = {}", mqttMsg.getTopic(), msgStr); - } - } - } + try { + // not a plume_stats report and not + // network_metadata report, attempt to + // deserialize as WCStatsReport + encodedMsg = WCStatsReport.parseFrom(payload); + MQTT_LOG.info("topic = {} IpDnsTelemetry = {}", mqttMsg.getTopic(), + jsonPrinter.print(encodedMsg)); + extIntegrationInterface.processMqttMessage(mqttMsg.getTopic(), + (WCStatsReport) encodedMsg); + } catch (Exception e2) { + String msgStr = new String(mqttMsg.getPayload(), utf8); + MQTT_LOG.info("topic = {} message = {}", mqttMsg.getTopic(), msgStr); + } + } + } - } + } - } catch (Exception e) { - LOG.error("Exception in MQTT receiver", e); - } finally { - try { - if (connection != null) { - connection.disconnect(); - } - } catch (Exception e1) { - // do nothing - } - } - } + } catch (Exception e) { + LOG.error("Exception in MQTT receiver", e); + } finally { + try { + if (connection != null) { + connection.disconnect(); + } + } catch (Exception e1) { + // do nothing + } + } + } - }; + } + }; - mqttClientThread = new Thread(mqttClientRunnable, "mqttClientThread"); - mqttClientThread.setDaemon(true); - mqttClientThread.start(); + mqttClientThread = new Thread(mqttClientRunnable, "mqttClientThread"); + mqttClientThread.setDaemon(true); + mqttClientThread.start(); - } + } - @Override - public void onApplicationEvent(ContextClosedEvent event) { - LOG.debug("Processing ContextClosedEvent event"); - keepReconnecting = false; + @Override + public void onApplicationEvent(ContextClosedEvent event) { + LOG.debug("Processing ContextClosedEvent event"); + keepReconnecting = false; - if (mqttClientThread != null) { - mqttClientThread.interrupt(); - } - } + if (mqttClientThread != null) { + mqttClientThread.interrupt(); + } + } } diff --git a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/ConnectusOvsdbClient.java b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/ConnectusOvsdbClient.java index 06d5ecb..fdce6f3 100644 --- a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/ConnectusOvsdbClient.java +++ b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/ConnectusOvsdbClient.java @@ -97,7 +97,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { // with the serialNumber and using it as a key (equivalent // of KDC unique qrCode) String key = clientCn + "_" + connectNodeInfo.serialNumber; - ConnectusOvsdbClient.this.ovsdbSessionMapInterface.newSession(key, ovsdbClient); + ovsdbSessionMapInterface.newSession(key, ovsdbClient); extIntegrationInterface.apConnected(key, connectNodeInfo); // push configuration to AP @@ -105,8 +105,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { monitorOvsdbStateTables(ovsdbClient, key); LOG.info("ovsdbClient connected from {} on port {} key {} ", remoteHost, localPort, key); - LOG.info("ovsdbClient connectedClients = {}", - ConnectusOvsdbClient.this.ovsdbSessionMapInterface.getNumSessions()); + LOG.info("ovsdbClient connectedClients = {}", ovsdbSessionMapInterface.getNumSessions()); } catch (Exception e) { LOG.error("ovsdbClient error", e); @@ -139,7 +138,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { // so we are doing a reverse lookup here, and then if we find // the key we will // remove the entry from the connectedClients. - String key = ConnectusOvsdbClient.this.ovsdbSessionMapInterface.lookupClientId(ovsdbClient); + String key = ovsdbSessionMapInterface.lookupClientId(ovsdbClient); if (key != null) { try { @@ -155,7 +154,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { } try { extIntegrationInterface.apDisconnected(key); - ConnectusOvsdbClient.this.ovsdbSessionMapInterface.removeSession(key); + ovsdbSessionMapInterface.removeSession(key); } catch (Exception e) { LOG.debug("Unable to process ap disconnect. {}", e.getMessage()); } finally { @@ -165,8 +164,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { LOG.info("ovsdbClient disconnected from {} on port {} clientCn {} key {} ", remoteHost, localPort, clientCn, key); - LOG.info("ovsdbClient connectedClients = {}", - ConnectusOvsdbClient.this.ovsdbSessionMapInterface.getNumSessions()); + LOG.info("ovsdbClient connectedClients = {}", ovsdbSessionMapInterface.getNumSessions()); } }; @@ -182,8 +180,8 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { LOG.debug("Starting Client connect"); connectNodeInfo = ovsdbDao.updateConnectNodeInfoOnConnect(ovsdbClient, clientCn, connectNodeInfo); - String apId = clientCn + "_" + connectNodeInfo.serialNumber; - OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId); + ovsdbDao.vifBridge = connectNodeInfo.ifName; + try { ovsdbDao.provisionBridgePortInterface(ovsdbClient); @@ -193,10 +191,12 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { } ovsdbDao.removeAllSsids(ovsdbClient); // always - + String apId = clientCn + "_" + connectNodeInfo.serialNumber; + OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId); if (opensyncAPConfig != null) { ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig); ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig); + ovsdbDao.configureWifiInet(ovsdbClient, opensyncAPConfig); } ovsdbDao.configureStats(ovsdbClient); @@ -208,8 +208,6 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats); } - // ovsdbDao.configureWifiInet(ovsdbClient); - LOG.debug("Client connect Done"); return connectNodeInfo; } @@ -307,22 +305,22 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { for (Entry rowUpdate : tableUpdate.getValue().getRowUpdates() .entrySet()) { - if (rowUpdate.getValue().getOld() != null - && rowUpdate.getValue().getNew() == null) { + if ((rowUpdate.getValue().getOld() != null) + && (rowUpdate.getValue().getNew() == null)) { Row row = rowUpdate.getValue().getOld(); String ifName = null; String ssid = null; - if (row.getColumns().get("ssid") != null + if ((row.getColumns().get("ssid") != null) && row.getColumns().get("ssid").getClass().equals( com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { ssid = row.getStringColumn("ssid"); } - if (row.getColumns().get("if_name") != null + if ((row.getColumns().get("if_name") != null) && row.getColumns().get("if_name").getClass().equals( com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { ifName = row.getStringColumn("if_name"); } - if (ifName != null && ssid != null) { + if ((ifName != null) && (ssid != null)) { OpensyncAPVIFState toBeDeleted = new OpensyncAPVIFState(); toBeDeleted.setSsid(ssid); toBeDeleted.setIfName(ifName); @@ -333,7 +331,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { } - if (tableUpdate.getValue().getRowUpdates().values().isEmpty()) { + if (tableUpdate.getValue().getRowUpdates().isEmpty()) { tableUpdates.getTableUpdates().remove(tableUpdate.getKey()); } @@ -378,7 +376,7 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface { for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) { - if (rowUpdate.getOld() != null && rowUpdate.getNew() == null) { + if ((rowUpdate.getOld() != null) && (rowUpdate.getNew() == null)) { Row row = rowUpdate.getOld(); String deletedClientMac = row.getStringColumn("mac"); extIntegrationInterface.wifiAssociatedClientsDbTableDelete(deletedClientMac, 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 63f386e..e168d91 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 @@ -12,6 +12,8 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.function.Consumer; +import java.util.function.Predicate; import java.util.stream.Collectors; import org.slf4j.Logger; @@ -65,7 +67,6 @@ import com.vmware.ovsdb.protocol.operation.notation.Value; import com.vmware.ovsdb.protocol.operation.result.InsertResult; import com.vmware.ovsdb.protocol.operation.result.OperationResult; import com.vmware.ovsdb.protocol.operation.result.SelectResult; -import com.vmware.ovsdb.protocol.operation.result.UpdateResult; import com.vmware.ovsdb.service.OvsdbClient; @Component @@ -91,7 +92,7 @@ public class OvsdbDao { private int ovsdbTimeoutSec; @org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_bridge:br-home}") - public String bridgeNameVifInterfaces; + public String vifBridge; @org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_radio1:home-ap-24}") public String ifName2pt4GHz; @@ -100,13 +101,6 @@ public class OvsdbDao { @org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_radio0:home-ap-u50}") public String ifName5GHzU; - @org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-device.radio0:wifi2}") - public String radioName5GHzU; - @org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-device.radio2:wifi1}") - public String radioName5GHzL; - @org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-device.radio1:wifi0}") - public String radioName2pt4GHz; - public static final String ovsdbName = "Open_vSwitch"; public static final String awlanNodeDbTable = "AWLAN_Node"; public static final String wifiStatsConfigDbTable = "Wifi_Stats_Config"; @@ -156,7 +150,7 @@ public class OvsdbDao { } Row row = null; - if (result != null && result.length > 0 && !((SelectResult) result[0]).getRows().isEmpty()) { + if ((result != null) && (result.length > 0) && !((SelectResult) result[0]).getRows().isEmpty()) { row = ((SelectResult) result[0]).getRows().iterator().next(); } @@ -174,12 +168,16 @@ public class OvsdbDao { ret.model = getSingleValueFromSet(row, "model"); // now populate macAddress, ipV4Address from Wifi_Inet_State - // first look them up for if_name = br-wan - fillInIpAddressAndMac(ovsdbClient, ret, "br-wan"); - if (ret.ipV4Address == null || ret.macAddress == null) { - // when not found - look them up for if_name = br-lan - fillInIpAddressAndMac(ovsdbClient, ret, "br-lan"); - } + // first look for bridge + fillInIpAddressAndMac(ovsdbClient, ret, "bridge"); + // if ((ret.ipV4Address == null) || (ret.macAddress == null)) { + // // when not found - look them up for if_name = br-lan + // fillInIpAddressAndMac(ovsdbClient, ret, "br-lan"); + // } + getRadiosInterfaceFreqAndMac(ovsdbClient, ret); + + // Get Radio IFs from Wifi_Radio_State + // } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { throw new RuntimeException(e); @@ -188,7 +186,7 @@ public class OvsdbDao { return ret; } - public void fillInIpAddressAndMac(OvsdbClient ovsdbClient, ConnectNodeInfo connectNodeInfo, String ifName) { + public void fillInIpAddressAndMac(OvsdbClient ovsdbClient, ConnectNodeInfo connectNodeInfo, String ifType) { try { List operations = new ArrayList<>(); List conditions = new ArrayList<>(); @@ -197,8 +195,13 @@ public class OvsdbDao { columns.add("inet_addr"); columns.add("hwaddr"); + columns.add("if_name"); + columns.add("if_type"); + columns.add("network"); - conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(ifName))); + conditions.add(new Condition("if_type", Function.EQUALS, new Atom<>(ifType))); + conditions.add(new Condition("network", Function.EQUALS, new Atom<>(true))); + conditions.add(new Condition("enabled", Function.EQUALS, new Atom<>(true))); operations.add(new Select(wifiInetStateDbTable, conditions, columns)); CompletableFuture fResult = ovsdbClient.transact(ovsdbName, operations); @@ -213,10 +216,13 @@ public class OvsdbDao { } Row row = null; - if (result != null && result.length > 0 && !((SelectResult) result[0]).getRows().isEmpty()) { + if ((result != null) && (result.length > 0) && !((SelectResult) result[0]).getRows().isEmpty()) { row = ((SelectResult) result[0]).getRows().iterator().next(); connectNodeInfo.ipV4Address = getSingleValueFromSet(row, "inet_addr"); connectNodeInfo.macAddress = row.getStringColumn("hwaddr"); + connectNodeInfo.ifName = row.getStringColumn("if_name"); + connectNodeInfo.ifType = getSingleValueFromSet(row, "if_type"); + } } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { @@ -225,6 +231,55 @@ public class OvsdbDao { } + public void getRadiosInterfaceFreqAndMac(OvsdbClient ovsdbClient, ConnectNodeInfo connectNodeInfo) { + try { + List operations = new ArrayList<>(); + List conditions = new ArrayList<>(); + List columns = new ArrayList<>(); + + // Get radio if_name and mac for each radio + columns.add("freq_band"); + columns.add("if_name"); + columns.add("mac"); + columns.add("country"); + + operations.add(new Select(wifiRadioStateDbTable, conditions, columns)); + CompletableFuture fResult = ovsdbClient.transact(ovsdbName, operations); + OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); + + if (LOG.isDebugEnabled()) { + LOG.debug("Select from {}:", wifiRadioStateDbTable); + + for (OperationResult res : result) { + LOG.debug("Op Result {}", res); + } + } + + if ((result != null) && (result.length > 0)) { + + for (Row row : ((SelectResult) result[0]).getRows()) { + if (connectNodeInfo.wifiRadioStates == null) { + connectNodeInfo.wifiRadioStates = new HashMap<>(); + } + Map wifiRadioState = new HashMap<>(); + wifiRadioState.put("if_name", row.getStringColumn("if_name")); + wifiRadioState.put("mac", getSingleValueFromSet(row, "mac")); + if (connectNodeInfo.country == null) { + connectNodeInfo.country = wifiRadioState.get("country"); + } + connectNodeInfo.wifiRadioStates.put(getSingleValueFromSet(row, "freq_band"), wifiRadioState); + } + + } + + LOG.debug("Retrieved WifiRadioState info for connectNode {}", connectNodeInfo); + + } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { + throw new RuntimeException(e); + } + + } + public ConnectNodeInfo updateConnectNodeInfoOnConnect(OvsdbClient ovsdbClient, String clientCn, ConnectNodeInfo incomingConnectNodeInfo) { ConnectNodeInfo ret = incomingConnectNodeInfo.clone(); @@ -237,7 +292,7 @@ public class OvsdbDao { // updateColumns.put("device_mode", new Atom("cloud") ); // update sku_number if it was empty - if (ret.skuNumber == null || ret.skuNumber.isEmpty()) { + if ((ret.skuNumber == null) || ret.skuNumber.isEmpty()) { ret.skuNumber = "connectus.ai_" + ret.serialNumber; updateColumns.put("sku_number", new Atom<>(ret.skuNumber)); } @@ -253,7 +308,7 @@ public class OvsdbDao { newMqttSettings.put("qos", "0"); newMqttSettings.put("remote_log", "1"); - if (ret.mqttSettings == null || !ret.mqttSettings.equals(newMqttSettings)) { + if ((ret.mqttSettings == null) || !ret.mqttSettings.equals(newMqttSettings)) { @SuppressWarnings("unchecked") com.vmware.ovsdb.protocol.operation.notation.Map mgttSettings = com.vmware.ovsdb.protocol.operation.notation.Map .of(newMqttSettings); @@ -316,7 +371,7 @@ public class OvsdbDao { } Row row = null; - if (result != null && result.length > 0 && !((SelectResult) result[0]).getRows().isEmpty()) { + if ((result != null) && (result.length > 0) && !((SelectResult) result[0]).getRows().isEmpty()) { row = ((SelectResult) result[0]).getRows().iterator().next(); ret = row.getIntegerColumn("reporting_interval"); LOG.info("Stats collection for stats_type=device is already configured with reporting_interval = {}", @@ -401,7 +456,7 @@ public class OvsdbDao { String firmwareVersion = null; Row row = null; - if (result != null && result.length > 0 && !((SelectResult) result[0]).getRows().isEmpty()) { + if ((result != null) && (result.length > 0) && !((SelectResult) result[0]).getRows().isEmpty()) { row = ((SelectResult) result[0]).getRows().iterator().next(); } @@ -450,7 +505,7 @@ public class OvsdbDao { public T getSingleValueFromSet(Row row, String columnName) { Set set = row != null ? row.getSetColumn(columnName) : null; - T ret = set != null && !set.isEmpty() ? set.iterator().next() : null; + T ret = (set != null) && !set.isEmpty() ? set.iterator().next() : null; return ret; } @@ -659,7 +714,7 @@ public class OvsdbDao { wifiRadioConfigInfo.freqBand = row.getStringColumn("freq_band"); wifiRadioConfigInfo.hwConfig = row.getMapColumn("hw_config"); wifiRadioConfigInfo.hwType = row.getStringColumn("hw_type"); - ret.put(wifiRadioConfigInfo.ifName, wifiRadioConfigInfo); + ret.put(wifiRadioConfigInfo.freqBand, wifiRadioConfigInfo); } LOG.debug("Retrieved WifiRadioConfig: {}", ret); @@ -731,11 +786,11 @@ public class OvsdbDao { wifiVifConfigInfo.vifRadioIdx = radioIdxTmp.intValue(); wifiVifConfigInfo.security = row.getMapColumn("security"); - if (row.getColumns().get("vlan_id") != null && row.getColumns().get("vlan_id").getClass() + if ((row.getColumns().get("vlan_id") != null) && row.getColumns().get("vlan_id").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { wifiVifConfigInfo.vlanId = row.getIntegerColumn("vlan_id").intValue(); } - ret.put(wifiVifConfigInfo.ifName + '_' + wifiVifConfigInfo.ssid, wifiVifConfigInfo); + ret.put(wifiVifConfigInfo.ifName, wifiVifConfigInfo); } LOG.debug("Retrieved WifiVifConfigs: {}", ret); @@ -785,7 +840,7 @@ public class OvsdbDao { wifiInetConfigInfo.nat = natTmp != null ? natTmp : false; wifiInetConfigInfo.uuid = row.getUuidColumn("_uuid"); - if (row.getColumns().get("broadcast") != null && row.getColumns().get("broadcast").getClass() + if ((row.getColumns().get("broadcast") != null) && row.getColumns().get("broadcast").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { wifiInetConfigInfo.broadcast = row.getStringColumn("broadcast"); } @@ -794,19 +849,19 @@ public class OvsdbDao { wifiInetConfigInfo.ifType = row.getStringColumn("if_type"); wifiInetConfigInfo.ipAssignScheme = row.getStringColumn("ip_assign_scheme"); wifiInetConfigInfo.network = row.getBooleanColumn("network"); - if (row.getColumns().get("inet_addr") != null && row.getColumns().get("inet_addr").getClass() + if ((row.getColumns().get("inet_addr") != null) && row.getColumns().get("inet_addr").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { wifiInetConfigInfo.inetAddr = row.getStringColumn("inet_addr"); } - if (row.getColumns().get("mtu") != null && row.getColumns().get("mtu").getClass() + if ((row.getColumns().get("mtu") != null) && row.getColumns().get("mtu").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { wifiInetConfigInfo.mtu = row.getIntegerColumn("mtu").intValue(); } - if (row.getColumns().get("netmask") != null && row.getColumns().get("netmask").getClass() + if ((row.getColumns().get("netmask") != null) && row.getColumns().get("netmask").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { wifiInetConfigInfo.netmask = row.getStringColumn("netmask"); } - if (row.getColumns().get("vlan_id") != null && row.getColumns().get("vlan_id").getClass() + if ((row.getColumns().get("vlan_id") != null) && row.getColumns().get("vlan_id").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { wifiInetConfigInfo.vlanId = row.getIntegerColumn("vlan_id").intValue(); } @@ -1055,10 +1110,6 @@ public class OvsdbDao { } } - // public static final String homeAp24 = "home-ap-24"; - // public static final String homeApL50 = "home-ap-l50"; - // public static final String homeApU50 = "home-ap-u50"; - public static final String brWan = "br-wan"; public static final String brLan = "br-lan"; @@ -1077,21 +1128,29 @@ public class OvsdbDao { LOG.debug("Existing Bridges: {}", provisionedBridges.keySet()); Map patchH2wOptions = new HashMap<>(); - patchH2wOptions.put("peer", "patch-w2h"); + patchH2wOptions.put("peer", patchW2h); Map patchW2hOptions = new HashMap<>(); - patchH2wOptions.put("peer", "patch-h2w"); + patchH2wOptions.put("peer", patchH2w); - provisionSingleBridgePortInterface(ovsdbClient, patchH2w, bridgeNameVifInterfaces, "patch", patchH2wOptions, - provisionedInterfaces, provisionedPorts, provisionedBridges); - provisionSingleBridgePortInterface(ovsdbClient, patchW2h, brWan, "patch", patchW2hOptions, - provisionedInterfaces, provisionedPorts, provisionedBridges); + if (provisionedBridges.isEmpty() || provisionedPorts.isEmpty() || provisionedInterfaces.isEmpty()) { + LOG.debug("Bridge {} Port {} Interface {} not configured on this APs opensync db", provisionedBridges, + provisionedPorts, provisionedInterfaces); + return; + } + if (vifBridge != brLan) { - provisionSingleBridgePortInterface(ovsdbClient, ifName5GHzU, bridgeNameVifInterfaces, "vif", null, - provisionedInterfaces, provisionedPorts, provisionedBridges); - provisionSingleBridgePortInterface(ovsdbClient, ifName5GHzL, bridgeNameVifInterfaces, "vif", null, - provisionedInterfaces, provisionedPorts, provisionedBridges); - provisionSingleBridgePortInterface(ovsdbClient, ifName2pt4GHz, bridgeNameVifInterfaces, "vif", null, + provisionSingleBridgePortInterface(ovsdbClient, patchH2w, vifBridge, "patch", patchH2wOptions, + provisionedInterfaces, provisionedPorts, provisionedBridges); + provisionSingleBridgePortInterface(ovsdbClient, patchW2h, brLan, "patch", patchW2hOptions, + provisionedInterfaces, provisionedPorts, provisionedBridges); + } + + provisionSingleBridgePortInterface(ovsdbClient, ifName5GHzU, vifBridge, "vif", null, provisionedInterfaces, + provisionedPorts, provisionedBridges); + provisionSingleBridgePortInterface(ovsdbClient, ifName5GHzL, vifBridge, "vif", null, provisionedInterfaces, + provisionedPorts, provisionedBridges); + provisionSingleBridgePortInterface(ovsdbClient, ifName2pt4GHz, vifBridge, "vif", null, provisionedInterfaces, provisionedPorts, provisionedBridges); } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { @@ -1224,10 +1283,11 @@ public class OvsdbDao { if (!elementRadioConfig.getEirpTxPower().isAuto()) { txPower = elementRadioConfig.getEirpTxPower().getValue(); } - String configName = null; + String configFreqBand = null; // map to freq_band values + // "2.4G","5G","5GL","5GU" switch (radioType) { case is2dot4GHz: - configName = radioName2pt4GHz; + configFreqBand = "2.4G"; break; case is5GHz: // 802.11h dfs (Dynamic Frequency Selection) aka military and @@ -1238,7 +1298,7 @@ public class OvsdbDao { hwConfig.put("dfs_enable", "1"); hwConfig.put("dfs_ignorecac", "0"); hwConfig.put("dfs_usenol", "1"); - configName = radioName5GHzU; + configFreqBand = "5G"; break; case is5GHzL: // 802.11h dfs (Dynamic Frequency Selection) aka military and @@ -1249,7 +1309,7 @@ public class OvsdbDao { hwConfig.put("dfs_enable", "1"); hwConfig.put("dfs_ignorecac", "0"); hwConfig.put("dfs_usenol", "1"); - configName = radioName5GHzL; + configFreqBand = "5GL"; break; case is5GHzU: // 802.11h dfs (Dynamic Frequency Selection) aka military and @@ -1260,16 +1320,16 @@ public class OvsdbDao { hwConfig.put("dfs_enable", "1"); hwConfig.put("dfs_ignorecac", "0"); hwConfig.put("dfs_usenol", "1"); - configName = radioName5GHzU; + configFreqBand = "5GU"; break; default: // don't know this interface continue; } - if (configName != null) { + if (configFreqBand != null) { try { - configureWifiRadios(ovsdbClient, configName, provisionedWifiRadios, channel, hwConfig, country, + configureWifiRadios(ovsdbClient, configFreqBand, provisionedWifiRadios, channel, hwConfig, country, beaconInterval, enabled, ht_mode, txPower); } catch (OvsdbClientException e) { LOG.error("ConfigureWifiRadios failed with OvsdbClient exception.", e); @@ -1289,6 +1349,10 @@ public class OvsdbDao { } + public void configureWifiInet(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) { + configureWifiInet(ovsdbClient); + } + public List getOpensyncAPRadioState(TableUpdates tableUpdates, String apId, OvsdbClient ovsdbClient) { @@ -1309,15 +1373,15 @@ public class OvsdbDao { Map map = row.getColumns(); - if (map.get("mac") != null && map.get("mac").getClass() + if ((map.get("mac") != null) && map.get("mac").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setMac(row.getStringColumn("mac")); } - if (map.get("channel") != null && map.get("channel").getClass() + if ((map.get("channel") != null) && map.get("channel").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setChannel(row.getIntegerColumn("channel").intValue()); } - if (map.get("freq_band") != null && map.get("freq_band").getClass() + if ((map.get("freq_band") != null) && map.get("freq_band").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { String frequencyBand = row.getStringColumn("freq_band"); switch (frequencyBand) { @@ -1337,39 +1401,39 @@ public class OvsdbDao { tableState.setFreqBand(RadioType.UNSUPPORTED); } } - if (map.get("if_name") != null && map.get("if_name").getClass() + if ((map.get("if_name") != null) && map.get("if_name").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setIfName(row.getStringColumn("if_name")); } - if (map.get("channel_mode") != null && map.get("channel_mode").getClass() + if ((map.get("channel_mode") != null) && map.get("channel_mode").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setChannelMode(row.getStringColumn("channel_mode")); } - if (map.get("country") != null && map.get("country").getClass() + if ((map.get("country") != null) && map.get("country").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setCountry(row.getStringColumn("country")); } - if (map.get("enabled") != null && map.get("enabled").getClass() + if ((map.get("enabled") != null) && map.get("enabled").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setEnabled(row.getBooleanColumn("enabled")); } - if (map.get("ht_mode") != null && map.get("ht_mode").getClass() + if ((map.get("ht_mode") != null) && map.get("ht_mode").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setHtMode(row.getStringColumn("ht_mode")); } - if (map.get("tx_power") != null && map.get("tx_power").getClass() + if ((map.get("tx_power") != null) && map.get("tx_power").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setTxPower(row.getIntegerColumn("tx_power").intValue()); } - if (map.get("hw_config") != null && map.get("hw_config").getClass() + if ((map.get("hw_config") != null) && map.get("hw_config").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Map.class)) { tableState.setHwConfig(row.getMapColumn("hw_config")); } - if (map.get("_version") != null && map.get("_version").getClass() + if ((map.get("_version") != null) && map.get("_version").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setVersion(row.getUuidColumn("_version")); } - if (map.get("_uuid") != null && map.get("_uuid").getClass() + if ((map.get("_uuid") != null) && map.get("_uuid").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setVersion(row.getUuidColumn("_uuid")); } @@ -1389,8 +1453,11 @@ public class OvsdbDao { } } - ret.stream().forEach(wrs -> { - LOG.debug("Wifi_Radio_State row {}", wrs); + ret.stream().forEach(new Consumer() { + @Override + public void accept(OpensyncAPRadioState wrs) { + LOG.debug("Wifi_Radio_State row {}", wrs); + } }); } catch (Exception e) { @@ -1418,39 +1485,39 @@ public class OvsdbDao { OpensyncAPInetState tableState = new OpensyncAPInetState(); Map map = row.getColumns(); - if (map.get("NAT") != null && map.get("NAT").getClass() + if ((map.get("NAT") != null) && map.get("NAT").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setNat(row.getBooleanColumn("NAT")); } - if (map.get("enabled") != null && map.get("enabled").getClass() + if ((map.get("enabled") != null) && map.get("enabled").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setEnabled(row.getBooleanColumn("enabled")); } - if (map.get("if_name") != null && map.get("if_name").getClass() + if ((map.get("if_name") != null) && map.get("if_name").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setIfName(row.getStringColumn("if_name")); } - if (map.get("if_type") != null && map.get("if_type").getClass() + if ((map.get("if_type") != null) && map.get("if_type").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setIfType(row.getStringColumn("if_type")); } - if (map.get("ip_assign_scheme") != null && map.get("ip_assign_scheme").getClass() + if ((map.get("ip_assign_scheme") != null) && map.get("ip_assign_scheme").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setIpAssignScheme(row.getStringColumn("ip_assign_scheme")); } - if (map.get("network") != null && map.get("network").getClass() + if ((map.get("network") != null) && map.get("network").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setNetwork(row.getBooleanColumn("network")); } - if (map.get("hwaddr") != null && map.get("hwaddr").getClass() + if ((map.get("hwaddr") != null) && map.get("hwaddr").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setHwAddr(row.getStringColumn("hwaddr")); } - if (map.get("_version") != null && map.get("_version").getClass() + if ((map.get("_version") != null) && map.get("_version").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setVersion(row.getUuidColumn("_version")); } - if (map.get("_uuid") != null && map.get("_uuid").getClass() + if ((map.get("_uuid") != null) && map.get("_uuid").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setVersion(row.getUuidColumn("_uuid")); } @@ -1460,8 +1527,11 @@ public class OvsdbDao { } } - ret.stream().forEach(wrs -> { - LOG.debug("Wifi_Inet_State row {}", wrs); + ret.stream().forEach(new Consumer() { + @Override + public void accept(OpensyncAPInetState wrs) { + LOG.debug("Wifi_Inet_State row {}", wrs); + } }); } catch (Exception e) { @@ -1488,61 +1558,61 @@ public class OvsdbDao { Map map = row.getColumns(); - if (map.get("mac") != null && map.get("mac").getClass() + if ((map.get("mac") != null) && map.get("mac").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setMac(row.getStringColumn("mac")); } - if (map.get("bridge") != null && map.get("bridge").getClass() + if ((map.get("bridge") != null) && map.get("bridge").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setBridge(row.getStringColumn("bridge")); } - if (map.get("btm") != null && map.get("btm").getClass() + if ((map.get("btm") != null) && map.get("btm").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setBtm(row.getIntegerColumn("btm").intValue()); } - if (map.get("channel") != null && map.get("channel").getClass() + if ((map.get("channel") != null) && map.get("channel").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setChannel(row.getIntegerColumn("channel").intValue()); } - if (map.get("enabled") != null && map.get("enabled").getClass() + if ((map.get("enabled") != null) && map.get("enabled").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setEnabled(row.getBooleanColumn("enabled")); } - if (map.get("group_rekey") != null && map.get("group_rekey").getClass() + if ((map.get("group_rekey") != null) && map.get("group_rekey").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setGroupRekey(row.getIntegerColumn("group_rekey").intValue()); } - if (map.get("if_name") != null && map.get("if_name").getClass() + if ((map.get("if_name") != null) && map.get("if_name").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setIfName(row.getStringColumn("if_name")); } - if (map.get("mode") != null && map.get("mode").getClass() + if ((map.get("mode") != null) && map.get("mode").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setMode(row.getStringColumn("mode")); } - if (map.get("rrm") != null && map.get("rrm").getClass() + if ((map.get("rrm") != null) && map.get("rrm").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setRrm(row.getIntegerColumn("rrm").intValue()); } - if (map.get("ssid") != null && map.get("ssid").getClass() + if ((map.get("ssid") != null) && map.get("ssid").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setSsid(row.getStringColumn("ssid")); } - if (map.get("ssid_broadcast") != null && map.get("ssid_broadcast").getClass() + if ((map.get("ssid_broadcast") != null) && map.get("ssid_broadcast").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setSsidBroadcast(row.getStringColumn("ssid_broadcast")); } - if (map.get("uapsd_enable") != null && map.get("uapsd_enable").getClass() + if ((map.get("uapsd_enable") != null) && map.get("uapsd_enable").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setUapsdEnable(row.getBooleanColumn("uapsd_enable")); } - if (map.get("vif_radio_idx") != null && map.get("vif_radio_idx").getClass() + if ((map.get("vif_radio_idx") != null) && map.get("vif_radio_idx").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setVifRadioIdx(row.getIntegerColumn("vif_radio_idx").intValue()); } @@ -1555,11 +1625,11 @@ public class OvsdbDao { tableState.setSecurity(row.getMapColumn("security")); } - if (map.get("_version") != null && map.get("_version").getClass() + if ((map.get("_version") != null) && map.get("_version").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setVersion(row.getUuidColumn("_version")); } - if (map.get("_uuid") != null && map.get("_uuid").getClass() + if ((map.get("_uuid") != null) && map.get("_uuid").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setVersion(row.getUuidColumn("_uuid")); } @@ -1571,8 +1641,11 @@ public class OvsdbDao { } } - ret.stream().forEach(wrs -> { - LOG.debug("Wifi_VIF_State row {}", wrs); + ret.stream().forEach(new Consumer() { + @Override + public void accept(OpensyncAPVIFState wrs) { + LOG.debug("Wifi_VIF_State row {}", wrs); + } }); } catch (Exception e) { @@ -1599,22 +1672,22 @@ public class OvsdbDao { OpensyncWifiAssociatedClients tableState = new OpensyncWifiAssociatedClients(); Map map = row.getColumns(); - if (map.get("mac") != null && map.get("mac").getClass() + if ((map.get("mac") != null) && map.get("mac").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setMac(row.getStringColumn("mac")); } if (row.getSetColumn("capabilities") != null) { tableState.setCapabilities(row.getSetColumn("capabilities")); } - if (map.get("state") != null && map.get("state").getClass() + if ((map.get("state") != null) && map.get("state").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setState(row.getStringColumn("state")); } - if (map.get("_version") != null && map.get("_version").getClass() + if ((map.get("_version") != null) && map.get("_version").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setVersion(row.getUuidColumn("_version")); } - if (map.get("_uuid") != null && map.get("_uuid").getClass() + if ((map.get("_uuid") != null) && map.get("_uuid").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setVersion(row.getUuidColumn("_uuid")); } @@ -1624,8 +1697,11 @@ public class OvsdbDao { } } } - ret.stream().forEach(wrs -> { - LOG.debug("Wifi_Associated_Clients row {}", wrs); + ret.stream().forEach(new Consumer() { + @Override + public void accept(OpensyncWifiAssociatedClients wrs) { + LOG.debug("Wifi_Associated_Clients row {}", wrs); + } }); } catch (Exception e) { LOG.error("Could not get Wifi_Associated_Clients list from table update", e); @@ -1659,15 +1735,15 @@ public class OvsdbDao { tableState.setMqttHeaders(row.getMapColumn("mqtt_topics")); } - if (map.get("model") != null && map.get("model").getClass() + if ((map.get("model") != null) && map.get("model").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setModel(row.getStringColumn("model")); } - if (map.get("sku_number") != null && map.get("sku_number").getClass() + if ((map.get("sku_number") != null) && map.get("sku_number").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setSkuNumber(row.getStringColumn("sku_number")); } - if (map.get("id") != null && map.get("id").getClass() + if ((map.get("id") != null) && map.get("id").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setId(row.getStringColumn("id")); } @@ -1675,76 +1751,76 @@ public class OvsdbDao { if (map.get("version_matrix") != null) { tableState.setVersionMatrix(row.getMapColumn("version_matrix")); } - if (map.get("firmware_version") != null && map.get("firmware_version").getClass() + if ((map.get("firmware_version") != null) && map.get("firmware_version").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setFirmwareVersion(row.getStringColumn("firmware_version")); } - if (map.get("firmware_url") != null && map.get("firmware_url").getClass() + if ((map.get("firmware_url") != null) && map.get("firmware_url").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setFirmwareUrl(row.getStringColumn("firmware_url")); } - if (map.get("_uuid") != null && map.get("_uuid").getClass() + if ((map.get("_uuid") != null) && map.get("_uuid").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setVersion(row.getUuidColumn("_uuid")); } - if (map.get("upgrade_dl_timer") != null && map.get("upgrade_dl_timer").getClass() + if ((map.get("upgrade_dl_timer") != null) && map.get("upgrade_dl_timer").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setUpgradeDlTimer(row.getIntegerColumn("upgrade_dl_timer").intValue()); } - if (map.get("platform_version") != null && map.get("platform_version").getClass() + if ((map.get("platform_version") != null) && map.get("platform_version").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setPlatformVersion(row.getStringColumn("platform_version")); } - if (map.get("firmware_pass") != null && map.get("firmware_pass").getClass() + if ((map.get("firmware_pass") != null) && map.get("firmware_pass").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setFirmwarePass(row.getStringColumn("firmware_pass")); } - if (map.get("upgrade_timer") != null && map.get("upgrade_timer").getClass() + if ((map.get("upgrade_timer") != null) && map.get("upgrade_timer").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setUpgradeTimer(row.getIntegerColumn("upgrade_timer").intValue()); } - if (map.get("max_backoff") != null && map.get("max_backoff").getClass() + if ((map.get("max_backoff") != null) && map.get("max_backoff").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setMaxBackoff(row.getIntegerColumn("max_backoff").intValue()); } if (map.get("led_config") != null) { tableState.setLedConfig(row.getMapColumn("led_config")); } - if (map.get("redirector_addr") != null && map.get("redirector_addr").getClass() + if ((map.get("redirector_addr") != null) && map.get("redirector_addr").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setRedirectorAddr(row.getStringColumn("redirector_addr")); } - if (map.get("serial_number") != null && map.get("serial_number").getClass() + if ((map.get("serial_number") != null) && map.get("serial_number").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setSerialNumber(row.getStringColumn("serial_number")); } - if (map.get("_version") != null && map.get("_version").getClass() + if ((map.get("_version") != null) && map.get("_version").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setVersion(row.getUuidColumn("_version")); } - if (map.get("upgrade_status") != null && map.get("upgrade_status").getClass() + if ((map.get("upgrade_status") != null) && map.get("upgrade_status").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setUpgradeTimer(row.getIntegerColumn("upgrade_status").intValue()); } - if (map.get("device_mode") != null && map.get("device_mode").getClass() + if ((map.get("device_mode") != null) && map.get("device_mode").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setDeviceMode(row.getStringColumn("device_mode")); } - if (map.get("min_backoff") != null && map.get("min_backoff").getClass() + if ((map.get("min_backoff") != null) && map.get("min_backoff").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setMinBackoff(row.getIntegerColumn("min_backoff").intValue()); } - if (map.get("revision") != null && map.get("revision").getClass() + if ((map.get("revision") != null) && map.get("revision").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setRevision(row.getStringColumn("revision")); } - if (map.get("manager_addr") != null && map.get("manager_addr").getClass() + if ((map.get("manager_addr") != null) && map.get("manager_addr").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setManagerAddr(row.getStringColumn("manager_addr")); } - if (map.get("factory_reset") != null && map.get("factory_reset").getClass() + if ((map.get("factory_reset") != null) && map.get("factory_reset").getClass() .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { tableState.setFactoryReset(row.getBooleanColumn("factory_reset")); } @@ -1761,22 +1837,22 @@ public class OvsdbDao { } - public void configureWifiRadios(OvsdbClient ovsdbClient, String configName, + public void configureWifiRadios(OvsdbClient ovsdbClient, String configFreqBand, Map provisionedWifiRadios, int channel, Map hwConfig, String country, int beaconInterval, boolean enabled, String ht_mode, int txPower) throws OvsdbClientException, TimeoutException, ExecutionException, InterruptedException { - WifiRadioConfigInfo existingConfig = provisionedWifiRadios.get(configName); + WifiRadioConfigInfo existingConfig = provisionedWifiRadios.get(configFreqBand); if (existingConfig == null) { - LOG.warn("There is no WifiRadioConfig {}", configName); + LOG.warn("There is no WifiRadioConfig {}", configFreqBand); return; } List operations = new ArrayList<>(); Map updateColumns = new HashMap<>(); List conditions = new ArrayList<>(); - conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(configName))); + conditions.add(new Condition("freq_band", Function.EQUALS, new Atom<>(configFreqBand))); updateColumns.put("channel", new Atom<>(channel)); updateColumns.put("country", new Atom<>(country)); @@ -1786,7 +1862,7 @@ public class OvsdbDao { updateColumns.put("hw_config", hwConfigMap); updateColumns.put("bcn_int", new Atom<>(beaconInterval)); updateColumns.put("enabled", new Atom<>(enabled)); - if (ht_mode != null && !ht_mode.equals("0")) { + if ((ht_mode != null) && !ht_mode.equals("0")) { updateColumns.put("ht_mode", new Atom<>(ht_mode)); } else { updateColumns.put("ht_mode", new com.vmware.ovsdb.protocol.operation.notation.Set()); @@ -1803,7 +1879,7 @@ public class OvsdbDao { CompletableFuture fResult = ovsdbClient.transact(ovsdbName, operations); OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); - LOG.debug("Provisioned channel {} for {}", channel, configName); + LOG.debug("Provisioned channel {} for freq_band {}", channel, configFreqBand); for (OperationResult res : result) { LOG.debug("Op Result {}", res); @@ -1811,8 +1887,7 @@ public class OvsdbDao { } public void configureSingleSsid(OvsdbClient ovsdbClient, String bridge, String ifName, String ssid, - boolean ssidBroadcast, Map security, - Map provisionedWifiRadioConfigs, String radioIfName, int vlanId, + boolean ssidBroadcast, Map security, String radioFrequencyBand, int vlanId, boolean rrmEnabled, boolean enable80211r, String minHwMode, boolean enabled, int keyRefresh, boolean uapsdEnabled, boolean apBridge, NetworkForwardMode networkForwardMode, String gateway, String inet, Map dns, String ipAssignScheme) { @@ -1877,9 +1952,10 @@ public class OvsdbDao { updateColumns.clear(); operations.clear(); - WifiRadioConfigInfo wifiRadioConfigInfo = provisionedWifiRadioConfigs.get(radioIfName); + WifiRadioConfigInfo wifiRadioConfigInfo = getProvisionedWifiRadioConfigs(ovsdbClient) + .get(radioFrequencyBand); if (wifiRadioConfigInfo == null) { - throw new IllegalStateException("missing Wifi_Radio_Config entry " + radioIfName); + throw new IllegalStateException("missing Wifi_Radio_Config entry " + radioFrequencyBand); } Set vifConfigsSet = new HashSet<>(wifiRadioConfigInfo.vifConfigUuids); @@ -1889,7 +1965,7 @@ public class OvsdbDao { updateColumns.put("vif_configs", vifConfigs); List conditions = new ArrayList<>(); - conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(radioIfName))); + conditions.add(new Condition("freq_band", Function.EQUALS, new Atom<>(radioFrequencyBand))); row = new Row(updateColumns); operations.add(new Update(wifiRadioConfigDbTable, conditions, row)); @@ -1898,24 +1974,27 @@ public class OvsdbDao { result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); if (LOG.isDebugEnabled()) { - LOG.debug("Updated WifiRadioConfig {} for SSID {}:", radioIfName, ssid); + LOG.debug("Updated WifiRadioConfig freq_band {} for SSID {}:", radioFrequencyBand, ssid); for (OperationResult res : result) { LOG.debug("Op Result {}", res); } } - Map inetConfigs = getProvisionedWifiInetConfigs(ovsdbClient); - if (inetConfigs.containsKey(ifName)) { - updateWifiInetConfig(ovsdbClient, vlanId, ifName, enabled, networkForwardMode == NetworkForwardMode.NAT, - "vif", gateway, inet, dns, ipAssignScheme, vifConfigUuid); - } else { - LOG.debug("No corresponding WifiInetConfig for this Interface"); - insertWifiInetConfigForVif(ovsdbClient, vlanId, ifName, enabled, - networkForwardMode == NetworkForwardMode.NAT, "vif", gateway, inet, dns, ipAssignScheme, - vifConfigUuid); - } + // Map inetConfigs = + // getProvisionedWifiInetConfigs(ovsdbClient); + // if (inetConfigs.containsKey(ifName)) { + // updateWifiInetConfig(ovsdbClient, vlanId, ifName, enabled, + // networkForwardMode == NetworkForwardMode.NAT, + // "vif", gateway, inet, dns, ipAssignScheme, vifConfigUuid); + // } else { + // LOG.debug("No corresponding WifiInetConfig for this Interface"); + // insertWifiInetConfigForVif(ovsdbClient, vlanId, ifName, enabled, + // networkForwardMode == NetworkForwardMode.NAT, "vif", gateway, + // inet, dns, ipAssignScheme, + // vifConfigUuid); + // } - LOG.info("Provisioned SSID {} on interface {} / {}", ssid, ifName, radioIfName); + LOG.info("Provisioned SSID {} on interface {} / {}", ssid, ifName, radioFrequencyBand); } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { LOG.error("Error in configureSingleSsid", e); @@ -1926,8 +2005,8 @@ public class OvsdbDao { public void configureSsids(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncApConfig) { boolean rrmEnabled = false; - if (opensyncApConfig.getEquipmentLocation() != null - && opensyncApConfig.getEquipmentLocation().getDetails() != null) { + if ((opensyncApConfig.getEquipmentLocation() != null) + && (opensyncApConfig.getEquipmentLocation().getDetails() != null)) { rrmEnabled = opensyncApConfig.getEquipmentLocation().getDetails().isRrmEnabled(); } @@ -1943,9 +2022,6 @@ public class OvsdbDao { int keyRefresh = ssidConfig.getKeyRefresh(); - Map provisionedWifiRadioConfigs = getProvisionedWifiRadioConfigs( - ovsdbClient); - boolean ssidBroadcast = ssidConfig.getBroadcastSsid() == StateSetting.enabled; Map security = new HashMap<>(); String ssidSecurityMode = ssidConfig.getSecureMode().name(); @@ -1985,7 +2061,7 @@ public class OvsdbDao { if (ssidConfig.getRadioBasedConfigs() != null) { if (ssidConfig.getRadioBasedConfigs().containsKey(radioType) - && ssidConfig.getRadioBasedConfigs().get(radioType) != null) { + && (ssidConfig.getRadioBasedConfigs().get(radioType) != null)) { if (ssidConfig.getRadioBasedConfigs().get(radioType).getEnable80211r() != null) { enable80211r = ssidConfig.getRadioBasedConfigs().get(radioType).getEnable80211r(); } @@ -2042,31 +2118,34 @@ public class OvsdbDao { boolean enabled = ssidConfig.getSsidAdminState().equals(StateSetting.enabled); - String ifName = null; - String radioIfName = null; + String vifInterfaceName = null; + String radioFrequencyBand = null; if (radioType == RadioType.is2dot4GHz) { - ifName = ifName2pt4GHz; - radioIfName = radioName2pt4GHz; + vifInterfaceName = ifName2pt4GHz; + radioFrequencyBand = "2.4G"; } else if (radioType == RadioType.is5GHzL) { - ifName = ifName5GHzL; - radioIfName = radioName5GHzL; + vifInterfaceName = ifName5GHzL; + radioFrequencyBand = "5GL"; } else if (radioType == RadioType.is5GHzU) { - ifName = ifName5GHzU; - radioIfName = radioName5GHzU; + vifInterfaceName = ifName5GHzU; + radioFrequencyBand = "5GU"; + } else if (radioType == RadioType.is5GHz) { + vifInterfaceName = ifName5GHzU; + radioFrequencyBand = "5G"; } - if (!provisionedWifiVifConfigs.containsKey(ifName + "_" + ssidConfig.getSsid())) { + if (!provisionedWifiVifConfigs.containsKey(vifInterfaceName)) { try { - configureSingleSsid(ovsdbClient, bridgeNameVifInterfaces, ifName, ssidConfig.getSsid(), - ssidBroadcast, security, provisionedWifiRadioConfigs, radioIfName, - ssidConfig.getVlanId(), rrmEnabled, enable80211r, minHwMode, enabled, keyRefresh, - uapsdEnabled, apBridge, ssidConfig.getForwardMode(), gateway, inet, dns, - ipAssignScheme); + ConnectNodeInfo connectNodeInfo = getConnectNodeInfo(ovsdbClient); + configureSingleSsid(ovsdbClient, connectNodeInfo.ifName, vifInterfaceName, ssidConfig.getSsid(), + ssidBroadcast, security, radioFrequencyBand, ssidConfig.getVlanId(), rrmEnabled, + enable80211r, minHwMode, enabled, keyRefresh, uapsdEnabled, apBridge, + ssidConfig.getForwardMode(), gateway, inet, dns, ipAssignScheme); } catch (IllegalStateException e) { // could not provision this SSID, but still can go on - LOG.warn("could not provision SSID {} on {}", ssidConfig.getSsid(), radioIfName); + LOG.warn("could not provision SSID {} on {}", ssidConfig.getSsid(), radioFrequencyBand); } } @@ -2078,8 +2157,12 @@ public class OvsdbDao { private void getRadiusConfiguration(OpensyncAPConfig opensyncApConfig, SsidConfiguration ssidConfig, Map security) { List radiusServiceList = new ArrayList<>(); - radiusServiceList = opensyncApConfig.getRadiusProfiles().stream() - .filter(p -> p.getName().equals((ssidConfig.getRadiusServiceName()))).collect(Collectors.toList()); + radiusServiceList = opensyncApConfig.getRadiusProfiles().stream().filter(new Predicate() { + @Override + public boolean test(Profile p) { + return p.getName().equals((ssidConfig.getRadiusServiceName())); + } + }).collect(Collectors.toList()); if (!radiusServiceList.isEmpty()) { Profile profileRadius = radiusServiceList.get(0); String region = opensyncApConfig.getEquipmentLocation().getName(); @@ -2096,133 +2179,133 @@ public class OvsdbDao { } } - private void updateWifiInetConfig(OvsdbClient ovsdbClient, int vlanId, String ifName, boolean enabled, - boolean isNAT, String ifType, String gateway, String inet, Map dns, String ipAssignScheme, - Uuid vifConfigUuid) { +// private void updateWifiInetConfig(OvsdbClient ovsdbClient, int vlanId, String ifName, boolean enabled, +// boolean isNAT, String ifType, String gateway, String inet, Map dns, String ipAssignScheme, +// Uuid vifConfigUuid) { +// +// List operations = new ArrayList<>(); +// Map updateColumns = new HashMap<>(); +// List conditions = new ArrayList<>(); +// conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(ifName))); +// +// try { +// /// usr/plume/tools/ovsh i Wifi_Inet_Config NAT:=false enabled:=true +// /// if_name:=home-ap-24 if_type:=vif ip_assign_scheme:=none +// /// network:=true +// // dhcpd +// updateColumns.put("if_name", new Atom<>(ifName)); +// updateColumns.put("if_type", new Atom<>(ifType)); +// updateColumns.put("if_uuid", new Atom<>(vifConfigUuid.toString())); +// updateColumns.put("enabled", new Atom<>(enabled)); +// updateColumns.put("NAT", new Atom<>(isNAT)); +// +// // mtu // specified in interface, should take that value when +// // implemented +// updateColumns.put("mtu", new Atom<>(1500)); +// updateColumns.put("network", new Atom<>(true)); +// +// updateColumns.put("ip_assign_scheme", new Atom<>(ipAssignScheme)); +// +// if (ipAssignScheme.equals("static")) { +// updateColumns.put("dns", com.vmware.ovsdb.protocol.operation.notation.Map.of(dns)); +// updateColumns.put("inet_addr", new Atom<>(inet)); +// updateColumns.put("gateway", new Atom<>(gateway)); +// // netmask +// // broadcast +// } +// if (ipAssignScheme.equals("dhcp")) { +// updateColumns.put("dhcp_sniff", new Atom<>(true)); +// } else { +// updateColumns.put("dhcp_sniff", new Atom<>(false)); +// } +// +// if (ifType.equals("vlan")) { +// updateColumns.put("vlan_id", new Atom<>(vlanId)); +// } else { +// updateColumns.put("vlan_id", new com.vmware.ovsdb.protocol.operation.notation.Set()); +// } +// +// Row row = new Row(updateColumns); +// operations.add(new Update(wifiInetConfigDbTable, conditions, row)); +// +// CompletableFuture fResult = ovsdbClient.transact(ovsdbName, operations); +// OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); +// +// LOG.debug("Provisioned WifiInetConfig {}", ifName); +// +// for (OperationResult res : result) { +// LOG.debug("Op Result {}", res); +// } +// +// } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { +// LOG.error("Error in configureWifiInet", e); +// throw new RuntimeException(e); +// } +// +// } - List operations = new ArrayList<>(); - Map updateColumns = new HashMap<>(); - List conditions = new ArrayList<>(); - conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(ifName))); - - try { - /// usr/plume/tools/ovsh i Wifi_Inet_Config NAT:=false enabled:=true - /// if_name:=home-ap-24 if_type:=vif ip_assign_scheme:=none - /// network:=true - // dhcpd - updateColumns.put("if_name", new Atom<>(ifName)); - updateColumns.put("if_type", new Atom<>(ifType)); - updateColumns.put("if_uuid", new Atom<>(vifConfigUuid.toString())); - updateColumns.put("enabled", new Atom<>(enabled)); - updateColumns.put("NAT", new Atom<>(isNAT)); - - // mtu // specified in interface, should take that value when - // implemented - updateColumns.put("mtu", new Atom<>(1500)); - updateColumns.put("network", new Atom<>(true)); - - updateColumns.put("ip_assign_scheme", new Atom<>(ipAssignScheme)); - - if (ipAssignScheme.equals("static")) { - updateColumns.put("dns", com.vmware.ovsdb.protocol.operation.notation.Map.of(dns)); - updateColumns.put("inet_addr", new Atom<>(inet)); - updateColumns.put("gateway", new Atom<>(gateway)); - // netmask - // broadcast - } - if (ipAssignScheme.equals("dhcp")) { - updateColumns.put("dhcp_sniff", new Atom<>(true)); - } else { - updateColumns.put("dhcp_sniff", new Atom<>(false)); - } - - if (ifType.equals("vlan")) { - updateColumns.put("vlan_id", new Atom<>(vlanId)); - } else { - updateColumns.put("vlan_id", new com.vmware.ovsdb.protocol.operation.notation.Set()); - } - - Row row = new Row(updateColumns); - operations.add(new Update(wifiInetConfigDbTable, conditions, row)); - - CompletableFuture fResult = ovsdbClient.transact(ovsdbName, operations); - OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); - - LOG.debug("Provisioned WifiInetConfig {}", ifName); - - for (OperationResult res : result) { - LOG.debug("Op Result {}", res); - } - - } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { - LOG.error("Error in configureWifiInet", e); - throw new RuntimeException(e); - } - - } - - private void insertWifiInetConfigForVif(OvsdbClient ovsdbClient, int vlanId, String ifName, boolean enabled, - boolean isNAT, String ifType, String gateway, String inet, Map dns, String ipAssignScheme, - Uuid vifConfigUuid) { - - List operations = new ArrayList<>(); - Map updateColumns = new HashMap<>(); - - try { - /// usr/plume/tools/ovsh i Wifi_Inet_Config NAT:=false enabled:=true - /// if_name:=home-ap-24 if_type:=vif ip_assign_scheme:=none - /// network:=true - // dhcpd - updateColumns.put("if_name", new Atom<>(ifName)); - updateColumns.put("if_type", new Atom<>(ifType)); - updateColumns.put("if_uuid", new Atom<>(vifConfigUuid.toString())); - updateColumns.put("enabled", new Atom<>(enabled)); - updateColumns.put("NAT", new Atom<>(isNAT)); - - // mtu // specified in interface, should take that value when - // implemented - updateColumns.put("mtu", new Atom<>(1500)); - updateColumns.put("network", new Atom<>(true)); - - updateColumns.put("ip_assign_scheme", new Atom<>(ipAssignScheme)); - - if (ipAssignScheme.equals("static")) { - updateColumns.put("dns", com.vmware.ovsdb.protocol.operation.notation.Map.of(dns)); - updateColumns.put("inet_addr", new Atom<>(inet)); - updateColumns.put("gateway", new Atom<>(gateway)); - // netmask - // broadcast - } - if (ipAssignScheme.equals("dhcp")) { - updateColumns.put("dhcp_sniff", new Atom<>(true)); - } else { - updateColumns.put("dhcp_sniff", new Atom<>(false)); - } - - if (ifType.equals("vlan")) { - updateColumns.put("vlan_id", new Atom<>(vlanId)); - } else { - updateColumns.put("vlan_id", new com.vmware.ovsdb.protocol.operation.notation.Set()); - } - - Row row = new Row(updateColumns); - operations.add(new Insert(wifiInetConfigDbTable, row)); - - CompletableFuture fResult = ovsdbClient.transact(ovsdbName, operations); - OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); - - LOG.debug("Provisioned WifiInetConfig {}", ifName); - - for (OperationResult res : result) { - LOG.debug("Op Result {}", res); - } - - } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { - LOG.error("Error in configureWifiInet", e); - throw new RuntimeException(e); - } - - } +// private void insertWifiInetConfigForVif(OvsdbClient ovsdbClient, int vlanId, String ifName, boolean enabled, +// boolean isNAT, String ifType, String gateway, String inet, Map dns, String ipAssignScheme, +// Uuid vifConfigUuid) { +// +// List operations = new ArrayList<>(); +// Map updateColumns = new HashMap<>(); +// +// try { +// /// usr/plume/tools/ovsh i Wifi_Inet_Config NAT:=false enabled:=true +// /// if_name:=home-ap-24 if_type:=vif ip_assign_scheme:=none +// /// network:=true +// // dhcpd +// updateColumns.put("if_name", new Atom<>(ifName)); +// updateColumns.put("if_type", new Atom<>(ifType)); +// updateColumns.put("if_uuid", new Atom<>(vifConfigUuid.toString())); +// updateColumns.put("enabled", new Atom<>(enabled)); +// updateColumns.put("NAT", new Atom<>(isNAT)); +// +// // mtu // specified in interface, should take that value when +// // implemented +// updateColumns.put("mtu", new Atom<>(1500)); +// updateColumns.put("network", new Atom<>(true)); +// +// updateColumns.put("ip_assign_scheme", new Atom<>(ipAssignScheme)); +// +// if (ipAssignScheme.equals("static")) { +// updateColumns.put("dns", com.vmware.ovsdb.protocol.operation.notation.Map.of(dns)); +// updateColumns.put("inet_addr", new Atom<>(inet)); +// updateColumns.put("gateway", new Atom<>(gateway)); +// // netmask +// // broadcast +// } +// if (ipAssignScheme.equals("dhcp")) { +// updateColumns.put("dhcp_sniff", new Atom<>(true)); +// } else { +// updateColumns.put("dhcp_sniff", new Atom<>(false)); +// } +// +// if (ifType.equals("vlan")) { +// updateColumns.put("vlan_id", new Atom<>(vlanId)); +// } else { +// updateColumns.put("vlan_id", new com.vmware.ovsdb.protocol.operation.notation.Set()); +// } +// +// Row row = new Row(updateColumns); +// operations.add(new Insert(wifiInetConfigDbTable, row)); +// +// CompletableFuture fResult = ovsdbClient.transact(ovsdbName, operations); +// OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); +// +// LOG.debug("Provisioned WifiInetConfig {}", ifName); +// +// for (OperationResult res : result) { +// LOG.debug("Op Result {}", res); +// } +// +// } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { +// LOG.error("Error in configureWifiInet", e); +// throw new RuntimeException(e); +// } +// +// } public void configureWifiInet(OvsdbClient ovsdbClient, Map provisionedWifiInetConfigs, String ifName) { @@ -2291,28 +2374,21 @@ public class OvsdbDao { } - public void configureWifiInet(OvsdbClient ovsdbClient) { + private void configureWifiInet(OvsdbClient ovsdbClient) { + Map provisionedWifiVIFConfigs = getProvisionedWifiVifConfigs(ovsdbClient); + Map provisionedWifiInetConfigs = getProvisionedWifiInetConfigs(ovsdbClient); LOG.debug("Existing WifiInetConfigs: {}", provisionedWifiInetConfigs.keySet()); - String ifName = ifName2pt4GHz; - if (!provisionedWifiInetConfigs.containsKey(ifName)) { - configureWifiInet(ovsdbClient, provisionedWifiInetConfigs, ifName); + for (String ifName : provisionedWifiVIFConfigs.keySet()) { + if (!provisionedWifiInetConfigs.containsKey(ifName)) { + configureWifiInet(ovsdbClient, provisionedWifiInetConfigs, ifName); + } } - ifName = ifName5GHzL; - if (!provisionedWifiInetConfigs.containsKey(ifName)) { - configureWifiInet(ovsdbClient, provisionedWifiInetConfigs, ifName); - } - - ifName = ifName5GHzU; - if (!provisionedWifiInetConfigs.containsKey(ifName)) { - configureWifiInet(ovsdbClient, provisionedWifiInetConfigs, ifName); - } - - if (!provisionedWifiInetConfigs.containsKey(brLan) || !provisionedWifiInetConfigs.get(brLan).network) { + if (!provisionedWifiInetConfigs.containsKey(vifBridge) || !provisionedWifiInetConfigs.get(vifBridge).network) { // set network flag on brHome in wifiInetConfig table - configureWifiInetSetNetwork(ovsdbClient, brLan); + configureWifiInetSetNetwork(ovsdbClient, vifBridge); } } @@ -2363,20 +2439,23 @@ public class OvsdbDao { private void provisionWifiStatsConfigCapacity(Map radioConfigs, Map provisionedWifiStatsConfigs, List operations) { - radioConfigs.values().stream().forEach(rc -> { - if (!provisionedWifiStatsConfigs.containsKey(rc.freqBand + "_capacity")) { - // - Map rowColumns = new HashMap<>(); - rowColumns.put("radio_type", new Atom<>(rc.freqBand)); - rowColumns.put("reporting_interval", new Atom<>(60)); - // rowColumns.put("sampling_interval", new Atom<>(3)); - rowColumns.put("stats_type", new Atom<>("capacity")); - // rowColumns.put("survey_interval_ms", new Atom<>(65)); - // rowColumns.put("survey_type", new Atom<>("on-chan")); + radioConfigs.values().stream().forEach(new Consumer() { + @Override + public void accept(WifiRadioConfigInfo rc) { + if (!provisionedWifiStatsConfigs.containsKey(rc.freqBand + "_capacity")) { + // + Map rowColumns = new HashMap<>(); + rowColumns.put("radio_type", new Atom<>(rc.freqBand)); + rowColumns.put("reporting_interval", new Atom<>(60)); + // rowColumns.put("sampling_interval", new Atom<>(3)); + rowColumns.put("stats_type", new Atom<>("capacity")); + // rowColumns.put("survey_interval_ms", new Atom<>(65)); + // rowColumns.put("survey_type", new Atom<>("on-chan")); - Row updateRow = new Row(rowColumns); - operations.add(new Insert(wifiStatsConfigDbTable, updateRow)); + Row updateRow = new Row(rowColumns); + operations.add(new Insert(wifiStatsConfigDbTable, updateRow)); + } } }); @@ -2385,20 +2464,23 @@ public class OvsdbDao { private void provisionWifiStatsConfigBandSteering(Map radioConfigs, Map provisionedWifiStatsConfigs, List operations) { - radioConfigs.values().stream().forEach(rc -> { - if (!provisionedWifiStatsConfigs.containsKey(rc.freqBand + "_steering")) { - // - Map rowColumns = new HashMap<>(); - rowColumns.put("radio_type", new Atom<>(rc.freqBand)); - rowColumns.put("reporting_interval", new Atom<>(60)); - // rowColumns.put("sampling_interval", new Atom<>(3)); - rowColumns.put("stats_type", new Atom<>("steering")); - // rowColumns.put("survey_interval_ms", new Atom<>(65)); - // rowColumns.put("survey_type", new Atom<>("on-chan")); + radioConfigs.values().stream().forEach(new Consumer() { + @Override + public void accept(WifiRadioConfigInfo rc) { + if (!provisionedWifiStatsConfigs.containsKey(rc.freqBand + "_steering")) { + // + Map rowColumns = new HashMap<>(); + rowColumns.put("radio_type", new Atom<>(rc.freqBand)); + rowColumns.put("reporting_interval", new Atom<>(60)); + // rowColumns.put("sampling_interval", new Atom<>(3)); + rowColumns.put("stats_type", new Atom<>("steering")); + // rowColumns.put("survey_interval_ms", new Atom<>(65)); + // rowColumns.put("survey_type", new Atom<>("on-chan")); - Row updateRow = new Row(rowColumns); - operations.add(new Insert(wifiStatsConfigDbTable, updateRow)); + Row updateRow = new Row(rowColumns); + operations.add(new Insert(wifiStatsConfigDbTable, updateRow)); + } } }); @@ -2407,20 +2489,23 @@ public class OvsdbDao { private void provisionWifiStatsRssi(Map radioConfigs, Map provisionedWifiStatsConfigs, List operations) { - radioConfigs.values().stream().forEach(rc -> { - if (!provisionedWifiStatsConfigs.containsKey(rc.freqBand + "_rssi")) { - // - Map rowColumns = new HashMap<>(); - rowColumns.put("radio_type", new Atom<>(rc.freqBand)); - rowColumns.put("reporting_interval", new Atom<>(30)); - // rowColumns.put("sampling_interval", new Atom<>(3)); - rowColumns.put("stats_type", new Atom<>("rssi")); - rowColumns.put("survey_interval_ms", new Atom<>(65)); - // rowColumns.put("survey_type", new Atom<>("on-chan")); + radioConfigs.values().stream().forEach(new Consumer() { + @Override + public void accept(WifiRadioConfigInfo rc) { + if (!provisionedWifiStatsConfigs.containsKey(rc.freqBand + "_rssi")) { + // + Map rowColumns = new HashMap<>(); + rowColumns.put("radio_type", new Atom<>(rc.freqBand)); + rowColumns.put("reporting_interval", new Atom<>(30)); + // rowColumns.put("sampling_interval", new Atom<>(3)); + rowColumns.put("stats_type", new Atom<>("rssi")); + rowColumns.put("survey_interval_ms", new Atom<>(65)); + // rowColumns.put("survey_type", new Atom<>("on-chan")); - Row updateRow = new Row(rowColumns); - operations.add(new Insert(wifiStatsConfigDbTable, updateRow)); + Row updateRow = new Row(rowColumns); + operations.add(new Insert(wifiStatsConfigDbTable, updateRow)); + } } }); } @@ -2552,18 +2637,21 @@ public class OvsdbDao { } - radioConfigs.values().stream().forEach(rc -> { - if (!provisionedWifiStatsConfigs.containsKey(rc.freqBand + "_neighbor_on-chan")) { - // - Map rowColumns = new HashMap<>(); - rowColumns.put("radio_type", new Atom<>(rc.freqBand)); - rowColumns.put("reporting_interval", new Atom<>(60)); - rowColumns.put("stats_type", new Atom<>("neighbor")); - rowColumns.put("survey_type", new Atom<>("on-chan")); + radioConfigs.values().stream().forEach(new Consumer() { + @Override + public void accept(WifiRadioConfigInfo rc) { + if (!provisionedWifiStatsConfigs.containsKey(rc.freqBand + "_neighbor_on-chan")) { + // + Map rowColumns = new HashMap<>(); + rowColumns.put("radio_type", new Atom<>(rc.freqBand)); + rowColumns.put("reporting_interval", new Atom<>(60)); + rowColumns.put("stats_type", new Atom<>("neighbor")); + rowColumns.put("survey_type", new Atom<>("on-chan")); - Row updateRow = new Row(rowColumns); - operations.add(new Insert(wifiStatsConfigDbTable, updateRow)); + Row updateRow = new Row(rowColumns); + operations.add(new Insert(wifiStatsConfigDbTable, updateRow)); + } } }); @@ -2600,21 +2688,24 @@ public class OvsdbDao { Map updateColumns; Row row; - radioConfigs.values().stream().forEach(rc -> { - if (!provisionedWifiStatsConfigs.containsKey(rc.freqBand + "_survey_on-chan")) { + radioConfigs.values().stream().forEach(new Consumer() { + @Override + public void accept(WifiRadioConfigInfo rc) { + if (!provisionedWifiStatsConfigs.containsKey(rc.freqBand + "_survey_on-chan")) { - Map rowColumns = new HashMap<>(); - rowColumns.put("radio_type", new Atom<>(rc.freqBand)); - rowColumns.put("reporting_interval", new Atom<>(60)); - rowColumns.put("report_type", new Atom<>("raw")); - rowColumns.put("sampling_interval", new Atom<>(6)); - rowColumns.put("stats_type", new Atom<>("survey")); - rowColumns.put("survey_interval_ms", new Atom<>(65)); - rowColumns.put("survey_type", new Atom<>("on-chan")); + Map rowColumns = new HashMap<>(); + rowColumns.put("radio_type", new Atom<>(rc.freqBand)); + rowColumns.put("reporting_interval", new Atom<>(60)); + rowColumns.put("report_type", new Atom<>("raw")); + rowColumns.put("sampling_interval", new Atom<>(6)); + rowColumns.put("stats_type", new Atom<>("survey")); + rowColumns.put("survey_interval_ms", new Atom<>(65)); + rowColumns.put("survey_type", new Atom<>("on-chan")); - Row updateRow = new Row(rowColumns); - operations.add(new Insert(wifiStatsConfigDbTable, updateRow)); + Row updateRow = new Row(rowColumns); + operations.add(new Insert(wifiStatsConfigDbTable, updateRow)); + } } }); @@ -2674,21 +2765,24 @@ public class OvsdbDao { private void provisionWifiStatsConfigClient(Map radioConfigs, Map provisionedWifiStatsConfigs, List operations) { - radioConfigs.values().stream().forEach(rc -> { - if (!provisionedWifiStatsConfigs.containsKey(rc.freqBand + "_client")) { - // - Map rowColumns = new HashMap<>(); - rowColumns.put("radio_type", new Atom<>(rc.freqBand)); - rowColumns.put("reporting_interval", new Atom<>(60)); - rowColumns.put("report_type", new Atom<>("raw")); - rowColumns.put("sampling_interval", new Atom<>(10)); - rowColumns.put("stats_type", new Atom<>("client")); - rowColumns.put("survey_interval_ms", new Atom<>(65)); - // rowColumns.put("survey_type", new Atom<>("on-chan")); + radioConfigs.values().stream().forEach(new Consumer() { + @Override + public void accept(WifiRadioConfigInfo rc) { + if (!provisionedWifiStatsConfigs.containsKey(rc.freqBand + "_client")) { + // + Map rowColumns = new HashMap<>(); + rowColumns.put("radio_type", new Atom<>(rc.freqBand)); + rowColumns.put("reporting_interval", new Atom<>(60)); + rowColumns.put("report_type", new Atom<>("raw")); + rowColumns.put("sampling_interval", new Atom<>(10)); + rowColumns.put("stats_type", new Atom<>("client")); + rowColumns.put("survey_interval_ms", new Atom<>(65)); + // rowColumns.put("survey_type", new Atom<>("on-chan")); - Row updateRow = new Row(rowColumns); - operations.add(new Insert(wifiStatsConfigDbTable, updateRow)); + Row updateRow = new Row(rowColumns); + operations.add(new Insert(wifiStatsConfigDbTable, updateRow)); + } } });