mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-01 11:07:49 +00:00
WIFI-1848: Gateway: Support new AWLAN_Node columns for manufacturing identity data
WIFI-1849: Gateway: Update status with additional manufacturing data
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,4 @@
|
||||
|
||||
package com.telecominfraproject.wlan.opensync.external.integration.models;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -26,6 +27,13 @@ public class ConnectNodeInfo implements Cloneable {
|
||||
public String lanIfName;
|
||||
public String lanIfType;
|
||||
public String lanMacAddress;
|
||||
public String referenceDesign;
|
||||
public Map<String, String> qrCode;
|
||||
public String modelDescription;
|
||||
public String manufacturerUrl;
|
||||
public String manufacturerName;
|
||||
public String manufacturerDate;
|
||||
public String certificationRegion;
|
||||
|
||||
@Override
|
||||
public ConnectNodeInfo clone() {
|
||||
@@ -40,6 +48,9 @@ public class ConnectNodeInfo implements Cloneable {
|
||||
if (this.versionMatrix != null) {
|
||||
ret.versionMatrix = new HashMap<>(this.versionMatrix);
|
||||
}
|
||||
if (this.qrCode != null) {
|
||||
ret.qrCode = new HashMap<>(this.qrCode);
|
||||
}
|
||||
return ret;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new IllegalStateException("Cannot clone ", e);
|
||||
@@ -47,44 +58,45 @@ public class ConnectNodeInfo implements Cloneable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ConnectNodeInfo)) {
|
||||
return false;
|
||||
}
|
||||
ConnectNodeInfo other = (ConnectNodeInfo) obj;
|
||||
return Objects.equals(country, other.country) && Objects.equals(firmwareVersion, other.firmwareVersion)
|
||||
&& Objects.equals(ifName, other.ifName) && Objects.equals(ifType, other.ifType)
|
||||
&& Objects.equals(ipV4Address, other.ipV4Address) && Objects.equals(lanIfName, other.lanIfName)
|
||||
&& Objects.equals(lanIfType, other.lanIfType) && Objects.equals(lanIpV4Address, other.lanIpV4Address)
|
||||
&& Objects.equals(lanMacAddress, other.lanMacAddress) && Objects.equals(macAddress, other.macAddress)
|
||||
&& Objects.equals(managerAddr, other.managerAddr) && Objects.equals(model, other.model)
|
||||
&& Objects.equals(mqttSettings, other.mqttSettings)
|
||||
&& Objects.equals(platformVersion, other.platformVersion)
|
||||
&& Objects.equals(redirectorAddr, other.redirectorAddr) && Objects.equals(revision, other.revision)
|
||||
&& Objects.equals(serialNumber, other.serialNumber) && Objects.equals(skuNumber, other.skuNumber)
|
||||
&& Objects.equals(versionMatrix, other.versionMatrix)
|
||||
&& Objects.equals(wifiRadioStates, other.wifiRadioStates);
|
||||
public int hashCode() {
|
||||
return Objects.hash(certificationRegion, country, firmwareVersion, ifName, ifType, ipV4Address, lanIfName, lanIfType, lanIpV4Address, lanMacAddress,
|
||||
macAddress, managerAddr, manufacturerDate, manufacturerName, manufacturerUrl, model, modelDescription, mqttSettings, platformVersion, qrCode,
|
||||
redirectorAddr, referenceDesign, revision, serialNumber, skuNumber, versionMatrix, wifiRadioStates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(country, firmwareVersion, ifName, ifType, ipV4Address, lanIfName, lanIfType, lanIpV4Address,
|
||||
lanMacAddress, macAddress, managerAddr, model, mqttSettings, platformVersion, redirectorAddr, revision,
|
||||
serialNumber, skuNumber, versionMatrix, wifiRadioStates);
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ConnectNodeInfo other = (ConnectNodeInfo) obj;
|
||||
return Objects.equals(certificationRegion, other.certificationRegion) && Objects.equals(country, other.country)
|
||||
&& Objects.equals(firmwareVersion, other.firmwareVersion) && Objects.equals(ifName, other.ifName) && Objects.equals(ifType, other.ifType)
|
||||
&& Objects.equals(ipV4Address, other.ipV4Address) && Objects.equals(lanIfName, other.lanIfName) && Objects.equals(lanIfType, other.lanIfType)
|
||||
&& Objects.equals(lanIpV4Address, other.lanIpV4Address) && Objects.equals(lanMacAddress, other.lanMacAddress)
|
||||
&& Objects.equals(macAddress, other.macAddress) && Objects.equals(managerAddr, other.managerAddr)
|
||||
&& Objects.equals(manufacturerDate, other.manufacturerDate) && Objects.equals(manufacturerName, other.manufacturerName)
|
||||
&& Objects.equals(manufacturerUrl, other.manufacturerUrl) && Objects.equals(model, other.model)
|
||||
&& Objects.equals(modelDescription, other.modelDescription) && Objects.equals(mqttSettings, other.mqttSettings)
|
||||
&& Objects.equals(platformVersion, other.platformVersion) && Objects.equals(qrCode, other.qrCode)
|
||||
&& Objects.equals(redirectorAddr, other.redirectorAddr) && Objects.equals(referenceDesign, other.referenceDesign)
|
||||
&& Objects.equals(revision, other.revision) && Objects.equals(serialNumber, other.serialNumber) && Objects.equals(skuNumber, other.skuNumber)
|
||||
&& Objects.equals(versionMatrix, other.versionMatrix) && Objects.equals(wifiRadioStates, other.wifiRadioStates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConnectNodeInfo [mqttSettings=" + mqttSettings + ", versionMatrix=" + versionMatrix
|
||||
+ ", wifiRadioStates=" + wifiRadioStates + ", redirectorAddr=" + redirectorAddr + ", managerAddr="
|
||||
+ managerAddr + ", skuNumber=" + skuNumber + ", serialNumber=" + serialNumber + ", macAddress="
|
||||
+ macAddress + ", ipV4Address=" + ipV4Address + ", platformVersion=" + platformVersion
|
||||
+ ", firmwareVersion=" + firmwareVersion + ", revision=" + revision + ", model=" + model + ", ifName="
|
||||
+ ifName + ", ifType=" + ifType + ", country=" + country + ", lanIpV4Address=" + lanIpV4Address
|
||||
+ ", lanIfName=" + lanIfName + ", lanIfType=" + lanIfType + ", lanMacAddress=" + lanMacAddress + "]";
|
||||
return "ConnectNodeInfo [mqttSettings=" + mqttSettings + ", versionMatrix=" + versionMatrix + ", wifiRadioStates=" + wifiRadioStates
|
||||
+ ", redirectorAddr=" + redirectorAddr + ", managerAddr=" + managerAddr + ", skuNumber=" + skuNumber + ", serialNumber=" + serialNumber
|
||||
+ ", macAddress=" + macAddress + ", ipV4Address=" + ipV4Address + ", platformVersion=" + platformVersion + ", firmwareVersion="
|
||||
+ firmwareVersion + ", revision=" + revision + ", model=" + model + ", ifName=" + ifName + ", ifType=" + ifType + ", country=" + country
|
||||
+ ", lanIpV4Address=" + lanIpV4Address + ", lanIfName=" + lanIfName + ", lanIfType=" + lanIfType + ", lanMacAddress=" + lanMacAddress
|
||||
+ ", referenceDesign=" + referenceDesign + ", qrCode=" + qrCode + ", modelDescription=" + modelDescription + ", manufacturerUrl="
|
||||
+ manufacturerUrl + ", manufacturerName=" + manufacturerName + ", manufacturerDate=" + manufacturerDate + ", certificationRegion="
|
||||
+ certificationRegion + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
package com.telecominfraproject.wlan.opensync.external.integration.models;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -45,6 +46,14 @@ public class OpensyncAWLANNode extends OpensyncAPBase {
|
||||
public String revision;
|
||||
public String managerAddr;
|
||||
public boolean factoryReset;
|
||||
public String referenceDesign;
|
||||
public Map<String, String> qrCode;
|
||||
public String modelDescription;
|
||||
public String manufacturerUrl;
|
||||
public String manufacturerName;
|
||||
public String manufacturerDate;
|
||||
public String certificationRegion;
|
||||
|
||||
public Uuid _uuid;
|
||||
|
||||
public Uuid version;
|
||||
@@ -60,7 +69,6 @@ public class OpensyncAWLANNode extends OpensyncAPBase {
|
||||
public OpensyncAWLANNode(Row row) {
|
||||
this();
|
||||
Map<String, Value> map = row.getColumns();
|
||||
|
||||
if (map.get("mqtt_settings") != null) {
|
||||
this.setMqttSettings(row.getMapColumn("mqtt_settings"));
|
||||
}
|
||||
@@ -70,93 +78,89 @@ public class OpensyncAWLANNode extends OpensyncAPBase {
|
||||
if (map.get("mqtt_topics") != null) {
|
||||
this.setMqttHeaders(row.getMapColumn("mqtt_topics"));
|
||||
}
|
||||
|
||||
if ((map.get("model") != null)
|
||||
&& map.get("model").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("model") != null) && map.get("model").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setModel(row.getStringColumn("model"));
|
||||
}
|
||||
if ((map.get("sku_number") != null)
|
||||
&& map.get("sku_number").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("sku_number") != null) && map.get("sku_number").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setSkuNumber(row.getStringColumn("sku_number"));
|
||||
}
|
||||
if ((map.get("id") != null)
|
||||
&& map.get("id").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setId(row.getStringColumn("id"));
|
||||
if (map.get("id") != null) {
|
||||
this.setId(getSingleValueFromSet(row, "id"));
|
||||
}
|
||||
if (map.get("reference_design") != null) {
|
||||
this.setReferenceDesign(getSingleValueFromSet(row, "reference_design"));
|
||||
}
|
||||
if (map.get("qr_code") != null) {
|
||||
this.setQrCode(row.getMapColumn("qr_code"));
|
||||
}
|
||||
if ((map.get("model_description") != null)) {
|
||||
this.setModelDescription(getSingleValueFromSet(row, "model_description"));
|
||||
}
|
||||
if ((map.get("manufacturer_url") != null)) {
|
||||
this.setManufacturerUrl(getSingleValueFromSet(row, "manufacturer_url"));
|
||||
}
|
||||
if ((map.get("manufacturer_name") != null)) {
|
||||
this.setManufacturerName(getSingleValueFromSet(row, "manufacturer_name"));
|
||||
}
|
||||
if ((map.get("manufacturer_date") != null)) {
|
||||
this.setManufacturerDate(getSingleValueFromSet(row, "manufacturer_date"));
|
||||
}
|
||||
if (map.get("certification_region") != null) {
|
||||
this.setCertificationRegion(getSingleValueFromSet(row, "certification_region"));
|
||||
}
|
||||
|
||||
if (map.get("version_matrix") != null) {
|
||||
this.setVersionMatrix(row.getMapColumn("version_matrix"));
|
||||
}
|
||||
if ((map.get("firmware_version") != null) && map.get("firmware_version").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("firmware_version") != null) && map.get("firmware_version").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setFirmwareVersion(row.getStringColumn("firmware_version"));
|
||||
}
|
||||
if ((map.get("firmware_url") != null)
|
||||
&& map.get("firmware_url").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("firmware_url") != null) && map.get("firmware_url").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setFirmwareUrl(row.getStringColumn("firmware_url"));
|
||||
}
|
||||
|
||||
if ((map.get("_uuid") != null)
|
||||
&& map.get("_uuid").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("_uuid") != null) && map.get("_uuid").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setVersion(row.getUuidColumn("_uuid"));
|
||||
}
|
||||
if ((map.get("upgrade_dl_timer") != null) && map.get("upgrade_dl_timer").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("upgrade_dl_timer") != null) && map.get("upgrade_dl_timer").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setUpgradeDlTimer(row.getIntegerColumn("upgrade_dl_timer").intValue());
|
||||
}
|
||||
if ((map.get("platform_version") != null) && map.get("platform_version").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("platform_version") != null) && map.get("platform_version").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setPlatformVersion(row.getStringColumn("platform_version"));
|
||||
}
|
||||
if ((map.get("firmware_pass") != null) && map.get("firmware_pass").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("firmware_pass") != null) && map.get("firmware_pass").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setFirmwarePass(row.getStringColumn("firmware_pass"));
|
||||
}
|
||||
if ((map.get("upgrade_timer") != null) && map.get("upgrade_timer").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("upgrade_timer") != null) && map.get("upgrade_timer").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setUpgradeTimer(row.getIntegerColumn("upgrade_timer").intValue());
|
||||
}
|
||||
if ((map.get("max_backoff") != null)
|
||||
&& map.get("max_backoff").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("max_backoff") != null) && map.get("max_backoff").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setMaxBackoff(row.getIntegerColumn("max_backoff").intValue());
|
||||
}
|
||||
if (map.get("led_config") != null) {
|
||||
this.setLedConfig(row.getMapColumn("led_config"));
|
||||
}
|
||||
if ((map.get("redirector_addr") != null) && map.get("redirector_addr").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("redirector_addr") != null) && map.get("redirector_addr").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setRedirectorAddr(row.getStringColumn("redirector_addr"));
|
||||
}
|
||||
if ((map.get("serial_number") != null) && map.get("serial_number").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("serial_number") != null) && map.get("serial_number").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setSerialNumber(row.getStringColumn("serial_number"));
|
||||
}
|
||||
if ((map.get("_version") != null)
|
||||
&& map.get("_version").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("_version") != null) && map.get("_version").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setVersion(row.getUuidColumn("_version"));
|
||||
}
|
||||
|
||||
this.setUpgradeStatus(row.getIntegerColumn("upgrade_status").intValue());
|
||||
|
||||
if ((map.get("device_mode") != null)
|
||||
&& map.get("device_mode").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("device_mode") != null) && map.get("device_mode").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setDeviceMode(row.getStringColumn("device_mode"));
|
||||
}
|
||||
if ((map.get("min_backoff") != null)
|
||||
&& map.get("min_backoff").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("min_backoff") != null) && map.get("min_backoff").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setMinBackoff(row.getIntegerColumn("min_backoff").intValue());
|
||||
}
|
||||
|
||||
if ((map.get("revision") != null)
|
||||
&& map.get("revision").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("revision") != null) && map.get("revision").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setRevision(row.getStringColumn("revision"));
|
||||
}
|
||||
if ((map.get("manager_addr") != null)
|
||||
&& map.get("manager_addr").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("manager_addr") != null) && map.get("manager_addr").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setManagerAddr(row.getStringColumn("manager_addr"));
|
||||
}
|
||||
if ((map.get("factory_reset") != null) && map.get("factory_reset").getClass()
|
||||
.equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
if ((map.get("factory_reset") != null) && map.get("factory_reset").getClass().equals(com.vmware.ovsdb.protocol.operation.notation.Atom.class)) {
|
||||
this.setFactoryReset(row.getBooleanColumn("factory_reset"));
|
||||
}
|
||||
}
|
||||
@@ -261,6 +265,62 @@ public class OpensyncAWLANNode extends OpensyncAPBase {
|
||||
return factoryReset;
|
||||
}
|
||||
|
||||
public String getReferenceDesign() {
|
||||
return referenceDesign;
|
||||
}
|
||||
|
||||
public void setReferenceDesign(String referenceDesign) {
|
||||
this.referenceDesign = referenceDesign;
|
||||
}
|
||||
|
||||
public Map<String, String> getQrCode() {
|
||||
return qrCode;
|
||||
}
|
||||
|
||||
public void setQrCode(Map<String, String> qrCode) {
|
||||
this.qrCode = qrCode;
|
||||
}
|
||||
|
||||
public String getModelDescription() {
|
||||
return modelDescription;
|
||||
}
|
||||
|
||||
public void setModelDescription(String modelDescription) {
|
||||
this.modelDescription = modelDescription;
|
||||
}
|
||||
|
||||
public String getManufacturerUrl() {
|
||||
return manufacturerUrl;
|
||||
}
|
||||
|
||||
public void setManufacturerUrl(String manufacturerUrl) {
|
||||
this.manufacturerUrl = manufacturerUrl;
|
||||
}
|
||||
|
||||
public String getManufacturerName() {
|
||||
return manufacturerName;
|
||||
}
|
||||
|
||||
public void setManufacturerName(String manufacturerName) {
|
||||
this.manufacturerName = manufacturerName;
|
||||
}
|
||||
|
||||
public String getManufacturerDate() {
|
||||
return manufacturerDate;
|
||||
}
|
||||
|
||||
public void setManufacturerDate(String manufacturerDate) {
|
||||
this.manufacturerDate = manufacturerDate;
|
||||
}
|
||||
|
||||
public String getCertificationRegion() {
|
||||
return certificationRegion;
|
||||
}
|
||||
|
||||
public void setCertificationRegion(String certificationRegion) {
|
||||
this.certificationRegion = certificationRegion;
|
||||
}
|
||||
|
||||
public void set_uuid(Uuid _uuid) {
|
||||
this._uuid = _uuid;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
|
||||
package com.telecominfraproject.wlan.opensync.ovsdb.dao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -25,6 +27,7 @@ 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.schema.DatabaseSchema;
|
||||
import com.vmware.ovsdb.service.OvsdbClient;
|
||||
|
||||
@Component
|
||||
@@ -85,8 +88,7 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
}
|
||||
|
||||
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();
|
||||
connectNodeInfo.lanIpV4Address = getSingleValueFromSet(row, "inet_addr");
|
||||
connectNodeInfo.lanIfName = row.getStringColumn("if_name");
|
||||
@@ -103,8 +105,7 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
|
||||
}
|
||||
|
||||
void fillInWanIpAddressAndMac(OvsdbClient ovsdbClient, ConnectNodeInfo connectNodeInfo, String ifType,
|
||||
String ifName) {
|
||||
void fillInWanIpAddressAndMac(OvsdbClient ovsdbClient, ConnectNodeInfo connectNodeInfo, String ifType, String ifName) {
|
||||
try {
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
@@ -132,8 +133,7 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
}
|
||||
|
||||
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();
|
||||
connectNodeInfo.ipV4Address = getSingleValueFromSet(row, "inet_addr");
|
||||
connectNodeInfo.ifName = row.getStringColumn("if_name");
|
||||
@@ -166,6 +166,15 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
columns.add("platform_version");
|
||||
columns.add("revision");
|
||||
columns.add("version_matrix");
|
||||
columns.add("id");
|
||||
|
||||
DatabaseSchema dbSchema = ovsdbClient.getSchema(ovsdbName).get();
|
||||
Set<String> keys = dbSchema.getTables().get(awlanNodeDbTable).getColumns().keySet();
|
||||
if (keys.containsAll(Set.of("reference_design", "qr_code", "model_description", "manufacturer_url", "manufacturer_name", "manufacturer_date",
|
||||
"certification_region"))) {
|
||||
columns.addAll(Set.of("reference_design", "qr_code", "model_description", "manufacturer_url", "manufacturer_name", "manufacturer_date",
|
||||
"certification_region"));
|
||||
}
|
||||
|
||||
operations.add(new Select(awlanNodeDbTable, conditions, columns));
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
@@ -180,8 +189,7 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -199,6 +207,17 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
ret.serialNumber = getSingleValueFromSet(row, "serial_number");
|
||||
ret.model = getSingleValueFromSet(row, "model");
|
||||
|
||||
if (keys.containsAll(Set.of("reference_design", "qr_code", "model_description", "manufacturer_url", "manufacturer_name", "manufacturer_date",
|
||||
"certification_region"))) {
|
||||
ret.referenceDesign = getSingleValueFromSet(row, "reference_design");
|
||||
ret.qrCode = row.getMapColumn("qr_code");
|
||||
ret.modelDescription = getSingleValueFromSet(row, "model_description");
|
||||
ret.manufacturerUrl = getSingleValueFromSet(row, "manufacturer_url");
|
||||
ret.manufacturerName = getSingleValueFromSet(row, "manufacturer_name");
|
||||
ret.manufacturerDate = getSingleValueFromSet(row, "manufacturer_date");
|
||||
ret.certificationRegion = getSingleValueFromSet(row, "certification_region");
|
||||
}
|
||||
|
||||
// now populate macAddress, ipV4Address from Wifi_Inet_State
|
||||
// first look them up for if_name = br-wan
|
||||
fillInWanIpAddressAndMac(ovsdbClient, ret, defaultWanInterfaceType, defaultWanInterfaceName);
|
||||
@@ -207,8 +226,7 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
fillInWanIpAddressAndMac(ovsdbClient, ret, defaultLanInterfaceType, defaultLanInterfaceName);
|
||||
|
||||
if (ret.ipV4Address == null) {
|
||||
throw new RuntimeException(
|
||||
"Could not get inet address for Lan and Wan network interfaces. Node is not ready to connect.");
|
||||
throw new RuntimeException("Could not get inet address for Lan and Wan network interfaces. Node is not ready to connect.");
|
||||
}
|
||||
}
|
||||
fillInLanIpAddressAndMac(ovsdbClient, ret, defaultLanInterfaceType);
|
||||
@@ -262,8 +280,8 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
serialNumber = getSingleValueFromSet(row, "serial_number");
|
||||
model = getSingleValueFromSet(row, "model");
|
||||
|
||||
LOG.info("Redirecting AP Node: clientCn {} serialNumber {} model {} firmwareVersion {} skuNumber {}",
|
||||
clientCn, serialNumber, model, firmwareVersion, skuNumber);
|
||||
LOG.info("Redirecting AP Node: clientCn {} serialNumber {} model {} firmwareVersion {} skuNumber {}", clientCn, serialNumber, model,
|
||||
firmwareVersion, skuNumber);
|
||||
|
||||
// Update table AWLAN_Node - set manager_addr
|
||||
operations.clear();
|
||||
@@ -293,8 +311,7 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
|
||||
void rebootOrResetAp(OvsdbClient ovsdbClient, String desiredApAction) {
|
||||
try {
|
||||
LOG.debug("rebootOrResetAp on AP perform {}, setting timer for {} seconds.", desiredApAction,
|
||||
rebootOrResetTimerSeconds);
|
||||
LOG.debug("rebootOrResetAp on AP perform {}, setting timer for {} seconds.", desiredApAction, rebootOrResetTimerSeconds);
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Map<String, Value> updateColumns = new HashMap<>();
|
||||
updateColumns.put("firmware_url", new Atom<>(desiredApAction));
|
||||
@@ -315,8 +332,8 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
|
||||
}
|
||||
|
||||
ConnectNodeInfo updateConnectNodeInfoOnConnect(OvsdbClient ovsdbClient, String clientCn,
|
||||
ConnectNodeInfo incomingConnectNodeInfo, boolean preventCnAlteration) {
|
||||
ConnectNodeInfo updateConnectNodeInfoOnConnect(OvsdbClient ovsdbClient, String clientCn, ConnectNodeInfo incomingConnectNodeInfo,
|
||||
boolean preventCnAlteration) {
|
||||
ConnectNodeInfo ret = incomingConnectNodeInfo.clone();
|
||||
|
||||
try {
|
||||
@@ -337,8 +354,7 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
// mqtt_settings:ins:'["map",[["broker","testportal.123wlan.com"],["topics","/ap/dev-ap-0300/opensync"],["qos","0"],["port","1883"],["remote_log","1"]]]'
|
||||
Map<String, String> newMqttSettings = new HashMap<>();
|
||||
newMqttSettings.put("broker", mqttBrokerAddress);
|
||||
String mqttClientName = OvsdbToWlanCloudTypeMappingUtility.getAlteredClientCnIfRequired(clientCn,
|
||||
incomingConnectNodeInfo, preventCnAlteration);
|
||||
String mqttClientName = OvsdbToWlanCloudTypeMappingUtility.getAlteredClientCnIfRequired(clientCn, incomingConnectNodeInfo, preventCnAlteration);
|
||||
newMqttSettings.put("topics", "/ap/" + mqttClientName + "/opensync");
|
||||
newMqttSettings.put("port", "" + mqttBrokerExternalPort);
|
||||
newMqttSettings.put("compress", "zlib");
|
||||
@@ -347,8 +363,8 @@ public class OvsdbNode extends OvsdbDaoBase {
|
||||
|
||||
if ((ret.mqttSettings == null) || !ret.mqttSettings.equals(newMqttSettings)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
com.vmware.ovsdb.protocol.operation.notation.Map<String, String> mgttSettings = com.vmware.ovsdb.protocol.operation.notation.Map
|
||||
.of(newMqttSettings);
|
||||
com.vmware.ovsdb.protocol.operation.notation.Map<String, String> mgttSettings =
|
||||
com.vmware.ovsdb.protocol.operation.notation.Map.of(newMqttSettings);
|
||||
ret.mqttSettings = newMqttSettings;
|
||||
updateColumns.put("mqtt_settings", mgttSettings);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
package com.telecominfraproject.wlan.opensync.ovsdb.dao;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -60,16 +61,16 @@ import com.vmware.ovsdb.protocol.schema.TableSchema;
|
||||
import com.vmware.ovsdb.service.OvsdbClient;
|
||||
|
||||
@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
|
||||
// active profiles
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.NONE, classes = OvsdbDaoTest.class)
|
||||
@Import(value = { OvsdbDao.class, OvsdbDaoTest.Config.class, OvsdbNode.class, OvsdbRadioConfig.class,
|
||||
OvsdbHotspotConfig.class, OvsdbCommandConfig.class, OvsdbMonitor.class, OvsdbFirmwareConfig.class,
|
||||
OvsdbStatsConfig.class, OvsdbSsidConfig.class, OvsdbRrmConfig.class, OvsdbNetworkConfig.class,
|
||||
OvsdbNodeConfig.class,OvsdbRadiusProxyConfig.class
|
||||
@Import(
|
||||
value = {OvsdbDao.class, OvsdbDaoTest.Config.class, OvsdbNode.class, OvsdbRadioConfig.class, OvsdbHotspotConfig.class, OvsdbCommandConfig.class,
|
||||
OvsdbMonitor.class, OvsdbFirmwareConfig.class, OvsdbStatsConfig.class, OvsdbSsidConfig.class, OvsdbRrmConfig.class, OvsdbNetworkConfig.class,
|
||||
OvsdbNodeConfig.class, OvsdbRadiusProxyConfig.class
|
||||
|
||||
})
|
||||
})
|
||||
public class OvsdbDaoTest {
|
||||
|
||||
static final int DEFAULT_CUSTOMER_ID = 1;
|
||||
@@ -178,9 +179,8 @@ public class OvsdbDaoTest {
|
||||
@Test
|
||||
public void testConfigureGreTunnels() throws Exception {
|
||||
List<Row> rows = new ArrayList<>();
|
||||
OperationResult[] operationResult = new OperationResult[] { new SelectResult(rows) };
|
||||
Mockito.when(ovsdbClient.transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList()))
|
||||
.thenReturn(selectionFutureResult);
|
||||
OperationResult[] operationResult = new OperationResult[] {new SelectResult(rows)};
|
||||
Mockito.when(ovsdbClient.transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList())).thenReturn(selectionFutureResult);
|
||||
Mockito.when(selectionFutureResult.get(30, TimeUnit.SECONDS)).thenReturn(operationResult);
|
||||
Profile apProfile = new Profile();
|
||||
apProfile.setCustomerId(2);
|
||||
@@ -251,25 +251,21 @@ public class OvsdbDaoTest {
|
||||
passpointVenueProfile.setId(VENUE_ID);
|
||||
Profile hotspot20IdProviderProfile = new Profile();
|
||||
hotspot20IdProviderProfile.setId(HOTSPOT_PROVIDER_ID_1);
|
||||
hotspot20IdProviderProfile = OvsdbDaoTestUtilities.createPasspointIdProviderProfile(DEFAULT_CUSTOMER_ID,
|
||||
hotspot20IdProviderProfile, "TipWlan-Hotspot20-OSU-Provider", "Rogers AT&T Wireless", "Canada", "ca",
|
||||
302, 720, "rogers.com", 1);
|
||||
hotspot20IdProviderProfile = OvsdbDaoTestUtilities.createPasspointIdProviderProfile(DEFAULT_CUSTOMER_ID, hotspot20IdProviderProfile,
|
||||
"TipWlan-Hotspot20-OSU-Provider", "Rogers AT&T Wireless", "Canada", "ca", 302, 720, "rogers.com", 1);
|
||||
Profile hotspot20IdProviderProfile2 = new Profile();
|
||||
hotspot20IdProviderProfile2.setId(HOTSPOT_PROVIDER_ID_2);
|
||||
hotspot20IdProviderProfile2 = OvsdbDaoTestUtilities.createPasspointIdProviderProfile(DEFAULT_CUSTOMER_ID,
|
||||
hotspot20IdProviderProfile2, "TipWlan-Hotspot20-OSU-Provider-2", "Telus Mobility", "Canada", "ca", 302,
|
||||
220, "telus.com", 1);
|
||||
hotspot20IdProviderProfile2 = OvsdbDaoTestUtilities.createPasspointIdProviderProfile(DEFAULT_CUSTOMER_ID, hotspot20IdProviderProfile2,
|
||||
"TipWlan-Hotspot20-OSU-Provider-2", "Telus Mobility", "Canada", "ca", 302, 220, "telus.com", 1);
|
||||
|
||||
profileSsidOsu.getChildProfileIds().add(hotspot20IdProviderProfile.getId());
|
||||
profileSsidOsu.getChildProfileIds().add(hotspot20IdProviderProfile2.getId());
|
||||
|
||||
Profile passpointHotspotConfig = OvsdbDaoTestUtilities.createPasspointHotspotConfig(DEFAULT_CUSTOMER_ID,
|
||||
hotspot20IdProviderProfile2, hotspot20IdProviderProfile, passpointOperatorProfile,
|
||||
passpointVenueProfile, profileSsidPsk, profileSsidOsu);
|
||||
Profile passpointHotspotConfig = OvsdbDaoTestUtilities.createPasspointHotspotConfig(DEFAULT_CUSTOMER_ID, hotspot20IdProviderProfile2,
|
||||
hotspot20IdProviderProfile, passpointOperatorProfile, passpointVenueProfile, profileSsidPsk, profileSsidOsu);
|
||||
passpointHotspotConfig.setId(HOTSPOT_CONFIG_ID);
|
||||
|
||||
Profile hotspotProfileAp = OvsdbDaoTestUtilities.createPasspointApProfile(DEFAULT_CUSTOMER_ID, profileSsidPsk,
|
||||
profileSsidOsu);
|
||||
Profile hotspotProfileAp = OvsdbDaoTestUtilities.createPasspointApProfile(DEFAULT_CUSTOMER_ID, profileSsidPsk, profileSsidOsu);
|
||||
hotspotProfileAp.setId(EQUIPMENT_AP_ID);
|
||||
|
||||
hsConfig.setHotspot20OperatorSet(Set.of(passpointOperatorProfile));
|
||||
@@ -283,14 +279,12 @@ public class OvsdbDaoTest {
|
||||
|
||||
apConfig.setSsidProfile(List.of(profileSsidOsu, profileSsidPsk));
|
||||
|
||||
Mockito.when(futureResult.get(Mockito.anyLong(), Mockito.eq(TimeUnit.SECONDS)))
|
||||
.thenReturn(OvsdbDaoTestUtilities.hs20IconRows()).thenReturn(OvsdbDaoTestUtilities.hs20InsertIconRows())
|
||||
.thenReturn(OvsdbDaoTestUtilities.hs20OsuProviders()).thenReturn(OvsdbDaoTestUtilities.hs20IconRows())
|
||||
.thenReturn(OvsdbDaoTestUtilities.hs20IconRows())
|
||||
.thenReturn(OvsdbDaoTestUtilities.hs20InsertProviderRows())
|
||||
.thenReturn(OvsdbDaoTestUtilities.hs20Config()).thenReturn(OvsdbDaoTestUtilities.hs20OsuProviders())
|
||||
.thenReturn(OvsdbDaoTestUtilities.vifConfigRows()).thenReturn(OvsdbDaoTestUtilities.vifConfigRows())
|
||||
.thenReturn(OvsdbDaoTestUtilities.hs20Config());
|
||||
Mockito.when(futureResult.get(Mockito.anyLong(), Mockito.eq(TimeUnit.SECONDS))).thenReturn(OvsdbDaoTestUtilities.hs20IconRows())
|
||||
.thenReturn(OvsdbDaoTestUtilities.hs20InsertIconRows()).thenReturn(OvsdbDaoTestUtilities.hs20OsuProviders())
|
||||
.thenReturn(OvsdbDaoTestUtilities.hs20IconRows()).thenReturn(OvsdbDaoTestUtilities.hs20IconRows())
|
||||
.thenReturn(OvsdbDaoTestUtilities.hs20InsertProviderRows()).thenReturn(OvsdbDaoTestUtilities.hs20Config())
|
||||
.thenReturn(OvsdbDaoTestUtilities.hs20OsuProviders()).thenReturn(OvsdbDaoTestUtilities.vifConfigRows())
|
||||
.thenReturn(OvsdbDaoTestUtilities.vifConfigRows()).thenReturn(OvsdbDaoTestUtilities.hs20Config());
|
||||
|
||||
Mockito.when(ovsdbClient.transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList())).thenReturn(futureResult);
|
||||
|
||||
@@ -352,275 +346,12 @@ public class OvsdbDaoTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConnectNodeInfo() throws Exception {
|
||||
|
||||
Mockito.when(ovsdbClient.transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList())).thenReturn(futureResult);
|
||||
|
||||
java.util.Map<String, Value> awlanColumns = new HashMap<>();
|
||||
awlanColumns.put("mqtt_settings", com.vmware.ovsdb.protocol.operation.notation.Map
|
||||
.of(ImmutableMap.of("broker", "192.168.1.101", "port", "1883")));
|
||||
awlanColumns.put("redirector_addr", Atom.string(REDIRECT_ADDR));
|
||||
awlanColumns.put("manager_addr", Atom.string(MGR_ADDR));
|
||||
awlanColumns.put("platform_version", Atom.string(PLATFORM_VERSION));
|
||||
awlanColumns.put("firmware_version", Atom.string(FW_VERSION));
|
||||
awlanColumns.put("revision", Atom.string(REVISION));
|
||||
awlanColumns.put("sku_number", Atom.string(SKU_NUMBER));
|
||||
awlanColumns.put("serial_number", Atom.string(SERIAL_NUM));
|
||||
awlanColumns.put("model", Atom.string(MODEL));
|
||||
Row awlanRow = new Row(awlanColumns);
|
||||
|
||||
List<Row> awlanRows = ImmutableList.of(awlanRow);
|
||||
|
||||
OperationResult[] awlanResult = new OperationResult[] { new SelectResult(awlanRows) };
|
||||
|
||||
java.util.Map<String, Value> inetWanColumns = new HashMap<>();
|
||||
inetWanColumns.put("inet_addr", Atom.string(WAN_IP));
|
||||
inetWanColumns.put("hwaddr", Atom.string(WAN_MAC));
|
||||
inetWanColumns.put("if_name", Atom.string(WAN_IF_NAME));
|
||||
inetWanColumns.put("if_type", Atom.string(WAN_IF_TYPE));
|
||||
|
||||
Row inetWanRow = new Row(inetWanColumns);
|
||||
|
||||
List<Row> inetWanRows = ImmutableList.of(inetWanRow);
|
||||
|
||||
OperationResult[] inetWanResult = new OperationResult[] { new SelectResult(inetWanRows) };
|
||||
|
||||
java.util.Map<String, Value> inetLanColumns = new HashMap<>();
|
||||
inetLanColumns.put("inet_addr", Atom.string(LAN_IP));
|
||||
inetLanColumns.put("hwaddr", Atom.string(LAN_MAC));
|
||||
inetLanColumns.put("if_name", Atom.string(LAN_IF_NAME));
|
||||
inetLanColumns.put("if_type", Atom.string(LAN_IF_TYPE));
|
||||
|
||||
Row inetLanRow = new Row(inetLanColumns);
|
||||
|
||||
List<Row> inetLanRows = ImmutableList.of(inetLanRow);
|
||||
|
||||
OperationResult[] inetLanResult = new OperationResult[] { new SelectResult(inetLanRows) };
|
||||
|
||||
java.util.Map<String, Value> wifiRadioStateColumns = new HashMap<>();
|
||||
wifiRadioStateColumns.put("freq_band", Atom.string("2.4G"));
|
||||
wifiRadioStateColumns.put("if_name", Atom.string("home-ap-24"));
|
||||
Row wifiRadioStateRow = new Row(wifiRadioStateColumns);
|
||||
|
||||
java.util.Map<String, Value> wifiRadioStateColumns2 = new HashMap<>();
|
||||
wifiRadioStateColumns2.put("freq_band", Atom.string("5GL"));
|
||||
wifiRadioStateColumns2.put("if_name", Atom.string("home-ap-l50"));
|
||||
Row wifiRadioStateRow2 = new Row(wifiRadioStateColumns2);
|
||||
|
||||
java.util.Map<String, Value> wifiRadioStateColumns3 = new HashMap<>();
|
||||
wifiRadioStateColumns3.put("freq_band", Atom.string("5GU"));
|
||||
wifiRadioStateColumns3.put("if_name", Atom.string("home-ap-u50"));
|
||||
Row wifiRadioStateRow3 = new Row(wifiRadioStateColumns3);
|
||||
|
||||
List<Row> wifiRadioStateRows = ImmutableList.of(wifiRadioStateRow, wifiRadioStateRow2, wifiRadioStateRow3);
|
||||
|
||||
OperationResult[] wifiRadioStateResult = new OperationResult[] { new SelectResult(wifiRadioStateRows) };
|
||||
|
||||
Mockito.when(futureResult.get(Mockito.anyLong(), Mockito.eq(TimeUnit.SECONDS))).thenReturn(awlanResult)
|
||||
.thenReturn(inetWanResult).thenReturn(inetLanResult).thenReturn(wifiRadioStateResult);
|
||||
|
||||
ConnectNodeInfo connectNodeInfo = ovsdbDao.getConnectNodeInfo(ovsdbClient);
|
||||
|
||||
assertNotNull(connectNodeInfo);
|
||||
assert (connectNodeInfo.wifiRadioStates.entrySet().size() == 3);
|
||||
assert (connectNodeInfo.firmwareVersion.equals(FW_VERSION));
|
||||
assert (connectNodeInfo.redirectorAddr.equals(REDIRECT_ADDR));
|
||||
assert (connectNodeInfo.ipV4Address.equals(WAN_IP));
|
||||
|
||||
assert (connectNodeInfo.lanIfName.equals(LAN_IF_NAME));
|
||||
assert (connectNodeInfo.ifName.equals(WAN_IF_NAME));
|
||||
|
||||
Mockito.verify(ovsdbClient, Mockito.times(4)).transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList());
|
||||
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testFailGetConnectNodeInfo() throws Exception {
|
||||
|
||||
Mockito.when(ovsdbClient.transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList())).thenReturn(futureResult);
|
||||
|
||||
java.util.Map<String, Value> awlanColumns = new HashMap<>();
|
||||
awlanColumns.put("mqtt_settings", com.vmware.ovsdb.protocol.operation.notation.Map
|
||||
.of(ImmutableMap.of("broker", "192.168.1.101", "port", "1883")));
|
||||
awlanColumns.put("redirector_addr", Atom.string(REDIRECT_ADDR));
|
||||
awlanColumns.put("manager_addr", Atom.string(MGR_ADDR));
|
||||
awlanColumns.put("platform_version", Atom.string(PLATFORM_VERSION));
|
||||
awlanColumns.put("firmware_version", Atom.string(FW_VERSION));
|
||||
awlanColumns.put("revision", Atom.string(REVISION));
|
||||
awlanColumns.put("sku_number", Atom.string(SKU_NUMBER));
|
||||
awlanColumns.put("serial_number", Atom.string(SERIAL_NUM));
|
||||
awlanColumns.put("model", Atom.string(MODEL));
|
||||
Row awlanRow = new Row(awlanColumns);
|
||||
|
||||
List<Row> awlanRows = ImmutableList.of(awlanRow);
|
||||
|
||||
OperationResult[] awlanResult = new OperationResult[] { new SelectResult(awlanRows) };
|
||||
java.util.Map<String, Value> inetWanColumns = new HashMap<>();
|
||||
inetWanColumns.put("inet_addr", Atom.string(WAN_IP));
|
||||
inetWanColumns.put("hwaddr", Atom.string(WAN_MAC));
|
||||
inetWanColumns.put("if_name", Atom.string(WAN_IF_NAME));
|
||||
inetWanColumns.put("if_type", Atom.string(WAN_IF_TYPE));
|
||||
|
||||
Row inetWanRow = new Row(inetWanColumns);
|
||||
|
||||
List<Row> inetWanRows = ImmutableList.of(inetWanRow);
|
||||
|
||||
OperationResult[] inetWanResult = new OperationResult[] { new SelectResult(inetWanRows) };
|
||||
|
||||
OperationResult[] errorResult = new OperationResult[] { new ErrorResult("Error", "Error") };
|
||||
|
||||
java.util.Map<String, Value> inetLanColumns = new HashMap<>();
|
||||
inetLanColumns.put("inet_addr", Atom.string(LAN_IP));
|
||||
inetLanColumns.put("hwaddr", Atom.string(LAN_MAC));
|
||||
inetLanColumns.put("if_name", Atom.string(LAN_IF_NAME));
|
||||
inetLanColumns.put("if_type", Atom.string(LAN_IF_TYPE));
|
||||
|
||||
Row inetLanRow = new Row(inetLanColumns);
|
||||
|
||||
List<Row> inetLanRows = ImmutableList.of(inetLanRow);
|
||||
|
||||
OperationResult[] inetLanResult = new OperationResult[] { new SelectResult(inetLanRows) };
|
||||
|
||||
java.util.Map<String, Value> wifiRadioStateColumns = new HashMap<>();
|
||||
wifiRadioStateColumns.put("freq_band", Atom.string("2.4G"));
|
||||
wifiRadioStateColumns.put("if_name", Atom.string("home-ap-24"));
|
||||
Row wifiRadioStateRow = new Row(wifiRadioStateColumns);
|
||||
|
||||
java.util.Map<String, Value> wifiRadioStateColumns2 = new HashMap<>();
|
||||
wifiRadioStateColumns2.put("freq_band", Atom.string("5GL"));
|
||||
wifiRadioStateColumns2.put("if_name", Atom.string("home-ap-l50"));
|
||||
Row wifiRadioStateRow2 = new Row(wifiRadioStateColumns2);
|
||||
|
||||
java.util.Map<String, Value> wifiRadioStateColumns3 = new HashMap<>();
|
||||
wifiRadioStateColumns3.put("freq_band", Atom.string("5GU"));
|
||||
wifiRadioStateColumns3.put("if_name", Atom.string("home-ap-u50"));
|
||||
Row wifiRadioStateRow3 = new Row(wifiRadioStateColumns3);
|
||||
|
||||
List<Row> wifiRadioStateRows = ImmutableList.of(wifiRadioStateRow, wifiRadioStateRow2, wifiRadioStateRow3);
|
||||
|
||||
OperationResult[] wifiRadioStateResult = new OperationResult[] { new SelectResult(wifiRadioStateRows) };
|
||||
|
||||
// No 'WAN' for this test, will have an ERROR
|
||||
Mockito.when(futureResult.get(Mockito.anyLong(), Mockito.eq(TimeUnit.SECONDS))).thenReturn(awlanResult)
|
||||
.thenReturn(errorResult).thenReturn(errorResult).thenReturn(inetLanResult)
|
||||
.thenReturn(wifiRadioStateResult);
|
||||
ConnectNodeInfo connectNodeInfo = ovsdbDao.getConnectNodeInfo(ovsdbClient);
|
||||
assertNotNull(connectNodeInfo.firmwareVersion);
|
||||
assertNotNull(connectNodeInfo.model);
|
||||
assertNotNull(connectNodeInfo.skuNumber);
|
||||
assertNotNull(connectNodeInfo.platformVersion);
|
||||
assertNotNull(connectNodeInfo.serialNumber);
|
||||
assertNotNull(connectNodeInfo.mqttSettings);
|
||||
assertNotNull(connectNodeInfo.redirectorAddr);
|
||||
assertNotNull(connectNodeInfo.managerAddr);
|
||||
|
||||
assertNull(connectNodeInfo.ifName);
|
||||
assertNull(connectNodeInfo.ifType);
|
||||
assertNull(connectNodeInfo.ipV4Address);
|
||||
assertNull(connectNodeInfo.macAddress);
|
||||
|
||||
assertNotNull(connectNodeInfo.lanIfName);
|
||||
assertNotNull(connectNodeInfo.lanIfType);
|
||||
assertNotNull(connectNodeInfo.lanIpV4Address);
|
||||
assertNotNull(connectNodeInfo.lanMacAddress);
|
||||
|
||||
assert (connectNodeInfo.wifiRadioStates.entrySet().size() == 3);
|
||||
Mockito.verify(ovsdbClient, Mockito.times(5)).transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList());
|
||||
Mockito.clearInvocations(ovsdbClient);
|
||||
|
||||
// No 'LAN' for this test, will have an ERROR
|
||||
Mockito.when(futureResult.get(Mockito.anyLong(), Mockito.eq(TimeUnit.SECONDS))).thenReturn(awlanResult)
|
||||
.thenReturn(inetWanResult).thenReturn(errorResult).thenReturn(wifiRadioStateResult);
|
||||
connectNodeInfo = ovsdbDao.getConnectNodeInfo(ovsdbClient);
|
||||
assertNotNull(connectNodeInfo.firmwareVersion);
|
||||
assertNotNull(connectNodeInfo.model);
|
||||
assertNotNull(connectNodeInfo.skuNumber);
|
||||
assertNotNull(connectNodeInfo.platformVersion);
|
||||
assertNotNull(connectNodeInfo.serialNumber);
|
||||
assertNotNull(connectNodeInfo.mqttSettings);
|
||||
assertNotNull(connectNodeInfo.redirectorAddr);
|
||||
assertNotNull(connectNodeInfo.managerAddr);
|
||||
|
||||
assertNotNull(connectNodeInfo.ifName);
|
||||
assertNotNull(connectNodeInfo.ifType);
|
||||
assertNotNull(connectNodeInfo.ipV4Address);
|
||||
assertNotNull(connectNodeInfo.macAddress);
|
||||
|
||||
assertNull(connectNodeInfo.lanIfName);
|
||||
assertNull(connectNodeInfo.lanIfType);
|
||||
assertNull(connectNodeInfo.lanIpV4Address);
|
||||
assertNull(connectNodeInfo.lanMacAddress);
|
||||
|
||||
assert (connectNodeInfo.wifiRadioStates.entrySet().size() == 3);
|
||||
Mockito.verify(ovsdbClient, Mockito.times(4)).transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList());
|
||||
Mockito.clearInvocations(ovsdbClient);
|
||||
|
||||
// No 'Wifi_Radio_State data' for this test, will have an ERROR
|
||||
Mockito.when(futureResult.get(Mockito.anyLong(), Mockito.eq(TimeUnit.SECONDS))).thenReturn(awlanResult)
|
||||
.thenReturn(inetWanResult).thenReturn(inetLanResult).thenReturn(errorResult);
|
||||
connectNodeInfo = ovsdbDao.getConnectNodeInfo(ovsdbClient);
|
||||
|
||||
assertNotNull(connectNodeInfo.firmwareVersion);
|
||||
assertNotNull(connectNodeInfo.model);
|
||||
assertNotNull(connectNodeInfo.skuNumber);
|
||||
assertNotNull(connectNodeInfo.platformVersion);
|
||||
assertNotNull(connectNodeInfo.serialNumber);
|
||||
assertNotNull(connectNodeInfo.mqttSettings);
|
||||
assertNotNull(connectNodeInfo.redirectorAddr);
|
||||
assertNotNull(connectNodeInfo.managerAddr);
|
||||
|
||||
assertNotNull(connectNodeInfo.ifName);
|
||||
assertNotNull(connectNodeInfo.ifType);
|
||||
assertNotNull(connectNodeInfo.ipV4Address);
|
||||
assertNotNull(connectNodeInfo.macAddress);
|
||||
|
||||
assertNotNull(connectNodeInfo.lanIfName);
|
||||
assertNotNull(connectNodeInfo.lanIfType);
|
||||
assertNotNull(connectNodeInfo.lanIpV4Address);
|
||||
assertNotNull(connectNodeInfo.lanMacAddress);
|
||||
|
||||
assert (connectNodeInfo.wifiRadioStates.isEmpty());
|
||||
|
||||
Mockito.verify(ovsdbClient, Mockito.times(4)).transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList());
|
||||
Mockito.clearInvocations(ovsdbClient);
|
||||
|
||||
// No 'AWLAN_Node data' for this test, will have an ERROR
|
||||
Mockito.when(futureResult.get(Mockito.anyLong(), Mockito.eq(TimeUnit.SECONDS))).thenReturn(errorResult)
|
||||
.thenReturn(inetWanResult).thenReturn(inetLanResult).thenReturn(wifiRadioStateResult);
|
||||
connectNodeInfo = ovsdbDao.getConnectNodeInfo(ovsdbClient);
|
||||
assertNull(connectNodeInfo.firmwareVersion);
|
||||
assertNull(connectNodeInfo.model);
|
||||
assertNull(connectNodeInfo.skuNumber);
|
||||
assertNull(connectNodeInfo.platformVersion);
|
||||
assertNull(connectNodeInfo.serialNumber);
|
||||
assertNull(connectNodeInfo.mqttSettings);
|
||||
assertNull(connectNodeInfo.redirectorAddr);
|
||||
assertNull(connectNodeInfo.managerAddr);
|
||||
|
||||
assertNotNull(connectNodeInfo.ifName);
|
||||
assertNotNull(connectNodeInfo.ifType);
|
||||
assertNotNull(connectNodeInfo.ipV4Address);
|
||||
assertNotNull(connectNodeInfo.macAddress);
|
||||
|
||||
assertNotNull(connectNodeInfo.lanIfName);
|
||||
assertNotNull(connectNodeInfo.lanIfType);
|
||||
assertNotNull(connectNodeInfo.lanIpV4Address);
|
||||
assertNotNull(connectNodeInfo.lanMacAddress);
|
||||
|
||||
assert (connectNodeInfo.wifiRadioStates.entrySet().size() == 3);
|
||||
|
||||
Mockito.verify(ovsdbClient, Mockito.times(4)).transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList());
|
||||
Mockito.clearInvocations(ovsdbClient);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testObsdbDaoEnableNetworkProbe() throws Exception {
|
||||
|
||||
Uuid rowUuid = Uuid.of(UUID.randomUUID());
|
||||
|
||||
OperationResult[] wifiStatsConfigEnableNetworkProbe = new OperationResult[] { new InsertResult(rowUuid) };
|
||||
OperationResult[] wifiStatsConfigEnableNetworkProbe = new OperationResult[] {new InsertResult(rowUuid)};
|
||||
|
||||
Mockito.when(futureResult.get(30L, TimeUnit.SECONDS)).thenReturn(wifiStatsConfigEnableNetworkProbe);
|
||||
|
||||
@@ -635,9 +366,8 @@ public class OvsdbDaoTest {
|
||||
@Test
|
||||
public void testObsdbDaoEnableNetworkProbeError() throws Exception {
|
||||
|
||||
OperationResult[] wifiStatsConfigEnableNetworkProbeFail = new OperationResult[] { new ErrorResult(
|
||||
"constraint violation",
|
||||
"network_probe is not one of the allowed values ([capacity, client, device, essid, neighbor, quality, radio, rssi, steering, survey])") };
|
||||
OperationResult[] wifiStatsConfigEnableNetworkProbeFail = new OperationResult[] {new ErrorResult("constraint violation",
|
||||
"network_probe is not one of the allowed values ([capacity, client, device, essid, neighbor, quality, radio, rssi, steering, survey])")};
|
||||
|
||||
Mockito.when(futureResult.get(30L, TimeUnit.SECONDS)).thenReturn(wifiStatsConfigEnableNetworkProbeFail);
|
||||
|
||||
@@ -652,19 +382,16 @@ public class OvsdbDaoTest {
|
||||
@Test
|
||||
public void testProcessNewChannelsRequest() throws Exception {
|
||||
|
||||
OperationResult[] testProcessNewChannelsRequestResult = new OperationResult[] { new UpdateResult(1),
|
||||
new UpdateResult(1), new UpdateResult(1), new UpdateResult(1), new UpdateResult(1),
|
||||
new UpdateResult(1) };
|
||||
OperationResult[] testProcessNewChannelsRequestResult = new OperationResult[] {new UpdateResult(1), new UpdateResult(1), new UpdateResult(1),
|
||||
new UpdateResult(1), new UpdateResult(1), new UpdateResult(1)};
|
||||
|
||||
Mockito.when(futureResult.get(30L, TimeUnit.SECONDS)).thenReturn(testProcessNewChannelsRequestResult);
|
||||
|
||||
Mockito.when(ovsdbClient.transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList())).thenReturn(futureResult);
|
||||
|
||||
ovsdbDao.processNewChannelsRequest(ovsdbClient,
|
||||
Map.of(RadioType.is2dot4GHz, Integer.valueOf(1), RadioType.is5GHzL, Integer.valueOf(40),
|
||||
RadioType.is5GHzU, Integer.valueOf(153)),
|
||||
Map.of(RadioType.is2dot4GHz, Integer.valueOf(6), RadioType.is5GHzL, Integer.valueOf(36),
|
||||
RadioType.is5GHzU, Integer.valueOf(149)));
|
||||
Map.of(RadioType.is2dot4GHz, Integer.valueOf(1), RadioType.is5GHzL, Integer.valueOf(40), RadioType.is5GHzU, Integer.valueOf(153)),
|
||||
Map.of(RadioType.is2dot4GHz, Integer.valueOf(6), RadioType.is5GHzL, Integer.valueOf(36), RadioType.is5GHzU, Integer.valueOf(149)));
|
||||
|
||||
Mockito.verify(futureResult).get(30L, TimeUnit.SECONDS);
|
||||
|
||||
@@ -673,8 +400,7 @@ public class OvsdbDaoTest {
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testObsdbDaoEnableNetworkProbeException() throws Exception {
|
||||
|
||||
Mockito.when(futureResult.get(30L, TimeUnit.SECONDS))
|
||||
.thenThrow(new OvsdbClientException("OvsdbClientException"));
|
||||
Mockito.when(futureResult.get(30L, TimeUnit.SECONDS)).thenThrow(new OvsdbClientException("OvsdbClientException"));
|
||||
|
||||
Mockito.when(ovsdbClient.transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList())).thenReturn(futureResult);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user