Merge branch 'master' of github.com:Telecominfraproject/wlan-cloud-opensync-controller

# Conflicts:
#	opensync-ext-cloud/src/main/java/com/telecominfraproject/wlan/opensync/external/integration/OpensyncExternalIntegrationCloud.java
This commit is contained in:
Dmitry Toptygin
2020-06-29 11:58:53 -04:00
5 changed files with 140 additions and 69 deletions

View File

@@ -93,6 +93,7 @@ import com.telecominfraproject.wlan.status.equipment.report.models.ActiveBSSID;
import com.telecominfraproject.wlan.status.equipment.report.models.ActiveBSSIDs;
import com.telecominfraproject.wlan.status.equipment.report.models.EquipmentCapacityDetails;
import com.telecominfraproject.wlan.status.equipment.report.models.EquipmentPerRadioUtilizationDetails;
import com.telecominfraproject.wlan.status.equipment.report.models.OperatingSystemPerformance;
import com.telecominfraproject.wlan.status.equipment.report.models.RadioUtilizationReport;
import com.telecominfraproject.wlan.status.models.Status;
import com.telecominfraproject.wlan.status.models.StatusCode;
@@ -165,8 +166,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
private int autoProvisionedLocationId;
@Value("${connectus.ovsdb.autoProvisionedProfileId:1}")
private int autoProvisionedProfileId;
@Value("${connectus.ovsdb.autoProvisionedSsid:autoProvisionedSsid}")
@Value("${connectus.ovsdb.autoProvisionedSsid:DefaultSsid-}")
private String autoProvisionedSsid;
@Value("${connectus.ovsdb.autoprovisionedSsidKey:12345678}")
private String autoprovisionedSsidKey;
@Value("${connectus.ovsdb.isAutoconfigEnabled:true}")
private boolean isAutoconfigEnabled;
@Value("${connectus.ovsdb.defaultFwVersion:r10947-65030d81f3}")
@@ -256,9 +259,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ce.setEquipmentType(EquipmentType.AP);
ce.setInventoryId(apId);
try {
ce.setBaseMacAddress(new MacAddress(connectNodeInfo.macAddress));
}catch(RuntimeException e) {
LOG.warn("Auto-provisioning: cannot parse equipment mac address {}", connectNodeInfo.macAddress);
ce.setBaseMacAddress(new MacAddress(connectNodeInfo.macAddress));
} catch (RuntimeException e) {
LOG.warn("Auto-provisioning: cannot parse equipment mac address {}",
connectNodeInfo.macAddress);
}
Customer customer = customerServiceInterface.getOrNull(autoProvisionedCustomerId);
@@ -312,7 +316,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
if (!radioType.equals(RadioType.UNSUPPORTED)) {
advancedRadioConfiguration = RadioConfiguration.createWithDefaults(radioType);
advancedRadioConfiguration.setAutoChannelSelection(StateSetting.disabled);
advancedRadioMap.put(radioType, advancedRadioConfiguration);
radioConfiguration = ElementRadioConfiguration.createWithDefaults(radioType);
radioConfiguration.setAutoChannelSelection(false);
@@ -339,7 +343,6 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
}
if(profileId == null) {
//create default apProfile if cannot find applicable one:
Profile apProfile = createDefaultApProfile(ce, connectNodeInfo);
@@ -350,30 +353,34 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
ce = equipmentServiceInterface.create(ce);
//update the cache right away, no need to wait until the entry expires
// update the cache right away, no need to wait until the
// entry expires
cloudEquipmentRecordCache.put(ce.getInventoryId(), ce);
} else {
//equipment already exists
MacAddress reportedMacAddress = null;
// equipment already exists
MacAddress reportedMacAddress = null;
try {
reportedMacAddress = new MacAddress(connectNodeInfo.macAddress);
}catch(RuntimeException e) {
LOG.warn("AP connect: cannot parse equipment mac address {}", connectNodeInfo.macAddress);
reportedMacAddress = new MacAddress(connectNodeInfo.macAddress);
} catch (RuntimeException e) {
LOG.warn("AP connect: cannot parse equipment mac address {}", connectNodeInfo.macAddress);
}
if(reportedMacAddress != null) {
//check if reported mac address matches what is in the db
if(!reportedMacAddress.equals(ce.getBaseMacAddress())) {
//need to update base mac address on equipment in DB
ce = equipmentServiceInterface.get(ce.getId());
ce.setBaseMacAddress(reportedMacAddress);
ce = equipmentServiceInterface.update(ce);
//update the cache right away, no need to wait until the entry expires
if (reportedMacAddress != null) {
// check if reported mac address matches what is in the
// db
if (!reportedMacAddress.equals(ce.getBaseMacAddress())) {
// need to update base mac address on equipment in
// DB
ce = equipmentServiceInterface.get(ce.getId());
ce.setBaseMacAddress(reportedMacAddress);
ce = equipmentServiceInterface.update(ce);
// update the cache right away, no need to wait
// until the entry expires
cloudEquipmentRecordCache.put(ce.getInventoryId(), ce);
}
}
}
}
@@ -434,10 +441,15 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
for (RadioType radioType : radioTypes) {
Profile ssidProfile = new Profile();
ssidProfile.setCustomerId(ce.getCustomerId());
ssidProfile.setName("DefaultSsid-" + radioType.name()+ " for " + ce.getName() );
ssidProfile.setName(autoProvisionedSsid + radioType.name()+ " for " + ce.getName() );
SsidConfiguration ssidConfig = SsidConfiguration.createWithDefaults();
ssidConfig.setSecureMode(SecureMode.open);
ssidConfig.setSsid(ssidProfile.getName());
ssidConfig.setSsidAdminState(StateSetting.enabled);
ssidConfig.setBroadcastSsid(StateSetting.enabled);
ssidConfig.setSecureMode(SecureMode.wpa2PSK);
ssidConfig.setKeyStr(autoprovisionedSsidKey);
Set<RadioType> appliedRadios = new HashSet<>();
appliedRadios.add(radioType);
ssidConfig.setAppliedRadios(appliedRadios);
@@ -478,7 +490,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
statusRecord.setCustomerId(ce.getCustomerId());
statusRecord.setEquipmentId(ce.getId());
EquipmentLANStatusData statusData = new EquipmentLANStatusData();
EquipmentLANStatusData statusData = new EquipmentLANStatusData();
statusRecord.setDetails(statusData);
}
@@ -812,6 +824,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
for (Device deviceReport : report.getDeviceList()) {
int avgRadioTemp = 0;
ApPerformance apPerformance = new ApPerformance();
apNodeMetrics.setApPerformance(apPerformance);
@@ -820,7 +834,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
// data.setChannelUtilization5G(channelUtilization5G);
if (deviceReport.getRadioTempCount() > 0) {
int cpuTemperature = 0;
float cpuTemperature = 0;
int numSamples = 0;
for (RadioTemp r : deviceReport.getRadioTempList()) {
if (r.hasValue()) {
@@ -830,7 +844,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
if (numSamples > 0) {
apPerformance.setCpuTemperature(cpuTemperature / numSamples);
avgRadioTemp = Math.round((cpuTemperature / numSamples));
apPerformance.setCpuTemperature(avgRadioTemp);
}
}
@@ -847,8 +862,13 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
deviceReport.getMemUtil().getMemTotal() - deviceReport.getMemUtil().getMemUsed());
}
apPerformance.setUpTime((long) deviceReport.getUptime());
updateDeviceStatusForReport(customerId, equipmentId, deviceReport, avgRadioTemp);
}
// statusList.add(status);
// Main Network dashboard shows Traffic and Capacity values that
// are calculated from
// ApNodeMetric properties getPeriodLengthSec, getRxBytes2G,
@@ -866,17 +886,19 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
Set<String> clientMacs = new HashSet<>();
for (Client cl : clReport.getClientListList()) {
if(!cl.hasConnected() || cl.getConnected() != true) {
//this client is not currently connected, skip it
//TODO: how come AP reports disconencted clients? What if it is a busy coffe shop with thousands of peopele per day, when do clients disappear from the reports?
continue;
}
if(cl.hasMacAddress()) {
clientMacs.add(cl.getMacAddress());
}
if (!cl.hasConnected() || cl.getConnected() != true) {
// this client is not currently connected, skip it
// TODO: how come AP reports disconencted clients? What
// if it is a busy coffe shop with thousands of peopele
// per day, when do clients disappear from the reports?
continue;
}
if (cl.hasMacAddress()) {
clientMacs.add(cl.getMacAddress());
}
if (cl.getStats().hasTxBytes()) {
txBytes += cl.getStats().getTxBytes();
}
@@ -890,16 +912,16 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
apNodeMetrics.setRxBytes(radioType, rxBytes);
apNodeMetrics.setTxBytes(radioType, txBytes);
List<MacAddress> clientMacList = new ArrayList<>();
clientMacs.forEach(macStr -> {
try {
clientMacList.add(new MacAddress(macStr));
} catch(RuntimeException e) {
LOG.warn("Cannot parse mac address from MQTT ClientReport {} ", macStr);
}
});
List<MacAddress> clientMacList = new ArrayList<>();
clientMacs.forEach(macStr -> {
try {
clientMacList.add(new MacAddress(macStr));
} catch (RuntimeException e) {
LOG.warn("Cannot parse mac address from MQTT ClientReport {} ", macStr);
}
});
apNodeMetrics.setClientMacAddresses(radioType, clientMacList);
// TODO: temporary solution as this was causing Noise Floor to
@@ -990,6 +1012,39 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
}
private void updateDeviceStatusForReport(int customerId, long equipmentId, Device deviceReport, int avgRadioTemp) {
Status status = new Status();
status.setCustomerId(customerId);
status.setEquipmentId(equipmentId);
OperatingSystemPerformance eqOsPerformance = new OperatingSystemPerformance();
eqOsPerformance.setUptimeInSeconds(deviceReport.getUptime());
eqOsPerformance.setAvgCpuTemperature(avgRadioTemp);
eqOsPerformance.setAvgCpuUtilization(deviceReport.getCpuUtil().getCpuUtil());
eqOsPerformance
.setAvgFreeMemoryKb(deviceReport.getMemUtil().getMemTotal() - deviceReport.getMemUtil().getMemUsed());
eqOsPerformance.setTotalAvailableMemoryKb(deviceReport.getMemUtil().getMemTotal());
status.setDetails(eqOsPerformance);
status = statusServiceInterface.update(status);
LOG.debug("updated status {}", status);
Status networkAggStatusRec = statusServiceInterface.getOrNull(customerId, equipmentId,
StatusDataType.NETWORK_AGGREGATE);
NetworkAggregateStatusData naStatusData = (NetworkAggregateStatusData) networkAggStatusRec.getDetails();
EquipmentPerformanceDetails equipmentPerformanceDetails = new EquipmentPerformanceDetails();
equipmentPerformanceDetails.setAvgCpuTemperature((int) eqOsPerformance.getAvgCpuTemperature());
equipmentPerformanceDetails.setAvgFreeMemory(eqOsPerformance.getAvgFreeMemoryKb());
naStatusData.setApPerformanceDetails(
equipmentPerformanceDetails.combineWith(naStatusData.getApPerformanceDetails()));
networkAggStatusRec.setDetails(naStatusData);
networkAggStatusRec = statusServiceInterface.update(networkAggStatusRec);
LOG.debug("updated aggregate status {}", networkAggStatusRec);
}
private void populateApClientMetrics(List<ServiceMetric> metricRecordList, Report report, int customerId,
long equipmentId) {
LOG.debug("populateApClientMetrics for Customer {} Equipment {}", customerId, equipmentId);
@@ -1300,14 +1355,17 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
Status activeBssidsStatus = statusServiceInterface.getOrNull(customerId, equipmentId,
StatusDataType.ACTIVE_BSSIDS);
ActiveBSSIDs statusDetails = null;
int indexOfBssid = -1;
if (activeBssidsStatus != null) {
ActiveBSSIDs statusDetails = (ActiveBSSIDs) activeBssidsStatus.getDetails();
statusDetails = (ActiveBSSIDs) activeBssidsStatus.getDetails();
for (ActiveBSSID activeBSSID : statusDetails.getActiveBSSIDs()) {
if (activeBSSID.getRadioType().equals(radioType)) {
ssidStatistics.setBssid(new MacAddress(activeBSSID.getBssid()));
// ssid value, in case not in stats, else will take
// stats value after
ssid = activeBSSID.getSsid();
indexOfBssid = statusDetails.getActiveBSSIDs().indexOf(activeBSSID);
}
}
}
@@ -1383,6 +1441,13 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
apSsidMetrics.getSsidStats().put(radioType, ssidStatsList);
}
if (statusDetails != null && indexOfBssid >= 0) {
statusDetails.getActiveBSSIDs().get(indexOfBssid).setNumDevicesConnected(ssidStatistics.getNumClient());
activeBssidsStatus.setDetails(statusDetails);
activeBssidsStatus = statusServiceInterface.update(activeBssidsStatus);
LOG.debug("update activeBSSIDs {}", activeBssidsStatus);
}
}
LOG.debug("ApSsidMetrics {}", apSsidMetrics);

