mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-01 11:07:49 +00:00
OVSDB State Table Changes - add VIFs for Radio State Change, add AssociatedClient for VIF state change, updates to Status for ActiveBSSIDs and ClientDetails
This commit is contained in:
@@ -4,7 +4,6 @@ import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -13,6 +12,8 @@ import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@@ -1574,13 +1575,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
apSsidMetrics.getSsidStats().put(radioType, ssidStatsList);
|
||||
}
|
||||
|
||||
if ((statusDetails != null) && (indexOfBssid >= 0)) {
|
||||
statusDetails.getActiveBSSIDs().get(indexOfBssid).setNumDevicesConnected(numConnectedClients);
|
||||
activeBssidsStatus.setDetails(statusDetails);
|
||||
activeBssidsStatus = statusServiceInterface.update(activeBssidsStatus);
|
||||
LOG.debug("update activeBSSIDs {}", activeBssidsStatus);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LOG.debug("ApSsidMetrics {}", apSsidMetrics);
|
||||
@@ -1796,142 +1790,113 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
Status activeBssidsStatus = statusServiceInterface.getOrNull(customerId, equipmentId,
|
||||
StatusDataType.ACTIVE_BSSIDS);
|
||||
|
||||
if (activeBssidsStatus == null) {
|
||||
activeBssidsStatus = new Status();
|
||||
activeBssidsStatus.setCustomerId(customerId);
|
||||
activeBssidsStatus.setEquipmentId(equipmentId);
|
||||
activeBssidsStatus.setStatusDataType(StatusDataType.ACTIVE_BSSIDS);
|
||||
if (activeBssidsStatus != null) {
|
||||
|
||||
ActiveBSSIDs statusDetails = new ActiveBSSIDs();
|
||||
statusDetails.setActiveBSSIDs(new ArrayList<ActiveBSSID>());
|
||||
ActiveBSSIDs statusDetails = (ActiveBSSIDs) activeBssidsStatus.getDetails();
|
||||
|
||||
activeBssidsStatus.setDetails(statusDetails);
|
||||
for (OpensyncAPVIFState vifState : vifStateTables) {
|
||||
|
||||
LOG.debug("Processing vifState for interface {} on AP {}", vifState.getIfName(), apId);
|
||||
|
||||
String bssid = vifState.getMac();
|
||||
|
||||
if (bssid == null || bssid.equals("")) {
|
||||
LOG.warn("BSSID from AP {} interface {} is null or empty", apId, vifState.getIfName());
|
||||
continue;
|
||||
}
|
||||
String ssid = vifState.getSsid();
|
||||
|
||||
if (ssid == null || ssid.equals("")) {
|
||||
LOG.warn("SSID from AP {} interface {} is null or empty", apId, vifState.getIfName());
|
||||
continue;
|
||||
}
|
||||
|
||||
int numClients = vifState.getAssociatedClients().size();
|
||||
|
||||
LOG.debug("Values from Vif State Mac (BSSID) {} SSID {} AssociatedClients {}", bssid, ssid,
|
||||
vifState.getAssociatedClients());
|
||||
|
||||
List<ActiveBSSID> bssidList = statusDetails.getActiveBSSIDs();
|
||||
for (ActiveBSSID activeBssid : bssidList) {
|
||||
|
||||
LOG.debug("Checking BSSID {} and SSID {} from BssidList against BSSID {} SSID {}",
|
||||
activeBssid.getBssid(), activeBssid.getSsid(), bssid, ssid);
|
||||
if (activeBssid.getBssid().equals(bssid) && activeBssid.getSsid().equals(ssid)) {
|
||||
LOG.debug("Match BSSID {} and SSID {} from BssidList against BSSID {} SSID {}",
|
||||
activeBssid.getBssid(), activeBssid.getSsid(), bssid, ssid);
|
||||
|
||||
int idx = bssidList.indexOf(activeBssid);
|
||||
|
||||
activeBssid.setNumDevicesConnected(numClients);
|
||||
bssidList.set(idx, activeBssid);
|
||||
statusDetails.setActiveBSSIDs(bssidList);
|
||||
activeBssidsStatus.setDetails(statusDetails);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
activeBssidsStatus = statusServiceInterface.update(activeBssidsStatus);
|
||||
|
||||
}
|
||||
ActiveBSSIDs statusDetails = (ActiveBSSIDs) activeBssidsStatus.getDetails();
|
||||
|
||||
for (OpensyncAPVIFState vifState : vifStateTables) {
|
||||
|
||||
LOG.debug("Processing vifState for interface {} on AP {}", vifState.getIfName(), apId);
|
||||
|
||||
String bssid = vifState.getMac();
|
||||
|
||||
if (bssid == null || bssid.equals("")) {
|
||||
LOG.warn("BSSID from AP {} interface {} is null or empty", apId, vifState.getIfName());
|
||||
continue;
|
||||
}
|
||||
String ssid = vifState.getSsid();
|
||||
|
||||
if (ssid == null || ssid.equals("")) {
|
||||
LOG.warn("SSID from AP {} interface {} is null or empty", apId, vifState.getIfName());
|
||||
continue;
|
||||
}
|
||||
int channel = vifState.getChannel();
|
||||
|
||||
if (channel < 1) {
|
||||
LOG.warn("Channel from AP {} interface {} is invalid, {}", apId, vifState.getIfName(), channel);
|
||||
continue;
|
||||
}
|
||||
int numClients = vifState.getAssociatedClients().size();
|
||||
|
||||
LOG.debug("Values from Vif State Mac (BSSID) {} SSID {} Channel {} numAssociatedClients {}", bssid, ssid,
|
||||
channel, numClients);
|
||||
|
||||
RadioType radioType = null;
|
||||
|
||||
ApElementConfiguration apElementConfig = (ApElementConfiguration) apNode.getDetails();
|
||||
for (RadioType key : apElementConfig.getRadioMap().keySet()) {
|
||||
if (apElementConfig.getRadioMap().get(key).getChannelNumber() == channel) {
|
||||
radioType = key;
|
||||
break;
|
||||
}
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("ActiveBSSIDs {}", activeBssidsStatus.toPrettyString());
|
||||
}
|
||||
|
||||
if (radioType == null) {
|
||||
continue; // we cannot determine radioType for this BSSID
|
||||
}
|
||||
|
||||
List<ActiveBSSID> bssidList = statusDetails.getActiveBSSIDs();
|
||||
boolean bssidAlreadyPresent = false;
|
||||
for (ActiveBSSID activeBssid : bssidList) {
|
||||
|
||||
if (activeBssid.getBssid().equals(bssid) && activeBssid.getSsid().equals(ssid)
|
||||
&& activeBssid.getRadioType().equals(radioType)) {
|
||||
|
||||
LOG.debug(
|
||||
"BSSID {} is already present for radio {} on AP {} with SSID {}, update number of associated wifi clients to {}",
|
||||
bssid, radioType, apId, ssid, numClients);
|
||||
activeBssid.setNumDevicesConnected(numClients);
|
||||
bssidAlreadyPresent = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!bssidAlreadyPresent) {
|
||||
LOG.debug(
|
||||
"Adding new active BSSID {} for radio {} on AP {} with SSID {}, with number of associated wifi clients to {}",
|
||||
bssid, radioType, apId, ssid, numClients);
|
||||
|
||||
ActiveBSSID newActiveBssid = new ActiveBSSID();
|
||||
newActiveBssid.setBssid(bssid);
|
||||
newActiveBssid.setSsid(ssid);
|
||||
newActiveBssid.setRadioType(radioType);
|
||||
newActiveBssid.setNumDevicesConnected(vifState.getAssociatedClients().size());
|
||||
bssidList.add(newActiveBssid);
|
||||
}
|
||||
|
||||
statusDetails.setActiveBSSIDs(bssidList);
|
||||
updateClientDetailsStatus(customerId, equipmentId, (ActiveBSSIDs) activeBssidsStatus.getDetails());
|
||||
|
||||
}
|
||||
|
||||
activeBssidsStatus.setDetails(statusDetails);
|
||||
LOG.info("Finished wifiVIFStateDbTableUpdate updated {}", activeBssidsStatus);
|
||||
|
||||
if (!statusDetails.equals((ActiveBSSIDs) statusServiceInterface
|
||||
.getOrNull(customerId, equipmentId, StatusDataType.ACTIVE_BSSIDS).getDetails())) {
|
||||
activeBssidsStatus = statusServiceInterface.update(activeBssidsStatus);
|
||||
LOG.info("Updated activeBSSIDs for AP {} to {}", apId, activeBssidsStatus);
|
||||
}
|
||||
|
||||
// update clients based on all active BSSIDs per Radio Type
|
||||
// only if the BSSIDs have changed
|
||||
Status clientDetailsStatus = statusServiceInterface.getOrNull(customerId, equipmentId,
|
||||
StatusDataType.CLIENT_DETAILS);
|
||||
private void updateClientDetailsStatus(int customerId, long equipmentId, ActiveBSSIDs statusDetails) {
|
||||
Status clientDetailsStatus = statusServiceInterface.getOrNull(customerId, equipmentId,
|
||||
StatusDataType.CLIENT_DETAILS);
|
||||
|
||||
if (clientDetailsStatus == null) {
|
||||
clientDetailsStatus = new Status();
|
||||
clientDetailsStatus.setCustomerId(customerId);
|
||||
clientDetailsStatus.setEquipmentId(equipmentId);
|
||||
clientDetailsStatus.setStatusDataType(StatusDataType.CLIENT_DETAILS);
|
||||
clientDetailsStatus.setDetails(new ClientConnectionDetails());
|
||||
}
|
||||
LOG.debug("Processing updateClientDetailsStatus Status for ActiveBSSIDs {}", statusDetails);
|
||||
|
||||
ClientConnectionDetails clientConnectionDetails = (ClientConnectionDetails) clientDetailsStatus
|
||||
.getDetails();
|
||||
if (clientDetailsStatus == null) {
|
||||
clientDetailsStatus = new Status();
|
||||
clientDetailsStatus.setCustomerId(customerId);
|
||||
clientDetailsStatus.setEquipmentId(equipmentId);
|
||||
clientDetailsStatus.setStatusDataType(StatusDataType.CLIENT_DETAILS);
|
||||
clientDetailsStatus.setDetails(new ClientConnectionDetails());
|
||||
clientDetailsStatus = statusServiceInterface.update(clientDetailsStatus);
|
||||
|
||||
Map<RadioType, Integer> clientsPerRadioType = new EnumMap<>(RadioType.class);
|
||||
|
||||
statusDetails = (ActiveBSSIDs) activeBssidsStatus.getDetails();
|
||||
for (ActiveBSSID bssid : statusDetails.getActiveBSSIDs()) {
|
||||
int numConnectedForBssid = bssid.getNumDevicesConnected();
|
||||
if (clientsPerRadioType.containsKey(bssid.getRadioType())
|
||||
&& clientsPerRadioType.get(bssid.getRadioType()) != null) {
|
||||
numConnectedForBssid += clientsPerRadioType.get(bssid.getRadioType());
|
||||
}
|
||||
Integer numClientsPerRadioType = clientsPerRadioType.put(bssid.getRadioType(), numConnectedForBssid);
|
||||
LOG.debug("Upgrade numClients for RadioType {} to {} on AP {}", bssid.getRadioType(),
|
||||
numClientsPerRadioType, apId);
|
||||
}
|
||||
|
||||
if (!clientConnectionDetails.getNumClientsPerRadio().equals(clientsPerRadioType)) {
|
||||
clientConnectionDetails.setNumClientsPerRadio(clientsPerRadioType);
|
||||
clientDetailsStatus.setDetails(clientConnectionDetails);
|
||||
clientDetailsStatus = statusServiceInterface.update(clientDetailsStatus);
|
||||
LOG.info("Updated clientConnectionDetails for AP {) to {}", apId, clientDetailsStatus);
|
||||
}
|
||||
LOG.debug("Processing updateClientDetailsStatus, new ClientDetailsStatus {}", clientDetailsStatus);
|
||||
}
|
||||
|
||||
ClientConnectionDetails clientConnectionDetails = (ClientConnectionDetails) clientDetailsStatus.getDetails();
|
||||
|
||||
Map<RadioType, Integer> clientsPerRadioType = new HashMap<>();
|
||||
|
||||
for (ActiveBSSID bssid : statusDetails.getActiveBSSIDs()) {
|
||||
|
||||
if (!clientsPerRadioType.containsKey(bssid.getRadioType())) {
|
||||
clientsPerRadioType.put(bssid.getRadioType(), 0);
|
||||
}
|
||||
int numConnectedForBssid = bssid.getNumDevicesConnected();
|
||||
int currentNumberOfClients = clientsPerRadioType.get(bssid.getRadioType());
|
||||
clientsPerRadioType.put(bssid.getRadioType(), currentNumberOfClients + numConnectedForBssid);
|
||||
LOG.debug("Processing updateClientDetailsStatus. Upgrade numClients for RadioType {} from {} to {}",
|
||||
bssid.getRadioType(), currentNumberOfClients, clientsPerRadioType.get(bssid.getRadioType()));
|
||||
}
|
||||
|
||||
clientConnectionDetails.setNumClientsPerRadio(clientsPerRadioType);
|
||||
clientDetailsStatus.setDetails(clientConnectionDetails);
|
||||
clientDetailsStatus = statusServiceInterface.update(clientDetailsStatus);
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Processing updateClientDetailsStatus. Updated clientConnectionDetails to {}",
|
||||
clientDetailsStatus.toPrettyString());
|
||||
}
|
||||
|
||||
LOG.info("Finished updateClientDetailsStatus updated {}", clientDetailsStatus);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1965,6 +1930,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
EquipmentProtocolStatusData protocolStatusData = null;
|
||||
|
||||
for (OpensyncAPRadioState radioState : radioStateTables) {
|
||||
LOG.debug("Processing Wifi_Radio_State table update for AP {} {}", apId, radioState);
|
||||
|
||||
if (radioState.getFreqBand().equals(RadioType.UNSUPPORTED)) {
|
||||
LOG.debug("Could not get radio configuration for AP {}", apId);
|
||||
@@ -2009,12 +1975,74 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
.equals(CountryCode.valueOf(radioState.getCountry().toLowerCase()))) {
|
||||
protocolStatusData.setReportedCC(CountryCode.valueOf(radioState.getCountry().toLowerCase()));
|
||||
protocolStatus.setDetails(protocolStatusData);
|
||||
|
||||
} else {
|
||||
protocolStatus = null; // no change we will ignore at
|
||||
// the end
|
||||
protocolStatus = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Status activeBssidsStatus = statusServiceInterface.getOrNull(customerId, equipmentId,
|
||||
StatusDataType.ACTIVE_BSSIDS);
|
||||
|
||||
if (activeBssidsStatus == null) {
|
||||
activeBssidsStatus = new Status();
|
||||
activeBssidsStatus.setCustomerId(customerId);
|
||||
activeBssidsStatus.setEquipmentId(equipmentId);
|
||||
activeBssidsStatus.setStatusDataType(StatusDataType.ACTIVE_BSSIDS);
|
||||
|
||||
ActiveBSSIDs statusDetails = new ActiveBSSIDs();
|
||||
statusDetails.setActiveBSSIDs(new ArrayList<ActiveBSSID>());
|
||||
|
||||
activeBssidsStatus.setDetails(statusDetails);
|
||||
|
||||
activeBssidsStatus = statusServiceInterface.update(activeBssidsStatus);
|
||||
LOG.debug("Processing Wifi_Radio_State table update for AP {}, created new ACTIVE_BSSID Status {}",
|
||||
apId, activeBssidsStatus);
|
||||
|
||||
}
|
||||
|
||||
ActiveBSSIDs statusDetails = (ActiveBSSIDs) activeBssidsStatus.getDetails();
|
||||
|
||||
LOG.debug("Processing Wifi_Radio_State table update for AP {}, activeBSSIDs StatusDetails before update {}",
|
||||
apId, statusDetails);
|
||||
|
||||
List<ActiveBSSID> currentActiveBSSIDs = statusDetails.getActiveBSSIDs();
|
||||
if (currentActiveBSSIDs == null) {
|
||||
currentActiveBSSIDs = new ArrayList<>();
|
||||
} else {
|
||||
currentActiveBSSIDs = currentActiveBSSIDs.stream().filter(new Predicate<ActiveBSSID>() {
|
||||
@Override
|
||||
public boolean test(ActiveBSSID p) {
|
||||
return !(p.getRadioType().equals(radioState.getFreqBand()));
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
LOG.debug(
|
||||
"Processing Wifi_Radio_State table update for AP {}, activeBSSIDs bssidList without current radio freq {}",
|
||||
apId, currentActiveBSSIDs);
|
||||
}
|
||||
|
||||
for (OpensyncAPVIFState vifState : radioState.getVifStates()) {
|
||||
ActiveBSSID activeBssid = new ActiveBSSID();
|
||||
activeBssid.setBssid(vifState.getMac());
|
||||
activeBssid.setSsid(vifState.getSsid());
|
||||
activeBssid.setNumDevicesConnected(vifState.getAssociatedClients().size());
|
||||
activeBssid.setRadioType(radioState.getFreqBand());
|
||||
currentActiveBSSIDs.add(activeBssid);
|
||||
}
|
||||
|
||||
statusDetails.setActiveBSSIDs(currentActiveBSSIDs);
|
||||
activeBssidsStatus.setDetails(statusDetails);
|
||||
|
||||
activeBssidsStatus = statusServiceInterface.update(activeBssidsStatus);
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Processing Wifi_Radio_State table update for AP {}, updated ACTIVE_BSSID Status {}", apId,
|
||||
activeBssidsStatus.toPrettyString());
|
||||
}
|
||||
|
||||
updateClientDetailsStatus(customerId, equipmentId, (ActiveBSSIDs) activeBssidsStatus.getDetails());
|
||||
|
||||
}
|
||||
|
||||
if (protocolStatus != null) {
|
||||
@@ -2035,7 +2063,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
((ApElementConfiguration) ce.getDetails())
|
||||
.setAdvancedRadioMap(apElementConfiguration.getAdvancedRadioMap());
|
||||
|
||||
apElementConfiguration = (ApElementConfiguration) ce.getDetails();
|
||||
apElementConfiguration = (ApElementConfiguration) ce.getDetails();
|
||||
ce = equipmentServiceInterface.update(ce);
|
||||
}
|
||||
} catch (DsConcurrentModificationException e) {
|
||||
@@ -2044,6 +2072,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
ce.setDetails(apElementConfiguration);
|
||||
ce = equipmentServiceInterface.update(ce);
|
||||
}
|
||||
LOG.info("Finished wifiRadioStateDbTableUpdate");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
*/
|
||||
package com.telecominfraproject.wlan.opensync.external.integration.models;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -46,14 +48,15 @@ public class OpensyncAPRadioState extends BaseJsonModel {
|
||||
public Map<String, String> hwParams;
|
||||
public RadioType freqBand;
|
||||
public int thermalIntegration;
|
||||
|
||||
|
||||
public List<OpensyncAPVIFState> vifStates;
|
||||
|
||||
public OpensyncAPRadioState() {
|
||||
super();
|
||||
allowedChannels = new HashSet<>();
|
||||
hwConfig = new HashMap<>();
|
||||
channels = new HashMap<>();
|
||||
hwParams = new HashMap<>();
|
||||
vifStates = new ArrayList<>();
|
||||
}
|
||||
|
||||
public String channelMode;
|
||||
@@ -100,6 +103,14 @@ public class OpensyncAPRadioState extends BaseJsonModel {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public List<OpensyncAPVIFState> getVifStates() {
|
||||
return vifStates;
|
||||
}
|
||||
|
||||
public void setVifStates(List<OpensyncAPVIFState> vifStates) {
|
||||
this.vifStates = vifStates;
|
||||
}
|
||||
|
||||
public int getBcnInt() {
|
||||
return bcnInt;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.telecominfraproject.wlan.opensync.external.integration.models;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -23,9 +24,7 @@ public class OpensyncAPVIFState extends BaseJsonModel {
|
||||
public String ssid;
|
||||
public Map<String, String> security;
|
||||
public String macList;
|
||||
public Set<Uuid> associatedClients;
|
||||
public Set<String> associatedClientsByMac;
|
||||
|
||||
public List<OpensyncWifiAssociatedClients> associatedClients;
|
||||
|
||||
public boolean enabled;
|
||||
public int vlanId;
|
||||
@@ -50,8 +49,8 @@ public class OpensyncAPVIFState extends BaseJsonModel {
|
||||
public OpensyncAPVIFState() {
|
||||
super();
|
||||
security = new HashMap<>();
|
||||
associatedClients = new HashSet<>();
|
||||
|
||||
associatedClients = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
public void setIfName(String ifName) {
|
||||
@@ -138,11 +137,11 @@ public class OpensyncAPVIFState extends BaseJsonModel {
|
||||
this.macList = macList;
|
||||
}
|
||||
|
||||
public Set<Uuid> getAssociatedClients() {
|
||||
public List<OpensyncWifiAssociatedClients> getAssociatedClients() {
|
||||
return associatedClients;
|
||||
}
|
||||
|
||||
public void setAssociatedClients(Set<Uuid> list) {
|
||||
public void setAssociatedClients(List<OpensyncWifiAssociatedClients> list) {
|
||||
this.associatedClients = list;
|
||||
}
|
||||
|
||||
@@ -269,12 +268,4 @@ public class OpensyncAPVIFState extends BaseJsonModel {
|
||||
public void setVersion(Uuid version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Set<String> getAssociatedClientsByMac() {
|
||||
return associatedClientsByMac;
|
||||
}
|
||||
|
||||
public void setAssociatedClientsByMac(Set<String> associatedClientsByMac) {
|
||||
this.associatedClientsByMac = associatedClientsByMac;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbClientInterface;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.OpensyncExternalIntegrationInterface;
|
||||
@@ -515,16 +516,18 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
@Override
|
||||
public void update(TableUpdates tableUpdates) {
|
||||
LOG.info("Monitor callback received {}", tableUpdates);
|
||||
|
||||
extIntegrationInterface.wifiVIFStateDbTableUpdate(
|
||||
ovsdbDao.getOpensyncAPVIFState(tableUpdates, key, ovsdbClient), key);
|
||||
List<OpensyncAPVIFState> vifStates = ovsdbDao.getOpensyncAPVIFState(tableUpdates, key, ovsdbClient);
|
||||
LOG.info("Calling wifiVIFStateDbTableUpdate for {}, {}", vifStates, key);
|
||||
extIntegrationInterface.wifiVIFStateDbTableUpdate(vifStates, key);
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
extIntegrationInterface.wifiVIFStateDbTableUpdate(ovsdbDao.getOpensyncAPVIFState(vsCf.join(), key, ovsdbClient),
|
||||
key);
|
||||
|
||||
List<OpensyncAPVIFState> vifStates = ovsdbDao.getOpensyncAPVIFState(vsCf.join(), key, ovsdbClient);
|
||||
LOG.info("Calling wifiVIFStateDbTableUpdate init for {}, {}", vifStates, key);
|
||||
extIntegrationInterface.wifiVIFStateDbTableUpdate(vifStates, key);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,8 @@ public class OvsdbDao {
|
||||
}
|
||||
|
||||
Row row = null;
|
||||
if ((result != null) && (result.length > 0) && (result[0] instanceof SelectResult) && !((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
if ((result != null) && (result.length > 0) && (result[0] instanceof SelectResult)
|
||||
&& !((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
row = ((SelectResult) result[0]).getRows().iterator().next();
|
||||
}
|
||||
|
||||
@@ -233,7 +234,8 @@ public class OvsdbDao {
|
||||
}
|
||||
}
|
||||
|
||||
if ((result != null) && (result.length > 0) && (result[0] instanceof SelectResult) && !((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
if ((result != null) && (result.length > 0) && (result[0] instanceof SelectResult)
|
||||
&& !((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
|
||||
for (Row row : ((SelectResult) result[0]).getRows()) {
|
||||
ret.wifiRadioStates.put(getSingleValueFromSet(row, "freq_band"),
|
||||
@@ -271,7 +273,8 @@ public class OvsdbDao {
|
||||
}
|
||||
}
|
||||
|
||||
if ((result != null) && (result.length > 0) && (result[0] instanceof SelectResult) && !((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
if ((result != null) && (result.length > 0) && (result[0] instanceof SelectResult)
|
||||
&& !((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
|
||||
for (Row row : ((SelectResult) result[0]).getRows()) {
|
||||
|
||||
@@ -328,7 +331,8 @@ public class OvsdbDao {
|
||||
}
|
||||
}
|
||||
|
||||
if ((result != null) && (result.length > 0) && (result[0] instanceof SelectResult) && !((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
if ((result != null) && (result.length > 0) && (result[0] instanceof SelectResult)
|
||||
&& !((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
|
||||
for (Row row : ((SelectResult) result[0]).getRows()) {
|
||||
allowedChannels.put(getSingleValueFromSet(row, "freq_band"), row.getSetColumn("allowed_channels"));
|
||||
@@ -661,6 +665,129 @@ public class OvsdbDao {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void getWifiVIFsForRadioByUuid(OvsdbClient ovsdbClient, List<OpensyncAPVIFState> vifList, Uuid uuid) {
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
|
||||
conditions.add(new Condition("_uuid", Function.EQUALS, new Atom<>(uuid)));
|
||||
operations.add(new Select(wifiVifStateDbTable, conditions));
|
||||
|
||||
try {
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
|
||||
if ((result != null) && (result.length > 0) && result[0] instanceof SelectResult
|
||||
&& !((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
|
||||
Row row = ((SelectResult) result[0]).getRows().iterator().next();
|
||||
|
||||
OpensyncAPVIFState tableState = processWifiVIFStateColumn(ovsdbClient, row);
|
||||
|
||||
vifList.add(tableState);
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
LOG.error("Could not get Wifi_VIF_State for UUID {}", uuid, e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private OpensyncAPVIFState processWifiVIFStateColumn(OvsdbClient ovsdbClient, Row row) {
|
||||
OpensyncAPVIFState tableState = new OpensyncAPVIFState();
|
||||
|
||||
Map<String, Value> map = row.getColumns();
|
||||
|
||||
if ((map.get("mac") != null)
|
||||
&& map.get("mac").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setMac(row.getStringColumn("mac"));
|
||||
}
|
||||
if ((map.get("bridge") != null)
|
||||
&& map.get("bridge").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setBridge(row.getStringColumn("bridge"));
|
||||
}
|
||||
if ((map.get("btm") != null)
|
||||
&& map.get("btm").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setBtm(row.getIntegerColumn("btm").intValue());
|
||||
}
|
||||
|
||||
if ((map.get("channel") != null)
|
||||
&& map.get("channel").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setChannel(row.getIntegerColumn("channel").intValue());
|
||||
}
|
||||
|
||||
if ((map.get("enabled") != null)
|
||||
&& map.get("enabled").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setEnabled(row.getBooleanColumn("enabled"));
|
||||
}
|
||||
|
||||
if ((map.get("group_rekey") != null)
|
||||
&& map.get("group_rekey").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setGroupRekey(row.getIntegerColumn("group_rekey").intValue());
|
||||
}
|
||||
if ((map.get("if_name") != null)
|
||||
&& map.get("if_name").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setIfName(row.getStringColumn("if_name"));
|
||||
}
|
||||
|
||||
if ((map.get("mode") != null)
|
||||
&& map.get("mode").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setMode(row.getStringColumn("mode"));
|
||||
}
|
||||
|
||||
if ((map.get("rrm") != null)
|
||||
&& map.get("rrm").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setRrm(row.getIntegerColumn("rrm").intValue());
|
||||
}
|
||||
if ((map.get("ssid") != null)
|
||||
&& map.get("ssid").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setSsid(row.getStringColumn("ssid"));
|
||||
}
|
||||
|
||||
if ((map.get("ssid_broadcast") != null) && map.get("ssid_broadcast").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setSsidBroadcast(row.getStringColumn("ssid_broadcast"));
|
||||
}
|
||||
if ((map.get("uapsd_enable") != null)
|
||||
&& map.get("uapsd_enable").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setUapsdEnable(row.getBooleanColumn("uapsd_enable"));
|
||||
}
|
||||
if ((map.get("vif_radio_idx") != null) && map.get("vif_radio_idx").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVifRadioIdx(row.getIntegerColumn("vif_radio_idx").intValue());
|
||||
}
|
||||
|
||||
Set<Uuid> clients = row.getSetColumn("associated_clients");
|
||||
List<OpensyncWifiAssociatedClients> associatedClientsList = new ArrayList<>();
|
||||
|
||||
if (clients != null) {
|
||||
for (Uuid client : clients) {
|
||||
|
||||
getWifiAssociatedClientByUuid(associatedClientsList, client, ovsdbClient);
|
||||
|
||||
LOG.debug("Associated Client Uuid {} UUID {} ", client.toString(), client.getUuid());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
tableState.setAssociatedClients(associatedClientsList);
|
||||
|
||||
if (map.get("security") != null) {
|
||||
tableState.setSecurity(row.getMapColumn("security"));
|
||||
}
|
||||
|
||||
if ((map.get("_version") != null)
|
||||
&& map.get("_version").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_version"));
|
||||
}
|
||||
if ((map.get("_uuid") != null)
|
||||
&& map.get("_uuid").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_uuid"));
|
||||
}
|
||||
return tableState;
|
||||
}
|
||||
|
||||
public Map<String, InterfaceInfo> getProvisionedInterfaces(OvsdbClient ovsdbClient) {
|
||||
Map<String, InterfaceInfo> ret = new HashMap<>();
|
||||
@@ -1661,6 +1788,16 @@ public class OvsdbDao {
|
||||
tableState.setAllowedChannels(allowed);
|
||||
}
|
||||
|
||||
Set<Uuid> vifStates = row.getSetColumn("vif_states");
|
||||
List<OpensyncAPVIFState> vifStatesList = new ArrayList<>();
|
||||
if (vifStates != null) {
|
||||
for (Uuid uuid : vifStates) {
|
||||
getWifiVIFsForRadioByUuid(ovsdbClient, vifStatesList, uuid);
|
||||
}
|
||||
}
|
||||
|
||||
tableState.setVifStates(vifStatesList);
|
||||
|
||||
ret.add(tableState);
|
||||
}
|
||||
}
|
||||
@@ -1763,99 +1900,20 @@ public class OvsdbDao {
|
||||
for (RowUpdate rowUpdate : tableUpdate.getRowUpdates().values()) {
|
||||
|
||||
Row row = rowUpdate.getNew();
|
||||
// Row old = rowUpdate.getOld();
|
||||
|
||||
|
||||
if (rowUpdate.getOld() != null) {
|
||||
|
||||
LOG.debug("Wifi_VIF_State Columns changed {}", rowUpdate.getOld().getColumns().keySet());
|
||||
}
|
||||
|
||||
if (row != null) {
|
||||
|
||||
OpensyncAPVIFState tableState = new OpensyncAPVIFState();
|
||||
|
||||
Map<String, Value> map = row.getColumns();
|
||||
|
||||
if ((map.get("mac") != null) && map.get("mac").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setMac(row.getStringColumn("mac"));
|
||||
}
|
||||
if ((map.get("bridge") != null) && map.get("bridge").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setBridge(row.getStringColumn("bridge"));
|
||||
}
|
||||
if ((map.get("btm") != null) && map.get("btm").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setBtm(row.getIntegerColumn("btm").intValue());
|
||||
}
|
||||
|
||||
if ((map.get("channel") != null) && map.get("channel").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setChannel(row.getIntegerColumn("channel").intValue());
|
||||
}
|
||||
|
||||
if ((map.get("enabled") != null) && map.get("enabled").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setEnabled(row.getBooleanColumn("enabled"));
|
||||
}
|
||||
|
||||
if ((map.get("group_rekey") != null) && map.get("group_rekey").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setGroupRekey(row.getIntegerColumn("group_rekey").intValue());
|
||||
}
|
||||
if ((map.get("if_name") != null) && map.get("if_name").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setIfName(row.getStringColumn("if_name"));
|
||||
}
|
||||
|
||||
if ((map.get("mode") != null) && map.get("mode").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setMode(row.getStringColumn("mode"));
|
||||
}
|
||||
|
||||
if ((map.get("rrm") != null) && map.get("rrm").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setRrm(row.getIntegerColumn("rrm").intValue());
|
||||
}
|
||||
if ((map.get("ssid") != null) && map.get("ssid").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setSsid(row.getStringColumn("ssid"));
|
||||
}
|
||||
|
||||
if ((map.get("ssid_broadcast") != null) && map.get("ssid_broadcast").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setSsidBroadcast(row.getStringColumn("ssid_broadcast"));
|
||||
}
|
||||
if ((map.get("uapsd_enable") != null) && map.get("uapsd_enable").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setUapsdEnable(row.getBooleanColumn("uapsd_enable"));
|
||||
}
|
||||
if ((map.get("vif_radio_idx") != null) && map.get("vif_radio_idx").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVifRadioIdx(row.getIntegerColumn("vif_radio_idx").intValue());
|
||||
}
|
||||
|
||||
if (map.get("associated_clients") != null) {
|
||||
|
||||
LOG.debug("associated_clients {}", row.getSetColumn("associated_clients"));
|
||||
Set<Uuid> clients = row.getSetColumn("associated_clients");
|
||||
for (Uuid client : clients) {
|
||||
|
||||
LOG.debug("Associated Client Uuid {} UUID {} ", client.toString(), client.getUuid());
|
||||
|
||||
}
|
||||
|
||||
tableState.setAssociatedClients(row.getSetColumn("associated_clients"));
|
||||
}
|
||||
|
||||
if (map.get("security") != null) {
|
||||
tableState.setSecurity(row.getMapColumn("security"));
|
||||
}
|
||||
|
||||
if ((map.get("_version") != null) && map.get("_version").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_version"));
|
||||
}
|
||||
if ((map.get("_uuid") != null) && map.get("_uuid").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_uuid"));
|
||||
}
|
||||
|
||||
OpensyncAPVIFState tableState = processWifiVIFStateColumn(ovsdbClient, row);
|
||||
|
||||
|
||||
LOG.debug("Updated table state {}", tableState.toPrettyString());
|
||||
|
||||
|
||||
ret.add(tableState);
|
||||
|
||||
}
|
||||
@@ -1863,13 +1921,6 @@ public class OvsdbDao {
|
||||
}
|
||||
}
|
||||
|
||||
ret.stream().forEach(new Consumer<OpensyncAPVIFState>() {
|
||||
@Override
|
||||
public void accept(OpensyncAPVIFState wrs) {
|
||||
LOG.debug("Wifi_VIF_State row {}", wrs);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Could not parse update for Wifi_VIF_State", e);
|
||||
|
||||
@@ -1877,6 +1928,55 @@ public class OvsdbDao {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void getWifiAssociatedClientByUuid(List<OpensyncWifiAssociatedClients> associatedClients, Uuid uuid,
|
||||
OvsdbClient ovsdbClient) {
|
||||
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
|
||||
conditions.add(new Condition("_uuid", Function.EQUALS, new Atom<>(uuid)));
|
||||
operations.add(new Select(wifiAssociatedClientsDbTable, conditions));
|
||||
|
||||
try {
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
|
||||
if ((result != null) && (result.length > 0) && result[0] instanceof SelectResult
|
||||
&& !((SelectResult) result[0]).getRows().isEmpty()) {
|
||||
Row row = ((SelectResult) result[0]).getRows().iterator().next();
|
||||
|
||||
OpensyncWifiAssociatedClients tableState = new OpensyncWifiAssociatedClients();
|
||||
Map<String, Value> map = row.getColumns();
|
||||
|
||||
if ((map.get("mac") != null)
|
||||
&& map.get("mac").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setMac(row.getStringColumn("mac"));
|
||||
}
|
||||
if (row.getSetColumn("capabilities") != null) {
|
||||
tableState.setCapabilities(row.getSetColumn("capabilities"));
|
||||
}
|
||||
if ((map.get("state") != null) && map.get("state").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setState(row.getStringColumn("state"));
|
||||
}
|
||||
if ((map.get("_version") != null) && map.get("_version").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_version"));
|
||||
}
|
||||
if ((map.get("_uuid") != null) && map.get("_uuid").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
tableState.setVersion(row.getUuidColumn("_uuid"));
|
||||
}
|
||||
|
||||
associatedClients.add(tableState);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<OpensyncWifiAssociatedClients> getOpensyncWifiAssociatedClients(TableUpdates tableUpdates, String apId,
|
||||
OvsdbClient ovsdbClient) {
|
||||
List<OpensyncWifiAssociatedClients> ret = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user