mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-01 02:57:49 +00:00
WIFI-1000: Opensync Gateway: handle Configuration Changes in Wifi_RRM_Config via Insert/Update/Delete vs. delete entire config and re-insert
This commit is contained in:
@@ -1248,7 +1248,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
currentActiveBSSIDs = new ArrayList<>();
|
currentActiveBSSIDs = new ArrayList<>();
|
||||||
} else {
|
} else {
|
||||||
currentActiveBSSIDs = currentActiveBSSIDs.stream()
|
currentActiveBSSIDs = currentActiveBSSIDs.stream()
|
||||||
.filter(p -> (!p.getRadioType().equals(freqBand) || !p.getSsid().equals(ssid)))
|
.filter(p -> (p.getRadioType() != null && p.getSsid() != null)).filter(p -> !p.getRadioType().equals(freqBand) || !p.getSsid().equals(ssid))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"Processing Wifi_VIF_State table update for AP {}, activeBSSIDs bssidList without current radio freq {} and ssid {}",
|
"Processing Wifi_VIF_State table update for AP {}, activeBSSIDs bssidList without current radio freq {} and ssid {}",
|
||||||
|
|||||||
@@ -329,7 +329,9 @@ public class OpensyncCloudGatewayController {
|
|||||||
} else if (command instanceof CEGWNewChannelRequest) {
|
} else if (command instanceof CEGWNewChannelRequest) {
|
||||||
CEGWNewChannelRequest request = (CEGWNewChannelRequest) command;
|
CEGWNewChannelRequest request = (CEGWNewChannelRequest) command;
|
||||||
Map<RadioType, Integer> newBackupChannels = request.getNewBackupChannels();
|
Map<RadioType, Integer> newBackupChannels = request.getNewBackupChannels();
|
||||||
String resultDetails = tipwlanOvsdbClient.processNewChannelsRequest(inventoryId, newBackupChannels);
|
Map<RadioType, Integer> newPrimaryChannels = request.getNewPrimaryChannels();
|
||||||
|
|
||||||
|
String resultDetails = tipwlanOvsdbClient.processNewChannelsRequest(inventoryId, newBackupChannels,newPrimaryChannels);
|
||||||
response.setResultDetail(resultDetails);
|
response.setResultDetail(resultDetails);
|
||||||
|
|
||||||
} else if (command instanceof CEGWFirmwareDownloadRequest) {
|
} else if (command instanceof CEGWFirmwareDownloadRequest) {
|
||||||
|
|||||||
@@ -32,6 +32,6 @@ public interface OvsdbClientInterface {
|
|||||||
|
|
||||||
String processFactoryResetRequest(String apId);
|
String processFactoryResetRequest(String apId);
|
||||||
|
|
||||||
String processNewChannelsRequest(String apId, Map<RadioType,Integer> channelMap);
|
String processNewChannelsRequest(String apId, Map<RadioType,Integer> backupChannelMap, Map<RadioType,Integer> primaryChannelMap);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -896,19 +896,19 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String processNewChannelsRequest(String apId, Map<RadioType, Integer> channelMap) {
|
public String processNewChannelsRequest(String apId, Map<RadioType, Integer> backupChannelMap, Map<RadioType,Integer> primaryChannelMap) {
|
||||||
LOG.debug("TipWlanOvsdbClient::processNewChannelsRequest for AP {}", apId);
|
LOG.info("TipWlanOvsdbClient::processNewChannelsRequest for AP {}", apId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
|
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
|
||||||
OvsdbClient ovsdbClient = session.getOvsdbClient();
|
OvsdbClient ovsdbClient = session.getOvsdbClient();
|
||||||
ovsdbDao.processNewChannelsRequest(ovsdbClient, channelMap);
|
ovsdbDao.processNewChannelsRequest(ovsdbClient, backupChannelMap, primaryChannelMap);
|
||||||
LOG.debug("TipWlanOvsdbClient::processNewChannelsRequest change backup channels for AP {}", apId);
|
LOG.info("TipWlanOvsdbClient::processNewChannelsRequest change backup and/or primary channels for AP {}", apId);
|
||||||
return "Triggered a factory reset of AP " + apId;
|
return " change backup and/or primary channels for AP " + apId;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("TipWlanOvsdbClient::processNewChannelsRequest failed to change backup channels for AP {}", apId,
|
LOG.error("TipWlanOvsdbClient::processNewChannelsRequest failed to change backup and/or primary channels for AP {}", apId,
|
||||||
e);
|
e);
|
||||||
return " failed to change backup channels for AP " + apId;
|
return "failed to change backup and/or primary channels for AP " + apId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5656,13 +5656,13 @@ public class OvsdbDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processNewChannelsRequest(OvsdbClient ovsdbClient, Map<RadioType, Integer> channelMap) {
|
public void processNewChannelsRequest(OvsdbClient ovsdbClient, Map<RadioType, Integer> backupChannelMap, Map<RadioType, Integer> primaryChannelMap) {
|
||||||
|
|
||||||
LOG.info("OvsdbDao::processNewChannelsRequest {}", channelMap);
|
LOG.info("OvsdbDao::processNewChannelsRequest backup {} primary {}", backupChannelMap, primaryChannelMap);
|
||||||
try {
|
try {
|
||||||
List<Operation> operations = new ArrayList<>();
|
List<Operation> operations = new ArrayList<>();
|
||||||
|
|
||||||
channelMap.entrySet().stream().forEach(c -> {
|
backupChannelMap.entrySet().stream().forEach(c -> {
|
||||||
String freqBand = OvsdbToWlanCloudTypeMappingUtility.getOvsdbRadioFreqBandForRadioType(c.getKey());
|
String freqBand = OvsdbToWlanCloudTypeMappingUtility.getOvsdbRadioFreqBandForRadioType(c.getKey());
|
||||||
List<Condition> conditions = new ArrayList<>();
|
List<Condition> conditions = new ArrayList<>();
|
||||||
conditions.add(new Condition("freq_band", Function.EQUALS, new Atom<>(freqBand)));
|
conditions.add(new Condition("freq_band", Function.EQUALS, new Atom<>(freqBand)));
|
||||||
@@ -5672,19 +5672,25 @@ public class OvsdbDao {
|
|||||||
operations.add(new Update(wifiRrmConfigDbTable, conditions, row));
|
operations.add(new Update(wifiRrmConfigDbTable, conditions, row));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
primaryChannelMap.entrySet().stream().forEach(c -> {
|
||||||
|
String freqBand = OvsdbToWlanCloudTypeMappingUtility.getOvsdbRadioFreqBandForRadioType(c.getKey());
|
||||||
|
List<Condition> conditions = new ArrayList<>();
|
||||||
|
conditions.add(new Condition("freq_band", Function.EQUALS, new Atom<>(freqBand)));
|
||||||
|
Map<String, Value> updateColumns = new HashMap<>();
|
||||||
|
updateColumns.put("channel", new Atom<>(c.getValue()));
|
||||||
|
Row row = new Row(updateColumns);
|
||||||
|
operations.add(new Update(wifiRadioConfigDbTable, conditions, row));
|
||||||
|
});
|
||||||
|
|
||||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||||
|
|
||||||
if (LOG.isDebugEnabled()) {
|
for (OperationResult res : result) {
|
||||||
LOG.debug("processNewChannelsRequest::Update backup channel(s) for {}:", wifiRrmConfigDbTable);
|
LOG.info("Op Result {}", res);
|
||||||
|
|
||||||
for (OperationResult res : result) {
|
|
||||||
LOG.debug("Op Result {}", res);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.info("Updated Wifi_RRM_Config");
|
|
||||||
|
|
||||||
|
LOG.info("Updated ovsdb config for primary and backup channels.");
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
LOG.error("Error in processNewChannelsRequest", e);
|
LOG.error("Error in processNewChannelsRequest", e);
|
||||||
} catch (OvsdbClientException | TimeoutException | InterruptedException e) {
|
} catch (OvsdbClientException | TimeoutException | InterruptedException e) {
|
||||||
@@ -5694,6 +5700,8 @@ public class OvsdbDao {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public AutoOrManualValue getSourcedValue(SourceType source, int profileValue, int equipmentValue) {
|
public AutoOrManualValue getSourcedValue(SourceType source, int profileValue, int equipmentValue) {
|
||||||
if (source == SourceType.profile) {
|
if (source == SourceType.profile) {
|
||||||
return AutoOrManualValue.createManualInstance(profileValue);
|
return AutoOrManualValue.createManualInstance(profileValue);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.telecominfraproject.wlan.opensync.ovsdb;
|
package com.telecominfraproject.wlan.opensync.ovsdb;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ import org.springframework.context.annotation.Import;
|
|||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.OpensyncExternalIntegrationInterface;
|
import com.telecominfraproject.wlan.opensync.external.integration.OpensyncExternalIntegrationInterface;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSession;
|
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSession;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSessionMapInterface;
|
import com.telecominfraproject.wlan.opensync.external.integration.OvsdbSessionMapInterface;
|
||||||
@@ -33,6 +35,7 @@ import com.vmware.ovsdb.callback.MonitorCallback;
|
|||||||
import com.vmware.ovsdb.exception.OvsdbClientException;
|
import com.vmware.ovsdb.exception.OvsdbClientException;
|
||||||
import com.vmware.ovsdb.protocol.methods.MonitorRequests;
|
import com.vmware.ovsdb.protocol.methods.MonitorRequests;
|
||||||
import com.vmware.ovsdb.protocol.methods.TableUpdates;
|
import com.vmware.ovsdb.protocol.methods.TableUpdates;
|
||||||
|
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
|
||||||
import com.vmware.ovsdb.service.OvsdbClient;
|
import com.vmware.ovsdb.service.OvsdbClient;
|
||||||
|
|
||||||
import io.netty.handler.ssl.SslContext;
|
import io.netty.handler.ssl.SslContext;
|
||||||
@@ -68,6 +71,9 @@ public class OpensyncGatewayTipWlanOvsdbClientTest {
|
|||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private CompletableFuture<TableUpdates> completableFuture;
|
private CompletableFuture<TableUpdates> completableFuture;
|
||||||
|
|
||||||
|
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||||
|
private CompletableFuture<OperationResult[]> operationResult;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
TipWlanOvsdbClient tipwlanOvsdbClient;
|
TipWlanOvsdbClient tipwlanOvsdbClient;
|
||||||
|
|
||||||
@@ -156,4 +162,30 @@ public class OpensyncGatewayTipWlanOvsdbClientTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProcessNewChannelsRequest() throws Exception {
|
||||||
|
|
||||||
|
OvsdbSession ovsdbSession = Mockito.mock(OvsdbSession.class, Mockito.RETURNS_DEEP_STUBS);
|
||||||
|
Mockito.when(ovsdbSession.getOvsdbClient()).thenReturn(ovsdbClient);
|
||||||
|
|
||||||
|
Mockito.when(ovsdbSessionMapInterface.getSession("Test_Client_21P10C68818122")).thenReturn(ovsdbSession);
|
||||||
|
|
||||||
|
|
||||||
|
String expectedResponse = " change backup and/or primary channels for AP Test_Client_21P10C68818122";
|
||||||
|
|
||||||
|
assert (tipwlanOvsdbClient.processNewChannelsRequest("Test_Client_21P10C68818122",
|
||||||
|
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)))
|
||||||
|
.equals(expectedResponse));
|
||||||
|
|
||||||
|
Mockito.verify(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)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||||
|
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||||
import com.telecominfraproject.wlan.location.models.Location;
|
import com.telecominfraproject.wlan.location.models.Location;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.ConnectNodeInfo;
|
import com.telecominfraproject.wlan.opensync.external.integration.models.ConnectNodeInfo;
|
||||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
||||||
@@ -53,6 +54,7 @@ import com.vmware.ovsdb.protocol.operation.result.ErrorResult;
|
|||||||
import com.vmware.ovsdb.protocol.operation.result.InsertResult;
|
import com.vmware.ovsdb.protocol.operation.result.InsertResult;
|
||||||
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
|
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
|
||||||
import com.vmware.ovsdb.protocol.operation.result.SelectResult;
|
import com.vmware.ovsdb.protocol.operation.result.SelectResult;
|
||||||
|
import com.vmware.ovsdb.protocol.operation.result.UpdateResult;
|
||||||
import com.vmware.ovsdb.protocol.schema.DatabaseSchema;
|
import com.vmware.ovsdb.protocol.schema.DatabaseSchema;
|
||||||
import com.vmware.ovsdb.protocol.schema.TableSchema;
|
import com.vmware.ovsdb.protocol.schema.TableSchema;
|
||||||
import com.vmware.ovsdb.service.OvsdbClient;
|
import com.vmware.ovsdb.service.OvsdbClient;
|
||||||
@@ -699,6 +701,28 @@ public class OvsdbDaoTest {
|
|||||||
|
|
||||||
Mockito.verify(futureResult).get(30L, TimeUnit.SECONDS);
|
Mockito.verify(futureResult).get(30L, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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) };
|
||||||
|
|
||||||
|
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)));
|
||||||
|
|
||||||
|
Mockito.verify(futureResult).get(30L, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = RuntimeException.class)
|
@Test(expected = RuntimeException.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user