View File

@@ -60,15 +60,19 @@ then
fi
DEFAULT_BRIDGE="${DEFAULT_BRIDGE:=br-lan}"
DEFAULT_WAN="${DEFAULT_WAN:=eth}"
DEFAULT_LAN="${DEFAULT_LAN:=br-lan}"
DEFAULT_WAN_TYPE="${DEFAULT_WAN_TYPE:=eth}"
DEFAULT_LAN_TYPE="${DEFAULT_LAN_TYPE:=bridge}"
DEFAULT_LAN_NAME="${DEFAULT_LAN_NAME:=lan}"
AUTO_PROV_CUSTOMER_ID="${AUTO_PROV_CUSTOMER_ID:=2}"
PROV_PROPS=" "
PROV_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_bridge=$DEFAULT_BRIDGE"
PROV_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_wan=$DEFAULT_WAN"
PROV_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_lan=$DEFAULT_LAN"
PROV_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_wan_type=$DEFAULT_WAN_TYPE"
PROV_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_lan_type=$DEFAULT_LAN_TYPE"
PROV_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_lan_name=$DEFAULT_LAN_NAME"
PROV_PROPS+=" -Dconnectus.ovsdb.autoProvisionedCustomerId=$AUTO_PROV_CUSTOMER_ID"
export ALL_PROPS="$PROFILES $SSL_PROPS $CLIENT_MQTT_SSL_PROPS $OVSDB_PROPS $MQTT_PROPS $LOGGING_PROPS $RESTAPI_PROPS $SPRING_EXTRA_PROPS $HOST_PROPS $PROV_PROPS"

