Retrieve Radio State information on initial AP connect

This commit is contained in:
Mike Hansen
2020-06-24 16:28:15 -04:00
parent 7010919c11
commit 39e10c90ad
4 changed files with 261 additions and 237 deletions

View File

@@ -271,6 +271,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ssidConfig.setSsid("DefaultSsid-2g"); ssidConfig.setSsid("DefaultSsid-2g");
ssidConfig.setSecureMode(SecureMode.wpa2PSK); ssidConfig.setSecureMode(SecureMode.wpa2PSK);
ssidConfig.setKeyStr("12345678"); ssidConfig.setKeyStr("12345678");
ssidConfig.setVlanId(0);
Set<RadioType> appliedRadios = new HashSet<>(); Set<RadioType> appliedRadios = new HashSet<>();
appliedRadios.add(RadioType.is2dot4GHz); appliedRadios.add(RadioType.is2dot4GHz);
@@ -287,6 +289,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ssidConfig5g.setSecureMode(SecureMode.wpa2PSK); ssidConfig5g.setSecureMode(SecureMode.wpa2PSK);
ssidConfig5g.setSsid("DefaultSsid-5g"); ssidConfig5g.setSsid("DefaultSsid-5g");
ssidConfig5g.setKeyStr("12345678"); ssidConfig5g.setKeyStr("12345678");
ssidConfig5g.setVlanId(0);
Set<RadioType> appliedRadios5g = new HashSet<>(); Set<RadioType> appliedRadios5g = new HashSet<>();
appliedRadios5g.add(RadioType.is5GHzL); appliedRadios5g.add(RadioType.is5GHzL);
appliedRadios5g.add(RadioType.is5GHzU); appliedRadios5g.add(RadioType.is5GHzU);
@@ -1438,24 +1441,24 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
@Override @Override
public void wifiVIFStateDbTableUpdate(List<OpensyncAPVIFState> vifStateTables, String apId) { public void wifiVIFStateDbTableUpdate(List<OpensyncAPVIFState> vifStateTables, String apId) {
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
Equipment ce = getCustomerEquipment(apId); if (ovsdbSession == null) {
if (ce == null) { LOG.debug("wifiVIFStateDbTableUpdate::Cannot get Session for AP {}", apId);
LOG.debug("wifiVIFStateDbTableUpdate::Cannot get Equipment for AP {}", apId);
return; return;
} }
long equipmentId = ce.getId(); int customerId = ovsdbSession.getCustomerId();
int customerId = ce.getCustomerId(); long equipmentId = ovsdbSession.getEquipmentId();
if (equipmentId < 0L) { if (customerId < 0 || equipmentId < 0) {
LOG.debug("Cannot get equipmentId {} for session {}", equipmentId); LOG.debug("wifiVIFStateDbTableUpdate::Cannot get valid CustomerId {} or EquipmentId {} for AP {}",
customerId, equipmentId, apId);
return; return;
} }
if (vifStateTables == null || vifStateTables.isEmpty() || apId == null) {
return;
}
for (OpensyncAPVIFState vifState : vifStateTables) { for (OpensyncAPVIFState vifState : vifStateTables) {
@@ -1698,12 +1701,16 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return; return;
} }
Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); int customerId = ovsdbSession.getCustomerId();
if (ce == null) { long equipmentId = ovsdbSession.getEquipmentId();
LOG.debug("wifiInetStateDbTableUpdate::Cannot get Equipment for AP {}", apId);
if (customerId < 0 || equipmentId < 0) {
LOG.debug("wifiInetStateDbTableUpdate::Cannot get valid CustomerId {} or EquipmentId {} for AP {}",
customerId, equipmentId, apId);
return; return;
} }
if (inetStateTables == null || inetStateTables.isEmpty() || apId == null) { if (inetStateTables == null || inetStateTables.isEmpty() || apId == null) {
return; return;
} }
@@ -1725,16 +1732,12 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return; return;
} }
Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); int customerId = ovsdbSession.getCustomerId();
if (ce == null) { long equipmentId = ovsdbSession.getEquipmentId();
LOG.debug("wifiAssociatedClientsDbTableUpdate::Cannot get Equipment for AP {}", apId);
return;
}
long equipmentId = ce.getId(); if (customerId < 0 || equipmentId < 0) {
LOG.debug("wifiAssociatedClientsDbTableUpdate::Cannot get valid CustomerId {} or EquipmentId {} for AP {}",
if (equipmentId < 0L) { customerId, equipmentId, apId);
LOG.debug("Cannot get equipmentId {} for session {}", equipmentId);
return; return;
} }
@@ -1798,14 +1801,15 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return; return;
} }
Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); int customerId = ovsdbSession.getCustomerId();
if (ce == null) { long equipmentId = ovsdbSession.getEquipmentId();
LOG.debug("wifiVIFStateDbTableDelete::Cannot get Equipment for AP {}", apId);
if (customerId < 0 || equipmentId < 0) {
LOG.debug("wifiVIFStateDbTableDelete::Cannot get valid CustomerId {} or EquipmentId {} for AP {}",
customerId, equipmentId, apId);
return; return;
} }
long equipmentId = ce.getId();
if (equipmentId < 0L) { if (equipmentId < 0L) {
LOG.debug("Cannot get equipmentId {} for session {}", equipmentId); LOG.debug("Cannot get equipmentId {} for session {}", equipmentId);
return; return;
@@ -1825,15 +1829,12 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
return; return;
} }
Equipment ce = equipmentServiceInterface.getByInventoryIdOrNull(apId); int customerId = ovsdbSession.getCustomerId();
if (ce == null) { long equipmentId = ovsdbSession.getEquipmentId();
LOG.debug("wifiAssociatedClientsDbTableDelete::Cannot get Equipment for AP {}", apId);
return;
}
long equipmentId = ce.getId();
if (equipmentId < 0L) { if (customerId < 0 || equipmentId < 0) {
LOG.debug("Cannot get equipmentId {} for session {}", equipmentId); LOG.debug("wifiAssociatedClientsDbTableDelete::Cannot get valid CustomerId {} or EquipmentId {} for AP {}",
customerId, equipmentId, apId);
return; return;
} }

