From cabbebcb7a8a3f337f7ea8aeaccfd9cbce4bb438 Mon Sep 17 00:00:00 2001 From: Mike Hansen Date: Tue, 15 Dec 2020 16:57:10 -0500 Subject: [PATCH] Network: AP Equipment Profile: SKU and Country Code should not be left empty. --- .../OpensyncExternalIntegrationCloud.java | 7 +- .../opensync/ovsdb/TipWlanOvsdbClient.java | 142 ++++--- .../wlan/opensync/ovsdb/dao/OvsdbDao.java | 401 +++++++++++------- 3 files changed, 323 insertions(+), 227 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 3532131..39ea80d 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 @@ -985,8 +985,11 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra Status activeBssidsStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.ACTIVE_BSSIDS); - if (activeBssidsStatus != null && activeBssidsStatus.getDetails() != null) { - updateClientDetailsStatus(customerId, equipmentId, (ActiveBSSIDs) activeBssidsStatus.getDetails()); + + ActiveBSSIDs bssidStatusDetails = (ActiveBSSIDs) activeBssidsStatus.getDetails(); + + if (activeBssidsStatus != null && bssidStatusDetails != null && bssidStatusDetails.getActiveBSSIDs() != null) { + updateClientDetailsStatus(customerId, equipmentId, bssidStatusDetails); } LOG.info("Finished wifiVIFStateDbTableUpdate updated {}", activeBssidsStatus); diff --git a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/TipWlanOvsdbClient.java b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/TipWlanOvsdbClient.java index 5e7615c..0c9a467 100644 --- a/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/TipWlanOvsdbClient.java +++ b/opensync-gateway/src/main/java/com/telecominfraproject/wlan/opensync/ovsdb/TipWlanOvsdbClient.java @@ -32,7 +32,6 @@ import com.telecominfraproject.wlan.opensync.external.integration.models.Opensyn import com.telecominfraproject.wlan.opensync.ovsdb.dao.OvsdbDao; import com.telecominfraproject.wlan.opensync.util.OvsdbStringConstants; import com.telecominfraproject.wlan.opensync.util.SslUtil; -import com.telecominfraproject.wlan.profile.network.models.ApNetworkConfiguration; import com.vmware.ovsdb.callback.ConnectionCallback; import com.vmware.ovsdb.callback.MonitorCallback; import com.vmware.ovsdb.exception.OvsdbClientException; @@ -532,7 +531,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface { private void monitorAwlanNodeDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { CompletableFuture awCf = ovsdbClient.monitor(OvsdbDao.ovsdbName, OvsdbDao.awlanNodeDbTable + "_" + key, - new MonitorRequests(ImmutableMap.of(OvsdbDao.awlanNodeDbTable, new MonitorRequest(new MonitorSelect(true, false, false, true)))), + new MonitorRequests(ImmutableMap.of(OvsdbDao.awlanNodeDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))), new MonitorCallback() { @Override @@ -549,8 +548,8 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface { }); - awCf.join(); - + extIntegrationInterface.awlanNodeDbTableUpdate( + ovsdbDao.getOpensyncAWLANNode(awCf.join(), key, ovsdbClient), key); } private void monitorWifiAssociatedClientsDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { @@ -559,44 +558,47 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface { new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable, new MonitorRequest())), new MonitorCallback() { - @Override - public void update(TableUpdates tableUpdates) { + @Override + public void update(TableUpdates tableUpdates) { - try { - LOG.info(OvsdbDao.wifiAssociatedClientsDbTable + "_" + key + " monitor callback received {}", - tableUpdates); + try { + LOG.info(OvsdbDao.wifiAssociatedClientsDbTable + "_" + key + " monitor callback received {}", + tableUpdates); - List associatedClients = new ArrayList<>(); + List associatedClients = new ArrayList<>(); - for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { - - for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) { - if ((rowUpdate.getOld() != null) && (rowUpdate.getNew() == null)) { - Row row = rowUpdate.getOld(); - String deletedClientMac = row.getStringColumn("mac"); - // take care of the deletes as we go through - // the updates, as we want to delete before - // adding anyway. - extIntegrationInterface.wifiAssociatedClientsDbTableDelete(deletedClientMac, key); - } else { - associatedClients.addAll( - ovsdbDao.getOpensyncWifiAssociatedClients(rowUpdate, key, ovsdbClient)); - } - } + for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { + for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) { + if ((rowUpdate.getOld() != null) && (rowUpdate.getNew() == null)) { + Row row = rowUpdate.getOld(); + String deletedClientMac = row.getStringColumn("mac"); + // take care of the deletes as we go through + // the updates, as we want to delete before + // adding anyway. + extIntegrationInterface.wifiAssociatedClientsDbTableDelete(deletedClientMac, key); + } else { + associatedClients.addAll( + ovsdbDao.getOpensyncWifiAssociatedClients(rowUpdate, key, ovsdbClient)); } - - // now address the update/add - extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(associatedClients, key); - } catch (Exception e) { - LOG.error("wifiAssociatedClientsDbTableUpdate failed", e); } } - }); + // now address the update/add + extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(associatedClients, key); + } catch (Exception e) { + LOG.error("wifiAssociatedClientsDbTableUpdate failed", e); + } + + } + + }); + + + + extIntegrationInterface.wifiAssociatedClientsDbTableUpdate(ovsdbDao.getInitialOpensyncWifiAssociatedClients(acCf.join(), key, ovsdbClient), key); - acCf.join(); } @@ -644,7 +646,8 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface { } }); - isCf.join(); + + extIntegrationInterface.wifiInetStateDbTableUpdate(ovsdbDao.getInitialOpensyncApInetStateForRowUpdate(isCf.join(), key, ovsdbClient), key); } @@ -652,7 +655,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface { CompletableFuture rsCf = ovsdbClient.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiRadioStateDbTable + "_" + key, - new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable, new MonitorRequest(new MonitorSelect(true, false, false, true)))), + new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))), new MonitorCallback() { @Override @@ -669,8 +672,8 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface { } }); - rsCf.join(); - + extIntegrationInterface.wifiRadioStatusDbTableUpdate( + ovsdbDao.getOpensyncAPRadioState(rsCf.join(), key, ovsdbClient), key); } private void monitorWifiVifStateDbTable(OvsdbClient ovsdbClient, String key) throws OvsdbClientException { @@ -680,51 +683,50 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface { new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))), new MonitorCallback() { - @Override - public void update(TableUpdates tableUpdates) { - try { - LOG.info(OvsdbDao.wifiVifStateDbTable + "_" + key + " monitor callback received {}", - tableUpdates); + @Override + public void update(TableUpdates tableUpdates) { + try { + LOG.info(OvsdbDao.wifiVifStateDbTable + "_" + key + " monitor callback received {}", + tableUpdates); - List vifsToDelete = new ArrayList<>(); - List vifsToInsertOrUpdate = new ArrayList<>(); - for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { + List vifsToDelete = new ArrayList<>(); + List vifsToInsertOrUpdate = new ArrayList<>(); + for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { - for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) { + for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) { - if (rowUpdate.getNew() == null) { - // this is a deletion - vifsToDelete.addAll( - ovsdbDao.getOpensyncApVifStateForRowUpdate(rowUpdate, key, ovsdbClient)); + if (rowUpdate.getNew() == null) { + // this is a deletion + vifsToDelete.addAll( + ovsdbDao.getOpensyncApVifStateForRowUpdate(rowUpdate, key, ovsdbClient)); - } else { - // either an insert or - // mutuate/update - vifsToInsertOrUpdate.addAll( - ovsdbDao.getOpensyncApVifStateForRowUpdate(rowUpdate, key, ovsdbClient)); - - } - - } - - // delete first, if required - if (!vifsToDelete.isEmpty()) { - extIntegrationInterface.wifiVIFStateDbTableDelete(vifsToDelete, key); - } - if (!vifsToInsertOrUpdate.isEmpty()) { - extIntegrationInterface.wifiVIFStateDbTableUpdate(vifsToInsertOrUpdate, key); - } + } else { + // either an insert or + // mutuate/update + vifsToInsertOrUpdate.addAll( + ovsdbDao.getOpensyncApVifStateForRowUpdate(rowUpdate, key, ovsdbClient)); } - } catch (Exception e) { - LOG.error("wifiVIFStateDbTableUpdate failed", e); + + } + + // delete first, if required + if (!vifsToDelete.isEmpty()) { + extIntegrationInterface.wifiVIFStateDbTableDelete(vifsToDelete, key); + } + if (!vifsToInsertOrUpdate.isEmpty()) { + extIntegrationInterface.wifiVIFStateDbTableUpdate(vifsToInsertOrUpdate, key); } } + } catch (Exception e) { + LOG.error("wifiVIFStateDbTableUpdate failed", e); + } - }); + } - vsCf.join(); + }); + extIntegrationInterface.wifiVIFStateDbTableUpdate(ovsdbDao.getInitialOpensyncApVifStateForTableUpdates(vsCf.join(), key, ovsdbClient),key); } 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 9eca627..182b334 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 @@ -688,17 +688,16 @@ public class OvsdbDao { CompletableFuture fResult = ovsdbClient.transact(ovsdbName, operations); OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); - LOG.debug("Updated {}:", wifiStatsConfigDbTable); + LOG.debug("Updated {}:", wifiStatsConfigDbTable); - for (OperationResult res : result) { - LOG.debug("Op Result {}", res); - if (res instanceof InsertResult) { - LOG.info("updateDeviceStatsReportingInterval insert new row result {}", ((InsertResult)res)); - // for insert, make sure it is actually in the table - confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), wifiStatsConfigDbTable); - } + for (OperationResult res : result) { + LOG.debug("Op Result {}", res); + if (res instanceof InsertResult) { + LOG.info("updateDeviceStatsReportingInterval insert new row result {}", ((InsertResult) res)); + // for insert, make sure it is actually in the table + confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), wifiStatsConfigDbTable); } - + } } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { throw new RuntimeException(e); @@ -730,8 +729,8 @@ public class OvsdbDao { if (LOG.isDebugEnabled()) { for (OperationResult res : result) { - if (res instanceof InsertResult) { - LOG.info("enableNetworkProbeForSyntheticClient insert new row result {}", ((InsertResult)res)); + if (res instanceof InsertResult) { + LOG.info("enableNetworkProbeForSyntheticClient insert new row result {}", ((InsertResult) res)); // for insert, make sure it is actually in the table confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), wifiStatsConfigDbTable); } else if (res instanceof ErrorResult) { @@ -1262,73 +1261,73 @@ public class OvsdbDao { .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) { wifiVifConfigInfo.macListType = row.getStringColumn("mac_list_type"); } - + wifiVifConfigInfo.customOptions = row.getMapColumn("custom_options"); wifiVifConfigInfo.captiveAllowlist = row.getSetColumn("captive_allowlist"); wifiVifConfigInfo.captivePortal = row.getMapColumn("captive_portal"); - + Boolean wpsPbc = getSingleValueFromSet(row, "wps_pbc"); if (wpsPbc != null) { wifiVifConfigInfo.wpsPbc = wpsPbc; } else { wifiVifConfigInfo.wpsPbc = false; } - + Boolean wps = getSingleValueFromSet(row, "wps"); if (wps != null) { wifiVifConfigInfo.wps = wps; } else { wifiVifConfigInfo.wps = false; } - + Boolean wds = getSingleValueFromSet(row, "wds"); if (wds != null) { wifiVifConfigInfo.wds = wds; } else { wifiVifConfigInfo.wds = false; } - + wifiVifConfigInfo.wpsPbcKeyId = row.getStringColumn("wps_pbc_key_id"); - + Boolean mcast2ucast = getSingleValueFromSet(row, "mcast2ucast"); if (mcast2ucast != null) { wifiVifConfigInfo.mcast2ucast = mcast2ucast; } else { wifiVifConfigInfo.mcast2ucast = false; } - + Boolean dynamicBeacon = getSingleValueFromSet(row, "dynamic_beacon"); if (dynamicBeacon != null) { wifiVifConfigInfo.dynamicBeacon = dynamicBeacon; } else { wifiVifConfigInfo.dynamicBeacon = false; } - + Long vifDbgLvl = getSingleValueFromSet(row, "vif_dbg_lvl"); if (vifDbgLvl != null) { wifiVifConfigInfo.vifDbgLvl = vifDbgLvl.intValue(); } else { wifiVifConfigInfo.vifDbgLvl = 0; } - + if (row.getColumns().containsKey("mesh_options")) { wifiVifConfigInfo.meshOptions = row.getMapColumn("mesh_options"); } - + wifiVifConfigInfo.credentialConfigs = row.getSetColumn("credential_configs"); - + String parent = getSingleValueFromSet(row, "parent"); if (parent != null) { wifiVifConfigInfo.parent = parent; } - + String multiAp = getSingleValueFromSet(row, "multi_ap"); if (multiAp != null) { wifiVifConfigInfo.multiAp = multiAp; } - + ret.put(wifiVifConfigInfo.ifName + '_' + wifiVifConfigInfo.ssid, wifiVifConfigInfo); - + } LOG.debug("Retrieved WifiVifConfigs: {}", ret); @@ -1787,26 +1786,26 @@ public class OvsdbDao { for (OperationResult res : result) { LOG.info("Op Result {}", res); } - - provisionedWifiInetConfigs = getProvisionedWifiInetConfigs(ovsdbClient) - .values(); + + provisionedWifiInetConfigs = getProvisionedWifiInetConfigs(ovsdbClient).values(); for (WifiInetConfigInfo inetConfigInfo : provisionedWifiInetConfigs) { if (inetConfigInfo.ifType.equals("vif") || inetConfigInfo.ifType.equals("gre")) { - throw new RuntimeException("Failed to remove all vif and gre interface configurations from Wifi_Inet_Config dbTable, still has " + provisionedWifiInetConfigs.stream().filter(new Predicate() { + throw new RuntimeException( + "Failed to remove all vif and gre interface configurations from Wifi_Inet_Config dbTable, still has " + + provisionedWifiInetConfigs.stream().filter(new Predicate() { - @Override - public boolean test(WifiInetConfigInfo t) { - if ((t.ifType.equals("vif")) || (t.ifType.equals("gre"))) return true; - return false; - } + @Override + public boolean test(WifiInetConfigInfo t) { + if ((t.ifType.equals("vif")) || (t.ifType.equals("gre"))) + return true; + return false; + } - }).collect(Collectors.toList()) ); + }).collect(Collectors.toList())); } } - - } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { LOG.error("Error in removeAllInetConfigs", e); @@ -1826,22 +1825,25 @@ public class OvsdbDao { CompletableFuture fResult = ovsdbClient.transact(ovsdbName, operations); OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); - for (OperationResult res : result) { LOG.info("Op Result {}", res); if (res instanceof UpdateResult) { - LOG.info("removeAllSsids:result {}", ((UpdateResult)res).toString()); + LOG.info("removeAllSsids:result {}", ((UpdateResult) res).toString()); } else if (res instanceof ErrorResult) { - LOG.error("removeAllSsids:result error {}", ((ErrorResult)res)); - throw new RuntimeException("removeAllSsids " + ((ErrorResult)res).getError() + " " + ((ErrorResult)res).getDetails()); + LOG.error("removeAllSsids:result error {}", ((ErrorResult) res)); + throw new RuntimeException("removeAllSsids " + ((ErrorResult) res).getError() + " " + + ((ErrorResult) res).getDetails()); } } Map provisionedVifConfigs = getProvisionedWifiVifConfigs(ovsdbClient); // this should be empty if (!provisionedVifConfigs.isEmpty()) { - throw new RuntimeException("Failed to remove all vif configurations from Wifi_VIF_Config dbTable, still has " + provisionedVifConfigs.values() ); - }; + throw new RuntimeException( + "Failed to remove all vif configurations from Wifi_VIF_Config dbTable, still has " + + provisionedVifConfigs.values()); + } + ; LOG.info("Removed all ssids"); @@ -2035,10 +2037,11 @@ public class OvsdbDao { for (OperationResult res : result) { if (res instanceof UpdateResult) { - LOG.info("configureLanInterfacesForDhcpSniffing {}", ((UpdateResult)res).toString()); + LOG.info("configureLanInterfacesForDhcpSniffing {}", ((UpdateResult) res).toString()); } else if (res instanceof ErrorResult) { - LOG.error("configureLanInterfacesForDhcpSniffing error {}", ((ErrorResult)res)); - throw new RuntimeException("configureLanInterfacesForDhcpSniffing " + ((ErrorResult)res).getError() + " " + ((ErrorResult)res).getDetails()); + LOG.error("configureLanInterfacesForDhcpSniffing error {}", ((ErrorResult) res)); + throw new RuntimeException("configureLanInterfacesForDhcpSniffing " + ((ErrorResult) res).getError() + + " " + ((ErrorResult) res).getDetails()); } } } catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) { @@ -2067,11 +2070,13 @@ public class OvsdbDao { for (OperationResult res : result) { if (res instanceof UpdateResult) { - LOG.info("configureWanInterfacesForDhcpSniffing {}", ((UpdateResult)res).toString()); + LOG.info("configureWanInterfacesForDhcpSniffing {}", ((UpdateResult) res).toString()); } else if (res instanceof ErrorResult) { - LOG.error("configureWanInterfacesForDhcpSniffing error {}", ((ErrorResult)res)); - throw new RuntimeException("configureWanInterfacesForDhcpSniffing " + ((ErrorResult)res).getError() + " " + ((ErrorResult)res).getDetails()); - } } + LOG.error("configureWanInterfacesForDhcpSniffing error {}", ((ErrorResult) res)); + throw new RuntimeException("configureWanInterfacesForDhcpSniffing " + ((ErrorResult) res).getError() + + " " + ((ErrorResult) res).getDetails()); + } + } } catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) { LOG.error("OvsdbDao::configureWanInterfaces failed.", e); throw new RuntimeException(e); @@ -2199,6 +2204,31 @@ public class OvsdbDao { return ret; } + public List getInitialOpensyncApInetStateForRowUpdate(TableUpdates tableUpdates, String apId, + OvsdbClient ovsdbClient) { + + LOG.info("getInitialOpensyncApInetStateForRowUpdate:"); + List ret = new ArrayList<>(); + try { + LOG.info(OvsdbDao.wifiInetStateDbTable + "_" + apId + " initial monitor table state received {}", + tableUpdates); + + for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { + + for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) { + + if (rowUpdate.getNew() != null) + ret.addAll(getOpensyncApInetStateForRowUpdate(rowUpdate, apId, ovsdbClient)); + } + + } + } catch (Exception e) { + throw (e); + } + return ret; + + } + public List getOpensyncApInetStateForRowUpdate(RowUpdate rowUpdate, String apId, OvsdbClient ovsdbClient) { List ret = new ArrayList<>(); @@ -2299,14 +2329,43 @@ public class OvsdbDao { return ret; } + public List getInitialOpensyncApVifStateForTableUpdates(TableUpdates tableUpdates, String apId, + OvsdbClient ovsdbClient) { + + LOG.info("getInitialOpensyncApVifStateForTableUpdates:"); + List ret = new ArrayList<>(); + try { + LOG.info(OvsdbDao.wifiVifStateDbTable + "_" + apId + " initial monitor table state received {}", + tableUpdates); + + for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { + + for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) { + + if (rowUpdate.getNew() != null) { + OpensyncAPVIFState tableState = processWifiVIFStateColumn(ovsdbClient, rowUpdate.getNew()); + + ret.add(tableState); + } + + } + + } + } catch (Exception e) { + throw (e); + } + return ret; + + } + public List getOpensyncApVifStateForRowUpdate(RowUpdate rowUpdate, String apId, OvsdbClient ovsdbClient) { List ret = new ArrayList<>(); try { - Row row = rowUpdate.getNew(); // add/modify + Row row = rowUpdate.getNew(); // add/modify/init if (row == null) { - row = rowUpdate.getOld(); // delete + row = rowUpdate.getOld(); // delete/modify } OpensyncAPVIFState tableState = processWifiVIFStateColumn(ovsdbClient, row); @@ -2320,6 +2379,35 @@ public class OvsdbDao { } return ret; } + + + public List getInitialOpensyncWifiAssociatedClients(TableUpdates tableUpdates, String apId, + OvsdbClient ovsdbClient) { + + LOG.info("getInitialOpensyncWifiAssociatedClients:"); + List ret = new ArrayList<>(); + try { + LOG.info(OvsdbDao.wifiAssociatedClientsDbTable + "_" + apId + " initial monitor table state received {}", + tableUpdates); + + for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) { + + for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) { + + if (rowUpdate.getNew() != null) + ret.addAll(getOpensyncWifiAssociatedClients(rowUpdate, apId, ovsdbClient)); + } + + } + } catch (Exception e) { + throw (e); + } + return ret; + + } + + + public List getOpensyncWifiAssociatedClients(RowUpdate rowUpdate, String apId, OvsdbClient ovsdbClient) { @@ -2589,7 +2677,8 @@ public class OvsdbDao { String ipAssignScheme, List macBlockList, boolean rateLimitEnable, int ssidDlLimit, int ssidUlLimit, int clientDlLimit, int clientUlLimit, int rtsCtsThreshold, int fragThresholdBytes, int dtimPeriod, Map captiveMap, List walledGardenAllowlist, - Map> bonjourServiceMap, String radiusNasId, String radiusNasIp, String radiusOperatorName) { + Map> bonjourServiceMap, String radiusNasId, String radiusNasIp, + String radiusOperatorName) { List operations = new ArrayList<>(); Map updateColumns = new HashMap<>(); @@ -2716,9 +2805,10 @@ public class OvsdbDao { insertResult = (InsertResult) res; LOG.info("configureSingleSsid:InsertResult {}", insertResult); vifConfigUuid = ((InsertResult) res).getUuid(); - } else if (res instanceof ErrorResult) { - LOG.error("configureSingleSsid: error {}", ((ErrorResult)res)); - throw new RuntimeException("configureSingleSsid " + ((ErrorResult)res).getError() + " " + ((ErrorResult)res).getDetails()); + } else if (res instanceof ErrorResult) { + LOG.error("configureSingleSsid: error {}", ((ErrorResult) res)); + throw new RuntimeException("configureSingleSsid " + ((ErrorResult) res).getError() + " " + + ((ErrorResult) res).getDetails()); } } if (vifConfigUuid == null) { @@ -2738,7 +2828,7 @@ public class OvsdbDao { } } - + private void confirmRowExistsInTable(OvsdbClient ovsdbClient, Uuid rowUuid, String table) { try { List conditions = new ArrayList<>(); @@ -2754,8 +2844,9 @@ public class OvsdbDao { LOG.info("Select Result for confirmRowExistsInTable {} with Uuid {} {}", table, rowUuid, ((SelectResult) res).getRows()); } else if (res instanceof ErrorResult) { - LOG.error("confirmRowExistsInTable error {}", ((ErrorResult)res)); - throw new RuntimeException("confirmRowExistsInTable " + ((ErrorResult)res).getError() + " " + ((ErrorResult)res).getDetails()); + LOG.error("confirmRowExistsInTable error {}", ((ErrorResult) res)); + throw new RuntimeException("confirmRowExistsInTable " + ((ErrorResult) res).getError() + " " + + ((ErrorResult) res).getDetails()); } } } catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) { @@ -2844,8 +2935,9 @@ public class OvsdbDao { if (res instanceof UpdateResult) { LOG.debug("updateVifConfigsSetForRadio:result {}", (UpdateResult) res); } else if (res instanceof ErrorResult) { - LOG.error("updateVifConfigsSetForRadio error {}", ((ErrorResult)res)); - throw new RuntimeException("updateVifConfigsSetForRadio " + ((ErrorResult)res).getError() + " " + ((ErrorResult)res).getDetails()); + LOG.error("updateVifConfigsSetForRadio error {}", ((ErrorResult) res)); + throw new RuntimeException("updateVifConfigsSetForRadio " + ((ErrorResult) res).getError() + " " + + ((ErrorResult) res).getDetails()); } } @@ -2864,8 +2956,9 @@ public class OvsdbDao { + "vif_configs table was not updated {} for new Wifi_VIF_Config " + vifConfigUuid); } } else if (res instanceof ErrorResult) { - LOG.error("updateVifConfigsSetForRadio error {}", ((ErrorResult)res)); - throw new RuntimeException("updateVifConfigsSetForRadio " + ((ErrorResult)res).getError() + " " + ((ErrorResult)res).getDetails()); + LOG.error("updateVifConfigsSetForRadio error {}", ((ErrorResult) res)); + throw new RuntimeException("updateVifConfigsSetForRadio " + ((ErrorResult) res).getError() + " " + + ((ErrorResult) res).getDetails()); } } LOG.info("Updated WifiRadioConfig {} for SSID {}:", radioFreqBand, ssid); @@ -3049,13 +3142,14 @@ public class OvsdbDao { String radiusNasId = null; String radiusNasIp = null; String radiusOperName = null; - + opensyncSecurityMode = getOpensyncSecurityMode(ssidSecurityMode, opensyncSecurityMode); populateSecurityMap(opensyncApConfig, ssidConfig, security, ssidSecurityMode, opensyncSecurityMode); - + if (opensyncSecurityMode.endsWith("EAP")) { radiusNasId = ssidConfig.getRadiusNasId(); - radiusNasIp = ssidConfig.getRadiusNasIp() != null ? ssidConfig.getRadiusNasIp().getHostAddress() : null; + radiusNasIp = ssidConfig.getRadiusNasIp() != null ? ssidConfig.getRadiusNasIp().getHostAddress() + : null; radiusOperName = ssidConfig.getRadiusOperName(); } @@ -3152,7 +3246,8 @@ public class OvsdbDao { if (ssidConfig.getRadiusAccountingServiceName() != null) { getRadiusAccountingConfiguration(opensyncApConfig, ssidConfig, security); } - } else if (ssidSecurityMode.equals("wpa2EAP") || ssidSecurityMode.equals("wpa2Radius") || ssidSecurityMode.equals("wpa3MixedEAP")) { + } else if (ssidSecurityMode.equals("wpa2EAP") || ssidSecurityMode.equals("wpa2Radius") + || ssidSecurityMode.equals("wpa3MixedEAP")) { security.put("mode", "mixed"); getRadiusConfiguration(opensyncApConfig, ssidConfig, security); if (ssidConfig.getRadiusAccountingServiceName() != null) { @@ -3185,7 +3280,7 @@ public class OvsdbDao { opensyncSecurityMode = "WPA-EAP"; } else if (ssidSecurityMode.equals("wpa3OnlySAE") || ssidSecurityMode.equals("wpa3MixedSAE")) { opensyncSecurityMode = "WPA-SAE"; - }else if (ssidSecurityMode.equals("wpa3OnlyEAP") || ssidSecurityMode.equals("wpa3MixedEAP")) { + } else if (ssidSecurityMode.equals("wpa3OnlyEAP") || ssidSecurityMode.equals("wpa3MixedEAP")) { opensyncSecurityMode = "WPA3-EAP"; } return opensyncSecurityMode; @@ -3210,9 +3305,6 @@ public class OvsdbDao { private void configureGreTunnel(OvsdbClient ovsdbClient, Profile apNetworkConfiguration) { - - - try { LOG.debug("Configure Gre Tunnel {}", apNetworkConfiguration); List operations = new ArrayList<>(); @@ -3223,7 +3315,7 @@ public class OvsdbDao { if (greTunnelConfiguration.getGreParentIfName() == null) { LOG.info("Cannot configure GRE profile without gre_ifname"); continue; - } + } if (greTunnelConfiguration.getGreRemoteInetAddr() == null) { LOG.info("Cannot configure GRE profile without gre_remote_inet_addr"); @@ -3234,20 +3326,23 @@ public class OvsdbDao { LOG.info("Cannot configure GRE profile without if_name"); continue; } - + Map tableColumns = new HashMap<>(); - tableColumns.put("gre_ifname", new Atom<>(greTunnelConfiguration.getGreParentIfName())); - tableColumns.put("gre_remote_inet_addr", new Atom<>(greTunnelConfiguration.getGreRemoteInetAddr().getHostAddress())); + tableColumns.put("gre_ifname", new Atom<>(greTunnelConfiguration.getGreParentIfName())); + tableColumns.put("gre_remote_inet_addr", + new Atom<>(greTunnelConfiguration.getGreRemoteInetAddr().getHostAddress())); tableColumns.put("if_name", new Atom<>(greTunnelConfiguration.getGreTunnelName())); - + // optional if (greTunnelConfiguration.getGreLocalInetAddr() != null) { - tableColumns.put("gre_local_inet_addr", new Atom<>(greTunnelConfiguration.getGreLocalInetAddr().getHostAddress())); + tableColumns.put("gre_local_inet_addr", + new Atom<>(greTunnelConfiguration.getGreLocalInetAddr().getHostAddress())); } // optional if (greTunnelConfiguration.getGreRemoteMacAddr() != null) { - tableColumns.put("gre_remote_mac_addr", new Atom<>(greTunnelConfiguration.getGreRemoteMacAddr().getAddressAsString())); + tableColumns.put("gre_remote_mac_addr", + new Atom<>(greTunnelConfiguration.getGreRemoteMacAddr().getAddressAsString())); } tableColumns.put("if_type", new Atom<>("gre")); @@ -3273,10 +3368,10 @@ public class OvsdbDao { LOG.info("configureGreTunnel {}", ((UpdateResult) res).toString()); } else if (res instanceof ErrorResult) { LOG.error("configureGreTunnel error {}", ((ErrorResult) res)); - throw new RuntimeException("configureGreTunnel " + ((ErrorResult) res).getError() - + " " + ((ErrorResult) res).getDetails()); + throw new RuntimeException("configureGreTunnel " + ((ErrorResult) res).getError() + " " + + ((ErrorResult) res).getDetails()); } - } + } } catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) { LOG.error("Couldn't configure Gre Tunnel {}", apNetworkConfiguration, e); throw new RuntimeException(e); @@ -3293,22 +3388,23 @@ public class OvsdbDao { } for (Integer vlanId : vlans) { + Optional tunnelConfiguration = ((ApNetworkConfiguration) opensyncApConfig + .getApProfile().getDetails()).getGreTunnelConfigurations().stream() + .filter(new Predicate() { - Optional tunnelConfiguration = ((ApNetworkConfiguration)opensyncApConfig.getApProfile().getDetails()).getGreTunnelConfigurations().stream().filter(new Predicate() { + @Override + public boolean test(GreTunnelConfiguration t) { - @Override - public boolean test(GreTunnelConfiguration t) { + return t.getVlanIdsInGreTunnel().contains(vlanId); + } - return t.getVlanIdsInGreTunnel().contains(vlanId); - } - - }).findFirst(); + }).findFirst(); if (tunnelConfiguration.isPresent()) { - createVlanInterfaceInGreTunnel(ovsdbClient,vlanId, tunnelConfiguration.get().getGreTunnelName()); + createVlanInterfaceInGreTunnel(ovsdbClient, vlanId, tunnelConfiguration.get().getGreTunnelName()); } else { - createVlanNetworkInterfaces(ovsdbClient, vlanId); - } + createVlanNetworkInterfaces(ovsdbClient, vlanId); + } } } @@ -3321,11 +3417,9 @@ public class OvsdbDao { Map inetConfigMap = getProvisionedWifiInetConfigs(ovsdbClient); - - WifiInetConfigInfo parentTunnel = inetConfigMap.get(greTunnel); + WifiInetConfigInfo parentTunnel = inetConfigMap.get(greTunnel); if (parentTunnel == null) - throw new RuntimeException( - "Cannot get tunnel interface " + parentTunnel + " for vlan " + vlanId); + throw new RuntimeException("Cannot get tunnel interface " + parentTunnel + " for vlan " + vlanId); tableColumns = new HashMap<>(); @@ -3363,8 +3457,8 @@ public class OvsdbDao { LOG.info("createVlanNetworkInterfaces {}", ((UpdateResult) res).toString()); } else if (res instanceof ErrorResult) { LOG.error("createVlanNetworkInterfaces error {}", ((ErrorResult) res)); - throw new RuntimeException("createVlanNetworkInterfaces " + ((ErrorResult) res).getError() - + " " + ((ErrorResult) res).getDetails()); + throw new RuntimeException("createVlanNetworkInterfaces " + ((ErrorResult) res).getError() + " " + + ((ErrorResult) res).getDetails()); } } @@ -3379,7 +3473,7 @@ public class OvsdbDao { } } - + private void createVlanNetworkInterfaces(OvsdbClient ovsdbClient, int vlanId) { try { @@ -3464,8 +3558,8 @@ public class OvsdbDao { LOG.info("createVlanNetworkInterfaces {}", ((UpdateResult) res).toString()); } else if (res instanceof ErrorResult) { LOG.error("createVlanNetworkInterfaces error {}", ((ErrorResult) res)); - throw new RuntimeException("createVlanNetworkInterfaces " + ((ErrorResult) res).getError() - + " " + ((ErrorResult) res).getDetails()); + throw new RuntimeException("createVlanNetworkInterfaces " + ((ErrorResult) res).getError() + " " + + ((ErrorResult) res).getDetails()); } } @@ -3721,18 +3815,19 @@ public class OvsdbDao { LOG.debug("Updated Inet {}", ifName); for (OperationResult res : result) { - - if (res instanceof InsertResult) { - LOG.info("configureInetInterface insert new row result {}", ((InsertResult)res)); + + if (res instanceof InsertResult) { + LOG.info("configureInetInterface insert new row result {}", ((InsertResult) res)); // for insert, make sure it is actually in the table confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), wifiInetConfigDbTable); } else if (res instanceof UpdateResult) { - LOG.info("configureInetInterface update new row result {}", ((UpdateResult)res)); - } else if (res instanceof ErrorResult) { - LOG.error("configureInetInterface error {}", ((ErrorResult)res)); - throw new RuntimeException("configureInetInterface " + ((ErrorResult)res).getError() + " " + ((ErrorResult)res).getDetails()); + LOG.info("configureInetInterface update new row result {}", ((UpdateResult) res)); + } else if (res instanceof ErrorResult) { + LOG.error("configureInetInterface error {}", ((ErrorResult) res)); + throw new RuntimeException("configureInetInterface " + ((ErrorResult) res).getError() + " " + + ((ErrorResult) res).getDetails()); } - + } } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { @@ -3776,8 +3871,8 @@ public class OvsdbDao { return t.getId() == hs2Profile.getPasspointVenueProfileId(); } - }).findFirst().get(); - + }).findFirst().get(); + PasspointVenueProfile passpointVenueProfile = (PasspointVenueProfile) venue.getDetails(); Map rowColumns = new HashMap<>(); @@ -3791,8 +3886,7 @@ public class OvsdbDao { .of(domainNames); rowColumns.put("domain_name", domainNameSet); } - - + Map osuProviders = getProvisionedHotspot20OsuProviders( ovsdbClient); List providerList = new ArrayList<>(); @@ -3809,7 +3903,7 @@ public class OvsdbDao { Set osuProvidersUuids = new HashSet<>(); Set osuIconUuids = new HashSet<>(); - + StringBuffer mccMncBuffer = new StringBuffer(); Set> naiRealms = new HashSet<>(); Set> roamingOis = new HashSet<>(); @@ -3862,8 +3956,6 @@ public class OvsdbDao { rowColumns.put("operator_icons", iconUuids); } - - hs2Profile.getIpAddressTypeAvailability(); rowColumns.put("deauth_request_timeout", new Atom<>(hs2Profile.getDeauthRequestTimeout())); rowColumns.put("osen", @@ -3992,9 +4084,10 @@ public class OvsdbDao { for (OperationResult res : result) { LOG.debug("provisionHotspot20Config Op Result {}", res); if (res instanceof InsertResult) { - LOG.info("provisionHotspot20Config insert new row result {}", ((InsertResult)res)); + LOG.info("provisionHotspot20Config insert new row result {}", ((InsertResult) res)); // for insert, make sure it is actually in the table - confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), hotspot20ConfigDbTable); + confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), + hotspot20ConfigDbTable); } } @@ -4070,11 +4163,12 @@ public class OvsdbDao { for (OperationResult res : result) { LOG.debug("provisionHotspot20OsuProviders Op Result {}", res); if (res instanceof InsertResult) { - LOG.info("provisionHotspot20OsuProviders insert new row result {}", ((InsertResult)res)); + LOG.info("provisionHotspot20OsuProviders insert new row result {}", ((InsertResult) res)); // for insert, make sure it is actually in the table - confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), hotspot20OsuProvidersDbTable); + confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), + hotspot20OsuProvidersDbTable); } else if (res instanceof UpdateResult) { - LOG.info("provisionHotspot20OsuProviders update row result {}", ((UpdateResult)res)); + LOG.info("provisionHotspot20OsuProviders update row result {}", ((UpdateResult) res)); } } @@ -4282,11 +4376,12 @@ public class OvsdbDao { for (OperationResult res : result) { LOG.debug("provisionHotspot20Config Op Result {}", res); if (res instanceof InsertResult) { - LOG.info("provisionHotspot20Config insert new row result {}", ((InsertResult)res)); + LOG.info("provisionHotspot20Config insert new row result {}", ((InsertResult) res)); // for insert, make sure it is actually in the table - confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), hotspot20IconConfigDbTable); + confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), + hotspot20IconConfigDbTable); } else if (res instanceof UpdateResult) { - LOG.info("provisionHotspot20Config update row result {}", ((UpdateResult)res)); + LOG.info("provisionHotspot20Config update row result {}", ((UpdateResult) res)); } } @@ -4810,24 +4905,23 @@ public class OvsdbDao { CompletableFuture fResult = ovsdbClient.transact(ovsdbName, operations); OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); - for (OperationResult res : result) { - if (res instanceof InsertResult) { - LOG.info("provisionVideoVoiceStats insert new row result {}", ((InsertResult)res)); - // for insert, make sure it is actually in the table - confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), wifiStatsConfigDbTable); - } else if (res instanceof UpdateResult) { - LOG.info("provisionVideoVoiceStats update row result {}", ((UpdateResult)res)); + for (OperationResult res : result) { + if (res instanceof InsertResult) { + LOG.info("provisionVideoVoiceStats insert new row result {}", ((InsertResult) res)); + // for insert, make sure it is actually in the table + confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), wifiStatsConfigDbTable); + } else if (res instanceof UpdateResult) { + LOG.info("provisionVideoVoiceStats update row result {}", ((UpdateResult) res)); - }else if (res instanceof ErrorResult) { - LOG.error("Could not update {}:", wifiStatsConfigDbTable); - LOG.error("Error: {} Details: {}", ((ErrorResult) res).getError(), - ((ErrorResult) res).getDetails()); - } else { - LOG.debug("Updated {}:", wifiStatsConfigDbTable); - LOG.debug("Op Result {}", res); - } + } else if (res instanceof ErrorResult) { + LOG.error("Could not update {}:", wifiStatsConfigDbTable); + LOG.error("Error: {} Details: {}", ((ErrorResult) res).getError(), + ((ErrorResult) res).getDetails()); + } else { + LOG.debug("Updated {}:", wifiStatsConfigDbTable); + LOG.debug("Op Result {}", res); } - + } } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { throw new RuntimeException(e); @@ -4868,11 +4962,11 @@ public class OvsdbDao { for (OperationResult res : result) { if (res instanceof InsertResult) { - LOG.info("provisionEventReporting insert new row result {}", ((InsertResult)res)); + LOG.info("provisionEventReporting insert new row result {}", ((InsertResult) res)); // for insert, make sure it is actually in the table confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), wifiStatsConfigDbTable); } else if (res instanceof UpdateResult) { - LOG.info("provisionEventReporting update row result {}", ((UpdateResult)res)); + LOG.info("provisionEventReporting update row result {}", ((UpdateResult) res)); } else if (res instanceof ErrorResult) { LOG.error("Could not update {}:", wifiStatsConfigDbTable); LOG.error("Error: {} Details: {}", ((ErrorResult) res).getError(), @@ -4884,9 +4978,6 @@ public class OvsdbDao { } } - - - } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { throw new RuntimeException(e); } @@ -4981,7 +5072,7 @@ public class OvsdbDao { public void rebootOrResetAp(OvsdbClient ovsdbClient, String desiredApAction) { try { LOG.debug("rebootOrResetAp on AP perform {}, setting timer for {} seconds.", desiredApAction, - rebootOrResetTimerSeconds); + rebootOrResetTimerSeconds); List operations = new ArrayList<>(); Map updateColumns = new HashMap<>(); updateColumns.put("firmware_url", new Atom<>(desiredApAction)); @@ -5013,12 +5104,11 @@ public class OvsdbDao { CompletableFuture fResult = ovsdbClient.transact(ovsdbName, operations); OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); - LOG.info("Removed all existing config from {}:", wifiStatsConfigDbTable); + LOG.info("Removed all existing config from {}:", wifiStatsConfigDbTable); - for (OperationResult res : result) { - LOG.debug("Op Result {}", res); - } - + for (OperationResult res : result) { + LOG.debug("Op Result {}", res); + } } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { LOG.error("Error in removeAllStatsConfigs", e); @@ -5204,14 +5294,15 @@ public class OvsdbDao { LOG.debug("Op Result {}", res); if (res instanceof InsertResult) { - LOG.info("configureWifiRrm insert new row result {}", ((InsertResult)res)); + LOG.info("configureWifiRrm insert new row result {}", ((InsertResult) res)); // for insert, make sure it is actually in the table confirmRowExistsInTable(ovsdbClient, ((InsertResult) res).getUuid(), wifiRrmConfigDbTable); - } else if (res instanceof ErrorResult) { - LOG.error("configureWifiRrm error {}", ((ErrorResult)res)); - throw new RuntimeException("configureWifiRrm " + ((ErrorResult)res).getError() + " " + ((ErrorResult)res).getDetails()); + } else if (res instanceof ErrorResult) { + LOG.error("configureWifiRrm error {}", ((ErrorResult) res)); + throw new RuntimeException( + "configureWifiRrm " + ((ErrorResult) res).getError() + " " + ((ErrorResult) res).getDetails()); } - + } }