View File

@@ -51,10 +51,11 @@ OVSDB_DEVICE_RADIO_1="${OVSDB_DEVICE_RADIO_1:=wifi0}"
echo $OVSDB_DEVICE_RADIO_1
OVSDB_DEVICE_RADIO_2="${OVSDB_DEVICE_RADIO_2:=wifi1}"
echo $OVSDB_DEVICE_RADIO_2
OVSDB_DEVICE_DEFAULT_WAN="${OVSDB_DEVICE_DEFAULT_WAN:=eth}"
OVSDB_DEVICE_DEFAULT_WAN_TYPE="${OVSDB_DEVICE_DEFAULT_WAN_NAME:=eth}"
echo $OVSDB_DEVICE_DEFAULT_WAN
OVSDB_DEVICE_DEFAULT_LAN="${OVSDB_DEVICE_DEFAULT_LAN:=br-lan}"
OVSDB_DEVICE_DEFAULT_LAN_TYPE="${OVSDB_DEVICE_DEFAULT_LAN_TYPE:=br-lan}"
echo $OVSDB_DEVICE_DEFAULT_LAN
OVSDB_DEVICE_DEFAULT_LAN_NAME="${OVSDB_DEVICE_DEFAULT_LAN_NAME:=lan}"
echo Reading AP configuration from $OVSDB_CONFIG_FILE
@@ -133,8 +134,9 @@ OVSDB_PROPS="$OVSDB_PROPS -Dconnectus.ovsdb.ssidProfileFileName=$OVSDB_SSIDPROFI
OVSDB_PROPS="$OVSDB_PROPS -Dconnectus.ovsdb.radiusProfileFileName=$OVSDB_RADIUSPROFILE_CONFIG_FILE"
OVSDB_PROPS="$OVSDB_PROPS -Dconnectus.ovsdb.locationFileName=$OVSDB_LOCATION_CONFIG_FILE"
OVSDB_PROPS="$OVSDB_PROPS -Dconnectus.ovsdb.wifi-iface.default_bridge=$OVSDB_IF_DEFAULT_BRIDGE"
OVSDB_PROPS="$OVSDB_PROPS -Dconnectus.ovsdb.wifi-iface.default_wan=$OVSDB_DEVICE_DEFAULT_WAN"
OVSDB_PROPS="$OVSDB_PROPS -Dconnectus.ovsdb.wifi-iface.default_lan=$OVSDB_DEVICE_DEFAULT_LAN"
OVSDB_PROPS="$OVSDB_PROPS -Dconnectus.ovsdb.wifi-iface.default_wan_type=$OVSDB_DEVICE_DEFAULT_WAN_TYPE"
OVSDB_PROPS="$OVSDB_PROPS -Dconnectus.ovsdb.wifi-iface.default_lan_type=$OVSDB_DEVICE_DEFAULT_LAN_TYPE"
OVSDB_PROPS="$OVSDB_PROPS -Dconnectus.ovsdb.wifi-iface.default_lan_name=$OVSDB_DEVICE_DEFAULT_LAN_NAME"
OVSDB_PROPS="$OVSDB_PROPS -Dconnectus.ovsdb.wifi-iface.default_radio0=$OVSDB_IF_DEFAULT_RADIO_0"
OVSDB_PROPS="$OVSDB_PROPS -Dconnectus.ovsdb.wifi-iface.default_radio1=$OVSDB_IF_DEFAULT_RADIO_1"
OVSDB_PROPS="$OVSDB_PROPS -Dconnectus.ovsdb.wifi-iface.default_radio2=$OVSDB_IF_DEFAULT_RADIO_2"

