mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-01 19:17:52 +00:00
Compare commits
9 Commits
WIFI-4415
...
WIFI-4417-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49aacc151d | ||
|
|
077c535750 | ||
|
|
6110a8d78d | ||
|
|
5614d87f79 | ||
|
|
ca511c70c1 | ||
|
|
836fbc95ca | ||
|
|
1d11b96a7d | ||
|
|
36ab26df07 | ||
|
|
dcfefa2adb |
@@ -1152,7 +1152,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG.debug("Values from Vif State Mac (BSSID) {} SSID {} AssociatedClients {} Channel {}", bssid, ssid, vifState.getAssociatedClients());
|
||||
LOG.debug("Values from Vif State Mac (BSSID) {} SSID {} AssociatedClients {} Channel {}", bssid, ssid,
|
||||
vifState.getAssociatedClients(), channel);
|
||||
|
||||
RadioType radioType = null;
|
||||
Map<RadioType, RfElementConfiguration> rfElementMap = rfConfig.getRfConfigMap();
|
||||
@@ -1404,7 +1405,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
apElementConfiguration.getRadioMap().get(radioState.getFreqBand()).setAllowedChannelsPowerLevels(channelPowerLevels);
|
||||
}
|
||||
|
||||
LOG.debug("Updated AllowedChannels from Wifi_Radio_State table change for AP {}", apId);
|
||||
LOG.debug("Updated AllowedChannels from Wifi_Radio_State table change for AP {} configStateMismatch {}", apId, configStateMismatch);
|
||||
return configStateMismatch;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.telecominfraproject.wlan</groupId>
|
||||
@@ -70,6 +72,33 @@
|
||||
</dependency>
|
||||
<!-- MQTT dependencies END -->
|
||||
|
||||
<!-- Test Dependencies BEGIN -->
|
||||
<dependency>
|
||||
<artifactId>status-service-local</artifactId>
|
||||
<groupId>com.telecominfraproject.wlan</groupId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>status-service</artifactId>
|
||||
<groupId>com.telecominfraproject.wlan</groupId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>status-datastore-inmemory</artifactId>
|
||||
<groupId>com.telecominfraproject.wlan</groupId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>cloud-event-dispatcher-empty</artifactId>
|
||||
<groupId>com.telecominfraproject.wlan</groupId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Test Dependencies END -->
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -239,18 +239,19 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
String apId = alterClientCnIfRequired(clientCn, connectNodeInfo);
|
||||
|
||||
LOG.debug("Client {} connect for AP {}", clientCn, apId);
|
||||
|
||||
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
|
||||
|
||||
ovsdbDao.removeAllPasspointConfigs(ovsdbClient);
|
||||
ovsdbDao.removeAllSsids(ovsdbClient); // always
|
||||
ovsdbDao.removeAllInetConfigs(ovsdbClient);
|
||||
ovsdbDao.resetWiredPorts(ovsdbClient, opensyncAPConfig);
|
||||
ovsdbDao.removeWifiRrm(ovsdbClient);
|
||||
ovsdbDao.removeRadsecRadiusAndRealmConfigs(ovsdbClient);
|
||||
ovsdbDao.removeAllStatsConfigs(ovsdbClient); // always
|
||||
|
||||
extIntegrationInterface.clearEquipmentStatus(apId);
|
||||
|
||||
OpensyncAPConfig opensyncAPConfig = extIntegrationInterface.getApConfig(apId);
|
||||
|
||||
if (opensyncAPConfig != null) {
|
||||
ovsdbDao.configureNode(ovsdbClient, opensyncAPConfig);
|
||||
ovsdbDao.configureWifiRrm(ovsdbClient, opensyncAPConfig);
|
||||
@@ -329,6 +330,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
ovsdbDao.removeAllPasspointConfigs(ovsdbClient);
|
||||
ovsdbDao.removeAllSsids(ovsdbClient); // always
|
||||
ovsdbDao.removeAllInetConfigs(ovsdbClient);
|
||||
ovsdbDao.resetWiredPorts(ovsdbClient, opensyncAPConfig); // need to run this first before remove Status
|
||||
ovsdbDao.removeWifiRrm(ovsdbClient);
|
||||
ovsdbDao.removeRadsecRadiusAndRealmConfigs(ovsdbClient);
|
||||
ovsdbDao.removeAllStatsConfigs(ovsdbClient);
|
||||
|
||||
@@ -210,6 +210,10 @@ public class OvsdbDao extends OvsdbDaoBase {
|
||||
public void removeAllInetConfigs(OvsdbClient ovsdbClient) {
|
||||
ovsdbNetwork.removeAllInetConfigs(ovsdbClient);
|
||||
}
|
||||
|
||||
public void resetWiredPorts(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncApConfig) {
|
||||
ovsdbNetwork.resetWiredPorts(ovsdbClient, opensyncApConfig);
|
||||
}
|
||||
|
||||
public void removeAllPasspointConfigs(OvsdbClient ovsdbClient) {
|
||||
ovsdbHotspot.removeAllPasspointConfigs(ovsdbClient);
|
||||
|
||||
@@ -40,11 +40,26 @@ public class OvsdbGet extends OvsdbDaoBase {
|
||||
Map<String, Set<Integer>> getAllowedChannels(OvsdbClient ovsdbClient) {
|
||||
Map<String, Set<Integer>> allowedChannels = new HashMap<>();
|
||||
for (Row row : getOvsdbTableRowsForCondition(ovsdbClient, wifiRadioStateDbTable, null)) {
|
||||
allowedChannels.put(getSingleValueFromSet(row, "freq_band"), row.getSetColumn("allowed_channels"));
|
||||
Set<Integer> channels = new HashSet<>();
|
||||
if (row.getMapColumn("channels").containsKey("allowed")) {
|
||||
for (String c : row.getMapColumn("channels").get("allowed").toString().split(",")) {
|
||||
if (c != null)
|
||||
channels.add(Integer.valueOf(c));
|
||||
} ;
|
||||
}
|
||||
if (row.getMapColumn("channels").containsKey("radar_detection")) {
|
||||
for (String c : row.getMapColumn("channels").get("radar_detection").toString().split(",")) {
|
||||
if (c != null)
|
||||
channels.add(Integer.valueOf(c));
|
||||
} ;
|
||||
}
|
||||
|
||||
allowedChannels.put(getSingleValueFromSet(row, "freq_band"), channels);
|
||||
}
|
||||
return allowedChannels;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all Rows from given table that satisfy the conditions.
|
||||
*
|
||||
|
||||
@@ -27,6 +27,11 @@ import com.telecominfraproject.wlan.profile.models.Profile;
|
||||
import com.telecominfraproject.wlan.profile.network.models.ApNetworkConfiguration;
|
||||
import com.telecominfraproject.wlan.profile.network.models.GreTunnelConfiguration;
|
||||
import com.telecominfraproject.wlan.profile.ssid.models.SsidConfiguration;
|
||||
import com.telecominfraproject.wlan.status.StatusServiceInterface;
|
||||
import com.telecominfraproject.wlan.status.equipment.report.models.WiredEthernetPortStatusData;
|
||||
import com.telecominfraproject.wlan.status.equipment.report.models.WiredPortStatus;
|
||||
import com.telecominfraproject.wlan.status.models.Status;
|
||||
import com.telecominfraproject.wlan.status.models.StatusDataType;
|
||||
import com.vmware.ovsdb.exception.OvsdbClientException;
|
||||
import com.vmware.ovsdb.protocol.operation.Delete;
|
||||
import com.vmware.ovsdb.protocol.operation.Insert;
|
||||
@@ -48,6 +53,8 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
|
||||
@Autowired
|
||||
private OvsdbGet ovsdbGet;
|
||||
@Autowired
|
||||
private StatusServiceInterface statusServiceInterface;
|
||||
|
||||
private static final String VLAN_IF_TYPE = "vlan";
|
||||
private static final String VLAN_TRUNK_IF_TYPE = "vlan_trunk";
|
||||
@@ -172,6 +179,9 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
}
|
||||
|
||||
private void handleEthernetPortConfiguration(OvsdbClient ovsdbClient, Set<WiredPort> desiredWiredPorts) {
|
||||
// lists are for more than one lan port moving to wan ("eth0 eth1 eth2")
|
||||
Set<String> availableLanEthNames = new HashSet<>();
|
||||
Set<String> availableWanEthNames = new HashSet<>();
|
||||
if (desiredWiredPorts == null) {
|
||||
LOG.info("Cannot handle the EthernetPort config for null desired Wired Ports. Exiting");
|
||||
return;
|
||||
@@ -182,22 +192,35 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
LOG.error("Cannot find the default wan port from the desired list of ports {}" , desiredWiredPorts);
|
||||
return;
|
||||
}
|
||||
for (WiredPort port: desiredWiredPorts) {
|
||||
if (port.getIfName().contains(LAN_IF_NAME)) { // for AP has ifName lan1, lan2 instead of lan
|
||||
availableLanEthNames.add(port.getName());
|
||||
} else if (WAN_IF_NAME.equals(port.getIfName())) {
|
||||
availableWanEthNames.add(port.getName());
|
||||
}
|
||||
}
|
||||
for (WiredPort desiredPort : desiredWiredPorts) {
|
||||
if (!desiredPort.equals(wanPort)) {
|
||||
if (isLanToBridgeConversion(desiredPort) && !desiredPort.isTrunkEnabled()) {
|
||||
// Flow 1: Desired Bridge + Access
|
||||
LOG.debug("Desired Config is Bridge with Access Mode");
|
||||
changeLanToWan(ovsdbClient, desiredPort, wanPort);
|
||||
availableLanEthNames.remove(desiredPort.getName());
|
||||
availableWanEthNames.add(desiredPort.getName());
|
||||
changeLanToWan(ovsdbClient, availableLanEthNames, availableWanEthNames, wanPort.getName());
|
||||
createVlanTag(ovsdbClient, desiredPort);
|
||||
} else if (isLanToBridgeConversion(desiredPort) && desiredPort.isTrunkEnabled()) {
|
||||
// Flow 2: Desired Bridge + Trunk
|
||||
LOG.debug("Desired Config is Bridge with Trunk Mode");
|
||||
changeLanToWan(ovsdbClient, desiredPort, wanPort);
|
||||
availableLanEthNames.remove(desiredPort.getName());
|
||||
availableWanEthNames.add(desiredPort.getName());
|
||||
changeLanToWan(ovsdbClient, availableLanEthNames, availableWanEthNames, wanPort.getName());
|
||||
createTrunkInterface(ovsdbClient, desiredPort);
|
||||
} else if (!BRIDGE_IF_TYPE.equalsIgnoreCase(desiredPort.getIfType())) {
|
||||
// Flow 3: Desired ifType is NAT
|
||||
LOG.debug("Desired Config is NAT (LAN) mode. Desired Port {} may still be tagged to WAN interface. Convert to LAN mode", desiredPort.getIfName());
|
||||
changeWanToLan(ovsdbClient, desiredPort, wanPort);
|
||||
availableLanEthNames.add(desiredPort.getName());
|
||||
availableWanEthNames.remove(desiredPort.getName());
|
||||
changeWanToLan(ovsdbClient, availableLanEthNames, availableWanEthNames, wanPort.getName());
|
||||
} else {
|
||||
LOG.info("Not a supported Config change requested for the port {}", desiredPort);
|
||||
}
|
||||
@@ -228,17 +251,23 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
return wanWiredPort;
|
||||
}
|
||||
|
||||
void changeLanToWan(OvsdbClient ovsdbClient, WiredPort desiredWiredPort, WiredPort wanPort) {
|
||||
LOG.debug("Moving Port {} with current ifName {} to WAN", desiredWiredPort.getName(), desiredWiredPort.getIfName());
|
||||
void changeLanToWan(OvsdbClient ovsdbClient, Set<String> lanPortsToUpdate, Set<String> wanPortsToUpdate, String wanEthName) {
|
||||
LOG.debug("Calling changeLanToWan: moving port {} to LAN and {} to WAN", lanPortsToUpdate, wanPortsToUpdate);
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
// Step1: remove lan from eth_ports
|
||||
// /usr/opensync/bin/ovsh u Wifi_Inet_Config eth_ports:=" " -w if_name==lan
|
||||
addEthPortsOperation(operations, SEPARATOR, LAN_IF_NAME);
|
||||
// or cases like: /usr/opensync/bin/ovsh u Wifi_Inet_Config eth_ports:="eth2" -w if_name==lan
|
||||
String lanPortsString = String.join(SEPARATOR, lanPortsToUpdate);
|
||||
addEthPortsOperation(operations, lanPortsString.equals("")? SEPARATOR : lanPortsString, LAN_IF_NAME);
|
||||
|
||||
// Step2: make lan to a wan port
|
||||
// /usr/opensync/bin/ovsh u Wifi_Inet_Config eth_ports:="eth0 eth1" -w if_name==wan
|
||||
// eth_ports syntax is set by AP (i.e, eth0 eth1)
|
||||
addEthPortsOperation(operations, desiredWiredPort.getName() + SEPARATOR + wanPort.getName(), WAN_IF_NAME);
|
||||
// AP needs the original wan port be the first port in the string. Since we will hard code it, we remove
|
||||
// original wan name from the set to avoid duplication
|
||||
wanPortsToUpdate.remove(wanEthName);
|
||||
// trim() is used when wanPortsToUpdate is empty (i.e. we want "eth0" instead of "eth0 ")
|
||||
addEthPortsOperation(operations, (wanEthName + SEPARATOR + String.join(SEPARATOR, wanPortsToUpdate)).trim(), WAN_IF_NAME);
|
||||
sendOperationsToAP(ovsdbClient, operations, "changeLanToWan");
|
||||
}
|
||||
|
||||
@@ -315,15 +344,19 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
return desiredWiredPort.getAllowedVlanIds().stream().map(String::valueOf).collect(Collectors.joining(SEPARATOR));
|
||||
}
|
||||
|
||||
void changeWanToLan(OvsdbClient ovsdbClient, WiredPort desiredWiredPort, WiredPort wanPort) {
|
||||
void changeWanToLan(OvsdbClient ovsdbClient, Set<String> lanPortsToUpdate, Set<String> wanPortsToUpdate, String wanEthName) {
|
||||
LOG.debug("Calling changeWanToLan: Moving port {} to LAN and {} to WAN", lanPortsToUpdate, wanPortsToUpdate);
|
||||
// Step1: set the correct port to lan
|
||||
// /usr/opensync/bin/ovsh u Wifi_Inet_Config eth_ports:="eth0" -w if_name==lan
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
addEthPortsOperation(operations, desiredWiredPort.getName(), LAN_IF_NAME);
|
||||
addEthPortsOperation(operations, String.join(SEPARATOR, lanPortsToUpdate), LAN_IF_NAME);
|
||||
|
||||
// Step2: set the correct port to wan
|
||||
// /usr/opensync/bin/ovsh u Wifi_Inet_Config eth_ports:="eth1" -w if_name==wan
|
||||
addEthPortsOperation(operations, wanPort.getName(), WAN_IF_NAME);
|
||||
// AP needs the original wan port be the first port in the string. Since we will hard code it, we remove
|
||||
// original wan name from the set to avoid duplication
|
||||
wanPortsToUpdate.remove(wanEthName);
|
||||
addEthPortsOperation(operations, (wanEthName + SEPARATOR + String.join(SEPARATOR, wanPortsToUpdate)).trim(), WAN_IF_NAME);
|
||||
|
||||
sendOperationsToAP(ovsdbClient, operations, "changeWanToLan");
|
||||
}
|
||||
@@ -543,4 +576,56 @@ public class OvsdbNetworkConfig extends OvsdbDaoBase {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset all LAN ports from WAN back to LAN (NAT mode)
|
||||
void resetWiredPorts(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncApConfig) {
|
||||
LOG.debug("Calling resetWiredPorts");
|
||||
// e.g. eth1
|
||||
Map<String, List<WiredPortStatus>> interfacePortStatusMap = getInterfacePortStatus(
|
||||
opensyncApConfig.getCustomerEquipment().getCustomerId(),
|
||||
opensyncApConfig.getCustomerEquipment().getId());
|
||||
if (interfacePortStatusMap == null) {
|
||||
LOG.info("No InterfacePort(EthernetPort) Status. Exiting");
|
||||
return;
|
||||
}
|
||||
List<WiredPortStatus> wanPortStatusList = interfacePortStatusMap.get(WAN_IF_NAME);
|
||||
if (wanPortStatusList == null) {
|
||||
LOG.info("No wan interface status available. Exiting");
|
||||
return;
|
||||
}
|
||||
WiredPortStatus originalWanPortStatus = wanPortStatusList.stream()
|
||||
.filter(wan -> WAN_IF_NAME.equals(wan.getOriginalIfName())).findFirst().orElse(null);
|
||||
if (originalWanPortStatus == null) {
|
||||
LOG.info("No original wan port available. Exiting");
|
||||
return;
|
||||
}
|
||||
String wanEthName = originalWanPortStatus.getName();
|
||||
Set<String> lanEthNames = new HashSet<>();
|
||||
for (WiredPortStatus wanPortStatus : wanPortStatusList) {
|
||||
if (wanPortStatus.getOriginalIfName().contains(LAN_IF_NAME)) {
|
||||
lanEthNames.add(wanPortStatus.getName());
|
||||
}
|
||||
}
|
||||
if (!lanEthNames.isEmpty()) {
|
||||
Set<String> wanEthNameSet = new HashSet<String>();
|
||||
wanEthNameSet.add(wanEthName);
|
||||
changeWanToLan(ovsdbClient, lanEthNames, wanEthNameSet, wanEthName);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, List<WiredPortStatus>> getInterfacePortStatus(int customerId, long equipmentId) {
|
||||
Map<String, List<WiredPortStatus>> interfacePortStatus = null;
|
||||
// Getting the status from the current AP
|
||||
Status existingPortStatus = statusServiceInterface.getOrNull(customerId, equipmentId,
|
||||
StatusDataType.WIRED_ETHERNET_PORT);
|
||||
if (existingPortStatus != null && existingPortStatus.getDetails() instanceof WiredEthernetPortStatusData) {
|
||||
interfacePortStatus = ((WiredEthernetPortStatusData) existingPortStatus.getDetails())
|
||||
.getInterfacePortStatusMap();
|
||||
}
|
||||
|
||||
if (interfacePortStatus == null || interfacePortStatus.isEmpty()) {
|
||||
LOG.info("No ethernetPortStatus found for customer {}, equipment {}", customerId, equipmentId);
|
||||
}
|
||||
return interfacePortStatus;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import java.util.concurrent.TimeoutException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.equipment.LedStatus;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
||||
import com.telecominfraproject.wlan.profile.network.models.ApNetworkConfiguration;
|
||||
import com.vmware.ovsdb.exception.OvsdbClientException;
|
||||
@@ -145,8 +144,24 @@ public class OvsdbNodeConfig extends OvsdbDaoBase {
|
||||
List.of(new Condition("module", Function.EQUALS, new Atom<>("led"))), new Row(columns)));
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
long numUpdates = 0;
|
||||
for (OperationResult res : result) {
|
||||
LOG.debug("processLedControlEnabled result {}", res);
|
||||
if (res instanceof UpdateResult) {
|
||||
numUpdates += ((UpdateResult) res).getCount();
|
||||
LOG.debug("processLedControlEnabled update result {}", res);
|
||||
}
|
||||
}
|
||||
if (numUpdates == 0) {
|
||||
// no records existed, insert the row instead
|
||||
operations.clear();
|
||||
operations.add(new Insert(nodeConfigTable, new Row(columns)));
|
||||
fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||
for (OperationResult res : result) {
|
||||
if (res instanceof InsertResult) {
|
||||
LOG.debug("processLedControlEnabled insert result {}", res);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherEmpty;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||
import com.telecominfraproject.wlan.location.models.Location;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
||||
@@ -43,6 +44,9 @@ import com.telecominfraproject.wlan.profile.models.ProfileType;
|
||||
import com.telecominfraproject.wlan.profile.network.models.ApNetworkConfiguration;
|
||||
import com.telecominfraproject.wlan.profile.network.models.GreTunnelConfiguration;
|
||||
import com.telecominfraproject.wlan.profile.ssid.models.SsidConfiguration;
|
||||
import com.telecominfraproject.wlan.status.StatusServiceLocal;
|
||||
import com.telecominfraproject.wlan.status.controller.StatusController;
|
||||
import com.telecominfraproject.wlan.status.datastore.inmemory.StatusDatastoreInMemory;
|
||||
import com.vmware.ovsdb.exception.OvsdbClientException;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Row;
|
||||
import com.vmware.ovsdb.protocol.operation.notation.Uuid;
|
||||
@@ -63,8 +67,8 @@ import com.vmware.ovsdb.service.OvsdbClient;
|
||||
@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
|
||||
|
||||
OvsdbNodeConfig.class, OvsdbRadiusProxyConfig.class, StatusServiceLocal.class, StatusController.class,
|
||||
CloudEventDispatcherEmpty.class, StatusDatastoreInMemory.class
|
||||
})
|
||||
public class OvsdbDaoTest {
|
||||
|
||||
|
||||
@@ -6,6 +6,11 @@ import com.telecominfraproject.wlan.profile.ethernetport.models.WiredEthernetPor
|
||||
import com.telecominfraproject.wlan.profile.ethernetport.models.WiredPort;
|
||||
import com.telecominfraproject.wlan.profile.models.Profile;
|
||||
import com.telecominfraproject.wlan.profile.models.ProfileType;
|
||||
import com.telecominfraproject.wlan.status.StatusServiceInterface;
|
||||
import com.telecominfraproject.wlan.status.equipment.report.models.WiredEthernetPortStatusData;
|
||||
import com.telecominfraproject.wlan.status.equipment.report.models.WiredPortStatus;
|
||||
import com.telecominfraproject.wlan.status.models.Status;
|
||||
import com.telecominfraproject.wlan.status.models.StatusDataType;
|
||||
import com.vmware.ovsdb.exception.OvsdbClientException;
|
||||
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
|
||||
import com.vmware.ovsdb.protocol.operation.result.UpdateResult;
|
||||
@@ -27,6 +32,7 @@ import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@@ -53,6 +59,9 @@ public class OvsdbNetworkConfigTest {
|
||||
@Autowired
|
||||
OvsdbNetworkConfig ovsdbNetworkConfig;
|
||||
|
||||
@MockBean(answer = Answers.RETURNS_MOCKS)
|
||||
StatusServiceInterface statusServiceInterface;
|
||||
|
||||
@MockBean(answer = Answers.RETURNS_MOCKS)
|
||||
OvsdbGet ovsdbGet;
|
||||
|
||||
@@ -60,10 +69,12 @@ public class OvsdbNetworkConfigTest {
|
||||
CompletableFuture<OperationResult[]> futureResult;
|
||||
|
||||
private MockitoSession mockito;
|
||||
|
||||
private static final String LAN_IF_NAME = "lan";
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mockito = Mockito.mockitoSession().initMocks(this).strictness(Strictness.STRICT_STUBS).startMocking();
|
||||
mockito = Mockito.mockitoSession().initMocks(this).strictness(Strictness.WARN).startMocking();
|
||||
Mockito.when(ovsdbClient.transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList())).thenReturn(futureResult);
|
||||
}
|
||||
|
||||
@@ -112,6 +123,41 @@ public class OvsdbNetworkConfigTest {
|
||||
Mockito.verify(ovsdbClient, times(1)).transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList());
|
||||
}
|
||||
|
||||
// Case when ETH port is in BRIDGE + Trunk and Profile is removed so we convert
|
||||
// it in NAT (LAN)
|
||||
@Test
|
||||
public void testResetWiredPorts_BridgeTrunkToNAT()
|
||||
throws ExecutionException, InterruptedException, TimeoutException, OvsdbClientException {
|
||||
// at the beginning LAN's currentIfName is wan
|
||||
Mockito.when(statusServiceInterface.getOrNull(Mockito.anyInt(), Mockito.anyLong(),
|
||||
Mockito.any(StatusDataType.class))).thenReturn(createWiredEthernetPortStatus("wan"));
|
||||
OperationResult[] updateResult = new OperationResult[] { new UpdateResult(1) };
|
||||
Mockito.when(futureResult.get(ovsdbNetworkConfig.ovsdbTimeoutSec, TimeUnit.SECONDS)).thenReturn(updateResult);
|
||||
|
||||
ovsdbNetworkConfig.resetWiredPorts(ovsdbClient, createOpensyncApConfig(true, "bridge"));
|
||||
// transact() execute 1 time as we move LAN from wan interface back to lan
|
||||
// interface
|
||||
// (vlan interface will be removed in inetC table directly)
|
||||
Mockito.verify(ovsdbClient, times(1)).transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList());
|
||||
}
|
||||
|
||||
// Case when ETH port is in NAT + Access and Profile is removed we don't do
|
||||
// anything
|
||||
@Test
|
||||
public void testResetWiredPorts_NATToNAT()
|
||||
throws ExecutionException, InterruptedException, TimeoutException, OvsdbClientException {
|
||||
// at the beginning LAN's currentIfName is wan
|
||||
Mockito.when(statusServiceInterface.getOrNull(Mockito.anyInt(), Mockito.anyLong(),
|
||||
Mockito.any(StatusDataType.class))).thenReturn(createWiredEthernetPortStatus("lan"));
|
||||
OperationResult[] updateResult = new OperationResult[] { new UpdateResult(1) };
|
||||
Mockito.when(futureResult.get(ovsdbNetworkConfig.ovsdbTimeoutSec, TimeUnit.SECONDS)).thenReturn(updateResult);
|
||||
|
||||
ovsdbNetworkConfig.resetWiredPorts(ovsdbClient, createOpensyncApConfig(false, "NAT"));
|
||||
// Note: Strictness set to WARN in setup() rather than STRICT_STUB as we are
|
||||
// adding unnecessary stubbings above to test if any transact() is called.
|
||||
Mockito.verify(ovsdbClient, times(0)).transact(Mockito.eq(OvsdbDao.ovsdbName), Mockito.anyList());
|
||||
}
|
||||
|
||||
private OpensyncAPConfig createOpensyncApConfig(boolean isTrunkEnabled, String ifType) {
|
||||
OpensyncAPConfig opensyncApConfig = new OpensyncAPConfig();
|
||||
|
||||
@@ -157,4 +203,43 @@ public class OvsdbNetworkConfigTest {
|
||||
|
||||
return wiredPort;
|
||||
}
|
||||
|
||||
private Status createWiredEthernetPortStatus(String lanPortIfName) {
|
||||
WiredEthernetPortStatusData statusDetails = new WiredEthernetPortStatusData();
|
||||
if (lanPortIfName.equals(LAN_IF_NAME)) {
|
||||
WiredPortStatus wiredPortStatusLan = createWiredPortStatus(lanPortIfName, "NAT", false, 0, null, "eth0", "lan", "up");
|
||||
WiredPortStatus wiredPortStatusWan = createWiredPortStatus("wan", "bridge", true, 0, null, "eth1", "wan", "up");
|
||||
statusDetails.setInterfacePortStatusMap(Map.of("lan", List.of(wiredPortStatusLan), "wan", List.of(wiredPortStatusWan)));
|
||||
} else {
|
||||
WiredPortStatus wiredPortStatusLan = createWiredPortStatus(lanPortIfName, "bridge", true, 10, List.of(100,200), "eth0", "lan", "up");
|
||||
WiredPortStatus wiredPortStatusWan = createWiredPortStatus("wan", "bridge", true, 0, null, "eth1", "wan", "up");
|
||||
statusDetails.setInterfacePortStatusMap(Map.of("lan", List.of(), "wan", List.of(wiredPortStatusLan, wiredPortStatusWan)));
|
||||
}
|
||||
|
||||
|
||||
Status status = new Status();
|
||||
status.setCustomerId(1);
|
||||
status.setEquipmentId(1L);
|
||||
status.setStatusDataType(StatusDataType.WIRED_ETHERNET_PORT);
|
||||
status.setDetails(statusDetails);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
private WiredPortStatus createWiredPortStatus(String ifName, String ifType, boolean isTrunkEnabled, int vlanId,
|
||||
List<Integer> allowedVlans, String name, String originalIfName, String operationalState) {
|
||||
WiredPortStatus status = new WiredPortStatus();
|
||||
status.setIfType(ifType);
|
||||
status.setCurrentIfName(ifName);
|
||||
status.setOriginalIfName(originalIfName);
|
||||
status.setName(name);
|
||||
status.setAllowedVlanIds(allowedVlans);
|
||||
status.setDuplex("full");
|
||||
status.setSpeed(1000);
|
||||
status.setTrunkEnabled(isTrunkEnabled);
|
||||
status.setOperationalState(operationalState);
|
||||
status.setVlanId(vlanId);
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,12 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherEmpty;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.ConnectNodeInfo;
|
||||
import com.telecominfraproject.wlan.opensync.util.OvsdbToWlanCloudTypeMappingUtility;
|
||||
import com.telecominfraproject.wlan.status.StatusServiceLocal;
|
||||
import com.telecominfraproject.wlan.status.controller.StatusController;
|
||||
import com.telecominfraproject.wlan.status.datastore.inmemory.StatusDatastoreInMemory;
|
||||
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
|
||||
import com.vmware.ovsdb.service.OvsdbClient;
|
||||
|
||||
@@ -36,7 +40,8 @@ import com.vmware.ovsdb.service.OvsdbClient;
|
||||
@Import(value = { OvsdbDao.class, OvsdbNodeTest.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
|
||||
OvsdbNodeConfig.class,OvsdbRadiusProxyConfig.class, StatusServiceLocal.class, StatusController.class,
|
||||
CloudEventDispatcherEmpty.class, StatusDatastoreInMemory.class
|
||||
})
|
||||
public class OvsdbNodeTest {
|
||||
|
||||
|
||||
@@ -24,12 +24,16 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherEmpty;
|
||||
import com.telecominfraproject.wlan.location.models.Location;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
||||
import com.telecominfraproject.wlan.profile.models.Profile;
|
||||
import com.telecominfraproject.wlan.profile.models.ProfileType;
|
||||
import com.telecominfraproject.wlan.profile.radius.models.RadiusProfile;
|
||||
import com.telecominfraproject.wlan.profile.ssid.models.SsidConfiguration;
|
||||
import com.telecominfraproject.wlan.status.StatusServiceLocal;
|
||||
import com.telecominfraproject.wlan.status.controller.StatusController;
|
||||
import com.telecominfraproject.wlan.status.datastore.inmemory.StatusDatastoreInMemory;
|
||||
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
|
||||
import com.vmware.ovsdb.service.OvsdbClient;
|
||||
|
||||
@@ -41,7 +45,8 @@ import com.vmware.ovsdb.service.OvsdbClient;
|
||||
@Import(value = { OvsdbDao.class, OvsdbSsidConfigTest.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
|
||||
OvsdbNodeConfig.class, OvsdbRadiusProxyConfig.class, StatusServiceLocal.class, StatusController.class,
|
||||
CloudEventDispatcherEmpty.class, StatusDatastoreInMemory.class
|
||||
})
|
||||
public class OvsdbSsidConfigTest {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user