mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-10-31 18:47:57 +00:00
Compare commits
1 Commits
WIFI-7579-
...
release/v1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af604289cc |
@@ -1,9 +1,27 @@
|
||||
package com.telecominfraproject.wlan.opensync.ovsdb.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.equipment.ChannelBandwidth;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.SourceType;
|
||||
import com.telecominfraproject.wlan.equipment.models.*;
|
||||
import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration;
|
||||
import com.telecominfraproject.wlan.equipment.models.ElementRadioConfiguration;
|
||||
import com.telecominfraproject.wlan.equipment.models.MimoMode;
|
||||
import com.telecominfraproject.wlan.equipment.models.RadioConfiguration;
|
||||
import com.telecominfraproject.wlan.equipment.models.StateSetting;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiRadioConfigInfo;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.models.WifiVifConfigInfo;
|
||||
@@ -12,19 +30,15 @@ import com.telecominfraproject.wlan.profile.rf.models.RfElementConfiguration;
|
||||
import com.vmware.ovsdb.exception.OvsdbClientException;
|
||||
import com.vmware.ovsdb.protocol.operation.Operation;
|
||||
import com.vmware.ovsdb.protocol.operation.Update;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.*;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Atom;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Condition;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Function;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Row;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Uuid;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Value;
|
||||
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
|
||||
import com.vmware.ovsdb.protocol.schema.DatabaseSchema;
|
||||
import com.vmware.ovsdb.service.OvsdbClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
@Component
|
||||
public class OvsdbRadioConfig extends OvsdbDaoBase {
|
||||
@@ -40,75 +54,80 @@ public class OvsdbRadioConfig extends OvsdbDaoBase {
|
||||
Map<String, WifiRadioConfigInfo> provisionedRadioConfigs = ovsdbGet.getProvisionedWifiRadioConfigs(ovsdbClient);
|
||||
Map<String, WifiVifConfigInfo> vifConfigs = ovsdbGet.getProvisionedWifiVifConfigs(ovsdbClient);
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
for (RadioType radioType : apElementConfiguration.getRadioMap().keySet()) {
|
||||
Map<String, String> hwConfig = new HashMap<>();
|
||||
ElementRadioConfiguration elementRadioConfig = apElementConfiguration.getRadioMap().get(radioType);
|
||||
RfElementConfiguration rfElementConfig = rfConfig.getRfConfig(radioType);
|
||||
boolean autoChannelSelection = rfElementConfig.getAutoChannelSelection();
|
||||
int channel = elementRadioConfig.getActiveChannel(autoChannelSelection);
|
||||
LOG.debug("configureWifiRadios autoChannelSelection {} activeChannel {} getChannelNumber {} ",
|
||||
autoChannelSelection, channel, elementRadioConfig.getChannelNumber());
|
||||
ChannelBandwidth bandwidth = rfElementConfig.getChannelBandwidth();
|
||||
String ht_mode = getBandwidth(bandwidth);
|
||||
RadioConfiguration radioConfig = apElementConfiguration.getAdvancedRadioMap().get(radioType);
|
||||
int beaconInterval = rfElementConfig.getBeaconInterval();
|
||||
boolean enabled = radioConfig.getRadioAdminState().equals(StateSetting.enabled);
|
||||
int txPower;
|
||||
if (elementRadioConfig.getEirpTxPower().getSource() == SourceType.profile) {
|
||||
txPower = rfElementConfig.getEirpTxPower();
|
||||
} else {
|
||||
txPower = elementRadioConfig.getEirpTxPower().getValue();
|
||||
}
|
||||
String hwMode = getHwMode(rfElementConfig);
|
||||
String freqBand = getHwConfigAndFreq(radioType, hwConfig);
|
||||
String radioName = null;
|
||||
for (String key : provisionedRadioConfigs.keySet()) {
|
||||
if (provisionedRadioConfigs.get(key).freqBand.equals(freqBand)) {
|
||||
radioName = key;
|
||||
break;
|
||||
try {
|
||||
CompletableFuture<DatabaseSchema> cfDatabaseSchema = ovsdbClient.getSchema(ovsdbName);
|
||||
DatabaseSchema databaseSchema = cfDatabaseSchema.get();
|
||||
Set<String> columnNames = databaseSchema.getTables().get(wifiRadioConfigDbTable).getColumns().keySet();
|
||||
|
||||
for (RadioType radioType : apElementConfiguration.getRadioMap().keySet()) {
|
||||
Map<String, String> hwConfig = new HashMap<>();
|
||||
ElementRadioConfiguration elementRadioConfig = apElementConfiguration.getRadioMap().get(radioType);
|
||||
RfElementConfiguration rfElementConfig = rfConfig.getRfConfig(radioType);
|
||||
boolean autoChannelSelection = rfElementConfig.getAutoChannelSelection();
|
||||
int channel = elementRadioConfig.getActiveChannel(autoChannelSelection);
|
||||
LOG.debug("configureWifiRadios autoChannelSelection {} activeChannel {} getChannelNumber {} ",
|
||||
autoChannelSelection, channel, elementRadioConfig.getChannelNumber());
|
||||
ChannelBandwidth bandwidth = rfElementConfig.getChannelBandwidth();
|
||||
String ht_mode = getBandwidth(bandwidth);
|
||||
RadioConfiguration radioConfig = apElementConfiguration.getAdvancedRadioMap().get(radioType);
|
||||
int beaconInterval = rfElementConfig.getBeaconInterval();
|
||||
boolean enabled = radioConfig.getRadioAdminState().equals(StateSetting.enabled);
|
||||
int txPower;
|
||||
if (elementRadioConfig.getEirpTxPower().getSource() == SourceType.profile) {
|
||||
txPower = rfElementConfig.getEirpTxPower();
|
||||
} else {
|
||||
txPower = elementRadioConfig.getEirpTxPower().getValue();
|
||||
}
|
||||
String hwMode = getHwMode(rfElementConfig);
|
||||
String freqBand = getHwConfigAndFreq(radioType, hwConfig);
|
||||
String radioName = null;
|
||||
for (String key : provisionedRadioConfigs.keySet()) {
|
||||
if (provisionedRadioConfigs.get(key).freqBand.equals(freqBand)) {
|
||||
radioName = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (radioName == null) continue;
|
||||
String ifName = null; // for vifConfigs
|
||||
if (radioName.equals(radio0)) {
|
||||
ifName = defaultRadio0;
|
||||
} else if (radioName.equals(radio1)) {
|
||||
ifName = defaultRadio1;
|
||||
} else if (radioName.equals(radio2)) {
|
||||
ifName = defaultRadio2;
|
||||
}
|
||||
if (ifName == null) continue;
|
||||
Set<Uuid> vifUuidsForRadio = new HashSet<>();
|
||||
for (String key : vifConfigs.keySet()) {
|
||||
if (key.contains(ifName))
|
||||
vifUuidsForRadio.add(vifConfigs.get(key).uuid);
|
||||
}
|
||||
int mimoMode = MimoMode.none.getId();
|
||||
if (rfElementConfig.getMimoMode() != null) {
|
||||
mimoMode = rfElementConfig.getMimoMode().getId();
|
||||
}
|
||||
int maxNumClients = 0;
|
||||
if (rfElementConfig.getMaxNumClients() != null) {
|
||||
maxNumClients = rfElementConfig.getMaxNumClients();
|
||||
}
|
||||
try {
|
||||
configureWifiRadios(freqBand, channel, hwConfig, country.toUpperCase(), beaconInterval,
|
||||
enabled, hwMode, ht_mode, txPower, mimoMode, vifUuidsForRadio, operations, maxNumClients,columnNames);
|
||||
} catch (OvsdbClientException e) {
|
||||
LOG.error("ConfigureWifiRadios failed with OvsdbClient exception.", e);
|
||||
throw new RuntimeException(e);
|
||||
} catch (TimeoutException e) {
|
||||
LOG.error("ConfigureWifiRadios failed with Timeout.", e);
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
LOG.error("ConfigureWifiRadios excecution failed.", e);
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("ConfigureWifiRadios interrupted.", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
if (radioName == null) continue;
|
||||
String ifName = null; // for vifConfigs
|
||||
if (radioName.equals(radio0)) {
|
||||
ifName = defaultRadio0;
|
||||
} else if (radioName.equals(radio1)) {
|
||||
ifName = defaultRadio1;
|
||||
} else if (radioName.equals(radio2)) {
|
||||
ifName = defaultRadio2;
|
||||
}
|
||||
if (ifName == null) continue;
|
||||
Set<Uuid> vifUuidsForRadio = new HashSet<>();
|
||||
for (String key : vifConfigs.keySet()) {
|
||||
if (key.contains(ifName))
|
||||
vifUuidsForRadio.add(vifConfigs.get(key).uuid);
|
||||
}
|
||||
int mimoMode = MimoMode.none.getId();
|
||||
if (rfElementConfig.getMimoMode() != null) {
|
||||
mimoMode = rfElementConfig.getMimoMode().getId();
|
||||
}
|
||||
int maxNumClients = 0;
|
||||
if (rfElementConfig.getMaxNumClients() != null) {
|
||||
maxNumClients = rfElementConfig.getMaxNumClients();
|
||||
}
|
||||
try {
|
||||
configureWifiRadios(freqBand, channel, hwConfig, country.toUpperCase(), beaconInterval,
|
||||
enabled, hwMode, ht_mode, txPower, mimoMode, vifUuidsForRadio, operations, maxNumClients);
|
||||
} catch (OvsdbClientException e) {
|
||||
LOG.error("ConfigureWifiRadios failed with OvsdbClient exception.", e);
|
||||
throw new RuntimeException(e);
|
||||
} catch (TimeoutException e) {
|
||||
LOG.error("ConfigureWifiRadios failed with Timeout.", e);
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
LOG.error("ConfigureWifiRadios excecution failed.", e);
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("ConfigureWifiRadios interrupted.", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
for (OperationResult res : result) {
|
||||
@@ -217,7 +236,7 @@ public class OvsdbRadioConfig extends OvsdbDaoBase {
|
||||
|
||||
void configureWifiRadios(String freqBand, int channel, Map<String, String> hwConfig,
|
||||
String country, int beaconInterval, boolean enabled, String hwMode, String ht_mode, int txPower,
|
||||
int mimoMode, Set<Uuid> vifUuidsForRadio, List<Operation> operations, int maxNumClients) throws OvsdbClientException, TimeoutException, ExecutionException, InterruptedException {
|
||||
int mimoMode, Set<Uuid> vifUuidsForRadio, List<Operation> operations, int maxNumClients, Set<String> tableColumns) throws OvsdbClientException, TimeoutException, ExecutionException, InterruptedException {
|
||||
Map<String, Value> updateColumns = new HashMap<>();
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
conditions.add(new Condition("freq_band", Function.EQUALS, new Atom<>(freqBand)));
|
||||
@@ -243,7 +262,7 @@ public class OvsdbRadioConfig extends OvsdbDaoBase {
|
||||
updateColumns.put("hw_mode", new Atom<>(hwMode));
|
||||
}
|
||||
configureCustomOptionsMap(maxNumClients, updateColumns);
|
||||
setTxAndRxChainmask(mimoMode, updateColumns);
|
||||
setTxAndRxChainmask(mimoMode, updateColumns,tableColumns);
|
||||
if (vifUuidsForRadio.size() > 0) {
|
||||
com.vmware.ovsdb.protocol.operation.notation.Set vifConfigUuids = com.vmware.ovsdb.protocol.operation.notation.Set
|
||||
.of(vifUuidsForRadio);
|
||||
@@ -262,23 +281,29 @@ public class OvsdbRadioConfig extends OvsdbDaoBase {
|
||||
updateColumns.put("custom_options", customOptionsMap);
|
||||
}
|
||||
|
||||
void setTxAndRxChainmask(int mimoMode, Map<String, Value> updateColumns) {
|
||||
void setTxAndRxChainmask(int mimoMode, Map<String, Value> updateColumns, Set<String> tableColumns) {
|
||||
/*
|
||||
* Chainmask is a bitmask, so map mimo mode values accordingly
|
||||
* Note values 0, 1 remain unchanged
|
||||
* Note values 0, 1 remain unchanged
|
||||
*
|
||||
* mimoMode bitmask
|
||||
* 0 0
|
||||
* 1 1
|
||||
* 2 3
|
||||
* 3 7
|
||||
* 4 15
|
||||
* mimoMode bitmask
|
||||
* 0 0
|
||||
* 1 1
|
||||
* 2 3
|
||||
* 3 7
|
||||
* 4 15
|
||||
*/
|
||||
if (mimoMode == 2) {mimoMode = 3;}
|
||||
else if (mimoMode == 3) {mimoMode = 7;}
|
||||
else if (mimoMode == 4) {mimoMode = 15;}
|
||||
if (mimoMode == 2) {
|
||||
mimoMode = 3;
|
||||
} else if (mimoMode == 3) {
|
||||
mimoMode = 7;
|
||||
} else if (mimoMode == 4) {
|
||||
mimoMode = 15;
|
||||
}
|
||||
updateColumns.put("tx_chainmask", new Atom<>(mimoMode));
|
||||
updateColumns.put("rx_chainmask", new Atom<>(mimoMode));
|
||||
if (tableColumns.contains("rx_chainmask")) {
|
||||
updateColumns.put("rx_chainmask", new Atom<>(mimoMode));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -39,6 +40,7 @@ import com.vmware.ovsdb.protocol.operation.result.ErrorResult;
|
||||
import com.vmware.ovsdb.protocol.operation.result.InsertResult;
|
||||
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
|
||||
import com.vmware.ovsdb.protocol.operation.result.UpdateResult;
|
||||
import com.vmware.ovsdb.protocol.schema.DatabaseSchema;
|
||||
import com.vmware.ovsdb.service.OvsdbClient;
|
||||
|
||||
@Component
|
||||
@@ -138,60 +140,70 @@ public class OvsdbRrmConfig extends OvsdbDaoBase {
|
||||
void configureWifiRrm(OvsdbClient ovsdbClient, String freqBand, int backupChannel,
|
||||
AutoOrManualValue probeResponseThreshold, AutoOrManualValue clientDisconnectThreshold,
|
||||
ManagementRate managementRate, RadioBestApSettings bestApSettings, MulticastRate multicastRate)
|
||||
throws OvsdbClientException, TimeoutException, ExecutionException, InterruptedException {
|
||||
throws OvsdbClientException, TimeoutException, ExecutionException, InterruptedException {
|
||||
|
||||
CompletableFuture<DatabaseSchema> cfDatabaseSchema = ovsdbClient.getSchema(ovsdbName);
|
||||
DatabaseSchema databaseSchema = cfDatabaseSchema.get();
|
||||
Set<String> columnNames = databaseSchema.getTables().get(wifiRrmConfigDbTable).getColumns().keySet();
|
||||
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Map<String, Value> updateColumns = new HashMap<>();
|
||||
|
||||
updateColumns.put("freq_band", new Atom<>(freqBand));
|
||||
updateColumns.put("backup_channel", new Atom<>(backupChannel));
|
||||
|
||||
if (multicastRate == null || multicastRate == MulticastRate.auto) {
|
||||
updateColumns.put("mcast_rate", new Atom<>(0));
|
||||
} else {
|
||||
updateColumns.put("mcast_rate", new Atom<>(managementRate.getId()));
|
||||
if (columnNames.contains("freq_band")) updateColumns.put("freq_band", new Atom<>(freqBand));
|
||||
if (columnNames.contains("backup_channel")) updateColumns.put("backup_channel", new Atom<>(backupChannel));
|
||||
if (columnNames.contains("mcast_rate")) {
|
||||
if (multicastRate == null || multicastRate == MulticastRate.auto) {
|
||||
updateColumns.put("mcast_rate", new Atom<>(0));
|
||||
} else {
|
||||
updateColumns.put("mcast_rate", new Atom<>(managementRate.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
if (probeResponseThreshold == null || probeResponseThreshold.isAuto()) {
|
||||
updateColumns.put("probe_resp_threshold", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
||||
} else {
|
||||
updateColumns.put("probe_resp_threshold", new Atom<>(probeResponseThreshold.getValue()));
|
||||
if (columnNames.contains("probe_resp_threshold")) {
|
||||
if (probeResponseThreshold == null || probeResponseThreshold.isAuto()) {
|
||||
updateColumns.put("probe_resp_threshold", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
||||
} else {
|
||||
updateColumns.put("probe_resp_threshold", new Atom<>(probeResponseThreshold.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
if (clientDisconnectThreshold == null || clientDisconnectThreshold.isAuto()) {
|
||||
updateColumns.put("client_disconnect_threshold", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
||||
} else {
|
||||
updateColumns.put("client_disconnect_threshold", new Atom<>(clientDisconnectThreshold.getValue()));
|
||||
if (columnNames.contains("client_disconnect_threshold")) {
|
||||
if (clientDisconnectThreshold == null || clientDisconnectThreshold.isAuto()) {
|
||||
updateColumns.put("client_disconnect_threshold", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
||||
} else {
|
||||
updateColumns.put("client_disconnect_threshold", new Atom<>(clientDisconnectThreshold.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
if (managementRate == null || managementRate == ManagementRate.auto) {
|
||||
updateColumns.put("beacon_rate", new Atom<>(0));
|
||||
} else {
|
||||
updateColumns.put("beacon_rate", new Atom<>(managementRate.getId() * 10));
|
||||
if (columnNames.contains("beacon_rate")) {
|
||||
if (managementRate == null || managementRate == ManagementRate.auto) {
|
||||
updateColumns.put("beacon_rate", new Atom<>(0));
|
||||
} else {
|
||||
updateColumns.put("beacon_rate", new Atom<>(managementRate.getId() * 10));
|
||||
}
|
||||
}
|
||||
|
||||
if (bestApSettings == null) {
|
||||
updateColumns.put("min_load", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
||||
updateColumns.put("snr_percentage_drop", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
||||
} else {
|
||||
if (bestApSettings.getDropInSnrPercentage() == null) {
|
||||
if (columnNames.contains("min_load") && columnNames.contains("snr_percentage_drop")) {
|
||||
if (bestApSettings == null) {
|
||||
updateColumns.put("min_load", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
||||
updateColumns.put("snr_percentage_drop", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
||||
} else {
|
||||
updateColumns.put("snr_percentage_drop", new Atom<>(bestApSettings.getDropInSnrPercentage()));
|
||||
}
|
||||
if (bestApSettings.getMinLoadFactor() == null) {
|
||||
updateColumns.put("min_load", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
||||
} else {
|
||||
updateColumns.put("min_load", new Atom<>(bestApSettings.getMinLoadFactor()));
|
||||
if (bestApSettings.getDropInSnrPercentage() == null) {
|
||||
updateColumns.put("snr_percentage_drop", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
||||
} else {
|
||||
updateColumns.put("snr_percentage_drop", new Atom<>(bestApSettings.getDropInSnrPercentage()));
|
||||
}
|
||||
if (bestApSettings.getMinLoadFactor() == null) {
|
||||
updateColumns.put("min_load", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
||||
} else {
|
||||
updateColumns.put("min_load", new Atom<>(bestApSettings.getMinLoadFactor()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row row = new Row(updateColumns);
|
||||
operations.add(new Insert(wifiRrmConfigDbTable, row));
|
||||
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
|
||||
|
||||
LOG.debug("Provisioned rrm config with multicastRate {} Mbps for {}", multicastRate, freqBand);
|
||||
|
||||
for (OperationResult res : result) {
|
||||
|
||||
Reference in New Issue
Block a user