View File

@@ -25,8 +25,9 @@ OVSDB_PROPS+=" -Dconnectus.ovsdb.ssidProfileFileName=$OVSDB_SSIDPROFILE_CONFIG_F
OVSDB_PROPS+=" -Dconnectus.ovsdb.radiusProfileFileName=$OVSDB_RADIUSPROFILE_CONFIG_FILE"
OVSDB_PROPS+=" -Dconnectus.ovsdb.locationFileName=$OVSDB_LOCATION_CONFIG_FILE"
OVSDB_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_bridge=$OVSDB_IF_DEFAULT_BRIDGE"
OVSDB_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_wan=$OVSDB_DEVICE_DEFAULT_WAN"
OVSDB_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_lan=$OVSDB_DEVICE_DEFAULT_LAN"
OVSDB_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_wan_type=$OVSDB_DEVICE_DEFAULT_WAN_TYPE"
OVSDB_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_lan_type=$OVSDB_DEVICE_DEFAULT_LAN_TYPE"
OVSDB_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_lan_name=$OVSDB_DEVICE_DEFAULT_LAN_NAME"
OVSDB_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_radio0=$OVSDB_IF_DEFAULT_RADIO_0"
OVSDB_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_radio1=$OVSDB_IF_DEFAULT_RADIO_1"
OVSDB_PROPS+=" -Dconnectus.ovsdb.wifi-iface.default_radio2=$OVSDB_IF_DEFAULT_RADIO_2"