View File

@@ -4,8 +4,8 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class ConnectNodeInfo implements Cloneable { public class ConnectNodeInfo implements Cloneable {
public Map<String, String> mqttSettings; public Map<String, String> mqttSettings = new HashMap<>();
public Map<String, Map<String,String>> wifiRadioStates; public Map<String, String> wifiRadioStates = new HashMap<>();
public String redirectorAddr; public String redirectorAddr;
public String managerAddr; public String managerAddr;
public String skuNumber; public String skuNumber;
@@ -42,7 +42,7 @@ public class ConnectNodeInfo implements Cloneable {
public String toString() { public String toString() {
return String.format( return String.format(
"ConnectNodeInfo [mqttSettings=%s, redirectorAddr=%s, managerAddr=%s, skuNumber=%s, serialNumber=%s, " "ConnectNodeInfo [mqttSettings=%s, redirectorAddr=%s, managerAddr=%s, skuNumber=%s, serialNumber=%s, "
+ "macAddress=%s, ipV4Address=%s, platformVersion=%s, firmwareVersion=%s, revision=%s, model=%s ifName=%s ifType=%s, wifiRadioStates=%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, mqttSettings, redirectorAddr, managerAddr, skuNumber, serialNumber, macAddress, ipV4Address,
platformVersion, firmwareVersion, revision, model, ifName, ifType, wifiRadioStates); platformVersion, firmwareVersion, revision, model, ifName, ifType, wifiRadioStates);
} }

View File

@@ -188,7 +188,6 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
try { try {
ovsdbDao.provisionBridgePortInterface(ovsdbClient); ovsdbDao.provisionBridgePortInterface(ovsdbClient);
} catch (Exception e) { } catch (Exception e) {
// TODO: for some AP configurations this 'may' not be necessary.
LOG.warn("Could not provision Bridge->Port->Interface mapping.", e); LOG.warn("Could not provision Bridge->Port->Interface mapping.", e);
} }
@@ -198,7 +197,8 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig); ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig); ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
} }
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
ovsdbDao.configureStats(ovsdbClient); ovsdbDao.configureStats(ovsdbClient);
// Check if device stats is configured in Wifi_Stats_Config table, // Check if device stats is configured in Wifi_Stats_Config table,
@@ -247,14 +247,24 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
OvsdbClient ovsdbClient = ovsdbSession.getOvsdbClient(); OvsdbClient ovsdbClient = ovsdbSession.getOvsdbClient();
ovsdbDao.removeAllSsids(ovsdbClient);
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId); OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
if (opensyncAPConfig != null) { if (opensyncAPConfig != null) {
ovsdbDao.removeAllSsids(ovsdbClient);
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig); ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig); ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
ovsdbDao.configureStats(ovsdbClient);
} else {
LOG.warn("Could not get provisioned configuration for AP {}", apId);
} }
LOG.debug("Finished processConfigChanged for {}", apId); LOG.debug("Finished processConfigChanged for {}", apId);
} }

View File

