mirror of
				https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
				synced 2025-10-31 10:37:51 +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<>(); | ||||
|         } else { | ||||
|             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()); | ||||
|             LOG.debug( | ||||
|                     "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) { | ||||
|             CEGWNewChannelRequest request = (CEGWNewChannelRequest) command; | ||||
|             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); | ||||
|  | ||||
|         } else if (command instanceof CEGWFirmwareDownloadRequest) { | ||||
|   | ||||
| @@ -32,6 +32,6 @@ public interface OvsdbClientInterface { | ||||
|      | ||||
|     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; | ||||
|     } | ||||
|  | ||||
|     public String processNewChannelsRequest(String apId, Map<RadioType, Integer> channelMap) { | ||||
|         LOG.debug("TipWlanOvsdbClient::processNewChannelsRequest for AP {}", apId); | ||||
|     public String processNewChannelsRequest(String apId, Map<RadioType, Integer> backupChannelMap, Map<RadioType,Integer> primaryChannelMap) { | ||||
|         LOG.info("TipWlanOvsdbClient::processNewChannelsRequest for AP {}", apId); | ||||
|  | ||||
|         try { | ||||
|             OvsdbSession session = ovsdbSessionMapInterface.getSession(apId); | ||||
|             OvsdbClient ovsdbClient = session.getOvsdbClient(); | ||||
|             ovsdbDao.processNewChannelsRequest(ovsdbClient, channelMap); | ||||
|             LOG.debug("TipWlanOvsdbClient::processNewChannelsRequest change backup channels for AP   {}", apId); | ||||
|             return "Triggered a factory reset of AP  " + apId; | ||||
|             ovsdbDao.processNewChannelsRequest(ovsdbClient, backupChannelMap, primaryChannelMap); | ||||
|             LOG.info("TipWlanOvsdbClient::processNewChannelsRequest change backup and/or primary channels for AP {}", apId); | ||||
|             return " change backup and/or primary channels for AP " + apId; | ||||
|         } 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); | ||||
|             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 { | ||||
|             List<Operation> operations = new ArrayList<>(); | ||||
|  | ||||
|             channelMap.entrySet().stream().forEach(c -> { | ||||
|             backupChannelMap.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))); | ||||
| @@ -5672,19 +5672,25 @@ public class OvsdbDao { | ||||
|                 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); | ||||
|             OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS); | ||||
|  | ||||
|             if (LOG.isDebugEnabled()) { | ||||
|                 LOG.debug("processNewChannelsRequest::Update backup channel(s) for {}:", wifiRrmConfigDbTable); | ||||
|  | ||||
|             for (OperationResult res : result) { | ||||
|                     LOG.debug("Op Result {}", res); | ||||
|                 } | ||||
|                 LOG.info("Op Result {}", res); | ||||
|             } | ||||
|  | ||||
|             LOG.info("Updated Wifi_RRM_Config"); | ||||
|  | ||||
|             LOG.info("Updated ovsdb config for primary and backup channels."); | ||||
|         } catch (ExecutionException e) { | ||||
|             LOG.error("Error in processNewChannelsRequest", e); | ||||
|         } catch (OvsdbClientException | TimeoutException | InterruptedException e) { | ||||
| @@ -5694,6 +5700,8 @@ public class OvsdbDao { | ||||
|  | ||||
|     } | ||||
|      | ||||
|      | ||||
|  | ||||
|     public AutoOrManualValue getSourcedValue(SourceType source, int profileValue, int equipmentValue) { | ||||
|         if (source == SourceType.profile) { | ||||
|             return AutoOrManualValue.createManualInstance(profileValue); | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| package com.telecominfraproject.wlan.opensync.ovsdb; | ||||
|  | ||||
| import java.util.HashSet; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| 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.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.OvsdbSession; | ||||
| 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.protocol.methods.MonitorRequests; | ||||
| import com.vmware.ovsdb.protocol.methods.TableUpdates; | ||||
| import com.vmware.ovsdb.protocol.operation.result.OperationResult; | ||||
| import com.vmware.ovsdb.service.OvsdbClient; | ||||
|  | ||||
| import io.netty.handler.ssl.SslContext; | ||||
| @@ -68,6 +71,9 @@ public class OpensyncGatewayTipWlanOvsdbClientTest { | ||||
|     @Mock(answer = Answers.RETURNS_DEEP_STUBS) | ||||
|     private CompletableFuture<TableUpdates> completableFuture; | ||||
|  | ||||
|     @Mock(answer = Answers.RETURNS_MOCKS) | ||||
|     private CompletableFuture<OperationResult[]> operationResult; | ||||
|  | ||||
|     @Autowired | ||||
|     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.ImmutableMap; | ||||
| 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.opensync.external.integration.models.ConnectNodeInfo; | ||||
| 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.OperationResult; | ||||
| 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.TableSchema; | ||||
| import com.vmware.ovsdb.service.OvsdbClient; | ||||
| @@ -699,6 +701,28 @@ public class OvsdbDaoTest { | ||||
|  | ||||
|         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) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Mike Hansen
					Mike Hansen