View File

@@ -94,10 +94,13 @@ public class OvsdbDao {
@org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_bridge:defaultBridgeForEAPOL}")
public String bridgeNameVifInterfaces;
@org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_lan:bridge}")
@org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_lan_type:bridge}")
public String defaultLanInterfaceType;
@org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_lan_name:lan}")
public String defaultLanInterfaceName;
@org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_wan:eth}")
@org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_wan_type:eth}")
public String defaultWanInterfaceType;
@org.springframework.beans.factory.annotation.Value("${connectus.ovsdb.wifi-iface.default_radio1:home-ap-24}")
@@ -2200,11 +2203,7 @@ public class OvsdbDao {
List<RadioType> enabledRadiosFromAp = new ArrayList<>();
getEnabledRadios(ovsdbClient, enabledRadiosFromAp);
ConnectNodeInfo connectNodeInfo = getConnectNodeInfo(ovsdbClient);
LOG.info("connectNodeInfo = {}", connectNodeInfo.toString());
for (Profile ssidProfile : opensyncApConfig.getSsidProfile()) {
SsidConfiguration ssidConfig = (SsidConfiguration) ssidProfile.getDetails();
@@ -2338,7 +2337,7 @@ public class OvsdbDao {
if (!getProvisionedWifiVifConfigs(ovsdbClient).containsKey(ifName + "_" + ssidConfig.getSsid())) {
try {
configureSingleSsid(ovsdbClient, connectNodeInfo.lanIfName, ifName, ssidConfig.getSsid(),
configureSingleSsid(ovsdbClient, defaultLanInterfaceName, ifName, ssidConfig.getSsid(),
ssidBroadcast, security, freqBand, ssidConfig.getVlanId(), rrmEnabled, enable80211r,
minHwMode, enabled, keyRefresh, uapsdEnabled, apBridge, ssidConfig.getForwardMode(),
gateway, inet, dns, ipAssignScheme);