mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-01 19:17:52 +00:00
WIFI-1601: Bulk Send for SSID Profile provision
WIFI-1602: Change configuration order to reduce UCI resets
This commit is contained in:
@@ -1,21 +1,5 @@
|
|||||||
package com.telecominfraproject.wlan.opensync.ovsdb;
|
package com.telecominfraproject.wlan.opensync.ovsdb;
|
||||||
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
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 javax.annotation.PostConstruct;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Profile;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||||
@@ -24,28 +8,27 @@ import com.telecominfraproject.wlan.opensync.external.integration.OpensyncExtern
|
|||||||
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbClientInterface;
|
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbClientInterface;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSession;
|
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSession;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSessionMapInterface;
|
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSessionMapInterface;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.ConnectNodeInfo;
|
import com.telecominfraproject.wlan.opensync.external.integration.models.*;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPInetState;
|
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPVIFState;
|
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncWifiAssociatedClients;
|
|
||||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.OvsdbDao;
|
import com.telecominfraproject.wlan.opensync.ovsdb.dao.OvsdbDao;
|
||||||
import com.telecominfraproject.wlan.opensync.util.OvsdbStringConstants;
|
import com.telecominfraproject.wlan.opensync.util.OvsdbStringConstants;
|
||||||
import com.telecominfraproject.wlan.opensync.util.SslUtil;
|
import com.telecominfraproject.wlan.opensync.util.SslUtil;
|
||||||
import com.vmware.ovsdb.callback.ConnectionCallback;
|
import com.vmware.ovsdb.callback.ConnectionCallback;
|
||||||
import com.vmware.ovsdb.callback.MonitorCallback;
|
|
||||||
import com.vmware.ovsdb.exception.OvsdbClientException;
|
import com.vmware.ovsdb.exception.OvsdbClientException;
|
||||||
import com.vmware.ovsdb.protocol.methods.MonitorRequest;
|
import com.vmware.ovsdb.protocol.methods.*;
|
||||||
import com.vmware.ovsdb.protocol.methods.MonitorRequests;
|
|
||||||
import com.vmware.ovsdb.protocol.methods.MonitorSelect;
|
|
||||||
import com.vmware.ovsdb.protocol.methods.RowUpdate;
|
|
||||||
import com.vmware.ovsdb.protocol.methods.TableUpdate;
|
|
||||||
import com.vmware.ovsdb.protocol.methods.TableUpdates;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.notation.Row;
|
import com.vmware.ovsdb.protocol.operation.notation.Row;
|
||||||
import com.vmware.ovsdb.service.OvsdbClient;
|
import com.vmware.ovsdb.service.OvsdbClient;
|
||||||
import com.vmware.ovsdb.service.OvsdbPassiveConnectionListener;
|
import com.vmware.ovsdb.service.OvsdbPassiveConnectionListener;
|
||||||
|
|
||||||
import io.netty.handler.ssl.SslContext;
|
import io.netty.handler.ssl.SslContext;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Profile;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Profile("ovsdb_manager")
|
@Profile("ovsdb_manager")
|
||||||
@Component
|
@Component
|
||||||
@@ -65,9 +48,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
@org.springframework.beans.factory.annotation.Value("${tip.wlan.defaultCommandDurationSec:3600}")
|
@org.springframework.beans.factory.annotation.Value("${tip.wlan.defaultCommandDurationSec:3600}")
|
||||||
private long defaultCommandDurationSec;
|
private long defaultCommandDurationSec;
|
||||||
|
|
||||||
@org.springframework.beans.factory.annotation.Value("${tip.wlan.defaultCommandDelaySec:60}")
|
|
||||||
private long defaultCommandDelaySec;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SslContext sslContext;
|
private SslContext sslContext;
|
||||||
|
|
||||||
@@ -100,7 +80,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
String remoteHost = ovsdbClient.getConnectionInfo().getRemoteAddress().getHostAddress();
|
String remoteHost = ovsdbClient.getConnectionInfo().getRemoteAddress().getHostAddress();
|
||||||
int localPort = ovsdbClient.getConnectionInfo().getLocalPort();
|
int localPort = ovsdbClient.getConnectionInfo().getLocalPort();
|
||||||
String subjectDn = null;
|
String subjectDn;
|
||||||
try {
|
try {
|
||||||
subjectDn = ((X509Certificate) ovsdbClient.getConnectionInfo().getRemoteCertificate())
|
subjectDn = ((X509Certificate) ovsdbClient.getConnectionInfo().getRemoteCertificate())
|
||||||
.getSubjectDN().getName();
|
.getSubjectDN().getName();
|
||||||
@@ -118,8 +98,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
extIntegrationInterface.apConnected(key, connectNodeInfo);
|
extIntegrationInterface.apConnected(key, connectNodeInfo);
|
||||||
|
|
||||||
// push configuration to AP
|
processConnectRequest(ovsdbClient, clientCn, connectNodeInfo);
|
||||||
connectNodeInfo = processConnectRequest(ovsdbClient, clientCn, connectNodeInfo);
|
|
||||||
|
|
||||||
monitorOvsdbStateTables(ovsdbClient, key);
|
monitorOvsdbStateTables(ovsdbClient, key);
|
||||||
|
|
||||||
@@ -130,12 +109,10 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
LOG.error("autoprovisioning error {}", e.getMessage(), e);
|
LOG.error("autoprovisioning error {}", e.getMessage(), e);
|
||||||
// something is wrong with the SSL
|
// something is wrong with the SSL
|
||||||
ovsdbClient.shutdown();
|
ovsdbClient.shutdown();
|
||||||
return;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("ovsdbClient error", e);
|
LOG.error("ovsdbClient error", e);
|
||||||
// something is wrong with the SSL
|
// something is wrong with the SSL
|
||||||
ovsdbClient.shutdown();
|
ovsdbClient.shutdown();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -184,7 +161,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
try {
|
try {
|
||||||
ovsdbClient.shutdown();
|
ovsdbClient.shutdown();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.info("Caught Exception shutting down ovsdb client, may have already been disconnected {}",
|
LOG.error("Caught Exception shutting down ovsdb client, may have already been disconnected",
|
||||||
e);
|
e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,8 +176,8 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
LOG.info("Manager waiting for connection on port {}...", ovsdbListenPort);
|
LOG.info("Manager waiting for connection on port {}...", ovsdbListenPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConnectNodeInfo processConnectRequest(OvsdbClient ovsdbClient, String clientCn,
|
private void processConnectRequest(OvsdbClient ovsdbClient, String clientCn,
|
||||||
ConnectNodeInfo connectNodeInfo) {
|
ConnectNodeInfo connectNodeInfo) {
|
||||||
|
|
||||||
LOG.debug("Starting Client connect");
|
LOG.debug("Starting Client connect");
|
||||||
connectNodeInfo = ovsdbDao.updateConnectNodeInfoOnConnect(ovsdbClient, clientCn, connectNodeInfo,
|
connectNodeInfo = ovsdbDao.updateConnectNodeInfoOnConnect(ovsdbClient, clientCn, connectNodeInfo,
|
||||||
@@ -224,17 +201,16 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
|
|
||||||
if (opensyncAPConfig != null) {
|
if (opensyncAPConfig != null) {
|
||||||
ovsdbDao.configureNtpServer(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureNtpServer(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
|
||||||
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.configureGreTunnels(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureGreTunnels(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.createVlanNetworkInterfaces(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.createVlanNetworkInterfaces(ovsdbClient, opensyncAPConfig);
|
||||||
|
|
||||||
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureSsids(ovsdbClient, opensyncAPConfig);
|
||||||
if (opensyncAPConfig.getHotspotConfig() != null) {
|
if (opensyncAPConfig.getHotspotConfig() != null) {
|
||||||
ovsdbDao.configureHotspots(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureHotspots(ovsdbClient, opensyncAPConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
ovsdbDao.configureInterfaces(ovsdbClient);
|
ovsdbDao.configureInterfaces(ovsdbClient);
|
||||||
|
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
||||||
|
|
||||||
ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig);
|
||||||
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
|
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
|
||||||
@@ -247,7 +223,6 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("Client connect Done");
|
LOG.debug("Client connect Done");
|
||||||
return connectNodeInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -267,9 +242,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
throw new IllegalStateException("AP with id " + apId + " is not connected");
|
throw new IllegalStateException("AP with id " + apId + " is not connected");
|
||||||
}
|
}
|
||||||
|
|
||||||
String ret = ovsdbDao.changeRedirectorAddress(ovsdbSession.getOvsdbClient(), apId, newRedirectorAddress);
|
return ovsdbDao.changeRedirectorAddress(ovsdbSession.getOvsdbClient(), apId, newRedirectorAddress);
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -293,11 +266,9 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
ovsdbDao.removeAllSsids(ovsdbClient); // always
|
ovsdbDao.removeAllSsids(ovsdbClient); // always
|
||||||
ovsdbDao.removeAllInetConfigs(ovsdbClient);
|
ovsdbDao.removeAllInetConfigs(ovsdbClient);
|
||||||
ovsdbDao.removeWifiRrm(ovsdbClient);
|
ovsdbDao.removeWifiRrm(ovsdbClient);
|
||||||
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
|
|
||||||
|
|
||||||
extIntegrationInterface.clearEquipmentStatus(apId);
|
extIntegrationInterface.clearEquipmentStatus(apId);
|
||||||
ovsdbDao.configureNtpServer(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureNtpServer(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
|
||||||
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.configureGreTunnels(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.configureGreTunnels(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.createVlanNetworkInterfaces(ovsdbClient, opensyncAPConfig);
|
ovsdbDao.createVlanNetworkInterfaces(ovsdbClient, opensyncAPConfig);
|
||||||
@@ -308,12 +279,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ovsdbDao.configureInterfaces(ovsdbClient);
|
ovsdbDao.configureInterfaces(ovsdbClient);
|
||||||
|
ovsdbDao.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
||||||
ovsdbDao.configureStatsFromProfile(ovsdbClient, opensyncAPConfig);
|
|
||||||
if (ovsdbDao.getDeviceStatsReportingInterval(ovsdbClient) != collectionIntervalSecDeviceStats) {
|
|
||||||
ovsdbDao.updateDeviceStatsReportingInterval(ovsdbClient, collectionIntervalSecDeviceStats);
|
|
||||||
}
|
|
||||||
ovsdbDao.updateEventReportingInterval(ovsdbClient, collectionIntervalSecEvent);
|
|
||||||
LOG.debug("Finished processConfigChanged for {}", apId);
|
LOG.debug("Finished processConfigChanged for {}", apId);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -404,75 +370,64 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
OvsdbDao.dhcpLeasedIpDbTable + "_" + key,
|
OvsdbDao.dhcpLeasedIpDbTable + "_" + key,
|
||||||
new MonitorRequests(ImmutableMap.of(OvsdbDao.dhcpLeasedIpDbTable,
|
new MonitorRequests(ImmutableMap.of(OvsdbDao.dhcpLeasedIpDbTable,
|
||||||
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
||||||
new MonitorCallback() {
|
tableUpdates -> {
|
||||||
|
try {
|
||||||
|
LOG.info(OvsdbDao.dhcpLeasedIpDbTable + "_" + key + " monitor callback received {}",
|
||||||
|
tableUpdates);
|
||||||
|
|
||||||
@Override
|
List<Map<String, String>> insert = new ArrayList<>();
|
||||||
public void update(TableUpdates tableUpdates) {
|
List<Map<String, String>> delete = new ArrayList<>();
|
||||||
try {
|
List<Map<String, String>> update = new ArrayList<>();
|
||||||
LOG.info(OvsdbDao.dhcpLeasedIpDbTable + "_" + key + " monitor callback received {}",
|
|
||||||
tableUpdates);
|
|
||||||
|
|
||||||
List<Map<String, String>> insert = new ArrayList<>();
|
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
||||||
List<Map<String, String>> delete = new ArrayList<>();
|
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
||||||
List<Map<String, String>> update = new ArrayList<>();
|
|
||||||
|
|
||||||
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
if (rowUpdate.getNew() == null) {
|
||||||
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
Map<String, String> rowMap = new HashMap<>();
|
||||||
|
|
||||||
if (rowUpdate.getNew() == null) {
|
rowUpdate.getOld().getColumns().entrySet().forEach(c -> OvsdbDao.translateDhcpFpValueToString(c, rowMap));
|
||||||
Map<String, String> rowMap = new HashMap<>();
|
|
||||||
|
|
||||||
rowUpdate.getOld().getColumns().entrySet().stream().forEach(c -> {
|
delete.add(rowMap);
|
||||||
OvsdbDao.translateDhcpFpValueToString(c, rowMap);
|
// delete
|
||||||
});
|
} else if (rowUpdate.getOld() == null) {
|
||||||
|
// insert
|
||||||
|
Map<String, String> rowMap = new HashMap<>();
|
||||||
|
|
||||||
delete.add(rowMap);
|
rowUpdate.getNew().getColumns().entrySet().forEach(c -> OvsdbDao.translateDhcpFpValueToString(c, rowMap));
|
||||||
// delete
|
|
||||||
} else if (rowUpdate.getOld() == null) {
|
|
||||||
// insert
|
|
||||||
Map<String, String> rowMap = new HashMap<>();
|
|
||||||
|
|
||||||
rowUpdate.getNew().getColumns().entrySet().stream().forEach(c -> {
|
insert.add(rowMap);
|
||||||
OvsdbDao.translateDhcpFpValueToString(c, rowMap);
|
} else {
|
||||||
});
|
|
||||||
|
|
||||||
insert.add(rowMap);
|
// insert
|
||||||
} else {
|
Map<String, String> rowMap = new HashMap<>();
|
||||||
|
|
||||||
// insert
|
rowUpdate.getOld().getColumns().putAll(rowUpdate.getNew().getColumns());
|
||||||
Map<String, String> rowMap = new HashMap<>();
|
rowUpdate.getOld().getColumns().entrySet().forEach(c -> OvsdbDao.translateDhcpFpValueToString(c, rowMap));
|
||||||
|
|
||||||
rowUpdate.getOld().getColumns().putAll(rowUpdate.getNew().getColumns());
|
update.add(rowMap);
|
||||||
rowUpdate.getOld().getColumns().entrySet().stream().forEach(c -> {
|
|
||||||
OvsdbDao.translateDhcpFpValueToString(c, rowMap);
|
|
||||||
});
|
|
||||||
|
|
||||||
update.add(rowMap);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!insert.isEmpty()) {
|
|
||||||
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(insert, key,
|
|
||||||
RowUpdateOperation.INSERT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!delete.isEmpty()) {
|
|
||||||
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(delete, key,
|
|
||||||
RowUpdateOperation.DELETE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!update.isEmpty()) {
|
|
||||||
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(update, key,
|
|
||||||
RowUpdateOperation.MODIFY);
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error("dhcpLeasedIpDbTableUpdate failed", e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!insert.isEmpty()) {
|
||||||
|
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(insert, key,
|
||||||
|
RowUpdateOperation.INSERT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!delete.isEmpty()) {
|
||||||
|
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(delete, key,
|
||||||
|
RowUpdateOperation.DELETE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!update.isEmpty()) {
|
||||||
|
extIntegrationInterface.dhcpLeasedIpDbTableUpdate(update, key,
|
||||||
|
RowUpdateOperation.MODIFY);
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("dhcpLeasedIpDbTableUpdate failed", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -486,75 +441,64 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
CompletableFuture<TableUpdates> csCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
CompletableFuture<TableUpdates> csCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
||||||
OvsdbDao.commandStateDbTable + "_" + key,
|
OvsdbDao.commandStateDbTable + "_" + key,
|
||||||
new MonitorRequests(ImmutableMap.of(OvsdbDao.commandStateDbTable, new MonitorRequest())),
|
new MonitorRequests(ImmutableMap.of(OvsdbDao.commandStateDbTable, new MonitorRequest())),
|
||||||
new MonitorCallback() {
|
tableUpdates -> {
|
||||||
|
try {
|
||||||
|
LOG.info(OvsdbDao.commandStateDbTable + "_" + key + " monitor callback received {}",
|
||||||
|
tableUpdates);
|
||||||
|
|
||||||
@Override
|
List<Map<String, String>> insert = new ArrayList<>();
|
||||||
public void update(TableUpdates tableUpdates) {
|
List<Map<String, String>> delete = new ArrayList<>();
|
||||||
try {
|
List<Map<String, String>> update = new ArrayList<>();
|
||||||
LOG.info(OvsdbDao.commandStateDbTable + "_" + key + " monitor callback received {}",
|
|
||||||
tableUpdates);
|
|
||||||
|
|
||||||
List<Map<String, String>> insert = new ArrayList<>();
|
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
||||||
List<Map<String, String>> delete = new ArrayList<>();
|
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
||||||
List<Map<String, String>> update = new ArrayList<>();
|
|
||||||
|
|
||||||
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
if (rowUpdate.getNew() == null) {
|
||||||
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
Map<String, String> rowMap = new HashMap<>();
|
||||||
|
|
||||||
if (rowUpdate.getNew() == null) {
|
rowUpdate.getOld().getColumns().forEach((key1, value) -> rowMap.put(key1, value.toString()));
|
||||||
Map<String, String> rowMap = new HashMap<>();
|
|
||||||
|
|
||||||
rowUpdate.getOld().getColumns().entrySet().stream().forEach(c -> {
|
delete.add(rowMap);
|
||||||
rowMap.put(c.getKey(), c.getValue().toString());
|
// delete
|
||||||
});
|
} else if (rowUpdate.getOld() == null) {
|
||||||
|
// insert
|
||||||
|
Map<String, String> rowMap = new HashMap<>();
|
||||||
|
|
||||||
delete.add(rowMap);
|
rowUpdate.getNew().getColumns().forEach((key1, value) -> rowMap.put(key1, value.toString()));
|
||||||
// delete
|
|
||||||
} else if (rowUpdate.getOld() == null) {
|
|
||||||
// insert
|
|
||||||
Map<String, String> rowMap = new HashMap<>();
|
|
||||||
|
|
||||||
rowUpdate.getNew().getColumns().entrySet().stream().forEach(c -> {
|
insert.add(rowMap);
|
||||||
rowMap.put(c.getKey(), c.getValue().toString());
|
} else {
|
||||||
});
|
|
||||||
|
|
||||||
insert.add(rowMap);
|
// insert
|
||||||
} else {
|
Map<String, String> rowMap = new HashMap<>();
|
||||||
|
|
||||||
// insert
|
rowUpdate.getOld().getColumns().putAll(rowUpdate.getNew().getColumns());
|
||||||
Map<String, String> rowMap = new HashMap<>();
|
rowUpdate.getOld().getColumns().forEach((key1, value) -> rowMap.put(key1, value.toString()));
|
||||||
|
|
||||||
rowUpdate.getOld().getColumns().putAll(rowUpdate.getNew().getColumns());
|
update.add(rowMap);
|
||||||
rowUpdate.getOld().getColumns().entrySet().stream().forEach(c -> {
|
|
||||||
rowMap.put(c.getKey(), c.getValue().toString());
|
|
||||||
});
|
|
||||||
|
|
||||||
update.add(rowMap);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!insert.isEmpty()) {
|
|
||||||
extIntegrationInterface.commandStateDbTableUpdate(insert, key,
|
|
||||||
RowUpdateOperation.INSERT);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!delete.isEmpty()) {
|
|
||||||
extIntegrationInterface.commandStateDbTableUpdate(delete, key,
|
|
||||||
RowUpdateOperation.DELETE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!update.isEmpty()) {
|
|
||||||
extIntegrationInterface.commandStateDbTableUpdate(update, key,
|
|
||||||
RowUpdateOperation.MODIFY);
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error("commandStateDbTableUpdate failed", e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!insert.isEmpty()) {
|
||||||
|
extIntegrationInterface.commandStateDbTableUpdate(insert, key,
|
||||||
|
RowUpdateOperation.INSERT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!delete.isEmpty()) {
|
||||||
|
extIntegrationInterface.commandStateDbTableUpdate(delete, key,
|
||||||
|
RowUpdateOperation.DELETE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!update.isEmpty()) {
|
||||||
|
extIntegrationInterface.commandStateDbTableUpdate(update, key,
|
||||||
|
RowUpdateOperation.MODIFY);
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("commandStateDbTableUpdate failed", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -567,21 +511,16 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(
|
CompletableFuture<TableUpdates> awCf = ovsdbClient.monitor(
|
||||||
OvsdbDao.ovsdbName, OvsdbDao.awlanNodeDbTable + "_" + key, new MonitorRequests(ImmutableMap
|
OvsdbDao.ovsdbName, OvsdbDao.awlanNodeDbTable + "_" + key, new MonitorRequests(ImmutableMap
|
||||||
.of(OvsdbDao.awlanNodeDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
.of(OvsdbDao.awlanNodeDbTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
||||||
new MonitorCallback() {
|
tableUpdates -> {
|
||||||
|
try {
|
||||||
|
LOG.info(OvsdbDao.awlanNodeDbTable + "_" + key + " monitor callback received {}",
|
||||||
|
tableUpdates);
|
||||||
|
|
||||||
@Override
|
extIntegrationInterface.awlanNodeDbTableUpdate(
|
||||||
public void update(TableUpdates tableUpdates) {
|
ovsdbDao.getOpensyncAWLANNode(tableUpdates, key, ovsdbClient), key);
|
||||||
try {
|
} catch (Exception e) {
|
||||||
LOG.info(OvsdbDao.awlanNodeDbTable + "_" + key + " monitor callback received {}",
|
LOG.error("awlanNodeDbTableUpdate failed", e);
|
||||||
tableUpdates);
|
|
||||||
|
|
||||||
extIntegrationInterface.awlanNodeDbTableUpdate(
|
|
||||||
ovsdbDao.getOpensyncAWLANNode(tableUpdates, key, ovsdbClient), key);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error("awlanNodeDbTableUpdate failed", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
extIntegrationInterface.awlanNodeDbTableUpdate(ovsdbDao.getOpensyncAWLANNode(awCf.join(), key, ovsdbClient),
|
extIntegrationInterface.awlanNodeDbTableUpdate(ovsdbDao.getOpensyncAWLANNode(awCf.join(), key, ovsdbClient),
|
||||||
@@ -592,45 +531,40 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
CompletableFuture<TableUpdates> acCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
CompletableFuture<TableUpdates> acCf = ovsdbClient.monitor(OvsdbDao.ovsdbName,
|
||||||
OvsdbDao.wifiAssociatedClientsDbTable + "_" + key,
|
OvsdbDao.wifiAssociatedClientsDbTable + "_" + key,
|
||||||
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable, new MonitorRequest())),
|
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiAssociatedClientsDbTable, new MonitorRequest())),
|
||||||
new MonitorCallback() {
|
tableUpdates -> {
|
||||||
|
|
||||||
@Override
|
try {
|
||||||
public void update(TableUpdates tableUpdates) {
|
LOG.info(
|
||||||
|
OvsdbDao.wifiAssociatedClientsDbTable + "_" + key + " monitor callback received {}",
|
||||||
|
tableUpdates);
|
||||||
|
|
||||||
try {
|
List<OpensyncWifiAssociatedClients> associatedClients = new ArrayList<>();
|
||||||
LOG.info(
|
|
||||||
OvsdbDao.wifiAssociatedClientsDbTable + "_" + key + " monitor callback received {}",
|
|
||||||
tableUpdates);
|
|
||||||
|
|
||||||
List<OpensyncWifiAssociatedClients> associatedClients = new ArrayList<>();
|
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
||||||
|
|
||||||
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
||||||
|
if ((rowUpdate.getOld() != null) && (rowUpdate.getNew() == null)) {
|
||||||
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
Row row = rowUpdate.getOld();
|
||||||
if ((rowUpdate.getOld() != null) && (rowUpdate.getNew() == null)) {
|
String deletedClientMac = row.getStringColumn("mac");
|
||||||
Row row = rowUpdate.getOld();
|
// take care of the deletes as we go
|
||||||
String deletedClientMac = row.getStringColumn("mac");
|
// through
|
||||||
// take care of the deletes as we go
|
// the updates, as we want to delete
|
||||||
// through
|
// before
|
||||||
// the updates, as we want to delete
|
// adding anyway.
|
||||||
// before
|
extIntegrationInterface.wifiAssociatedClientsDbTableDelete(deletedClientMac,
|
||||||
// adding anyway.
|
key);
|
||||||
extIntegrationInterface.wifiAssociatedClientsDbTableDelete(deletedClientMac,
|
} else {
|
||||||
key);
|
associatedClients.addAll(
|
||||||
} else {
|
ovsdbDao.getOpensyncWifiAssociatedClients(rowUpdate, key, ovsdbClient));
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -645,42 +579,35 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
OvsdbDao.wifiInetStateDbTable + "_" + key,
|
OvsdbDao.wifiInetStateDbTable + "_" + key,
|
||||||
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiInetStateDbTable,
|
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiInetStateDbTable,
|
||||||
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
||||||
new MonitorCallback() {
|
tableUpdates -> {
|
||||||
|
try {
|
||||||
|
LOG.info(OvsdbDao.wifiInetStateDbTable + "_" + key + " monitor callback received {}", tableUpdates);
|
||||||
|
|
||||||
@Override
|
List<OpensyncAPInetState> inetStateInsertOrUpdate = new ArrayList<>();
|
||||||
public void update(TableUpdates tableUpdates) {
|
List<OpensyncAPInetState> inetStateDelete = new ArrayList<>();
|
||||||
try {
|
|
||||||
LOG.info(OvsdbDao.ovsdbName,
|
|
||||||
OvsdbDao.wifiInetStateDbTable + "_" + key + " monitor callback received {}",
|
|
||||||
tableUpdates);
|
|
||||||
|
|
||||||
List<OpensyncAPInetState> inetStateInsertOrUpdate = new ArrayList<>();
|
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
||||||
List<OpensyncAPInetState> inetStateDelete = new ArrayList<>();
|
|
||||||
|
|
||||||
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
||||||
|
|
||||||
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
|
||||||
|
|
||||||
if (rowUpdate.getNew() == null) {
|
|
||||||
inetStateDelete.addAll(ovsdbDao.getOpensyncApInetStateForRowUpdate(rowUpdate,
|
|
||||||
key, ovsdbClient));
|
|
||||||
} else {
|
|
||||||
inetStateInsertOrUpdate.addAll(ovsdbDao
|
|
||||||
.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (rowUpdate.getNew() == null) {
|
||||||
|
inetStateDelete.addAll(ovsdbDao.getOpensyncApInetStateForRowUpdate(rowUpdate,
|
||||||
|
key, ovsdbClient));
|
||||||
|
} else {
|
||||||
|
inetStateInsertOrUpdate.addAll(ovsdbDao
|
||||||
|
.getOpensyncApInetStateForRowUpdate(rowUpdate, key, ovsdbClient));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete first
|
|
||||||
extIntegrationInterface.wifiInetStateDbTableUpdate(inetStateDelete, key);
|
|
||||||
|
|
||||||
// now process updates and mutations
|
|
||||||
extIntegrationInterface.wifiInetStateDbTableUpdate(inetStateInsertOrUpdate, key);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error("wifiInetStateDbTableUpdate failed", e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// delete first
|
||||||
|
extIntegrationInterface.wifiInetStateDbTableUpdate(inetStateDelete, key);
|
||||||
|
|
||||||
|
// now process updates and mutations
|
||||||
|
extIntegrationInterface.wifiInetStateDbTableUpdate(inetStateInsertOrUpdate, key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.error("wifiInetStateDbTableUpdate failed", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -696,21 +623,16 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
OvsdbDao.wifiRadioStateDbTable + "_" + key,
|
OvsdbDao.wifiRadioStateDbTable + "_" + key,
|
||||||
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable,
|
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiRadioStateDbTable,
|
||||||
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
||||||
new MonitorCallback() {
|
tableUpdates -> {
|
||||||
|
try {
|
||||||
|
LOG.info(OvsdbDao.wifiRadioStateDbTable + "_" + key + " monitor callback received {}",
|
||||||
|
tableUpdates);
|
||||||
|
|
||||||
@Override
|
extIntegrationInterface.wifiRadioStatusDbTableUpdate(
|
||||||
public void update(TableUpdates tableUpdates) {
|
ovsdbDao.getOpensyncAPRadioState(tableUpdates, key, ovsdbClient), key);
|
||||||
try {
|
} catch (Exception e) {
|
||||||
LOG.info(OvsdbDao.wifiRadioStateDbTable + "_" + key + " monitor callback received {}",
|
LOG.error("wifiRadioStatusDbTableUpdate failed", e);
|
||||||
tableUpdates);
|
|
||||||
|
|
||||||
extIntegrationInterface.wifiRadioStatusDbTableUpdate(
|
|
||||||
ovsdbDao.getOpensyncAPRadioState(tableUpdates, key, ovsdbClient), key);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.error("wifiRadioStatusDbTableUpdate failed", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
extIntegrationInterface
|
extIntegrationInterface
|
||||||
.wifiRadioStatusDbTableUpdate(ovsdbDao.getOpensyncAPRadioState(rsCf.join(), key, ovsdbClient), key);
|
.wifiRadioStatusDbTableUpdate(ovsdbDao.getOpensyncAPRadioState(rsCf.join(), key, ovsdbClient), key);
|
||||||
@@ -722,49 +644,44 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiVifStateDbTable + "_" + key,
|
.monitor(OvsdbDao.ovsdbName, OvsdbDao.wifiVifStateDbTable + "_" + key,
|
||||||
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable,
|
new MonitorRequests(ImmutableMap.of(OvsdbDao.wifiVifStateDbTable,
|
||||||
new MonitorRequest(new MonitorSelect(false, true, true, true)))),
|
new MonitorRequest(new MonitorSelect(false, true, true, true)))),
|
||||||
new MonitorCallback() {
|
tableUpdates -> {
|
||||||
|
try {
|
||||||
|
LOG.info(OvsdbDao.wifiVifStateDbTable + "_" + key + " monitor callback received {}",
|
||||||
|
tableUpdates);
|
||||||
|
|
||||||
@Override
|
List<OpensyncAPVIFState> vifsToDelete = new ArrayList<>();
|
||||||
public void update(TableUpdates tableUpdates) {
|
List<OpensyncAPVIFState> vifsToInsertOrUpdate = new ArrayList<>();
|
||||||
try {
|
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().values()) {
|
||||||
LOG.info(OvsdbDao.wifiVifStateDbTable + "_" + key + " monitor callback received {}",
|
|
||||||
tableUpdates);
|
|
||||||
|
|
||||||
List<OpensyncAPVIFState> vifsToDelete = new ArrayList<>();
|
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
||||||
List<OpensyncAPVIFState> vifsToInsertOrUpdate = new ArrayList<>();
|
|
||||||
for (TableUpdate tableUpdate : tableUpdates.getTableUpdates().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) {
|
} else {
|
||||||
// this is a deletion
|
// either an insert or
|
||||||
vifsToDelete.addAll(ovsdbDao.getOpensyncApVifStateForRowUpdate(
|
// mutuate/update
|
||||||
rowUpdate, key, ovsdbClient));
|
vifsToInsertOrUpdate.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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -776,24 +693,20 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
CompletableFuture<TableUpdates> nsCf = ovsdbClient.monitor(
|
CompletableFuture<TableUpdates> nsCf = ovsdbClient.monitor(
|
||||||
OvsdbDao.ovsdbName, OvsdbDao.nodeStateTable + "_" + key, new MonitorRequests(ImmutableMap
|
OvsdbDao.ovsdbName, OvsdbDao.nodeStateTable + "_" + key, new MonitorRequests(ImmutableMap
|
||||||
.of(OvsdbDao.nodeStateTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
.of(OvsdbDao.nodeStateTable, new MonitorRequest(new MonitorSelect(true, true, true, true)))),
|
||||||
new MonitorCallback() {
|
tableUpdates -> {
|
||||||
@Override
|
LOG.info(OvsdbDao.nodeStateTable + "_" + key + " monitor callback received {}");
|
||||||
public void update(TableUpdates tableUpdates) {
|
tableUpdates.getTableUpdates().forEach((key1, value) -> {
|
||||||
LOG.info(OvsdbDao.nodeStateTable + "_" + key + " monitor callback received {}");
|
LOG.info("TableUpdate for {}", key1);
|
||||||
tableUpdates.getTableUpdates().entrySet().stream().forEach(t -> {
|
value.getRowUpdates().values().forEach(r -> {
|
||||||
LOG.info("TableUpdate for {}", t.getKey());
|
if (r.getOld() != null) {
|
||||||
t.getValue().getRowUpdates().values().stream().forEach(r -> {
|
LOG.info("Node_State old row {}", r.getOld().getColumns());
|
||||||
if (r.getOld() != null) {
|
}
|
||||||
LOG.info("Node_State old row {}", r.getOld().getColumns());
|
if (r.getNew() != null) {
|
||||||
}
|
LOG.info("Node_State new row {}", r.getNew().getColumns());
|
||||||
if (r.getNew() != null) {
|
}
|
||||||
LOG.info("Node_State new row {}", r.getNew().getColumns());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
nsCf.join();
|
nsCf.join();
|
||||||
}
|
}
|
||||||
@@ -875,10 +788,8 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
try {
|
try {
|
||||||
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
|
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
|
||||||
OvsdbClient ovsdbClient = session.getOvsdbClient();
|
OvsdbClient ovsdbClient = session.getOvsdbClient();
|
||||||
|
|
||||||
Map<String, String> payload = new HashMap<>();
|
Map<String, String> payload = new HashMap<>();
|
||||||
ovsdbDao.configureCommands(ovsdbClient, OvsdbDao.StopDebugEngineApCommand, payload, Long.valueOf(0L),
|
ovsdbDao.configureCommands(ovsdbClient, OvsdbDao.StopDebugEngineApCommand, payload, 0L, 0L);
|
||||||
Long.valueOf(0L));
|
|
||||||
|
|
||||||
LOG.debug("TipWlanOvsdbClient::stopDebugEngine Stop debug engine on AP {}", apId);
|
LOG.debug("TipWlanOvsdbClient::stopDebugEngine Stop debug engine on AP {}", apId);
|
||||||
return "Stop debug engine on AP " + apId;
|
return "Stop debug engine on AP " + apId;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class OvsdbDao extends OvsdbDaoBase {
|
|||||||
|
|
||||||
public void configureBlockList(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig,
|
public void configureBlockList(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig,
|
||||||
List<MacAddress> blockList) {
|
List<MacAddress> blockList) {
|
||||||
ovsdbSsid.configureBlockList(ovsdbClient, opensyncAPConfig, blockList);
|
ovsdbSsid.configureBlockList(ovsdbClient, blockList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void configureCommands(OvsdbClient ovsdbClient, String startdebugengineapcommand,
|
public void configureCommands(OvsdbClient ovsdbClient, String startdebugengineapcommand,
|
||||||
|
|||||||
@@ -122,19 +122,13 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
|||||||
* @param isNat
|
* @param isNat
|
||||||
*/
|
*/
|
||||||
void configureInetInterface(OvsdbClient ovsdbClient, String ifName, boolean enabled, String ifType,
|
void configureInetInterface(OvsdbClient ovsdbClient, String ifName, boolean enabled, String ifType,
|
||||||
boolean isUpdate, boolean isNat) {
|
boolean isUpdate, boolean isNat, List<Operation> operations) {
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
List<Operation> operations = new ArrayList<>();
|
|
||||||
Map<String, Value> tableColumns = new HashMap<>();
|
Map<String, Value> tableColumns = new HashMap<>();
|
||||||
|
|
||||||
tableColumns.put("if_type", new Atom<>(ifType));
|
tableColumns.put("if_type", new Atom<>(ifType));
|
||||||
tableColumns.put("enabled", new Atom<>(enabled));
|
tableColumns.put("enabled", new Atom<>(enabled));
|
||||||
tableColumns.put("network", new Atom<>(true));
|
tableColumns.put("network", new Atom<>(true));
|
||||||
tableColumns.put("if_name", new Atom<>(ifName));
|
tableColumns.put("if_name", new Atom<>(ifName));
|
||||||
tableColumns.put("NAT", new Atom<>(isNat));
|
tableColumns.put("NAT", new Atom<>(isNat));
|
||||||
|
|
||||||
Row row = new Row(tableColumns);
|
Row row = new Row(tableColumns);
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
List<Condition> conditions = new ArrayList<>();
|
List<Condition> conditions = new ArrayList<>();
|
||||||
@@ -143,50 +137,24 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
|||||||
} else {
|
} else {
|
||||||
operations.add(new Insert(wifiInetConfigDbTable, row));
|
operations.add(new Insert(wifiInetConfigDbTable, row));
|
||||||
}
|
}
|
||||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
|
||||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
LOG.debug("Updated Inet {}", ifName);
|
|
||||||
|
|
||||||
for (OperationResult res : result) {
|
|
||||||
|
|
||||||
if (res instanceof InsertResult) {
|
|
||||||
LOG.info("configureInetInterface insert new row result {}", (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 {}", (res));
|
|
||||||
} else if (res instanceof ErrorResult) {
|
|
||||||
LOG.error("configureInetInterface error {}", (res));
|
|
||||||
throw new RuntimeException("configureInetInterface " + ((ErrorResult) res).getError() + " "
|
|
||||||
+ ((ErrorResult) res).getDetails());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
|
|
||||||
LOG.error("Error in updateWifiInetConfig", e);
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param ovsdbClient
|
||||||
* @param ovsdbClient
|
|
||||||
* @param vifInterfaceName
|
* @param vifInterfaceName
|
||||||
* @param enabled
|
* @param enabled
|
||||||
* @param networkForwardMode
|
* @param networkForwardMode
|
||||||
|
* @param operations
|
||||||
*/
|
*/
|
||||||
void configureInetVifInterface(OvsdbClient ovsdbClient, String vifInterfaceName, boolean enabled,
|
void configureInetVifInterface(OvsdbClient ovsdbClient, String vifInterfaceName, boolean enabled,
|
||||||
NetworkForwardMode networkForwardMode) {
|
NetworkForwardMode networkForwardMode, List<Operation> operations) {
|
||||||
Map<String, WifiInetConfigInfo> inetConfigs = ovsdbGet.getProvisionedWifiInetConfigs(ovsdbClient);
|
Map<String, WifiInetConfigInfo> inetConfigs = ovsdbGet.getProvisionedWifiInetConfigs(ovsdbClient);
|
||||||
if (inetConfigs.containsKey(vifInterfaceName)) {
|
if (inetConfigs.containsKey(vifInterfaceName)) {
|
||||||
configureInetInterface(ovsdbClient, vifInterfaceName, enabled, "vif", true,
|
configureInetInterface(ovsdbClient, vifInterfaceName, enabled, "vif", true,
|
||||||
(networkForwardMode == NetworkForwardMode.NAT));
|
(networkForwardMode == NetworkForwardMode.NAT), operations);
|
||||||
} else {
|
} else {
|
||||||
configureInetInterface(ovsdbClient, vifInterfaceName, enabled, "vif", false,
|
configureInetInterface(ovsdbClient, vifInterfaceName, enabled, "vif", false,
|
||||||
(networkForwardMode == NetworkForwardMode.NAT));
|
(networkForwardMode == NetworkForwardMode.NAT), operations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,48 +1,37 @@
|
|||||||
package com.telecominfraproject.wlan.opensync.ovsdb.dao;
|
package com.telecominfraproject.wlan.opensync.ovsdb.dao;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.telecominfraproject.wlan.core.model.equipment.ChannelBandwidth;
|
||||||
import java.util.HashMap;
|
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||||
import java.util.List;
|
import com.telecominfraproject.wlan.core.model.equipment.SourceType;
|
||||||
|
import com.telecominfraproject.wlan.equipment.models.*;
|
||||||
|
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;
|
||||||
|
import com.telecominfraproject.wlan.profile.rf.models.RfConfiguration;
|
||||||
|
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.result.OperationResult;
|
||||||
|
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.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
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.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.profile.rf.models.RfConfiguration;
|
|
||||||
import com.telecominfraproject.wlan.profile.rf.models.RfElementConfiguration;
|
|
||||||
import com.vmware.ovsdb.exception.OvsdbClientException;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.Mutate;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.Operation;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.Select;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.Update;
|
|
||||||
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.Mutation;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.notation.Mutator;
|
|
||||||
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.ErrorResult;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.result.SelectResult;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.result.UpdateResult;
|
|
||||||
import com.vmware.ovsdb.service.OvsdbClient;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class OvsdbRadioConfig extends OvsdbDaoBase {
|
public class OvsdbRadioConfig extends OvsdbDaoBase {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
OvsdbGet ovsdbGet;
|
||||||
|
|
||||||
void configureWifiRadios(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) {
|
void configureWifiRadios(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) {
|
||||||
|
|
||||||
String country = opensyncAPConfig.getCountryCode(); // should be the
|
String country = opensyncAPConfig.getCountryCode(); // should be the
|
||||||
@@ -54,6 +43,11 @@ public class OvsdbRadioConfig extends OvsdbDaoBase {
|
|||||||
.getDetails();
|
.getDetails();
|
||||||
RfConfiguration rfConfig = (RfConfiguration) opensyncAPConfig.getRfProfile().getDetails();
|
RfConfiguration rfConfig = (RfConfiguration) opensyncAPConfig.getRfProfile().getDetails();
|
||||||
|
|
||||||
|
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()) {
|
for (RadioType radioType : apElementConfiguration.getRadioMap().keySet()) {
|
||||||
Map<String, String> hwConfig = new HashMap<>();
|
Map<String, String> hwConfig = new HashMap<>();
|
||||||
|
|
||||||
@@ -64,7 +58,7 @@ public class OvsdbRadioConfig extends OvsdbDaoBase {
|
|||||||
LOG.debug("configureWifiRadios autoChannelSelection {} activeChannel {} getChannelNumber {} ",
|
LOG.debug("configureWifiRadios autoChannelSelection {} activeChannel {} getChannelNumber {} ",
|
||||||
autoChannelSelection, channel, elementRadioConfig.getChannelNumber());
|
autoChannelSelection, channel, elementRadioConfig.getChannelNumber());
|
||||||
ChannelBandwidth bandwidth = rfElementConfig.getChannelBandwidth();
|
ChannelBandwidth bandwidth = rfElementConfig.getChannelBandwidth();
|
||||||
String ht_mode = null;
|
String ht_mode;
|
||||||
switch (bandwidth) {
|
switch (bandwidth) {
|
||||||
case is20MHz:
|
case is20MHz:
|
||||||
ht_mode = "HT20";
|
ht_mode = "HT20";
|
||||||
@@ -89,7 +83,7 @@ public class OvsdbRadioConfig extends OvsdbDaoBase {
|
|||||||
int beaconInterval = rfElementConfig.getBeaconInterval();
|
int beaconInterval = rfElementConfig.getBeaconInterval();
|
||||||
boolean enabled = radioConfig.getRadioAdminState().equals(StateSetting.enabled);
|
boolean enabled = radioConfig.getRadioAdminState().equals(StateSetting.enabled);
|
||||||
|
|
||||||
int txPower = 0;
|
int txPower;
|
||||||
if (elementRadioConfig.getEirpTxPower().getSource() == SourceType.profile) {
|
if (elementRadioConfig.getEirpTxPower().getSource() == SourceType.profile) {
|
||||||
txPower = rfElementConfig.getEirpTxPower();
|
txPower = rfElementConfig.getEirpTxPower();
|
||||||
} else {
|
} else {
|
||||||
@@ -121,7 +115,7 @@ public class OvsdbRadioConfig extends OvsdbDaoBase {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
String freqBand = null;
|
String freqBand;
|
||||||
switch (radioType) {
|
switch (radioType) {
|
||||||
case is2dot4GHz:
|
case is2dot4GHz:
|
||||||
freqBand = "2.4G";
|
freqBand = "2.4G";
|
||||||
@@ -170,44 +164,77 @@ public class OvsdbRadioConfig extends OvsdbDaoBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
int mimoMode = MimoMode.none.getId();
|
||||||
if (rfElementConfig.getMimoMode() != null) {
|
if (rfElementConfig.getMimoMode() != null) {
|
||||||
mimoMode = rfElementConfig.getMimoMode().getId();
|
mimoMode = rfElementConfig.getMimoMode().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (freqBand != null) {
|
try {
|
||||||
try {
|
|
||||||
configureWifiRadios(ovsdbClient, freqBand, channel, hwConfig, country.toUpperCase(), beaconInterval,
|
|
||||||
enabled, hwMode, ht_mode, txPower, mimoMode);
|
|
||||||
} catch (OvsdbClientException e) {
|
|
||||||
LOG.error("ConfigureWifiRadios failed with OvsdbClient exception.", e);
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
|
|
||||||
} catch (TimeoutException e) {
|
configureWifiRadios(freqBand, channel, hwConfig, country.toUpperCase(), beaconInterval,
|
||||||
LOG.error("ConfigureWifiRadios failed with Timeout.", e);
|
enabled, hwMode, ht_mode, txPower, mimoMode, vifUuidsForRadio, operations);
|
||||||
throw new RuntimeException(e);
|
} catch (OvsdbClientException e) {
|
||||||
|
LOG.error("ConfigureWifiRadios failed with OvsdbClient exception.", e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
|
||||||
} catch (ExecutionException e) {
|
} catch (TimeoutException e) {
|
||||||
LOG.error("ConfigureWifiRadios excecution failed.", e);
|
LOG.error("ConfigureWifiRadios failed with Timeout.", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
||||||
} catch (InterruptedException e) {
|
} catch (ExecutionException e) {
|
||||||
LOG.error("ConfigureWifiRadios interrupted.", e);
|
LOG.error("ConfigureWifiRadios excecution failed.", e);
|
||||||
throw new RuntimeException(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) {
|
||||||
|
LOG.debug("Op Result {}", res);
|
||||||
|
}
|
||||||
|
} catch (OvsdbClientException | ExecutionException | InterruptedException | TimeoutException e) {
|
||||||
|
LOG.error("configureWifiRadios error", e); throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void configureWifiRadios(OvsdbClient ovsdbClient, String freqBand, int channel, Map<String, String> hwConfig,
|
void configureWifiRadios(String freqBand, int channel, Map<String, String> hwConfig,
|
||||||
String country, int beaconInterval, boolean enabled, String hwMode, String ht_mode, int txPower,
|
String country, int beaconInterval, boolean enabled, String hwMode, String ht_mode, int txPower,
|
||||||
int mimoMode) throws OvsdbClientException, TimeoutException, ExecutionException, InterruptedException {
|
int mimoMode, Set<Uuid> vifUuidsForRadio, List<Operation> operations) throws OvsdbClientException, TimeoutException, ExecutionException, InterruptedException {
|
||||||
|
|
||||||
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("freq_band", Function.EQUALS, new Atom<>(freqBand)));
|
conditions.add(new Condition("freq_band", Function.EQUALS, new Atom<>(freqBand)));
|
||||||
@@ -234,23 +261,20 @@ public class OvsdbRadioConfig extends OvsdbDaoBase {
|
|||||||
updateColumns.put("hw_mode", new Atom<>(hwMode));
|
updateColumns.put("hw_mode", new Atom<>(hwMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
setTxAndRxChainmask(ovsdbClient, mimoMode, updateColumns);
|
setTxAndRxChainmask(mimoMode, updateColumns);
|
||||||
|
|
||||||
|
if (vifUuidsForRadio.size() > 0) {
|
||||||
|
com.vmware.ovsdb.protocol.operation.notation.Set vifConfigUuids = com.vmware.ovsdb.protocol.operation.notation.Set
|
||||||
|
.of(vifUuidsForRadio);
|
||||||
|
updateColumns.put("vif_configs", vifConfigUuids);
|
||||||
|
}
|
||||||
|
|
||||||
Row row = new Row(updateColumns);
|
Row row = new Row(updateColumns);
|
||||||
operations.add(new Update(wifiRadioConfigDbTable, conditions, row));
|
operations.add(new Update(wifiRadioConfigDbTable, conditions, row));
|
||||||
|
|
||||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
|
||||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
LOG.debug("Provisioned channel {} for {}", channel, freqBand);
|
|
||||||
|
|
||||||
for (OperationResult res : result) {
|
|
||||||
LOG.debug("Op Result {}", res);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTxAndRxChainmask(OvsdbClient ovsdbClient, int mimoMode, Map<String, Value> updateColumns)
|
void setTxAndRxChainmask(int mimoMode, Map<String, Value> updateColumns) {
|
||||||
throws InterruptedException, ExecutionException, OvsdbClientException {
|
|
||||||
/*
|
/*
|
||||||
* Chainmask is a bitmask, so map mimo mode values accordingly
|
* Chainmask is a bitmask, so map mimo mode values accordingly
|
||||||
* Note values 0, 1 remain unchanged
|
* Note values 0, 1 remain unchanged
|
||||||
@@ -270,65 +294,4 @@ public class OvsdbRadioConfig extends OvsdbDaoBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the vif_configs column of the Wifi_Radio_Config ovsdb table for
|
|
||||||
* the given freqBand
|
|
||||||
*
|
|
||||||
* @param ovsdbClient
|
|
||||||
* @param ssid
|
|
||||||
* @param radioFreqBand
|
|
||||||
* @param vifConfigUuid
|
|
||||||
* @throws OvsdbClientException
|
|
||||||
* @throws InterruptedException
|
|
||||||
* @throws ExecutionException
|
|
||||||
* @throws TimeoutException
|
|
||||||
*/
|
|
||||||
void updateVifConfigsSetForRadio(OvsdbClient ovsdbClient, String ssid, String radioFreqBand, Uuid vifConfigUuid)
|
|
||||||
throws OvsdbClientException, InterruptedException, ExecutionException, TimeoutException {
|
|
||||||
List<Operation> operations = new ArrayList<>();
|
|
||||||
List<Condition> conditions = new ArrayList<>();
|
|
||||||
conditions.add(new Condition("freq_band", Function.EQUALS, new Atom<>(radioFreqBand)));
|
|
||||||
|
|
||||||
List<Mutation> mutations = new ArrayList<>();
|
|
||||||
Mutation mutation = new Mutation("vif_configs", Mutator.INSERT, new Atom<>(vifConfigUuid));
|
|
||||||
mutations.add(mutation);
|
|
||||||
operations.add(new Mutate(wifiRadioConfigDbTable, conditions, mutations));
|
|
||||||
|
|
||||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
|
||||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
for (OperationResult res : result) {
|
|
||||||
if (res instanceof UpdateResult) {
|
|
||||||
LOG.debug("updateVifConfigsSetForRadio:result {}", res);
|
|
||||||
} else if (res instanceof ErrorResult) {
|
|
||||||
LOG.error("updateVifConfigsSetForRadio error {}", (res));
|
|
||||||
throw new RuntimeException("updateVifConfigsSetForRadio " + ((ErrorResult) res).getError() + " "
|
|
||||||
+ ((ErrorResult) res).getDetails());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// confirm the table was updated with the new Wifi_VIF_Config Uuid
|
|
||||||
operations.clear();
|
|
||||||
operations.add(new Select(wifiRadioConfigDbTable, conditions));
|
|
||||||
fResult = ovsdbClient.transact(ovsdbName, operations);
|
|
||||||
result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
for (OperationResult res : result) {
|
|
||||||
if (res instanceof SelectResult) {
|
|
||||||
SelectResult selectResult = (SelectResult) res;
|
|
||||||
Row row = selectResult.getRows().get(0);
|
|
||||||
if (!row.getSetColumn("vif_configs").contains(vifConfigUuid)) {
|
|
||||||
throw new RuntimeException("Wifi_Radio_Config " + row
|
|
||||||
+ "vif_configs table was not updated {} for new Wifi_VIF_Config " + vifConfigUuid);
|
|
||||||
}
|
|
||||||
} else if (res instanceof ErrorResult) {
|
|
||||||
LOG.error("updateVifConfigsSetForRadio error {}", (res));
|
|
||||||
throw new RuntimeException("updateVifConfigsSetForRadio " + ((ErrorResult) res).getError() + " "
|
|
||||||
+ ((ErrorResult) res).getDetails());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LOG.info("Updated WifiRadioConfig {} for SSID {}:", radioFreqBand, ssid);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,8 @@
|
|||||||
package com.telecominfraproject.wlan.opensync.ovsdb.dao;
|
package com.telecominfraproject.wlan.opensync.ovsdb.dao;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Optional;
|
|
||||||
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 java.util.function.Predicate;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||||
import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration;
|
import com.telecominfraproject.wlan.equipment.models.*;
|
||||||
import com.telecominfraproject.wlan.equipment.models.NetworkForwardMode;
|
|
||||||
import com.telecominfraproject.wlan.equipment.models.RadioConfiguration;
|
|
||||||
import com.telecominfraproject.wlan.equipment.models.RadioMode;
|
|
||||||
import com.telecominfraproject.wlan.equipment.models.StateSetting;
|
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.ConnectNodeInfo;
|
import com.telecominfraproject.wlan.opensync.external.integration.models.ConnectNodeInfo;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
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.WifiRadioConfigInfo;
|
||||||
@@ -46,23 +23,22 @@ import com.telecominfraproject.wlan.profile.ssid.models.NasIdType;
|
|||||||
import com.telecominfraproject.wlan.profile.ssid.models.NasIpType;
|
import com.telecominfraproject.wlan.profile.ssid.models.NasIpType;
|
||||||
import com.telecominfraproject.wlan.profile.ssid.models.SsidConfiguration;
|
import com.telecominfraproject.wlan.profile.ssid.models.SsidConfiguration;
|
||||||
import com.vmware.ovsdb.exception.OvsdbClientException;
|
import com.vmware.ovsdb.exception.OvsdbClientException;
|
||||||
import com.vmware.ovsdb.protocol.operation.Delete;
|
import com.vmware.ovsdb.protocol.operation.*;
|
||||||
import com.vmware.ovsdb.protocol.operation.Insert;
|
import com.vmware.ovsdb.protocol.operation.notation.*;
|
||||||
import com.vmware.ovsdb.protocol.operation.Operation;
|
import com.vmware.ovsdb.protocol.operation.result.*;
|
||||||
import com.vmware.ovsdb.protocol.operation.Select;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.Update;
|
|
||||||
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.ErrorResult;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.result.InsertResult;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.result.SelectResult;
|
|
||||||
import com.vmware.ovsdb.protocol.operation.result.UpdateResult;
|
|
||||||
import com.vmware.ovsdb.service.OvsdbClient;
|
import com.vmware.ovsdb.service.OvsdbClient;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class OvsdbSsidConfig extends OvsdbDaoBase {
|
public class OvsdbSsidConfig extends OvsdbDaoBase {
|
||||||
@@ -70,8 +46,6 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
@Autowired
|
@Autowired
|
||||||
OvsdbGet getProvisionedData;
|
OvsdbGet getProvisionedData;
|
||||||
@Autowired
|
@Autowired
|
||||||
OvsdbRadioConfig radioConfig;
|
|
||||||
@Autowired
|
|
||||||
OvsdbNetworkConfig networkConfig;
|
OvsdbNetworkConfig networkConfig;
|
||||||
@Autowired
|
@Autowired
|
||||||
OvsdbNode ovsdbNode;
|
OvsdbNode ovsdbNode;
|
||||||
@@ -132,7 +106,7 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void configureBlockList(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncApConfig, List<MacAddress> macBlockList) {
|
void configureBlockList(OvsdbClient ovsdbClient, List<MacAddress> macBlockList) {
|
||||||
|
|
||||||
LOG.debug("Starting configureBlockList {}", macBlockList);
|
LOG.debug("Starting configureBlockList {}", macBlockList);
|
||||||
|
|
||||||
@@ -170,18 +144,11 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
*
|
*
|
||||||
* @param enable80211k
|
* @param enable80211k
|
||||||
* @param dtimPeriod
|
* @param dtimPeriod
|
||||||
* @param fragThresholdBytes
|
|
||||||
* @param customOptions
|
* @param customOptions
|
||||||
*/
|
*/
|
||||||
void configureCustomOptionsForDtimFragAnd80211k(boolean enable80211k, int dtimPeriod, int fragThresholdBytes,
|
void configureCustomOptionsForDtimFragAnd80211k(boolean enable80211k, int dtimPeriod,
|
||||||
Map<String, String> customOptions) {
|
Map<String, String> customOptions) {
|
||||||
|
|
||||||
// TODO: the frag_threshold is not supported on the AP
|
|
||||||
// customOptions.put("frag_threshold",
|
|
||||||
// String.valueOf(fragThresholdBytes));
|
|
||||||
|
|
||||||
customOptions.put("dtim_period", String.valueOf(dtimPeriod));
|
customOptions.put("dtim_period", String.valueOf(dtimPeriod));
|
||||||
|
|
||||||
if (enable80211k) {
|
if (enable80211k) {
|
||||||
customOptions.put("ieee80211k", String.valueOf(1));
|
customOptions.put("ieee80211k", String.valueOf(1));
|
||||||
} else {
|
} else {
|
||||||
@@ -254,7 +221,6 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
* @param clientDlLimit
|
* @param clientDlLimit
|
||||||
* @param clientUlLimit
|
* @param clientUlLimit
|
||||||
* @param rtsCtsThreshold
|
* @param rtsCtsThreshold
|
||||||
* @param fragThresholdBytes
|
|
||||||
* @param dtimPeriod
|
* @param dtimPeriod
|
||||||
* @param radiusNasId
|
* @param radiusNasId
|
||||||
* @param radiusNasIp
|
* @param radiusNasIp
|
||||||
@@ -263,16 +229,16 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
* @param dynamicVlan
|
* @param dynamicVlan
|
||||||
*/
|
*/
|
||||||
void configureCustomOptionsForSsid(OvsdbClient ovsdbClient, boolean enable80211k, boolean rateLimitEnable,
|
void configureCustomOptionsForSsid(OvsdbClient ovsdbClient, boolean enable80211k, boolean rateLimitEnable,
|
||||||
int ssidDlLimit, int ssidUlLimit, int clientDlLimit, int clientUlLimit, int rtsCtsThreshold,
|
int ssidDlLimit, int ssidUlLimit, int clientDlLimit, int clientUlLimit, int rtsCtsThreshold,
|
||||||
int fragThresholdBytes, int dtimPeriod, String radiusNasId, String radiusNasIp, String radiusOperatorName,
|
int dtimPeriod, String radiusNasId, String radiusNasIp, String radiusOperatorName,
|
||||||
Map<String, Value> updateColumns, int dynamicVlan) {
|
Map<String, Value> updateColumns, int dynamicVlan) {
|
||||||
Map<String, String> customOptions = new HashMap<>();
|
Map<String, String> customOptions = new HashMap<>();
|
||||||
configureCustomOptionsForRatesAndLimits(rateLimitEnable, ssidDlLimit, ssidUlLimit, clientDlLimit, clientUlLimit,
|
configureCustomOptionsForRatesAndLimits(rateLimitEnable, ssidDlLimit, ssidUlLimit, clientDlLimit, clientUlLimit,
|
||||||
rtsCtsThreshold, customOptions);
|
rtsCtsThreshold, customOptions);
|
||||||
|
|
||||||
configureCustomOptionsForRadiusNas(ovsdbClient, radiusNasId, radiusNasIp, radiusOperatorName, customOptions);
|
configureCustomOptionsForRadiusNas(ovsdbClient, radiusNasId, radiusNasIp, radiusOperatorName, customOptions);
|
||||||
|
|
||||||
configureCustomOptionsForDtimFragAnd80211k(enable80211k, dtimPeriod, fragThresholdBytes, customOptions);
|
configureCustomOptionsForDtimFragAnd80211k(enable80211k, dtimPeriod, customOptions);
|
||||||
|
|
||||||
configureCustomOptionsForDynamicVlan(dynamicVlan, customOptions);
|
configureCustomOptionsForDynamicVlan(dynamicVlan, customOptions);
|
||||||
|
|
||||||
@@ -282,26 +248,22 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
updateColumns.put("custom_options", customMap);
|
updateColumns.put("custom_options", customMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
Uuid configureSingleSsid(OvsdbClient ovsdbClient, String vifInterfaceName, String ssid, boolean ssidBroadcast,
|
void configureSingleSsid(OvsdbClient ovsdbClient, String vifInterfaceName, String ssid, boolean ssidBroadcast,
|
||||||
Map<String, String> security, String radioFreqBand, int vlanId, boolean rrmEnabled, boolean enable80211r,
|
Map<String, String> security, int vlanId, boolean rrmEnabled, boolean enable80211r,
|
||||||
int mobilityDomain, boolean enable80211v, boolean enable80211k, String minHwMode, boolean enabled,
|
int mobilityDomain, boolean enable80211v, boolean enable80211k, String minHwMode, boolean enabled,
|
||||||
int keyRefresh, boolean uapsdEnabled, boolean apBridge, NetworkForwardMode networkForwardMode,
|
int keyRefresh, boolean uapsdEnabled, boolean apBridge, NetworkForwardMode networkForwardMode,
|
||||||
String gateway, String inet, Map<String, String> dns, String ipAssignScheme, List<MacAddress> macBlockList,
|
List<MacAddress> macBlockList,
|
||||||
boolean rateLimitEnable, int ssidDlLimit, int ssidUlLimit, int clientDlLimit, int clientUlLimit,
|
boolean rateLimitEnable, int ssidDlLimit, int ssidUlLimit, int clientDlLimit, int clientUlLimit,
|
||||||
int rtsCtsThreshold, int fragThresholdBytes, int dtimPeriod, Map<String, String> captiveMap,
|
int rtsCtsThreshold, int dtimPeriod, Map<String, String> captiveMap,
|
||||||
List<String> walledGardenAllowlist, Map<Short, Set<String>> bonjourServiceMap, String radiusNasId,
|
List<String> walledGardenAllowlist, String radiusNasId,
|
||||||
String radiusNasIp, String radiusOperatorName, String greTunnelName, int dynamicVlan) {
|
String radiusNasIp, String radiusOperatorName, String greTunnelName, int dynamicVlan, List<Operation> operations) {
|
||||||
|
|
||||||
List<Operation> operations = new ArrayList<>();
|
|
||||||
Map<String, Value> updateColumns = new HashMap<>();
|
Map<String, Value> updateColumns = new HashMap<>();
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
// If we are doing a NAT SSID, no bridge, else yes
|
// If we are doing a NAT SSID, no bridge, else yes
|
||||||
// If gre tunnel and vlanId > 1 use vlan if name for bridge
|
// If gre tunnel and vlanId > 1 use vlan if name for bridge
|
||||||
String bridgeInterfaceName = defaultWanInterfaceName;
|
String bridgeInterfaceName = defaultWanInterfaceName;
|
||||||
if (greTunnelName != null && vlanId > 1) {
|
if (greTunnelName != null && vlanId > 1) {
|
||||||
bridgeInterfaceName = greTunnelName + "_" + String.valueOf(vlanId);
|
bridgeInterfaceName = greTunnelName + "_" + vlanId;
|
||||||
} else if (networkForwardMode == NetworkForwardMode.NAT) {
|
} else if (networkForwardMode == NetworkForwardMode.NAT) {
|
||||||
bridgeInterfaceName = defaultLanInterfaceName;
|
bridgeInterfaceName = defaultLanInterfaceName;
|
||||||
}
|
}
|
||||||
@@ -320,21 +282,14 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
|
|
||||||
if (walledGardenAllowlist != null && !walledGardenAllowlist.isEmpty()) {
|
if (walledGardenAllowlist != null && !walledGardenAllowlist.isEmpty()) {
|
||||||
Set<Atom<String>> atomMacList = new HashSet<>();
|
Set<Atom<String>> atomMacList = new HashSet<>();
|
||||||
walledGardenAllowlist.stream().forEach(allow -> atomMacList.add(new Atom<>(allow)));
|
walledGardenAllowlist.forEach(allow -> atomMacList.add(new Atom<>(allow)));
|
||||||
com.vmware.ovsdb.protocol.operation.notation.Set allowListSet = com.vmware.ovsdb.protocol.operation.notation.Set
|
com.vmware.ovsdb.protocol.operation.notation.Set allowListSet = com.vmware.ovsdb.protocol.operation.notation.Set
|
||||||
.of(atomMacList);
|
.of(atomMacList);
|
||||||
updateColumns.put("captive_allowlist", allowListSet);
|
updateColumns.put("captive_allowlist", allowListSet);
|
||||||
} else {
|
} else {
|
||||||
updateColumns.put("captive_allowlist", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
updateColumns.put("captive_allowlist", new com.vmware.ovsdb.protocol.operation.notation.Set());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: when AP support for Bonjour Gateway set values
|
|
||||||
if (bonjourServiceMap != null && bonjourServiceMap.size() > 0) {
|
|
||||||
LOG.info("SSID {} Bonjour Services per vlan {}", ssid, bonjourServiceMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateColumns.put("bridge", new Atom<>(bridgeInterfaceName));
|
updateColumns.put("bridge", new Atom<>(bridgeInterfaceName));
|
||||||
|
|
||||||
if (enable80211v) {
|
if (enable80211v) {
|
||||||
updateColumns.put("btm", new Atom<>(1));
|
updateColumns.put("btm", new Atom<>(1));
|
||||||
} else {
|
} else {
|
||||||
@@ -353,59 +308,19 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
updateColumns.put("ssid", new Atom<>(ssid));
|
updateColumns.put("ssid", new Atom<>(ssid));
|
||||||
updateColumns.put("ssid_broadcast", new Atom<>(ssidBroadcast ? "enabled" : "disabled"));
|
updateColumns.put("ssid_broadcast", new Atom<>(ssidBroadcast ? "enabled" : "disabled"));
|
||||||
updateColumns.put("uapsd_enable", new Atom<>(uapsdEnabled));
|
updateColumns.put("uapsd_enable", new Atom<>(uapsdEnabled));
|
||||||
|
|
||||||
updateColumns.put("min_hw_mode", new Atom<>(minHwMode));
|
updateColumns.put("min_hw_mode", new Atom<>(minHwMode));
|
||||||
|
|
||||||
updateColumns.put("group_rekey", new Atom<>(keyRefresh));
|
updateColumns.put("group_rekey", new Atom<>(keyRefresh));
|
||||||
updateColumns.put("uapsd_enable", new Atom<>(uapsdEnabled));
|
|
||||||
updateColumns.put("ap_bridge", new Atom<>(apBridge));
|
updateColumns.put("ap_bridge", new Atom<>(apBridge));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
com.vmware.ovsdb.protocol.operation.notation.Map<String, String> securityMap = com.vmware.ovsdb.protocol.operation.notation.Map
|
com.vmware.ovsdb.protocol.operation.notation.Map<String, String> securityMap = com.vmware.ovsdb.protocol.operation.notation.Map
|
||||||
.of(security);
|
.of(security);
|
||||||
updateColumns.put("security", securityMap);
|
updateColumns.put("security", securityMap);
|
||||||
|
|
||||||
configureCustomOptionsForSsid(ovsdbClient, enable80211k, rateLimitEnable, ssidDlLimit, ssidUlLimit,
|
configureCustomOptionsForSsid(ovsdbClient, enable80211k, rateLimitEnable, ssidDlLimit, ssidUlLimit,
|
||||||
clientDlLimit, clientUlLimit, rtsCtsThreshold, fragThresholdBytes, dtimPeriod, radiusNasId,
|
clientDlLimit, clientUlLimit, rtsCtsThreshold, dtimPeriod, radiusNasId,
|
||||||
radiusNasIp, radiusOperatorName, updateColumns, dynamicVlan);
|
radiusNasIp, radiusOperatorName, updateColumns, dynamicVlan);
|
||||||
|
|
||||||
updateBlockList(updateColumns, macBlockList);
|
updateBlockList(updateColumns, macBlockList);
|
||||||
Row row = new Row(updateColumns);
|
Row row = new Row(updateColumns);
|
||||||
|
|
||||||
operations.add(new Insert(wifiVifConfigDbTable, row));
|
operations.add(new Insert(wifiVifConfigDbTable, row));
|
||||||
|
|
||||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
|
||||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
Uuid vifConfigUuid = null;
|
|
||||||
for (OperationResult res : result) {
|
|
||||||
InsertResult insertResult = null;
|
|
||||||
if (res instanceof InsertResult) {
|
|
||||||
insertResult = (InsertResult) res;
|
|
||||||
LOG.info("configureSingleSsid:InsertResult {}", insertResult);
|
|
||||||
vifConfigUuid = ((InsertResult) res).getUuid();
|
|
||||||
} else if (res instanceof ErrorResult) {
|
|
||||||
LOG.error("configureSingleSsid: error {}", (res));
|
|
||||||
throw new RuntimeException("configureSingleSsid " + ((ErrorResult) res).getError() + " "
|
|
||||||
+ ((ErrorResult) res).getDetails());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vifConfigUuid == null) {
|
|
||||||
throw new IllegalStateException("Wifi_VIF_Config entry was not created successfully");
|
|
||||||
}
|
|
||||||
|
|
||||||
confirmRowExistsInTable(ovsdbClient, vifConfigUuid, wifiVifConfigDbTable);
|
|
||||||
|
|
||||||
LOG.info("configureSingleSsid:Provisioned SSID {} on interface {} / {}", ssid, vifInterfaceName,
|
|
||||||
radioFreqBand);
|
|
||||||
|
|
||||||
return vifConfigUuid;
|
|
||||||
|
|
||||||
} catch (OvsdbClientException | TimeoutException | ExecutionException | InterruptedException e) {
|
|
||||||
LOG.error("Error in configureSingleSsid", e);
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void configureSsids(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncApConfig) {
|
void configureSsids(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncApConfig) {
|
||||||
@@ -420,7 +335,8 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
|
|
||||||
List<RadioType> enabledRadiosFromAp = new ArrayList<>();
|
List<RadioType> enabledRadiosFromAp = new ArrayList<>();
|
||||||
getEnabledRadios(ovsdbClient, enabledRadiosFromAp);
|
getEnabledRadios(ovsdbClient, enabledRadiosFromAp);
|
||||||
|
Map<String, Integer> interfacesPerFreqBand = new HashMap<>();
|
||||||
|
List<Operation> operations = new ArrayList<>();
|
||||||
for (Profile ssidProfile : opensyncApConfig.getSsidProfile()) {
|
for (Profile ssidProfile : opensyncApConfig.getSsidProfile()) {
|
||||||
|
|
||||||
SsidConfiguration ssidConfig = (SsidConfiguration) ssidProfile.getDetails();
|
SsidConfiguration ssidConfig = (SsidConfiguration) ssidProfile.getDetails();
|
||||||
@@ -482,8 +398,8 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((radioName == null) || (freqBand == null)) {
|
if (radioName == null) {
|
||||||
LOG.debug("Cannot provision SSID with radio if_name {} and freqBand {}", radioName, freqBand);
|
LOG.debug("Cannot provision SSID with radio if_name null and freqBand {}", freqBand);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (radioName.equals(radio0)) {
|
if (radioName.equals(radio0)) {
|
||||||
@@ -494,8 +410,7 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
ifName = defaultRadio2;
|
ifName = defaultRadio2;
|
||||||
}
|
}
|
||||||
if (ifName == null) {
|
if (ifName == null) {
|
||||||
LOG.debug("Cannot provision SSID for radio {} freqBand {} with VIF if_name {}", radioName, freqBand,
|
LOG.debug("Cannot provision SSID for radio {} freqBand {} with VIF if_name null", radioName, freqBand);
|
||||||
ifName);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,43 +418,18 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
|
|
||||||
boolean ssidBroadcast = ssidConfig.getBroadcastSsid() == StateSetting.enabled;
|
boolean ssidBroadcast = ssidConfig.getBroadcastSsid() == StateSetting.enabled;
|
||||||
|
|
||||||
String ipAssignScheme = apElementConfig.getGettingIP().toString();
|
|
||||||
// the following 5 attributes only applicable to static
|
|
||||||
// ipAssignScheme,
|
|
||||||
// else they are
|
|
||||||
// ignored
|
|
||||||
String gateway = null;
|
|
||||||
String inet = null;
|
|
||||||
Map<String, String> dns = null;
|
|
||||||
if (ipAssignScheme.equals("manual")) {
|
|
||||||
if (apElementConfig.getStaticIP() != null) {
|
|
||||||
ipAssignScheme = "static";
|
|
||||||
inet = apElementConfig.getStaticIP().getHostAddress();
|
|
||||||
gateway = apElementConfig.getStaticIpGw().getHostAddress();
|
|
||||||
dns = new HashMap<>();
|
|
||||||
dns.put(apElementConfig.getStaticDnsIp1().getHostName(),
|
|
||||||
apElementConfig.getStaticDnsIp1().getHostAddress());
|
|
||||||
dns.put(apElementConfig.getStaticDnsIp2().getHostName(),
|
|
||||||
apElementConfig.getStaticDnsIp2().getHostAddress());
|
|
||||||
} else {
|
|
||||||
ipAssignScheme = "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RfElementConfiguration rfElementConfig = rfConfig.getRfConfig(radioType);
|
RfElementConfiguration rfElementConfig = rfConfig.getRfConfig(radioType);
|
||||||
int rtsCtsThreshold = rfElementConfig.getRtsCtsThreshold();
|
int rtsCtsThreshold = rfElementConfig.getRtsCtsThreshold();
|
||||||
RadioMode radioMode = rfElementConfig.getRadioMode();
|
RadioMode radioMode = rfElementConfig.getRadioMode();
|
||||||
|
|
||||||
int dtimPeriod = 2;
|
|
||||||
int fragThresholdBytes = 2346;
|
|
||||||
boolean uapsdEnabled = true;
|
boolean uapsdEnabled = true;
|
||||||
boolean apBridge = true;
|
boolean apBridge = true;
|
||||||
RadioConfiguration radioConfiguration = apElementConfig.getAdvancedRadioMap().get(radioType);
|
RadioConfiguration radioConfiguration = apElementConfig.getAdvancedRadioMap().get(radioType);
|
||||||
|
int dtimPeriod = 2;
|
||||||
if (radioConfiguration != null) {
|
if (radioConfiguration != null) {
|
||||||
dtimPeriod = radioConfiguration.getDtimPeriod();
|
dtimPeriod = radioConfiguration.getDtimPeriod();
|
||||||
uapsdEnabled = radioConfiguration.getUapsdState() == StateSetting.enabled;
|
uapsdEnabled = radioConfiguration.getUapsdState() == StateSetting.enabled;
|
||||||
apBridge = radioConfiguration.getStationIsolation() == StateSetting.disabled; // stationIsolation
|
apBridge = radioConfiguration.getStationIsolation() == StateSetting.disabled; // stationIsolation
|
||||||
fragThresholdBytes = radioConfiguration.getFragmentationThresholdBytes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String minHwMode = "11n"; // min_hw_mode is 11n
|
String minHwMode = "11n"; // min_hw_mode is 11n
|
||||||
@@ -634,46 +524,44 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
int vlanId = ssidConfig.getVlanId() != null ? ssidConfig.getVlanId() : 1;
|
int vlanId = ssidConfig.getVlanId() != null ? ssidConfig.getVlanId() : 1;
|
||||||
Optional<GreTunnelConfiguration> tunnelConfiguration = ((ApNetworkConfiguration) opensyncApConfig
|
Optional<GreTunnelConfiguration> tunnelConfiguration = ((ApNetworkConfiguration) opensyncApConfig
|
||||||
.getApProfile().getDetails()).getGreTunnelConfigurations().stream()
|
.getApProfile().getDetails()).getGreTunnelConfigurations().stream()
|
||||||
.filter(new Predicate<GreTunnelConfiguration>() {
|
.filter(t -> t.getVlanIdsInGreTunnel().contains(vlanId)).findFirst();
|
||||||
|
String greTunnelName = null;
|
||||||
@Override
|
if (tunnelConfiguration.isPresent()) {
|
||||||
public boolean test(GreTunnelConfiguration t) {
|
greTunnelName = tunnelConfiguration.get().getGreTunnelName();
|
||||||
|
}
|
||||||
return t.getVlanIdsInGreTunnel().contains(vlanId);
|
if (interfacesPerFreqBand.containsKey(freqBand)) {
|
||||||
}
|
Integer numIf = interfacesPerFreqBand.get(freqBand);
|
||||||
|
ifName = ifName + "_" + numIf.toString();
|
||||||
}).findFirst();
|
interfacesPerFreqBand.put(freqBand, ++numIf);
|
||||||
|
} else {
|
||||||
|
interfacesPerFreqBand.put(freqBand, 1);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
configureSingleSsid(ovsdbClient, ifName, ssidConfig.getSsid(), ssidBroadcast,
|
||||||
ifName = getInterfaceNameForVifConfig(ovsdbClient, opensyncApConfig, ssidConfig, freqBand, ifName);
|
security, vlanId, rrmEnabled, enable80211r, mobilityDomain, enable80211v,
|
||||||
String greTunnelName = null;
|
|
||||||
if (tunnelConfiguration.isPresent()) {
|
|
||||||
greTunnelName = tunnelConfiguration.get().getGreTunnelName();
|
|
||||||
}
|
|
||||||
|
|
||||||
Uuid vifConfigUuid = configureSingleSsid(ovsdbClient, ifName, ssidConfig.getSsid(), ssidBroadcast,
|
|
||||||
security, freqBand, vlanId, rrmEnabled, enable80211r, mobilityDomain, enable80211v,
|
|
||||||
enable80211k, minHwMode, enabled, keyRefresh, uapsdEnabled, apBridge,
|
enable80211k, minHwMode, enabled, keyRefresh, uapsdEnabled, apBridge,
|
||||||
ssidConfig.getForwardMode(), gateway, inet, dns, ipAssignScheme, macBlockList,
|
ssidConfig.getForwardMode(), macBlockList,
|
||||||
rateLimitEnable, ssidDlLimit, ssidUlLimit, clientDlLimit, clientUlLimit, rtsCtsThreshold,
|
rateLimitEnable, ssidDlLimit, ssidUlLimit, clientDlLimit, clientUlLimit, rtsCtsThreshold,
|
||||||
fragThresholdBytes, dtimPeriod, captiveMap, walledGardenAllowlist, bonjourServiceMap,
|
dtimPeriod, captiveMap, walledGardenAllowlist,
|
||||||
radiusNasId, radiusNasIp, radiusOperName, greTunnelName, dynamicVlan);
|
radiusNasId, radiusNasIp, radiusOperName, greTunnelName, dynamicVlan,operations);
|
||||||
|
|
||||||
radioConfig.updateVifConfigsSetForRadio(ovsdbClient, ssidConfig.getSsid(), freqBand, vifConfigUuid);
|
networkConfig.configureInetVifInterface(ovsdbClient, ifName, enabled, ssidConfig.getForwardMode(),operations );
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
networkConfig.configureInetVifInterface(ovsdbClient, ifName, enabled, ssidConfig.getForwardMode());
|
|
||||||
|
|
||||||
} catch (IllegalStateException | OvsdbClientException | InterruptedException | ExecutionException
|
|
||||||
| TimeoutException 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(), freqBand);
|
LOG.warn("could not provision SSID {} on {}", ssidConfig.getSsid(), freqBand);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||||
|
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||||
|
LOG.debug("configureSsids result {}", Arrays.toString(result));
|
||||||
|
} catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) {
|
||||||
|
LOG.error("Unable to configureSsids on AP.", e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void getBonjourGatewayConfiguration(OpensyncAPConfig opensyncApConfig, SsidConfiguration ssidConfig,
|
void getBonjourGatewayConfiguration(OpensyncAPConfig opensyncApConfig, SsidConfiguration ssidConfig,
|
||||||
@@ -689,7 +577,7 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
|
|
||||||
Collection<BonjourServiceSet> bonjourServicesCollection = bonjourGatewayConfiguration
|
Collection<BonjourServiceSet> bonjourServicesCollection = bonjourGatewayConfiguration
|
||||||
.getBonjourServices();
|
.getBonjourServices();
|
||||||
bonjourServicesCollection.stream().forEach(b -> {
|
bonjourServicesCollection.forEach(b -> {
|
||||||
Set<String> serviceSet = new HashSet<>();
|
Set<String> serviceSet = new HashSet<>();
|
||||||
if (bonjourServiceMap.containsKey(b.getVlanId())) {
|
if (bonjourServiceMap.containsKey(b.getVlanId())) {
|
||||||
serviceSet.addAll(bonjourServiceMap.get(b.getVlanId()));
|
serviceSet.addAll(bonjourServiceMap.get(b.getVlanId()));
|
||||||
@@ -749,7 +637,7 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
if (captiveProfileDetails.getAuthenticationType().equals(CaptivePortalAuthenticationType.radius)) {
|
if (captiveProfileDetails.getAuthenticationType().equals(CaptivePortalAuthenticationType.radius)) {
|
||||||
Optional<Profile> optional = opensyncApConfig.getRadiusProfiles().stream()
|
Optional<Profile> optional = opensyncApConfig.getRadiusProfiles().stream()
|
||||||
.filter(p -> p.getId() == captiveProfileDetails.getRadiusServiceId()).findFirst();
|
.filter(p -> p.getId() == captiveProfileDetails.getRadiusServiceId()).findFirst();
|
||||||
if (optional != null && optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
Profile profile = optional.get();
|
Profile profile = optional.get();
|
||||||
RadiusProfile radiusProfile = (RadiusProfile) profile.getDetails();
|
RadiusProfile radiusProfile = (RadiusProfile) profile.getDetails();
|
||||||
captiveMap.put("radius_server_ip", String.valueOf(
|
captiveMap.put("radius_server_ip", String.valueOf(
|
||||||
@@ -805,46 +693,6 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the interface name for the new Wifi_VIF_Config. Maximum of 8
|
|
||||||
* interface names per frequencyBand
|
|
||||||
*
|
|
||||||
* @param ovsdbClient
|
|
||||||
* @param opensyncApConfig
|
|
||||||
* @param ssidConfig
|
|
||||||
* @param freqBand
|
|
||||||
* @param ifName
|
|
||||||
* @return the interface name, i.e. wlan0, wlan0_1, etc
|
|
||||||
*/
|
|
||||||
String getInterfaceNameForVifConfig(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncApConfig,
|
|
||||||
SsidConfiguration ssidConfig, String freqBand, String ifName) {
|
|
||||||
Map<String, WifiVifConfigInfo> provisionedVifs = getProvisionedData.getProvisionedWifiVifConfigs(ovsdbClient);
|
|
||||||
|
|
||||||
List<String> interfaces = new ArrayList<>();
|
|
||||||
interfaces.add(ifName);
|
|
||||||
for (int i = 1; i < MAX_VIF_PER_FREQ; i++) {
|
|
||||||
interfaces.add(ifName + "_" + Integer.toString(i));
|
|
||||||
}
|
|
||||||
for (String key : provisionedVifs.keySet()) {
|
|
||||||
if (key.contains(ifName)) {
|
|
||||||
String provisionedIfName = provisionedVifs.get(key).ifName;
|
|
||||||
if (interfaces.remove(provisionedIfName)) {
|
|
||||||
LOG.info("Interface {} already in use on Radio {}, cannot be used for new Wifi_VIF_Config.",
|
|
||||||
provisionedIfName, freqBand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (interfaces.isEmpty()) {
|
|
||||||
throw new RuntimeException("No more available interfaces on AP "
|
|
||||||
+ opensyncApConfig.getCustomerEquipment().getName() + " for frequency band " + freqBand);
|
|
||||||
} else {
|
|
||||||
// take the first available interface for this band
|
|
||||||
ifName = interfaces.get(0);
|
|
||||||
LOG.info("Configuring new Wifi_VIF_Config for ssid {} with if_name {}", ssidConfig.getSsid(), ifName);
|
|
||||||
}
|
|
||||||
return ifName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps between the osvdb security definitions and the cloud's security mode
|
* Maps between the osvdb security definitions and the cloud's security mode
|
||||||
* for the give SSID being configured.
|
* for the give SSID being configured.
|
||||||
@@ -854,21 +702,31 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String getOpensyncSecurityMode(String ssidSecurityMode, String opensyncSecurityMode) {
|
String getOpensyncSecurityMode(String ssidSecurityMode, String opensyncSecurityMode) {
|
||||||
if (ssidSecurityMode.equals("wpaPSK") || ssidSecurityMode.equals("wpa2PSK")
|
switch (ssidSecurityMode) {
|
||||||
|| ssidSecurityMode.equals("wpa2OnlyPSK")) {
|
case "wpaPSK":
|
||||||
opensyncSecurityMode = "WPA-PSK";
|
case "wpa2PSK":
|
||||||
} else if (ssidSecurityMode.equals("wep")) {
|
case "wpa2OnlyPSK":
|
||||||
opensyncSecurityMode = "WEP";
|
opensyncSecurityMode = "WPA-PSK";
|
||||||
} else if (ssidSecurityMode.equals("wpaEAP") || ssidSecurityMode.equals("wpa2EAP")
|
break;
|
||||||
|| ssidSecurityMode.equals("wpa2OnlyEAP")) {
|
case "wep":
|
||||||
opensyncSecurityMode = "WPA-EAP";
|
opensyncSecurityMode = "WEP";
|
||||||
} else if (ssidSecurityMode.equals("wpaRadius") || ssidSecurityMode.equals("wpa2OnlyRadius")
|
break;
|
||||||
|| ssidSecurityMode.equals("wpa2Radius")) {
|
case "wpaEAP":
|
||||||
opensyncSecurityMode = "WPA-EAP";
|
case "wpa2EAP":
|
||||||
} else if (ssidSecurityMode.equals("wpa3OnlySAE") || ssidSecurityMode.equals("wpa3MixedSAE")) {
|
case "wpa2OnlyEAP":
|
||||||
opensyncSecurityMode = "WPA-SAE";
|
case "wpaRadius":
|
||||||
} else if (ssidSecurityMode.equals("wpa3OnlyEAP") || ssidSecurityMode.equals("wpa3MixedEAP")) {
|
case "wpa2OnlyRadius":
|
||||||
opensyncSecurityMode = "WPA3-EAP";
|
case "wpa2Radius":
|
||||||
|
opensyncSecurityMode = "WPA-EAP";
|
||||||
|
break;
|
||||||
|
case "wpa3OnlySAE":
|
||||||
|
case "wpa3MixedSAE":
|
||||||
|
opensyncSecurityMode = "WPA-SAE";
|
||||||
|
break;
|
||||||
|
case "wpa3OnlyEAP":
|
||||||
|
case "wpa3MixedEAP":
|
||||||
|
opensyncSecurityMode = "WPA3-EAP";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return opensyncSecurityMode;
|
return opensyncSecurityMode;
|
||||||
}
|
}
|
||||||
@@ -882,16 +740,9 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
LOG.debug("Radius Accounting Profiles {}", opensyncApConfig.getRadiusProfiles());
|
LOG.debug("Radius Accounting Profiles {}", opensyncApConfig.getRadiusProfiles());
|
||||||
|
|
||||||
List<Profile> radiusProfileList = opensyncApConfig.getRadiusProfiles().stream()
|
List<Profile> radiusProfileList = opensyncApConfig.getRadiusProfiles().stream()
|
||||||
.filter(new Predicate<Profile>() {
|
.filter(t -> t.getId() == ssidConfig.getRadiusServiceId()).collect(Collectors.toList());
|
||||||
|
|
||||||
@Override
|
if (radiusProfileList.size() > 0) {
|
||||||
public boolean test(Profile t) {
|
|
||||||
return t.getId() == ssidConfig.getRadiusServiceId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (radiusProfileList != null && radiusProfileList.size() > 0) {
|
|
||||||
Profile profileRadius = radiusProfileList.get(0);
|
Profile profileRadius = radiusProfileList.get(0);
|
||||||
RadiusProfile profileDetails = ((RadiusProfile) profileRadius.getDetails());
|
RadiusProfile profileDetails = ((RadiusProfile) profileRadius.getDetails());
|
||||||
RadiusServer rServer = profileDetails.getPrimaryRadiusAccountingServer();
|
RadiusServer rServer = profileDetails.getPrimaryRadiusAccountingServer();
|
||||||
@@ -907,7 +758,7 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
LOG.info("No radius_acct_interval defined for ssid {}, Setting radius_acct_interval to 0",
|
LOG.info("No radius_acct_interval defined for ssid {}, Setting radius_acct_interval to 0",
|
||||||
ssidConfig.getSsid(), rServer);
|
ssidConfig.getSsid());
|
||||||
security.put("radius_acct_interval", "0");
|
security.put("radius_acct_interval", "0");
|
||||||
}
|
}
|
||||||
LOG.info(
|
LOG.info(
|
||||||
@@ -934,16 +785,9 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
LOG.debug("Radius Profiles {}", opensyncApConfig.getRadiusProfiles());
|
LOG.debug("Radius Profiles {}", opensyncApConfig.getRadiusProfiles());
|
||||||
|
|
||||||
List<Profile> radiusProfileList = opensyncApConfig.getRadiusProfiles().stream()
|
List<Profile> radiusProfileList = opensyncApConfig.getRadiusProfiles().stream()
|
||||||
.filter(new Predicate<Profile>() {
|
.filter(t -> t.getId() == ssidConfig.getRadiusServiceId()).collect(Collectors.toList());
|
||||||
|
|
||||||
@Override
|
if (radiusProfileList.size() > 0) {
|
||||||
public boolean test(Profile t) {
|
|
||||||
return t.getId() == ssidConfig.getRadiusServiceId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
|
|
||||||
if (radiusProfileList != null && radiusProfileList.size() > 0) {
|
|
||||||
Profile profileRadius = radiusProfileList.get(0);
|
Profile profileRadius = radiusProfileList.get(0);
|
||||||
RadiusProfile profileDetails = ((RadiusProfile) profileRadius.getDetails());
|
RadiusProfile profileDetails = ((RadiusProfile) profileRadius.getDetails());
|
||||||
RadiusServer radiusServer = profileDetails.getPrimaryRadiusAuthServer();
|
RadiusServer radiusServer = profileDetails.getPrimaryRadiusAuthServer();
|
||||||
@@ -977,41 +821,51 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
security.put("encryption", opensyncSecurityMode);
|
security.put("encryption", opensyncSecurityMode);
|
||||||
// key and mode is N/A for OPEN security
|
// key and mode is N/A for OPEN security
|
||||||
if (!opensyncSecurityMode.equals("OPEN")) {
|
if (!opensyncSecurityMode.equals("OPEN")) {
|
||||||
if (ssidSecurityMode.equals("wpa2PSK") || ssidSecurityMode.equals("wpa3MixedSAE")) {
|
switch (ssidSecurityMode) {
|
||||||
security.put("key", ssidConfig.getKeyStr());
|
case "wpa2PSK":
|
||||||
security.put("mode", "mixed");
|
case "wpa3MixedSAE":
|
||||||
} else if (ssidSecurityMode.equals("wpa2OnlyPSK")) {
|
security.put("key", ssidConfig.getKeyStr());
|
||||||
security.put("key", ssidConfig.getKeyStr());
|
security.put("mode", "mixed");
|
||||||
security.put("mode", "2");
|
break;
|
||||||
} else if (ssidSecurityMode.equals("wpa3OnlySAE")) {
|
case "wpa2OnlyPSK":
|
||||||
security.put("key", ssidConfig.getKeyStr());
|
security.put("key", ssidConfig.getKeyStr());
|
||||||
security.put("mode", "3");
|
security.put("mode", "2");
|
||||||
} else if (ssidSecurityMode.equals("wpaPSK")) {
|
break;
|
||||||
security.put("key", ssidConfig.getKeyStr());
|
case "wpa3OnlySAE":
|
||||||
security.put("mode", "1");
|
security.put("key", ssidConfig.getKeyStr());
|
||||||
} else if (ssidSecurityMode.equals("wpa2OnlyEAP") || ssidSecurityMode.equals("wpa2OnlyRadius")) {
|
security.put("mode", "3");
|
||||||
security.put("mode", "2");
|
break;
|
||||||
getRadiusConfiguration(opensyncApConfig, ssidConfig, security);
|
case "wpaPSK":
|
||||||
getRadiusAccountingConfiguration(opensyncApConfig, ssidConfig, security);
|
case "wep":
|
||||||
} else if (ssidSecurityMode.equals("wpa3OnlyEAP")) {
|
security.put("key", ssidConfig.getKeyStr());
|
||||||
security.put("mode", "3");
|
security.put("mode", "1");
|
||||||
getRadiusConfiguration(opensyncApConfig, ssidConfig, security);
|
break;
|
||||||
getRadiusAccountingConfiguration(opensyncApConfig, ssidConfig, security);
|
case "wpa2OnlyEAP":
|
||||||
|
case "wpa2OnlyRadius":
|
||||||
|
security.put("mode", "2");
|
||||||
|
getRadiusConfiguration(opensyncApConfig, ssidConfig, security);
|
||||||
|
getRadiusAccountingConfiguration(opensyncApConfig, ssidConfig, security);
|
||||||
|
break;
|
||||||
|
case "wpa3OnlyEAP":
|
||||||
|
security.put("mode", "3");
|
||||||
|
getRadiusConfiguration(opensyncApConfig, ssidConfig, security);
|
||||||
|
getRadiusAccountingConfiguration(opensyncApConfig, ssidConfig, security);
|
||||||
|
|
||||||
} else if (ssidSecurityMode.equals("wpa2EAP") || ssidSecurityMode.equals("wpa2Radius")
|
break;
|
||||||
|| ssidSecurityMode.equals("wpa3MixedEAP")) {
|
case "wpa2EAP":
|
||||||
security.put("mode", "mixed");
|
case "wpa2Radius":
|
||||||
getRadiusConfiguration(opensyncApConfig, ssidConfig, security);
|
case "wpa3MixedEAP":
|
||||||
getRadiusAccountingConfiguration(opensyncApConfig, ssidConfig, security);
|
security.put("mode", "mixed");
|
||||||
|
getRadiusConfiguration(opensyncApConfig, ssidConfig, security);
|
||||||
|
getRadiusAccountingConfiguration(opensyncApConfig, ssidConfig, security);
|
||||||
|
|
||||||
} else if (ssidSecurityMode.equals("wpaEAP") || ssidSecurityMode.equals("wpaRadius")) {
|
break;
|
||||||
security.put("mode", "1");
|
case "wpaEAP":
|
||||||
getRadiusConfiguration(opensyncApConfig, ssidConfig, security);
|
case "wpaRadius":
|
||||||
getRadiusAccountingConfiguration(opensyncApConfig, ssidConfig, security);
|
security.put("mode", "1");
|
||||||
|
getRadiusConfiguration(opensyncApConfig, ssidConfig, security);
|
||||||
} else if (ssidSecurityMode.equals("wep")) {
|
getRadiusAccountingConfiguration(opensyncApConfig, ssidConfig, security);
|
||||||
security.put("key", ssidConfig.getKeyStr());
|
break;
|
||||||
security.put("mode", "1");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1030,7 +884,7 @@ public class OvsdbSsidConfig extends OvsdbDaoBase {
|
|||||||
for (OperationResult res : result) {
|
for (OperationResult res : result) {
|
||||||
LOG.info("Op Result {}", res);
|
LOG.info("Op Result {}", res);
|
||||||
if (res instanceof UpdateResult) {
|
if (res instanceof UpdateResult) {
|
||||||
LOG.info("removeAllSsids:result {}", ((UpdateResult) res).toString());
|
LOG.info("removeAllSsids:result {}", res.toString());
|
||||||
} else if (res instanceof ErrorResult) {
|
} else if (res instanceof ErrorResult) {
|
||||||
LOG.error("removeAllSsids:result error {}", (res));
|
LOG.error("removeAllSsids:result error {}", (res));
|
||||||
throw new RuntimeException("removeAllSsids " + ((ErrorResult) res).getError() + " "
|
throw new RuntimeException("removeAllSsids " + ((ErrorResult) res).getError() + " "
|
||||||
|
|||||||
@@ -133,10 +133,8 @@ public class OpensyncGatewayTipWlanOvsdbClientTest {
|
|||||||
Mockito.verify(ovsdbSession).getOvsdbClient();
|
Mockito.verify(ovsdbSession).getOvsdbClient();
|
||||||
Mockito.verify(opensyncExternalIntegrationInterface).getApConfig("Test_Client_21P10C68818122");
|
Mockito.verify(opensyncExternalIntegrationInterface).getApConfig("Test_Client_21P10C68818122");
|
||||||
Mockito.verify(ovsdbDao).removeAllSsids(ovsdbClient);
|
Mockito.verify(ovsdbDao).removeAllSsids(ovsdbClient);
|
||||||
Mockito.verify(ovsdbDao).removeAllStatsConfigs(ovsdbClient);
|
|
||||||
Mockito.verify(ovsdbDao).configureWifiRadios(ovsdbClient, apConfig);
|
Mockito.verify(ovsdbDao).configureWifiRadios(ovsdbClient, apConfig);
|
||||||
Mockito.verify(ovsdbDao).configureSsids(ovsdbClient, apConfig);
|
Mockito.verify(ovsdbDao).configureSsids(ovsdbClient, apConfig);
|
||||||
Mockito.verify(ovsdbDao).configureStatsFromProfile(ovsdbClient, apConfig);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.telecominfraproject.wlan.opensync.ovsdb.dao;
|
package com.telecominfraproject.wlan.opensync.ovsdb.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -14,30 +16,36 @@ import org.mockito.Mockito;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.telecominfraproject.wlan.core.model.entity.CountryCode;
|
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
|
||||||
import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration;
|
import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration;
|
||||||
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
||||||
|
import com.telecominfraproject.wlan.location.models.Location;
|
||||||
|
import com.telecominfraproject.wlan.location.models.LocationDetails;
|
||||||
|
import com.telecominfraproject.wlan.location.models.LocationType;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
||||||
import com.telecominfraproject.wlan.profile.models.Profile;
|
import com.telecominfraproject.wlan.profile.models.Profile;
|
||||||
|
import com.telecominfraproject.wlan.profile.models.ProfileType;
|
||||||
|
import com.telecominfraproject.wlan.profile.network.models.ApNetworkConfiguration;
|
||||||
import com.telecominfraproject.wlan.profile.rf.models.RfConfiguration;
|
import com.telecominfraproject.wlan.profile.rf.models.RfConfiguration;
|
||||||
|
import com.telecominfraproject.wlan.profile.ssid.models.SsidConfiguration;
|
||||||
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
|
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
|
||||||
import com.vmware.ovsdb.protocol.schema.DatabaseSchema;
|
import com.vmware.ovsdb.protocol.schema.DatabaseSchema;
|
||||||
import com.vmware.ovsdb.protocol.schema.TableSchema;
|
import com.vmware.ovsdb.protocol.schema.TableSchema;
|
||||||
import com.vmware.ovsdb.service.OvsdbClient;
|
import com.vmware.ovsdb.service.OvsdbClient;
|
||||||
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@ActiveProfiles(profiles = { "integration_test", }) // NOTE: these profiles will
|
@ActiveProfiles(profiles = { "integration_test", }) // NOTE: these profiles will
|
||||||
// be ADDED to the list of
|
// be ADDED to the list of
|
||||||
// active profiles
|
// active profiles
|
||||||
@SpringBootTest(webEnvironment = WebEnvironment.NONE, classes = OvsdbRadioConfigTest.class)
|
@SpringBootTest(webEnvironment = WebEnvironment.NONE, classes = OvsdbRadioConfigTest.class)
|
||||||
@Import(value = { OvsdbRadioConfig.class,OvsdbRadioConfigTest.Config.class,
|
@Import(value = { OvsdbRadioConfig.class, OvsdbRadioConfigTest.Config.class, OvsdbGet.class,
|
||||||
|
|
||||||
})
|
})
|
||||||
public class OvsdbRadioConfigTest {
|
public class OvsdbRadioConfigTest {
|
||||||
@@ -45,6 +53,9 @@ public class OvsdbRadioConfigTest {
|
|||||||
@Autowired
|
@Autowired
|
||||||
OvsdbRadioConfig ovsdbRadioConfig;
|
OvsdbRadioConfig ovsdbRadioConfig;
|
||||||
|
|
||||||
|
@MockBean(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
|
OvsdbGet ovsdbGet;
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||||
CompletableFuture<OperationResult[]> selectionFutureResult;
|
CompletableFuture<OperationResult[]> selectionFutureResult;
|
||||||
|
|
||||||
@@ -55,7 +66,7 @@ public class OvsdbRadioConfigTest {
|
|||||||
DatabaseSchema databaseSchema;
|
DatabaseSchema databaseSchema;
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||||
Map<String,TableSchema> tableSchemaMap;
|
Map<String, TableSchema> tableSchemaMap;
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||||
TableSchema tableSchema;
|
TableSchema tableSchema;
|
||||||
@@ -63,6 +74,8 @@ public class OvsdbRadioConfigTest {
|
|||||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||||
OvsdbClient ovsdbClient;
|
OvsdbClient ovsdbClient;
|
||||||
|
|
||||||
|
OpensyncAPConfig opensyncAPConfig;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
// @PropertySource({ "classpath:persistence-${envTarget:dev}.properties" })
|
// @PropertySource({ "classpath:persistence-${envTarget:dev}.properties" })
|
||||||
static class Config {
|
static class Config {
|
||||||
@@ -75,13 +88,57 @@ public class OvsdbRadioConfigTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
Mockito.when(selectionFutureResult.get(Mockito.anyLong(), Mockito.eq(TimeUnit.SECONDS))).thenReturn(new OperationResult[0]);
|
|
||||||
|
Mockito.when(selectionFutureResult.get(Mockito.anyLong(), Mockito.eq(TimeUnit.SECONDS)))
|
||||||
|
.thenReturn(new OperationResult[0]);
|
||||||
Mockito.when(ovsdbClient.transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList()))
|
Mockito.when(ovsdbClient.transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList()))
|
||||||
.thenReturn(selectionFutureResult);
|
.thenReturn(selectionFutureResult);
|
||||||
Mockito.when(tableSchemaMap.get(Mockito.anyString())).thenReturn(tableSchema);
|
Mockito.when(tableSchemaMap.get(Mockito.anyString())).thenReturn(tableSchema);
|
||||||
Mockito.when(databaseSchema.getTables()).thenReturn(tableSchemaMap);
|
Mockito.when(databaseSchema.getTables()).thenReturn(tableSchemaMap);
|
||||||
Mockito.when(getSchemaResult.get()).thenReturn(databaseSchema);
|
Mockito.when(getSchemaResult.get()).thenReturn(databaseSchema);
|
||||||
Mockito.when(ovsdbClient.getSchema(OvsdbDaoBase.ovsdbName)).thenReturn(getSchemaResult);
|
Mockito.when(ovsdbClient.getSchema(OvsdbDaoBase.ovsdbName)).thenReturn(getSchemaResult);
|
||||||
|
|
||||||
|
opensyncAPConfig = new OpensyncAPConfig();
|
||||||
|
|
||||||
|
Equipment ce = new Equipment();
|
||||||
|
ce.setEquipmentType(EquipmentType.AP);
|
||||||
|
ce.setDetails(ApElementConfiguration.createWithDefaults());
|
||||||
|
ce.setProfileId(8);
|
||||||
|
ce.setLocationId(8L);
|
||||||
|
opensyncAPConfig.setCustomerEquipment(ce);
|
||||||
|
|
||||||
|
Location equipmentLocation = new Location();
|
||||||
|
equipmentLocation.setCustomerId(2);
|
||||||
|
equipmentLocation.setId(8);
|
||||||
|
equipmentLocation.setDetails(LocationDetails.createWithDefaults());
|
||||||
|
equipmentLocation.setLocationType(LocationType.COUNTRY);
|
||||||
|
equipmentLocation.setName("location");
|
||||||
|
opensyncAPConfig.setEquipmentLocation(equipmentLocation);
|
||||||
|
|
||||||
|
Profile ssidProfile = new Profile();
|
||||||
|
ssidProfile.setId(2);
|
||||||
|
ssidProfile.setName("ssid-profile");
|
||||||
|
ssidProfile.setProfileType(ProfileType.ssid);
|
||||||
|
ssidProfile.setDetails(SsidConfiguration.createWithDefaults());
|
||||||
|
|
||||||
|
opensyncAPConfig.setSsidProfile(List.of(ssidProfile));
|
||||||
|
|
||||||
|
Profile rfProfile = new Profile();
|
||||||
|
rfProfile.setId(4);
|
||||||
|
rfProfile.setName("rf-profile");
|
||||||
|
rfProfile.setDetails(RfConfiguration.createWithDefaults());
|
||||||
|
rfProfile.setProfileType(ProfileType.rf);
|
||||||
|
opensyncAPConfig.setRfProfile(rfProfile);
|
||||||
|
|
||||||
|
Profile apProfile = new Profile();
|
||||||
|
apProfile.setId(8);
|
||||||
|
apProfile.setCustomerId(2);
|
||||||
|
apProfile.setDetails(ApNetworkConfiguration.createWithDefaults());
|
||||||
|
apProfile.setProfileType(ProfileType.equipment_ap);
|
||||||
|
apProfile.setName("ap-profile");
|
||||||
|
apProfile.setChildProfileIds(Set.of(2L, 4L));
|
||||||
|
opensyncAPConfig.setApProfile(apProfile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
@@ -90,22 +147,7 @@ public class OvsdbRadioConfigTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConfigureWifiRadiosOvsdbClientOpensyncAPConfig() throws Exception {
|
public void testConfigureWifiRadiosOvsdbClientOpensyncAPConfig() throws Exception {
|
||||||
OpensyncAPConfig opensyncAPConfig = constructOpensyncAPConfig();
|
|
||||||
ovsdbRadioConfig.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
ovsdbRadioConfig.configureWifiRadios(ovsdbClient, opensyncAPConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
OpensyncAPConfig constructOpensyncAPConfig() {
|
|
||||||
ApElementConfiguration equipmentDetails = Mockito.mock(ApElementConfiguration.class, Mockito.RETURNS_MOCKS);
|
|
||||||
RfConfiguration rfConfig = Mockito.mock(RfConfiguration.class, Mockito.RETURNS_MOCKS);
|
|
||||||
Profile rfProfile = Mockito.mock(Profile.class, Mockito.RETURNS_MOCKS);
|
|
||||||
Mockito.when(rfProfile.getDetails()).thenReturn(rfConfig);
|
|
||||||
Equipment equipment = Mockito.mock(Equipment.class);
|
|
||||||
Mockito.when(equipment.getDetails()).thenReturn(equipmentDetails);
|
|
||||||
OpensyncAPConfig opensyncAPConfig = Mockito.mock(OpensyncAPConfig.class, Mockito.RETURNS_MOCKS);
|
|
||||||
Mockito.when(opensyncAPConfig.getCountryCode()).thenReturn(CountryCode.CA.getName());
|
|
||||||
Mockito.when(opensyncAPConfig.getCustomerEquipment()).thenReturn(equipment);
|
|
||||||
Mockito.when(opensyncAPConfig.getRfProfile()).thenReturn(rfProfile);
|
|
||||||
return opensyncAPConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user