@@ -65,7 +65,6 @@ import com.vmware.ovsdb.protocol.operation.notation.Value;
import com.vmware.ovsdb.protocol.operation.result.InsertResult; import com.vmware.ovsdb.protocol.operation.result.InsertResult;
import com.vmware.ovsdb.protocol.operation.result.OperationResult; import com.vmware.ovsdb.protocol.operation.result.OperationResult;
import com.vmware.ovsdb.protocol.operation.result.SelectResult; import com.vmware.ovsdb.protocol.operation.result.SelectResult;
import com.vmware.ovsdb.protocol.operation.result.UpdateResult;
import com.vmware.ovsdb.service.OvsdbClient; import com.vmware.ovsdb.service.OvsdbClient;
@Component @Component
@@ -100,13 +99,6 @@ public class OvsdbDao {
@org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_radio0:home-ap-u50}") @org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_radio0:home-ap-u50}")
public String ifName5GHzU; 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 ovsdbName = "Open_vSwitch";
public static final String awlanNodeDbTable = "AWLAN_Node"; public static final String awlanNodeDbTable = "AWLAN_Node";
public static final String wifiStatsConfigDbTable = "Wifi_Stats_Config"; public static final String wifiStatsConfigDbTable = "Wifi_Stats_Config";
@@ -181,6 +173,8 @@ public class OvsdbDao {
fillInIpAddressAndMac(ovsdbClient, ret, "br-lan"); fillInIpAddressAndMac(ovsdbClient, ret, "br-lan");
} }
fillInRadioInterfaceNames(ovsdbClient, ret);
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@@ -188,6 +182,83 @@ public class OvsdbDao {
return ret; return ret;
} }
private void fillInRadioInterfaceNames(OvsdbClient ovsdbClient, ConnectNodeInfo ret) {
try {
List<Operation> operations = new ArrayList<>();
List<Condition> conditions = new ArrayList<>();
List<String> columns = new ArrayList<>();
columns.add("freq_band");
columns.add("if_name");
operations.add(new Select(wifiRadioStateDbTable, conditions, columns));
CompletableFuture<OperationResult[]> 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 && !((SelectResult) result[0]).getRows().isEmpty()) {
for (Row row : ((SelectResult) result[0]).getRows()) {
ret.wifiRadioStates.put(getSingleValueFromSet(row, "freq_band"),
getSingleValueFromSet(row, "if_name"));
}
}
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
throw new RuntimeException(e);
}
}
private Map<String, Set<Integer>> getAllowedChannels(OvsdbClient ovsdbClient) {
Map<String, Set<Integer>> allowedChannels = new HashMap<>();
try {
List<Operation> operations = new ArrayList<>();
List<Condition> conditions = new ArrayList<>();
List<String> columns = new ArrayList<>();
columns.add("freq_band");
columns.add("allowed_channels");
operations.add(new Select(wifiRadioStateDbTable, conditions, columns));
CompletableFuture<OperationResult[]> 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 && !((SelectResult) result[0]).getRows().isEmpty()) {
for (Row row : ((SelectResult) result[0]).getRows()) {
allowedChannels.put(getSingleValueFromSet(row, "freq_band"), row.getSetColumn("allowed_channels"));
}
}
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
throw new RuntimeException(e);
}
return allowedChannels;
}
public void fillInIpAddressAndMac(OvsdbClient ovsdbClient, ConnectNodeInfo connectNodeInfo, String ifName) { public void fillInIpAddressAndMac(OvsdbClient ovsdbClient, ConnectNodeInfo connectNodeInfo, String ifName) {
try { try {
List<Operation> operations = new ArrayList<>(); List<Operation> operations = new ArrayList<>();
@@ -197,6 +268,8 @@ public class OvsdbDao {
columns.add("inet_addr"); columns.add("inet_addr");
columns.add("hwaddr"); columns.add("hwaddr");
columns.add("if_name");
columns.add("if_type");
conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(ifName))); conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(ifName)));
@@ -216,7 +289,9 @@ public class OvsdbDao {
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(); row = ((SelectResult) result[0]).getRows().iterator().next();
connectNodeInfo.ipV4Address = getSingleValueFromSet(row, "inet_addr"); 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) { } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
@@ -1177,9 +1252,6 @@ public class OvsdbDao {
public void configureWifiRadios(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) { public void configureWifiRadios(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) {
Map<String, WifiRadioConfigInfo> provisionedWifiRadios = getProvisionedWifiRadioConfigs(ovsdbClient);
LOG.debug("Existing WifiRadioConfigs: {}", provisionedWifiRadios.keySet());
String country = opensyncAPConfig.getCountryCode(); // should be the String country = opensyncAPConfig.getCountryCode(); // should be the
// same for all // same for all
// radios on this AP // radios on this AP
@@ -1224,10 +1296,10 @@ public class OvsdbDao {
if (!elementRadioConfig.getEirpTxPower().isAuto()) { if (!elementRadioConfig.getEirpTxPower().isAuto()) {
txPower = elementRadioConfig.getEirpTxPower().getValue(); txPower = elementRadioConfig.getEirpTxPower().getValue();
} }
String configName = null; String freqBand = null;
switch (radioType) { switch (radioType) {
case is2dot4GHz: case is2dot4GHz:
configName = radioName2pt4GHz; freqBand = "2.4G";
break; break;
case is5GHz: case is5GHz:
// 802.11h dfs (Dynamic Frequency Selection) aka military and // 802.11h dfs (Dynamic Frequency Selection) aka military and
@@ -1238,7 +1310,8 @@ public class OvsdbDao {
hwConfig.put("dfs_enable", "1"); hwConfig.put("dfs_enable", "1");
hwConfig.put("dfs_ignorecac", "0"); hwConfig.put("dfs_ignorecac", "0");
hwConfig.put("dfs_usenol", "1"); hwConfig.put("dfs_usenol", "1");
configName = radioName5GHzU; freqBand = "5G";
break; break;
case is5GHzL: case is5GHzL:
// 802.11h dfs (Dynamic Frequency Selection) aka military and // 802.11h dfs (Dynamic Frequency Selection) aka military and
@@ -1249,7 +1322,8 @@ public class OvsdbDao {
hwConfig.put("dfs_enable", "1"); hwConfig.put("dfs_enable", "1");
hwConfig.put("dfs_ignorecac", "0"); hwConfig.put("dfs_ignorecac", "0");
hwConfig.put("dfs_usenol", "1"); hwConfig.put("dfs_usenol", "1");
configName = radioName5GHzL; freqBand = "5GL";
break; break;
case is5GHzU: case is5GHzU:
// 802.11h dfs (Dynamic Frequency Selection) aka military and // 802.11h dfs (Dynamic Frequency Selection) aka military and
@@ -1260,17 +1334,18 @@ public class OvsdbDao {
hwConfig.put("dfs_enable", "1"); hwConfig.put("dfs_enable", "1");
hwConfig.put("dfs_ignorecac", "0"); hwConfig.put("dfs_ignorecac", "0");
hwConfig.put("dfs_usenol", "1"); hwConfig.put("dfs_usenol", "1");
configName = radioName5GHzU; freqBand = "5GU";
break; break;
default: // don't know this interface default: // don't know this interface
continue; continue;
} }
if (configName != null) { if (freqBand != null) {
try { try {
configureWifiRadios(ovsdbClient, configName, provisionedWifiRadios, channel, hwConfig, country, configureWifiRadios(ovsdbClient, freqBand, channel, hwConfig, country.toUpperCase(), beaconInterval,
beaconInterval, enabled, ht_mode, txPower); enabled, ht_mode, txPower);
} catch (OvsdbClientException e) { } catch (OvsdbClientException e) {
LOG.error("ConfigureWifiRadios failed with OvsdbClient exception.", e); LOG.error("ConfigureWifiRadios failed with OvsdbClient exception.", e);
} catch (TimeoutException e) { } catch (TimeoutException e) {
@@ -1347,7 +1422,7 @@ public class OvsdbDao {
} }
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)) { .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
tableState.setCountry(row.getStringColumn("country")); tableState.setCountry(row.getStringColumn("country").toUpperCase());
} }
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)) { .equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
@@ -1761,22 +1836,16 @@ public class OvsdbDao {
} }
public void configureWifiRadios(OvsdbClient ovsdbClient, String configName, public void configureWifiRadios(OvsdbClient ovsdbClient, String freqBand,
Map<String, WifiRadioConfigInfo> provisionedWifiRadios, int channel, Map<String, String> hwConfig, int channel, Map<String, String> hwConfig,
String country, int beaconInterval, boolean enabled, String ht_mode, int txPower) String country, int beaconInterval, boolean enabled, String ht_mode, int txPower)
throws OvsdbClientException, TimeoutException, ExecutionException, InterruptedException { throws OvsdbClientException, TimeoutException, ExecutionException, InterruptedException {
WifiRadioConfigInfo existingConfig = provisionedWifiRadios.get(configName);
if (existingConfig == null) {
LOG.warn("There is no WifiRadioConfig {}", configName);
return;
}
List<Operation> operations = new ArrayList<>(); List<Operation> operations = new ArrayList<>();
Map<String, Value> updateColumns = new HashMap<>(); Map<String, Value> updateColumns = new HashMap<>();
List<Condition> conditions = new ArrayList<>(); List<Condition> conditions = new ArrayList<>();
conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(configName))); conditions.add(new Condition("freq_band", Function.EQUALS, new Atom<>(freqBand)));
updateColumns.put("channel", new Atom<>(channel)); updateColumns.put("channel", new Atom<>(channel));
updateColumns.put("country", new Atom<>(country)); updateColumns.put("country", new Atom<>(country));
@@ -1803,7 +1872,7 @@ public class OvsdbDao {
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations); CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
LOG.debug("Provisioned channel {} for {}", channel, configName); LOG.debug("Provisioned channel {} for {}", channel, freqBand);
for (OperationResult res : result) { for (OperationResult res : result) {
LOG.debug("Op Result {}", res); LOG.debug("Op Result {}", res);
@@ -1811,8 +1880,7 @@ public class OvsdbDao {
} }
public void configureSingleSsid(OvsdbClient ovsdbClient, String bridge, String ifName, String ssid, public void configureSingleSsid(OvsdbClient ovsdbClient, String bridge, String ifName, String ssid,
boolean ssidBroadcast, Map<String, String> security, boolean ssidBroadcast, Map<String, String> security, String radioFreqBand, int vlanId,
Map<String, WifiRadioConfigInfo> provisionedWifiRadioConfigs, String radioIfName, int vlanId,
boolean rrmEnabled, boolean enable80211r, String minHwMode, boolean enabled, int keyRefresh, boolean rrmEnabled, boolean enable80211r, String minHwMode, boolean enabled, int keyRefresh,
boolean uapsdEnabled, boolean apBridge, NetworkForwardMode networkForwardMode, String gateway, String inet, boolean uapsdEnabled, boolean apBridge, NetworkForwardMode networkForwardMode, String gateway, String inet,
Map<String, String> dns, String ipAssignScheme) { Map<String, String> dns, String ipAssignScheme) {
@@ -1840,7 +1908,11 @@ public class OvsdbDao {
// updateColumns.put("vif_radio_idx", new // updateColumns.put("vif_radio_idx", new
// Atom<Integer>(vifRadioIdx)); // Atom<Integer>(vifRadioIdx));
updateColumns.put("min_hw_mode", new Atom<>(minHwMode)); updateColumns.put("min_hw_mode", new Atom<>(minHwMode));
updateColumns.put("vlan_id", new Atom<>(vlanId)); if (vlanId > 0) {
updateColumns.put("vlan_id", new Atom<>(vlanId));
} else {
updateColumns.put("vlan_id", new com.vmware.ovsdb.protocol.operation.notation.Set());
}
updateColumns.put("group_rekey", new Atom<>(keyRefresh)); updateColumns.put("group_rekey", new Atom<>(keyRefresh));
updateColumns.put("uapsd_enable", new Atom<>(uapsdEnabled)); updateColumns.put("uapsd_enable", new Atom<>(uapsdEnabled));
updateColumns.put("ap_bridge", new Atom<>(apBridge)); updateColumns.put("ap_bridge", new Atom<>(apBridge));
@@ -1869,42 +1941,15 @@ public class OvsdbDao {
if (vifConfigUuid == null) { if (vifConfigUuid == null) {
throw new IllegalStateException("Wifi_VIF_Config entry was not created successfully"); throw new IllegalStateException("Wifi_VIF_Config entry was not created successfully");
} }
// update Wifi_Radio_Config here - add vifConfigUuid
/// usr/plume/tools/ovsh u Wifi_Radio_Config
// vif_configs:='["set",[["uuid","98e42897-b567-4186-84a6-4a4e38a51e9d"],["uuid","4314920e-c4e6-42a6-93e3-261142ed9adf"]]]'
// --where if_name==wifi0
updateColumns.clear(); updateColumns.clear();
operations.clear(); operations.clear();
WifiRadioConfigInfo wifiRadioConfigInfo = provisionedWifiRadioConfigs.get(radioIfName);
if (wifiRadioConfigInfo == null) { updateVifConfigsSetForRadio(ovsdbClient, ssid, radioFreqBand, operations, updateColumns, vifConfigUuid);
throw new IllegalStateException("missing Wifi_Radio_Config entry " + radioIfName);
}
Set<Uuid> vifConfigsSet = new HashSet<>(wifiRadioConfigInfo.vifConfigUuids);
vifConfigsSet.add(vifConfigUuid);
com.vmware.ovsdb.protocol.operation.notation.Set vifConfigs = com.vmware.ovsdb.protocol.operation.notation.Set
.of(vifConfigsSet);
updateColumns.put("vif_configs", vifConfigs);
List<Condition> conditions = new ArrayList<>();
conditions.add(new Condition("if_name", Function.EQUALS, new Atom<>(radioIfName)));
row = new Row(updateColumns);
operations.add(new Update(wifiRadioConfigDbTable, conditions, row));
fResult = ovsdbClient.transact(ovsdbName, operations);
result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
if (LOG.isDebugEnabled()) {
LOG.debug("Updated WifiRadioConfig {} for SSID {}:", radioIfName, ssid);
for (OperationResult res : result) {
LOG.debug("Op Result {}", res);
}
}
Map<String, WifiInetConfigInfo> inetConfigs = getProvisionedWifiInetConfigs(ovsdbClient); Map<String, WifiInetConfigInfo> inetConfigs = getProvisionedWifiInetConfigs(ovsdbClient);
if (inetConfigs.containsKey(ifName)) { if (inetConfigs.containsKey(ifName)) {
updateWifiInetConfig(ovsdbClient, vlanId, ifName, enabled, networkForwardMode == NetworkForwardMode.NAT, updateWifiInetConfig(ovsdbClient, vlanId, ifName, enabled, networkForwardMode == NetworkForwardMode.NAT,
"vif", gateway, inet, dns, ipAssignScheme, vifConfigUuid); "vif", gateway, inet, dns, ipAssignScheme, vifConfigUuid);
@@ -1915,7 +1960,7 @@ public class OvsdbDao {
vifConfigUuid); vifConfigUuid);
} }
LOG.info("Provisioned SSID {} on interface {} / {}", ssid, ifName, radioIfName); LOG.info("Provisioned SSID {} on interface {} / {}", ssid, ifName, radioFreqBand);
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) { } catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
LOG.error("Error in configureSingleSsid", e); LOG.error("Error in configureSingleSsid", e);
@@ -1923,6 +1968,53 @@ public class OvsdbDao {
} }
} }
private void updateVifConfigsSetForRadio(OvsdbClient ovsdbClient, String ssid, String radioFreqBand,
List<Operation> operations, Map<String, Value> updateColumns, Uuid vifConfigUuid)
throws OvsdbClientException, InterruptedException, ExecutionException, TimeoutException {
Row row;
CompletableFuture<OperationResult[]> fResult;
OperationResult[] result;
List<Condition> conditions = new ArrayList<>();
conditions.add(new Condition("freq_band", Function.EQUALS, new Atom<>(radioFreqBand)));
List<String> columns = new ArrayList<>();
columns.add("vif_configs");
operations.add(new Select(wifiRadioConfigDbTable, conditions, columns));
fResult = ovsdbClient.transact(ovsdbName, operations);
result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
Set<Uuid> vifConfigsSet = null;
if (result != null && result.length > 0 && !((SelectResult) result[0]).getRows().isEmpty()) {
row = ((SelectResult) result[0]).getRows().iterator().next();
if (row != null) {
vifConfigsSet = row.getSetColumn("vif_configs");
} else {
vifConfigsSet = new HashSet<Uuid>();
}
}
vifConfigsSet.add(vifConfigUuid);
com.vmware.ovsdb.protocol.operation.notation.Set vifConfigs = com.vmware.ovsdb.protocol.operation.notation.Set
.of(vifConfigsSet);
updateColumns.put("vif_configs", vifConfigs);
row = new Row(updateColumns);
operations.add(new Update(wifiRadioConfigDbTable, conditions, row));
fResult = ovsdbClient.transact(ovsdbName, operations);
result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
if (LOG.isDebugEnabled()) {
LOG.debug("Updated WifiRadioConfig {} for SSID {}:", radioFreqBand, ssid);
for (OperationResult res : result) {
LOG.debug("Op Result {}", res);
}
}
}
public void configureSsids(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncApConfig) { public void configureSsids(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncApConfig) {
boolean rrmEnabled = false; boolean rrmEnabled = false;
@@ -2043,30 +2135,33 @@ public class OvsdbDao {
boolean enabled = ssidConfig.getSsidAdminState().equals(StateSetting.enabled); boolean enabled = ssidConfig.getSsidAdminState().equals(StateSetting.enabled);
String ifName = null; String ifName = null;
String radioIfName = null; String freqBand = null;
if (radioType == RadioType.is2dot4GHz) { if (radioType == RadioType.is2dot4GHz) {
ifName = ifName2pt4GHz; ifName = ifName2pt4GHz;
radioIfName = radioName2pt4GHz; freqBand = "2.4G";
} else if (radioType == RadioType.is5GHzL) { } else if (radioType == RadioType.is5GHzL) {
ifName = ifName5GHzL; ifName = ifName5GHzL;
radioIfName = radioName5GHzL; freqBand = "5GL";
} else if (radioType == RadioType.is5GHzU) { } else if (radioType == RadioType.is5GHzU) {
ifName = ifName5GHzU; ifName = ifName5GHzU;
radioIfName = radioName5GHzU; freqBand = "5GU";
} else if (radioType == RadioType.is5GHz) {
ifName = ifName5GHzU;
freqBand = "5G";
} }
if (!provisionedWifiVifConfigs.containsKey(ifName + "_" + ssidConfig.getSsid())) { if (!provisionedWifiVifConfigs.containsKey(ifName + "_" + ssidConfig.getSsid())) {
try { try {
configureSingleSsid(ovsdbClient, bridgeNameVifInterfaces, ifName, ssidConfig.getSsid(), configureSingleSsid(ovsdbClient, bridgeNameVifInterfaces, ifName, ssidConfig.getSsid(),
ssidBroadcast, security, provisionedWifiRadioConfigs, radioIfName, ssidBroadcast, security, freqBand,
ssidConfig.getVlanId(), rrmEnabled, enable80211r, minHwMode, enabled, keyRefresh, ssidConfig.getVlanId(), rrmEnabled, enable80211r, minHwMode, enabled, keyRefresh,
uapsdEnabled, apBridge, ssidConfig.getForwardMode(), gateway, inet, dns, uapsdEnabled, apBridge, ssidConfig.getForwardMode(), gateway, inet, dns,
ipAssignScheme); ipAssignScheme);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// could not provision this SSID, but still can go on // 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(), freqBand);
} }
} }
@@ -2329,10 +2424,11 @@ public class OvsdbDao {
.of(thresholdMap); .of(thresholdMap);
Map<String, WifiRadioConfigInfo> radioConfigs = getProvisionedWifiRadioConfigs(ovsdbClient); Map<String, WifiRadioConfigInfo> radioConfigs = getProvisionedWifiRadioConfigs(ovsdbClient);
provisionWifiStatsConfigSurvey(radioConfigs, getProvisionedWifiStatsConfigs(ovsdbClient), operations, provisionWifiStatsConfigSurvey(getAllowedChannels(ovsdbClient), radioConfigs,
thresholds); getProvisionedWifiStatsConfigs(ovsdbClient), operations, thresholds);
provisionWifiStatsConfigNeighbor(radioConfigs, getProvisionedWifiStatsConfigs(ovsdbClient), operations); provisionWifiStatsConfigNeighbor(getAllowedChannels(ovsdbClient), radioConfigs,
getProvisionedWifiStatsConfigs(ovsdbClient), operations);
provisionWifiStatsConfigClient(radioConfigs, getProvisionedWifiStatsConfigs(ovsdbClient), operations); provisionWifiStatsConfigClient(radioConfigs, getProvisionedWifiStatsConfigs(ovsdbClient), operations);
@@ -2425,94 +2521,19 @@ public class OvsdbDao {
}); });
} }
private void provisionWifiStatsConfigNeighbor(Map<String, WifiRadioConfigInfo> radioConfigs, private void provisionWifiStatsConfigNeighbor(Map<String, Set<Integer>> allowedChannels,
Map<String, WifiStatsConfigInfo> provisionedWifiStatsConfigs, List<Operation> operations) { Map<String, WifiRadioConfigInfo> radioConfigs, Map<String, WifiStatsConfigInfo> provisionedWifiStatsConfigs,
List<Operation> operations) {
Map<String, Value> updateColumns; Map<String, Value> updateColumns;
Row row; Row row;
// For off channel, all allowed channels
// * 2412 MHz [1] (30.0 dBm)
// * 2417 MHz [2] (30.0 dBm)
// * 2422 MHz [3] (30.0 dBm)
// * 2427 MHz [4] (30.0 dBm)
// * 2432 MHz [5] (30.0 dBm)
// * 2437 MHz [6] (30.0 dBm)
// * 2442 MHz [7] (30.0 dBm)
// * 2447 MHz [8] (30.0 dBm)
// * 2452 MHz [9] (30.0 dBm)
// * 2457 MHz [10] (30.0 dBm)
// * 2462 MHz [11] (30.0 dBm)
Set<Integer> channelSet2g = new HashSet<>();
channelSet2g.add(1);
// channelSet2g.add(2);
// channelSet2g.add(3);
// channelSet2g.add(4);
// channelSet2g.add(5);
channelSet2g.add(6);
// channelSet2g.add(7);
// channelSet2g.add(8);
// channelSet2g.add(9);
// channelSet2g.add(10);
channelSet2g.add(11);
com.vmware.ovsdb.protocol.operation.notation.Set channels2g = com.vmware.ovsdb.protocol.operation.notation.Set com.vmware.ovsdb.protocol.operation.notation.Set channels2g = com.vmware.ovsdb.protocol.operation.notation.Set
.of(channelSet2g); .of(allowedChannels.get("2.4G"));
Set<Integer> channelSet5gl = new HashSet<>();
// * 5180 MHz [36] (23.0 dBm)
// * 5200 MHz [40] (23.0 dBm)
// * 5220 MHz [44] (23.0 dBm)
// * 5240 MHz [48] (23.0 dBm)
// * 5260 MHz [52] (24.0 dBm) (radar detection)
// * 5280 MHz [56] (24.0 dBm) (radar detection)
// * 5300 MHz [60] (24.0 dBm) (radar detection)
// * 5320 MHz [64] (24.0 dBm) (radar detection)
channelSet5gl.add(36);
channelSet5gl.add(40);
channelSet5gl.add(44);
channelSet5gl.add(48);
// channelSet5gl.add(52);
// channelSet5gl.add(56);
// channelSet5gl.add(60);
// channelSet5gl.add(64);
com.vmware.ovsdb.protocol.operation.notation.Set channels5gl = com.vmware.ovsdb.protocol.operation.notation.Set com.vmware.ovsdb.protocol.operation.notation.Set channels5gl = com.vmware.ovsdb.protocol.operation.notation.Set
.of(channelSet5gl); .of(allowedChannels.get("5GL"));
Set<Integer> channelSet5gu = new HashSet<>();
// * 5500 MHz [100] (24.0 dBm) (radar detection)
// * 5520 MHz [104] (24.0 dBm) (radar detection)
// * 5540 MHz [108] (24.0 dBm) (radar detection)
// * 5560 MHz [112] (24.0 dBm) (radar detection)
// * 5580 MHz [116] (24.0 dBm) (radar detection)
// * 5600 MHz [120] (disabled)
// * 5620 MHz [124] (disabled)
// * 5640 MHz [128] (disabled)
// * 5660 MHz [132] (24.0 dBm) (radar detection)
// * 5680 MHz [136] (24.0 dBm) (radar detection)
// * 5700 MHz [140] (24.0 dBm) (radar detection)
// * 5720 MHz [144] (24.0 dBm) (radar detection)
// * 5745 MHz [149] (30.0 dBm)
// * 5765 MHz [153] (30.0 dBm)
// * 5785 MHz [157] (30.0 dBm)
// * 5805 MHz [161] (30.0 dBm)
// * 5825 MHz [165] (30.0 dBm)
// channelSet5gu.add(100);
// channelSet5gu.add(104);
// channelSet5gu.add(108);
// channelSet5gu.add(112);
// channelSet5gu.add(116);
// channelSet5gu.add(132);
// channelSet5gu.add(136);
// channelSet5gu.add(140);
// channelSet5gu.add(144);
channelSet5gu.add(149);
channelSet5gu.add(153);
channelSet5gu.add(157);
channelSet5gu.add(161);
channelSet5gu.add(165);
com.vmware.ovsdb.protocol.operation.notation.Set channels5gu = com.vmware.ovsdb.protocol.operation.notation.Set com.vmware.ovsdb.protocol.operation.notation.Set channels5gu = com.vmware.ovsdb.protocol.operation.notation.Set
.of(channelSet5gu); .of(allowedChannels.get("5GU"));
if (!provisionedWifiStatsConfigs.containsKey("2.4G_neighbor_off-chan")) { if (!provisionedWifiStatsConfigs.containsKey("2.4G_neighbor_off-chan")) {
updateColumns = new HashMap<>(); updateColumns = new HashMap<>();
@@ -2569,33 +2590,18 @@ public class OvsdbDao {
} }
private void provisionWifiStatsConfigSurvey(Map<String, WifiRadioConfigInfo> radioConfigs, private void provisionWifiStatsConfigSurvey(Map<String, Set<Integer>> allowedChannels,
Map<String, WifiStatsConfigInfo> provisionedWifiStatsConfigs, List<Operation> operations, Map<String, WifiRadioConfigInfo> radioConfigs, Map<String, WifiStatsConfigInfo> provisionedWifiStatsConfigs,
com.vmware.ovsdb.protocol.operation.notation.Map<String, Integer> thresholds) { List<Operation> operations, com.vmware.ovsdb.protocol.operation.notation.Map<String, Integer> thresholds) {
Set<Integer> channelSet2g = new HashSet<>();
channelSet2g.add(1);
channelSet2g.add(6);
channelSet2g.add(11);
com.vmware.ovsdb.protocol.operation.notation.Set channels2g = com.vmware.ovsdb.protocol.operation.notation.Set com.vmware.ovsdb.protocol.operation.notation.Set channels2g = com.vmware.ovsdb.protocol.operation.notation.Set
.of(channelSet2g); .of(allowedChannels.get("2.4G"));
Set<Integer> channelSet5gl = new HashSet<>();
channelSet5gl.add(36);
channelSet5gl.add(40);
channelSet5gl.add(44);
channelSet5gl.add(48);
com.vmware.ovsdb.protocol.operation.notation.Set channels5gl = com.vmware.ovsdb.protocol.operation.notation.Set com.vmware.ovsdb.protocol.operation.notation.Set channels5gl = com.vmware.ovsdb.protocol.operation.notation.Set
.of(channelSet5gl); .of(allowedChannels.get("5GL"));
Set<Integer> channelSet5gu = new HashSet<>();
channelSet5gu.add(149);
channelSet5gu.add(153);
channelSet5gu.add(157);
channelSet5gu.add(161);
channelSet5gu.add(165);
com.vmware.ovsdb.protocol.operation.notation.Set channels5gu = com.vmware.ovsdb.protocol.operation.notation.Set com.vmware.ovsdb.protocol.operation.notation.Set channels5gu = com.vmware.ovsdb.protocol.operation.notation.Set
.of(channelSet5gu); .of(allowedChannels.get("5GU"));
Map<String, Value> updateColumns; Map<String, Value> updateColumns;
Row row; Row row;
@@ -2753,23 +2759,30 @@ public class OvsdbDao {
// TODO: This needs to be implemented when the AP has Firmware Upgrade // TODO: This needs to be implemented when the AP has Firmware Upgrade
// List<Operation> operations = new ArrayList<>(); }
// Map<String, Value> updateColumns = new HashMap<>();
// public void removeAllStatsConfigs(OvsdbClient ovsdbClient) {
// updateColumns.put("firmware_version", new Atom<>(firmwareVersion));
// Enabled. try {
// Row row = new Row(updateColumns); List<Operation> operations = new ArrayList<>();
// operations.add(new Update(awlanNodeDbTable, row));
// operations.add(new Delete(wifiStatsConfigDbTable));
//
// CompletableFuture<OperationResult[]> fResult = CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
// ovsdbClient.transact(ovsdbName, operations); OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
// OperationResult[] result = fResult.get(ovsdbTimeoutSec,
// TimeUnit.SECONDS); if (LOG.isDebugEnabled()) {
// for (OperationResult r : result) { LOG.debug("Removed all existing config from {}:", wifiStatsConfigDbTable);
// LOG.debug("Op Result {}", r);
// for (OperationResult res : result) {
// } LOG.debug("Op Result {}", res);
}
}
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
LOG.error("Error in removeAllStatsConfigs", e);
throw new RuntimeException(e);
}
} }