mirror of
https://github.com/Telecominfraproject/wlan-cloud-services.git
synced 2026-03-20 19:39:19 +00:00
Compare commits
32 Commits
WIFI-4732
...
WIFI-7580-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98760bbfda | ||
|
|
f64816dbbe | ||
|
|
f87600d283 | ||
|
|
9d19a6c436 | ||
|
|
eb19907513 | ||
|
|
1502913097 | ||
|
|
27e7c0173a | ||
|
|
051458b9d4 | ||
|
|
d98d5a2ad3 | ||
|
|
dda25eac2e | ||
|
|
c8c3e85a55 | ||
|
|
d5df9485f6 | ||
|
|
83e4f3613a | ||
|
|
aa77c4a2d5 | ||
|
|
3a4561b323 | ||
|
|
7abc4c8554 | ||
|
|
34bec5009a | ||
|
|
824568a128 | ||
|
|
5211ed7e68 | ||
|
|
1bffb4f96a | ||
|
|
fa77d3896d | ||
|
|
55c4671211 | ||
|
|
a540274210 | ||
|
|
56f43d8e7f | ||
|
|
607c1c815e | ||
|
|
f750d0cad2 | ||
|
|
1551babca2 | ||
|
|
70bd1f5eda | ||
|
|
88fa6ca8a5 | ||
|
|
e090bd6b00 | ||
|
|
aa1fbfd645 | ||
|
|
9ee24beb64 |
@@ -262,7 +262,7 @@ public class AlarmController {
|
||||
public AlarmCounts getAlarmCounts(@RequestParam int customerId,
|
||||
@RequestParam Set<Long> equipmentIdSet,
|
||||
@RequestParam Set<AlarmCode> alarmCodeSet,
|
||||
@RequestParam Boolean acknowledged) {
|
||||
@RequestParam(required = false) Boolean acknowledged) {
|
||||
|
||||
LOG.debug("Getting Alarm counts for {} {} {} {}", customerId, equipmentIdSet, alarmCodeSet, acknowledged);
|
||||
|
||||
|
||||
@@ -634,7 +634,7 @@ public class AllInOneStartListener implements ApplicationRunner {
|
||||
((PasspointProfile) passpointHotspotConfig.getDetails()).setPasspointVenueProfileId(passpointVenueProfileId);
|
||||
((PasspointProfile) passpointHotspotConfig.getDetails()).setOsuSsidProfileId(profileSsidOpenId);
|
||||
((PasspointProfile) passpointHotspotConfig.getDetails())
|
||||
.setAssociatedAccessSsidProfileIds(List.of(profileSsidPskId));
|
||||
.setAssociatedAccessSsidProfileIds(Set.of(profileSsidPskId));
|
||||
|
||||
return profileServiceInterface.create(passpointHotspotConfig);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.telecominfraproject.wlan.client.models.events.ClientChangedEvent;
|
||||
import com.telecominfraproject.wlan.client.models.events.ClientRemovedEvent;
|
||||
import com.telecominfraproject.wlan.client.models.events.ClientSessionChangedEvent;
|
||||
import com.telecominfraproject.wlan.client.models.events.ClientSessionRemovedEvent;
|
||||
import com.telecominfraproject.wlan.client.session.models.AssociationState;
|
||||
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
||||
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherInterface;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||
@@ -351,6 +352,8 @@ public class ClientController {
|
||||
throw new DsDataValidationException("Client session contains unsupported value");
|
||||
}
|
||||
|
||||
forceDisconnectOtherClientSessions(clientSession);
|
||||
|
||||
ClientSession ret = clientDatastore.updateSession(clientSession);
|
||||
|
||||
LOG.debug("Updated Client session {}", ret);
|
||||
@@ -384,6 +387,8 @@ public class ClientController {
|
||||
throw new DsDataValidationException("Client session contains unsupported value");
|
||||
}
|
||||
|
||||
clientSessions.forEach(s -> forceDisconnectOtherClientSessions(s));
|
||||
|
||||
ListOfClientSessions ret = new ListOfClientSessions();
|
||||
|
||||
ret.addAll(clientDatastore.updateSessions(clientSessions));
|
||||
@@ -460,5 +465,39 @@ public class ClientController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Force disconnects other client sessions with the same client Mac address.
|
||||
* In an ideal world, this doesn't happen often.
|
||||
* This usually happens when a client is roaming from one AP to another and the AP does not send a
|
||||
* disconnect until much later (5+ minutes timeout on the AP).
|
||||
* Also happens if the AP was disconnected from the cloud from some time and we "missed" the disconnect event.
|
||||
* @param clientSession
|
||||
*/
|
||||
private void forceDisconnectOtherClientSessions(ClientSession clientSession) {
|
||||
if (clientSession.getDetails().getAssociationState() != AssociationState._802_11_Associated) {
|
||||
// updating a session that is not associated should not disconnect other sessions
|
||||
return;
|
||||
}
|
||||
|
||||
List<ClientSession> allSessions = clientDatastore.getSessions(clientSession.getCustomerId(), Set.of(clientSession.getMacAddress()));
|
||||
|
||||
if (allSessions == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ClientSession cl : allSessions) {
|
||||
if (cl.getEquipmentId() == clientSession.getEquipmentId()) {
|
||||
// Don't disconnect ourselves!
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cl.getDetails().getAssociationState() == AssociationState._802_11_Associated) {
|
||||
// Force disconnect this client session:
|
||||
LOG.info("Forcing a Disconnect of Client session {}", cl);
|
||||
cl.getDetails().setAssociationState(AssociationState.Disconnected);
|
||||
cl.setLastModifiedTimestamp(System.currentTimeMillis());
|
||||
updateSession(cl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@@ -32,8 +33,8 @@ public class CloudEventDispatcherController {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CloudEventDispatcherController.class);
|
||||
|
||||
@Autowired @Qualifier("metricStreamInterface") private StreamInterface<ServiceMetric> metricStream;
|
||||
@Autowired @Qualifier("eventStreamInterface") private StreamInterface<SystemEventRecord> systemEventStream;
|
||||
@Autowired @Qualifier("metricStreamInterface") @Lazy private StreamInterface<ServiceMetric> metricStream;
|
||||
@Autowired @Qualifier("eventStreamInterface") @Lazy private StreamInterface<SystemEventRecord> systemEventStream;
|
||||
@Autowired private ServiceMetricServiceInterface serviceMetricInterface;
|
||||
@Autowired private SystemEventServiceInterface systemEventInterface;
|
||||
|
||||
|
||||
@@ -3422,6 +3422,16 @@ components:
|
||||
type: integer
|
||||
format: int64
|
||||
|
||||
ChannelBandwidthPerRadioTypeMap:
|
||||
properties:
|
||||
is5GHz:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
is5GHzU:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
is5GHzL:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
is2dot4GHz:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
|
||||
EquipmentAdminStatusData:
|
||||
type: object
|
||||
@@ -4381,6 +4391,8 @@ components:
|
||||
- RADIO_CHANNEL
|
||||
channelNumberStatusDataMap:
|
||||
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
||||
channelBandwidthStatusDataMap:
|
||||
$ref: '#/components/schemas/ChannelBandwidthPerRadioTypeMap'
|
||||
txPowerDataMap:
|
||||
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
||||
|
||||
@@ -5675,28 +5687,5 @@ paths:
|
||||
items:
|
||||
$ref: '#/components/schemas/GenericResponse'
|
||||
500:
|
||||
$ref: '#/components/responses/GenericApiError'
|
||||
|
||||
$ref: '#/components/responses/GenericApiError'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -263,7 +263,8 @@ public class EquipmentDAO extends BaseJdbcDao {
|
||||
},
|
||||
keyHolder);
|
||||
}catch (DuplicateKeyException e) {
|
||||
throw new DsDuplicateEntityException(e);
|
||||
LOG.error("Duplicate equipment found", e);
|
||||
throw new DsDuplicateEntityException("Equipment with the assetId " + equipment.getInventoryId() + " already exists!");
|
||||
}
|
||||
|
||||
// keyHolder.getKey() now contains the generated key
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.telecominfraproject.wlan.equipment.models;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -48,6 +50,38 @@ public class ElementRadioConfiguration extends BaseJsonModel
|
||||
|
||||
private Boolean deauthAttackDetection;
|
||||
private Set<ChannelPowerLevel> allowedChannelsPowerLevels = new HashSet<>();
|
||||
|
||||
public final static int DEFAULT_CHANNEL_NUMBER_2DOT4GHZ = 6;
|
||||
public final static int DEFAULT_BACKUP_CHANNEL_NUMBER_2DOT4GHZ = 11;
|
||||
public final static int DEFAULT_CHANNEL_NUMBER_5GHZ = 36;
|
||||
public final static int DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZ = 44;
|
||||
public final static int DEFAULT_CHANNEL_NUMBER_5GHZL = 36;
|
||||
public final static int DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZL = 44;
|
||||
public final static int DEFAULT_CHANNEL_NUMBER_5GHZU = 149;
|
||||
public final static int DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZU = 157;
|
||||
|
||||
private static final Map<RadioType, Integer> defaultChannelNumberMap = new EnumMap<>(RadioType.class);
|
||||
private static final Map<RadioType, Integer> defaultBackupChannelNumberMap = new EnumMap<>(RadioType.class);
|
||||
|
||||
static {
|
||||
defaultChannelNumberMap.put(RadioType.is2dot4GHz, DEFAULT_CHANNEL_NUMBER_2DOT4GHZ);
|
||||
defaultChannelNumberMap.put(RadioType.is5GHz, DEFAULT_CHANNEL_NUMBER_5GHZ);
|
||||
defaultChannelNumberMap.put(RadioType.is5GHzL, DEFAULT_CHANNEL_NUMBER_5GHZL);
|
||||
defaultChannelNumberMap.put(RadioType.is5GHzU, DEFAULT_CHANNEL_NUMBER_5GHZU);
|
||||
|
||||
defaultBackupChannelNumberMap.put(RadioType.is2dot4GHz, DEFAULT_BACKUP_CHANNEL_NUMBER_2DOT4GHZ);
|
||||
defaultBackupChannelNumberMap.put(RadioType.is5GHz, DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZ);
|
||||
defaultBackupChannelNumberMap.put(RadioType.is5GHzL, DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZL);
|
||||
defaultBackupChannelNumberMap.put(RadioType.is5GHzU, DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZU);
|
||||
}
|
||||
|
||||
public static Integer getDefaultChannelNumber(RadioType radioType) {
|
||||
return defaultChannelNumberMap.get(radioType);
|
||||
}
|
||||
|
||||
public static Integer getDefaultBackupChannelNumber(RadioType radioType) {
|
||||
return defaultBackupChannelNumberMap.get(radioType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Static creator
|
||||
@@ -60,19 +94,8 @@ public class ElementRadioConfiguration extends BaseJsonModel
|
||||
|
||||
returnValue.setRadioType(radioType);
|
||||
|
||||
if (radioType == RadioType.is5GHz) {
|
||||
returnValue.setChannelNumber(36);
|
||||
returnValue.setBackupChannelNumber(44);
|
||||
} else if (radioType == RadioType.is5GHzL) {
|
||||
returnValue.setChannelNumber(36);
|
||||
returnValue.setBackupChannelNumber(44);
|
||||
} else if (radioType == RadioType.is5GHzU) {
|
||||
returnValue.setChannelNumber(149);
|
||||
returnValue.setBackupChannelNumber(157);
|
||||
} else {
|
||||
returnValue.setChannelNumber(6);
|
||||
returnValue.setBackupChannelNumber(11);
|
||||
}
|
||||
returnValue.setChannelNumber(getDefaultChannelNumber(radioType));
|
||||
returnValue.setBackupChannelNumber(getDefaultBackupChannelNumber(radioType));
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -36,11 +36,9 @@ import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
|
||||
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
|
||||
import com.telecominfraproject.wlan.core.model.pagination.SortOrder;
|
||||
import com.telecominfraproject.wlan.core.model.pair.PairLongLong;
|
||||
import com.telecominfraproject.wlan.datastore.exceptions.DsDataValidationException;
|
||||
import com.telecominfraproject.wlan.equipment.models.AntennaType;
|
||||
import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration;
|
||||
import com.telecominfraproject.wlan.equipment.models.CellSizeAttributes;
|
||||
import com.telecominfraproject.wlan.equipment.models.ChannelPowerLevel;
|
||||
import com.telecominfraproject.wlan.equipment.models.CustomerEquipmentCounts;
|
||||
import com.telecominfraproject.wlan.equipment.models.ElementRadioConfiguration;
|
||||
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
||||
@@ -623,94 +621,6 @@ public class EquipmentServiceRemoteTest extends BaseRemoteTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquipmentUpdateChannelNumValidation() {
|
||||
|
||||
//Create new Equipment - success
|
||||
Equipment equipment = new Equipment();
|
||||
equipment.setName("testName-"+getNextEquipmentId());
|
||||
equipment.setInventoryId("test-inv-"+getNextEquipmentId());
|
||||
equipment.setEquipmentType(EquipmentType.AP);
|
||||
equipment.setDetails(ApElementConfiguration.createWithDefaults());
|
||||
|
||||
ElementRadioConfiguration element2dot4RadioConfig = ((ApElementConfiguration)equipment.getDetails()).getRadioMap().get(RadioType.is2dot4GHz);
|
||||
element2dot4RadioConfig.setAllowedChannelsPowerLevels(new HashSet<>());
|
||||
|
||||
for (int i = 1; i <= 11; i++) {
|
||||
ChannelPowerLevel cpl = new ChannelPowerLevel();
|
||||
cpl.setChannelNumber(i);
|
||||
cpl.setChannelWidth(20);
|
||||
cpl.setDfs(false);
|
||||
cpl.setPowerLevel(30);
|
||||
element2dot4RadioConfig.getAllowedChannelsPowerLevels().add(cpl);
|
||||
}
|
||||
|
||||
Equipment ret = remoteInterface.create(equipment);
|
||||
assertNotNull(ret);
|
||||
|
||||
ret = remoteInterface.get(ret.getId());
|
||||
assertEqualEquipments(equipment, ret);
|
||||
|
||||
ElementRadioConfiguration retElement2dot4RadioConfig = ((ApElementConfiguration)ret.getDetails()).getRadioMap().get(RadioType.is2dot4GHz);
|
||||
assertEquals(retElement2dot4RadioConfig.getChannelNumber().intValue(), 6);
|
||||
|
||||
//Update success
|
||||
retElement2dot4RadioConfig.setChannelNumber(1);
|
||||
retElement2dot4RadioConfig.setManualChannelNumber(2);
|
||||
retElement2dot4RadioConfig.setBackupChannelNumber(3);
|
||||
retElement2dot4RadioConfig.setManualBackupChannelNumber(4);
|
||||
|
||||
Equipment updatedEquipment = remoteInterface.update(ret);
|
||||
|
||||
Equipment retUpdate = remoteInterface.get(ret.getId());
|
||||
assertEqualEquipments(retUpdate, updatedEquipment);
|
||||
ElementRadioConfiguration ret2Element2dot4RadioConfig = ((ApElementConfiguration)retUpdate.getDetails()).getRadioMap().get(RadioType.is2dot4GHz);
|
||||
assertEquals(retElement2dot4RadioConfig.getChannelNumber().intValue(), 1);
|
||||
assertEquals(retElement2dot4RadioConfig.getManualChannelNumber().intValue(), 2);
|
||||
assertEquals(retElement2dot4RadioConfig.getBackupChannelNumber().intValue(), 3);
|
||||
assertEquals(retElement2dot4RadioConfig.getManualBackupChannelNumber().intValue(), 4);
|
||||
|
||||
//Update failure
|
||||
ret2Element2dot4RadioConfig.setChannelNumber(12);
|
||||
try {
|
||||
remoteInterface.update(retUpdate);
|
||||
fail("EquipmentService update channelNumber failed");
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
ret2Element2dot4RadioConfig.setChannelNumber(6);
|
||||
ret2Element2dot4RadioConfig.setManualChannelNumber(13);
|
||||
try {
|
||||
remoteInterface.update(retUpdate);
|
||||
fail("EquipmentService update manualChannelNumber failed");
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
ret2Element2dot4RadioConfig.setManualChannelNumber(7);
|
||||
ret2Element2dot4RadioConfig.setBackupChannelNumber(14);
|
||||
try {
|
||||
remoteInterface.update(retUpdate);
|
||||
fail("EquipmentService update backupChannelNumber failed");
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
ret2Element2dot4RadioConfig.setBackupChannelNumber(8);
|
||||
ret2Element2dot4RadioConfig.setManualBackupChannelNumber(15);
|
||||
try {
|
||||
remoteInterface.update(retUpdate);
|
||||
fail("EquipmentService update manualBackupChannelNumber failed");
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
//Tolerate null now
|
||||
ret2Element2dot4RadioConfig.setManualBackupChannelNumber(null);
|
||||
remoteInterface.update(retUpdate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPaginatedEquipmentIds()
|
||||
{
|
||||
@@ -869,7 +779,6 @@ public class EquipmentServiceRemoteTest extends BaseRemoteTest {
|
||||
|
||||
// Clean up after test
|
||||
createdSet.forEach( c-> remoteInterface.delete(c));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.telecominfraproject.wlan.equipment.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -34,7 +32,6 @@ import com.telecominfraproject.wlan.datastore.exceptions.DsDataValidationExcepti
|
||||
import com.telecominfraproject.wlan.equipment.datastore.EquipmentDatastore;
|
||||
import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration;
|
||||
import com.telecominfraproject.wlan.equipment.models.CellSizeAttributes;
|
||||
import com.telecominfraproject.wlan.equipment.models.ChannelPowerLevel;
|
||||
import com.telecominfraproject.wlan.equipment.models.CustomerEquipmentCounts;
|
||||
import com.telecominfraproject.wlan.equipment.models.ElementRadioConfiguration;
|
||||
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
||||
@@ -91,12 +88,7 @@ public class EquipmentController {
|
||||
throw new DsDataValidationException("Equipment contains unsupported value");
|
||||
}
|
||||
|
||||
long ts = System.currentTimeMillis();
|
||||
if (equipment.getCreatedTimestamp() == 0) {
|
||||
equipment.setCreatedTimestamp(ts);
|
||||
}
|
||||
equipment.setLastModifiedTimestamp(ts);
|
||||
|
||||
updateValuesIfNeeded(equipment);
|
||||
Equipment ret = equipmentDatastore.create(equipment);
|
||||
|
||||
LOG.debug("Created Equipment {}", ret);
|
||||
@@ -107,7 +99,24 @@ public class EquipmentController {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
private void updateValuesIfNeeded(Equipment equipment) {
|
||||
// strip out whitespaces from user entered inventoryId and name strings
|
||||
if (equipment.getName() != null) {
|
||||
equipment.setName(equipment.getName().strip());
|
||||
}
|
||||
if (equipment.getInventoryId() != null) {
|
||||
equipment.setInventoryId(equipment.getInventoryId().strip());
|
||||
}
|
||||
|
||||
// Update timestamp
|
||||
long ts = System.currentTimeMillis();
|
||||
if (equipment.getCreatedTimestamp() == 0) {
|
||||
equipment.setCreatedTimestamp(ts);
|
||||
}
|
||||
equipment.setLastModifiedTimestamp(ts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves Equipment by id
|
||||
* @param equipmentId
|
||||
@@ -263,14 +272,12 @@ public class EquipmentController {
|
||||
throw new DsDataValidationException("Equipment contains unsupported value");
|
||||
}
|
||||
|
||||
validateChannelNum(equipment);
|
||||
|
||||
Equipment existingEquipment = equipmentDatastore.getOrNull(equipment.getId());
|
||||
ApElementConfiguration existingApElementConfig = null;
|
||||
if (existingEquipment != null && existingEquipment.getDetails() instanceof ApElementConfiguration) {
|
||||
existingApElementConfig = (ApElementConfiguration) existingEquipment.getDetails();
|
||||
}
|
||||
|
||||
|
||||
Equipment ret = equipmentDatastore.update(equipment);
|
||||
ApElementConfiguration updatedApElementConfig = null;
|
||||
if (ret != null && ret.getDetails() instanceof ApElementConfiguration) {
|
||||
@@ -299,39 +306,6 @@ public class EquipmentController {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void validateChannelNum(Equipment equipment) {
|
||||
if (equipment.getDetails() instanceof ApElementConfiguration) {
|
||||
ApElementConfiguration apElementConfiguration = (ApElementConfiguration) equipment.getDetails();
|
||||
if (apElementConfiguration.getRadioMap() != null) {
|
||||
for (RadioType radioType : apElementConfiguration.getRadioMap().keySet()) {
|
||||
|
||||
ElementRadioConfiguration elementRadioConfig = apElementConfiguration.getRadioMap().get(radioType);
|
||||
Integer channelNum = elementRadioConfig.getChannelNumber();
|
||||
Integer manualChannelNum = elementRadioConfig.getManualChannelNumber();
|
||||
Integer backupChannelNum = elementRadioConfig.getBackupChannelNumber();
|
||||
Integer manualBackupChannelNum = elementRadioConfig.getManualBackupChannelNumber();
|
||||
|
||||
List<Integer> allowedChannels = elementRadioConfig.getAllowedChannelsPowerLevels().stream().map(ChannelPowerLevel::getChannelNumber).collect(Collectors.toList());
|
||||
|
||||
if (allowedChannels != null && !allowedChannels.isEmpty()) {
|
||||
checkAllowedChannels(channelNum, "channelNumber", allowedChannels);
|
||||
checkAllowedChannels(backupChannelNum, "backupChannelNumber", allowedChannels);
|
||||
checkAllowedChannels(manualChannelNum, "manualChannelNumber", allowedChannels);
|
||||
checkAllowedChannels(manualBackupChannelNum, "manualBackupChannelNumber", allowedChannels);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAllowedChannels(Integer channelNum, String channelType, List<Integer> allowedChannels) {
|
||||
if (channelNum != null && !allowedChannels.contains(channelNum)) {
|
||||
LOG.error("Failed to update Equipment. The {} ({}) is out of the allowed channels range {}",
|
||||
channelType, channelNum, allowedChannels);
|
||||
throw new DsDataValidationException("Equipment contains disallowed " + channelType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates Equipment Channels
|
||||
*
|
||||
@@ -574,25 +548,13 @@ public class EquipmentController {
|
||||
Set<Long> equipmentIds = new HashSet<>();
|
||||
request.getItems().forEach(item -> equipmentIds.add(item.getEquipmentId()));
|
||||
|
||||
//validate equipment before the bulk update
|
||||
List<Equipment> equipmentBeforeUpdate = equipmentDatastore.get(equipmentIds);
|
||||
Map<Long, Equipment> eqMap = new HashMap<>();
|
||||
equipmentBeforeUpdate.forEach(eq -> eqMap.put(eq.getId(), eq));
|
||||
|
||||
request.getItems().forEach(item -> {
|
||||
Equipment eq = eqMap.get(item.getEquipmentId());
|
||||
if(item.applyToEquipment(eq)) {
|
||||
validateChannelNum(eq);
|
||||
}
|
||||
});
|
||||
|
||||
equipmentDatastore.updateRrmBulk(request);
|
||||
|
||||
//send events after the bulk update
|
||||
List<Equipment> equipmentAfterUpdate = equipmentDatastore.get(equipmentIds);
|
||||
|
||||
List<SystemEvent> events = new ArrayList<>();
|
||||
equipmentAfterUpdate.forEach(eq -> events.add(new EquipmentChangedEvent(eq)));
|
||||
equipmentAfterUpdate.forEach(eq -> events.add(new EquipmentApImpactingChangedEvent(eq)));
|
||||
publishEvents(events);
|
||||
|
||||
return new GenericResponse(true, "");
|
||||
|
||||
@@ -71,11 +71,33 @@ public class EquipmentControllerTest {
|
||||
equipmentController.delete(ret.getId());
|
||||
|
||||
}
|
||||
|
||||
private void assertEqualEquipments(
|
||||
Equipment expected,
|
||||
Equipment actual) {
|
||||
|
||||
|
||||
@Test
|
||||
public void testEquipmentCRUD_ValidateSpaceInInputString() {
|
||||
|
||||
//Create new Equipment - success
|
||||
Equipment equipment = new Equipment();
|
||||
equipment.setName(" nameAndInventoryIdWithTrailingSpaces ");
|
||||
equipment.setInventoryId(" C4411EAA31F5 ");
|
||||
equipment.setEquipmentType(EquipmentType.AP);
|
||||
|
||||
Equipment ret = equipmentController.create(equipment);
|
||||
assertNotNull(ret);
|
||||
|
||||
ret = equipmentController.get(ret.getId());
|
||||
assertEqualEquipments(equipment, ret);
|
||||
|
||||
ret = equipmentController.getOrNull(ret.getId());
|
||||
assertEqualEquipments(equipment, ret);
|
||||
|
||||
assertNull(equipmentController.getOrNull(-1));
|
||||
|
||||
//Delete - success
|
||||
equipmentController.delete(ret.getId());
|
||||
|
||||
}
|
||||
|
||||
private void assertEqualEquipments(Equipment expected, Equipment actual) {
|
||||
assertEquals(expected.getName(), actual.getName());
|
||||
//TODO: add more fields to check here
|
||||
}
|
||||
|
||||
@@ -209,6 +209,7 @@ public class CustomerFirmwareTrackDAO extends BaseJdbcDao {
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Transactional(noRollbackFor = { EmptyResultDataAccessException.class })
|
||||
public CustomerFirmwareTrackRecord getCustomerFirmwareTrackRecord(int customerId) {
|
||||
CustomerFirmwareTrackRecord ret = null;
|
||||
try {
|
||||
|
||||
@@ -57,6 +57,7 @@ public interface FirmwareServiceInterface {
|
||||
CustomerFirmwareTrackRecord updateCustomerFirmwareTrackRecord(CustomerFirmwareTrackRecord record);
|
||||
CustomerFirmwareTrackRecord deleteCustomerFirmwareTrackRecord(int customerId);
|
||||
CustomerFirmwareTrackSettings getDefaultCustomerTrackSetting();
|
||||
CustomerFirmwareTrackSettings updateDefaultCustomerTrackSetting(CustomerFirmwareTrackSettings defaultSettings);
|
||||
|
||||
/**
|
||||
* @param equipmentType
|
||||
|
||||
@@ -81,6 +81,9 @@ public class FirmwareServiceLocal implements FirmwareServiceInterface {
|
||||
public CustomerFirmwareTrackSettings getDefaultCustomerTrackSetting() {
|
||||
return firmwareController.getDefaultCustomerTrackSetting();
|
||||
}
|
||||
public CustomerFirmwareTrackSettings updateDefaultCustomerTrackSetting(CustomerFirmwareTrackSettings defaultSettings) {
|
||||
return firmwareController.updateDefaultCustomerTrackSetting(defaultSettings);
|
||||
}
|
||||
public CustomerFirmwareTrackRecord getCustomerFirmwareTrackRecord(int customerId) {
|
||||
return firmwareController.getCustomerFirmwareTrackRecord(customerId);
|
||||
}
|
||||
|
||||
@@ -387,6 +387,21 @@ public class FirmwareServiceRemote extends BaseRemoteClient implements FirmwareS
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CustomerFirmwareTrackSettings updateDefaultCustomerTrackSetting(CustomerFirmwareTrackSettings defaultSettings) {
|
||||
LOG.debug("calling updateDefaultCustomerTrackSetting {} ", defaultSettings);
|
||||
|
||||
ResponseEntity<CustomerFirmwareTrackSettings> responseEntity = restTemplate.exchange(
|
||||
getBaseUrl()
|
||||
+"/customerTrack/default", HttpMethod.PUT, null,
|
||||
CustomerFirmwareTrackSettings.class, defaultSettings);
|
||||
|
||||
CustomerFirmwareTrackSettings ret = responseEntity.getBody();
|
||||
|
||||
LOG.debug("completed updateDefaultCustomerTrackSetting {} ", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.telecominfraproject.wlan.firmware.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -22,11 +20,11 @@ import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundExcepti
|
||||
import com.telecominfraproject.wlan.firmware.datastore.FirmwareDatastore;
|
||||
import com.telecominfraproject.wlan.firmware.models.CustomerFirmwareTrackRecord;
|
||||
import com.telecominfraproject.wlan.firmware.models.CustomerFirmwareTrackSettings;
|
||||
import com.telecominfraproject.wlan.firmware.models.CustomerFirmwareTrackSettings.TrackFlag;
|
||||
import com.telecominfraproject.wlan.firmware.models.FirmwareTrackAssignmentDetails;
|
||||
import com.telecominfraproject.wlan.firmware.models.FirmwareTrackAssignmentRecord;
|
||||
import com.telecominfraproject.wlan.firmware.models.FirmwareTrackRecord;
|
||||
import com.telecominfraproject.wlan.firmware.models.FirmwareVersion;
|
||||
import com.telecominfraproject.wlan.firmware.models.CustomerFirmwareTrackSettings.TrackFlag;
|
||||
import com.telecominfraproject.wlan.systemevent.models.SystemEvent;
|
||||
|
||||
|
||||
@@ -44,35 +42,11 @@ public class FirmwareController {
|
||||
@Autowired private FirmwareDatastore firmwareDatastore;
|
||||
@Autowired private CloudEventDispatcherInterface cloudEventDispatcher;
|
||||
@Autowired Environment environment;
|
||||
|
||||
CustomerFirmwareTrackSettings defaultCustomerTrackSettings;
|
||||
|
||||
@PostConstruct
|
||||
private void postConstruct() {
|
||||
defaultCustomerTrackSettings = new CustomerFirmwareTrackSettings();
|
||||
defaultCustomerTrackSettings.setAutoUpgradeDeprecatedOnBind(environment
|
||||
.getProperty("whizcontrol.autoupgrade.deprecated", TrackFlag.class, TrackFlag.NEVER));
|
||||
defaultCustomerTrackSettings.setAutoUpgradeUnknownOnBind(environment
|
||||
.getProperty("whizcontrol.autoupgrade.unknown", TrackFlag.class, TrackFlag.NEVER));
|
||||
defaultCustomerTrackSettings.setAutoUpgradeDeprecatedDuringMaintenance(environment.getProperty(
|
||||
"whizcontrol.maintenanceupgrade.deprecated", TrackFlag.class, TrackFlag.NEVER));
|
||||
defaultCustomerTrackSettings.setAutoUpgradeUnknownDuringMaintenance(environment
|
||||
.getProperty("whizcontrol.maintenanceupgrade.unknown", TrackFlag.class, TrackFlag.NEVER));
|
||||
LOG.info("Default CustomerFirmwareTrackSettings: {}", defaultCustomerTrackSettings);
|
||||
}
|
||||
|
||||
private void publishEvent(SystemEvent event) {
|
||||
if (event == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
cloudEventDispatcher.publishEvent(event);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to publish event : {}", event, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* FirmwareVersion API
|
||||
*/
|
||||
@RequestMapping(value = "/version", method = RequestMethod.POST)
|
||||
public FirmwareVersion createFirmwareVersion(@RequestBody FirmwareVersion firmwareVersion) {
|
||||
|
||||
@@ -149,6 +123,10 @@ public class FirmwareController {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* FirmwareTrackRecord API
|
||||
*/
|
||||
@RequestMapping(value = "/track", method = RequestMethod.POST)
|
||||
public FirmwareTrackRecord createFirmwareTrack(@RequestBody FirmwareTrackRecord firmwareTrack) {
|
||||
LOG.debug("calling createFirmwareTrack({})", firmwareTrack);
|
||||
@@ -193,7 +171,10 @@ public class FirmwareController {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* FirmwareTrackAssignmentDetails API
|
||||
*/
|
||||
@RequestMapping(value = "/trackAssignment", method = RequestMethod.GET)
|
||||
public List<FirmwareTrackAssignmentDetails> getFirmwareTrackAssignments (
|
||||
@RequestParam String firmwareTrackName) {
|
||||
@@ -220,33 +201,50 @@ public class FirmwareController {
|
||||
FirmwareTrackAssignmentDetails result = new FirmwareTrackAssignmentDetails(assignment, version);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* CustomerFirmwareTrackSettings API
|
||||
*/
|
||||
@RequestMapping(value = "/customerTrack/default", method = RequestMethod.GET)
|
||||
public CustomerFirmwareTrackSettings getDefaultCustomerTrackSetting() {
|
||||
if (defaultCustomerTrackSettings == null) {
|
||||
if (defaultCustomerTrackSettings == null) {
|
||||
defaultCustomerTrackSettings = new CustomerFirmwareTrackSettings();
|
||||
defaultCustomerTrackSettings.setAutoUpgradeDeprecatedOnBind(environment
|
||||
.getProperty("whizcontrol.autoupgrade.deprecated", TrackFlag.class, TrackFlag.NEVER));
|
||||
defaultCustomerTrackSettings.setAutoUpgradeUnknownOnBind(environment
|
||||
.getProperty("whizcontrol.autoupgrade.unknown", TrackFlag.class, TrackFlag.NEVER));
|
||||
defaultCustomerTrackSettings.setAutoUpgradeDeprecatedDuringMaintenance(environment.getProperty(
|
||||
"whizcontrol.maintenanceupgrade.deprecated", TrackFlag.class, TrackFlag.NEVER));
|
||||
defaultCustomerTrackSettings.setAutoUpgradeUnknownDuringMaintenance(environment
|
||||
.getProperty("whizcontrol.maintenanceupgrade.unknown", TrackFlag.class, TrackFlag.NEVER));
|
||||
LOG.info("Default CustomerFirmwareTrackSettings: {}", defaultCustomerTrackSettings);
|
||||
}
|
||||
CustomerFirmwareTrackRecord defaultRecord = firmwareDatastore.getCustomerFirmwareTrackRecord(0);
|
||||
if (defaultRecord == null) {
|
||||
LOG.debug("No default record exists, creating the default");
|
||||
defaultRecord = new CustomerFirmwareTrackRecord();
|
||||
defaultRecord.setCustomerId(0);
|
||||
CustomerFirmwareTrackSettings defaultSettings = new CustomerFirmwareTrackSettings();
|
||||
defaultSettings.setAutoUpgradeDeprecatedOnBind(TrackFlag.NEVER);
|
||||
defaultSettings.setAutoUpgradeUnknownOnBind(TrackFlag.NEVER);
|
||||
defaultSettings.setAutoUpgradeDeprecatedDuringMaintenance(TrackFlag.NEVER);
|
||||
defaultSettings.setAutoUpgradeUnknownDuringMaintenance(TrackFlag.NEVER);
|
||||
|
||||
defaultRecord.setSettings(defaultSettings);
|
||||
defaultRecord.setTrackRecordId(firmwareDatastore.getFirmwareTrackByName("DEFAULT").getRecordId());
|
||||
defaultRecord = firmwareDatastore.createCustomerFirmwareTrackRecord(defaultRecord);
|
||||
}
|
||||
return defaultCustomerTrackSettings;
|
||||
return defaultRecord.getSettings();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/customerTrack/default", method = RequestMethod.PUT)
|
||||
public CustomerFirmwareTrackSettings updateDefaultCustomerTrackSetting(@RequestBody CustomerFirmwareTrackSettings customerTrackSettings) {
|
||||
CustomerFirmwareTrackRecord defaultRecord = firmwareDatastore.getCustomerFirmwareTrackRecord(0);
|
||||
if (defaultRecord == null) {
|
||||
defaultRecord = new CustomerFirmwareTrackRecord();
|
||||
defaultRecord.setCustomerId(0);
|
||||
defaultRecord.setSettings(customerTrackSettings);
|
||||
defaultRecord.setTrackRecordId(firmwareDatastore.getFirmwareTrackByName("DEFAULT").getRecordId());
|
||||
return firmwareDatastore.createCustomerFirmwareTrackRecord(defaultRecord).getSettings();
|
||||
}
|
||||
defaultRecord.setSettings(customerTrackSettings);
|
||||
return firmwareDatastore.updateCustomerFirmwareTrackRecord(defaultRecord).getSettings();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/customerTrack", method = RequestMethod.GET)
|
||||
public CustomerFirmwareTrackRecord getCustomerFirmwareTrackRecord(@RequestParam int customerId) {
|
||||
LOG.debug("calling getCustomerFirmwareTrackRecord({})", customerId);
|
||||
return firmwareDatastore.getCustomerFirmwareTrackRecord(customerId);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/customerTrack", method = RequestMethod.POST)
|
||||
public CustomerFirmwareTrackRecord createCustomerFirmwareTrackRecord(@RequestBody CustomerFirmwareTrackRecord customerTrack) {
|
||||
@@ -255,7 +253,6 @@ public class FirmwareController {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/customerTrack", method = RequestMethod.PUT)
|
||||
public CustomerFirmwareTrackRecord updateCustomerFirmwareTrackRecord(@RequestBody CustomerFirmwareTrackRecord customerTrack) {
|
||||
LOG.debug("calling updateCustomerFirmwareTrackRecord({})", customerTrack);
|
||||
@@ -270,8 +267,6 @@ public class FirmwareController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/customerTrack", method = RequestMethod.DELETE)
|
||||
public CustomerFirmwareTrackRecord deleteCustomerFirmwareTrackRecord(@RequestParam int customerId) {
|
||||
@@ -279,6 +274,17 @@ public class FirmwareController {
|
||||
CustomerFirmwareTrackRecord result = firmwareDatastore.deleteCustomerFirmwareTrackRecord(customerId);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private void publishEvent(SystemEvent event) {
|
||||
if (event == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
cloudEventDispatcher.publishEvent(event);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to publish event : {}", event, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -619,11 +619,12 @@ paths:
|
||||
$ref: '#/components/schemas/FirmwareTrackAssignmentDetails'
|
||||
500:
|
||||
$ref: '#/components/responses/GenericApiError'
|
||||
|
||||
/api/firmware/customerTrack/default:
|
||||
get:
|
||||
tags:
|
||||
- Firmware Data
|
||||
summary: Get customer firmware track settings
|
||||
summary: Get customer firmware track settings, if it doesn't exist, create it
|
||||
operationId: getCustomerFirmwareTrackSettings
|
||||
responses:
|
||||
200:
|
||||
@@ -634,6 +635,27 @@ paths:
|
||||
$ref: '#/components/schemas/CustomerFirmwareTrackSettings'
|
||||
500:
|
||||
$ref: '#/components/responses/GenericApiError'
|
||||
put:
|
||||
tags:
|
||||
- Firmware Data
|
||||
summary: Update customer firmware track settings, if it doesn't exist, create it
|
||||
operationId: updateCustomerFirmwareTrackSettings
|
||||
requestBody:
|
||||
description: CustomerFirmwareTrackSettings
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CustomerFirmwareTrackSettings'
|
||||
responses:
|
||||
200:
|
||||
description: Successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CustomerFirmwareTrackSettings'
|
||||
500:
|
||||
$ref: '#/components/responses/GenericApiError'
|
||||
|
||||
/api/firmware/customerTrack:
|
||||
post:
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.telecominfraproject.wlan.location.models.events;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.json.interfaces.HasLocationId;
|
||||
import com.telecominfraproject.wlan.location.models.Location;
|
||||
import com.telecominfraproject.wlan.systemevent.models.CustomerEventWithPayload;
|
||||
|
||||
public class LocationChangedApImpactingEvent extends CustomerEventWithPayload<Location> implements HasLocationId {
|
||||
private static final long serialVersionUID = -8369849230866347412L;
|
||||
|
||||
public LocationChangedApImpactingEvent(Location location){
|
||||
super(location.getCustomerId(), location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLocationId() {
|
||||
if (getPayload() != null) {
|
||||
return getPayload().getId();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used by JSON
|
||||
*/
|
||||
public LocationChangedApImpactingEvent() {
|
||||
super(0, 0, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class LocationServiceRemoteTest extends BaseRemoteTest {
|
||||
location.setLocationType(LocationType.FLOOR);
|
||||
location.setCustomerId(getNextCustomerId());
|
||||
location.setName("testName_updated");
|
||||
location.setDetails(generateDetails(CountryCode.US));
|
||||
location.setDetails(generateDetails(CountryCode.CA));
|
||||
|
||||
Location retFromUpdate = testInterface.update(location);
|
||||
assertFieldEquals(location, retFromUpdate);
|
||||
@@ -95,6 +95,14 @@ public class LocationServiceRemoteTest extends BaseRemoteTest {
|
||||
// expected it
|
||||
}
|
||||
|
||||
//UPDATE test - fail because country code cannot be modified once created
|
||||
try {
|
||||
location.setDetails(generateDetails(CountryCode.US));
|
||||
testInterface.update(location);
|
||||
fail("failed to detect country code update");
|
||||
} catch (IllegalStateException e) {
|
||||
// expected it
|
||||
}
|
||||
|
||||
//DELETE Test
|
||||
testInterface.delete(ret.getId());
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundExcepti
|
||||
import com.telecominfraproject.wlan.location.datastore.LocationDatastore;
|
||||
import com.telecominfraproject.wlan.location.models.Location;
|
||||
import com.telecominfraproject.wlan.location.models.events.LocationAddedEvent;
|
||||
import com.telecominfraproject.wlan.location.models.events.LocationChangedApImpactingEvent;
|
||||
import com.telecominfraproject.wlan.location.models.events.LocationChangedEvent;
|
||||
import com.telecominfraproject.wlan.location.models.events.LocationRemovedEvent;
|
||||
import com.telecominfraproject.wlan.systemevent.models.SystemEvent;
|
||||
@@ -97,14 +96,15 @@ public class LocationServiceController {
|
||||
}
|
||||
|
||||
Location existingLocation = locationDatastore.get(location.getId());
|
||||
|
||||
if (location.needsToBeUpdatedOnDevice(existingLocation)) {
|
||||
throw new IllegalStateException("Cannot update location. Country code is not allow to modify once created.");
|
||||
}
|
||||
|
||||
Location ret = locationDatastore.update(location);
|
||||
|
||||
List<SystemEvent> events = new ArrayList<>();
|
||||
|
||||
if (ret.needsToBeUpdatedOnDevice(existingLocation)) {
|
||||
events.add(new LocationChangedApImpactingEvent(ret));
|
||||
}
|
||||
events.add(new LocationChangedEvent(ret));
|
||||
|
||||
publishEvents(events);
|
||||
|
||||
@@ -161,6 +161,42 @@
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>location-service-local</artifactId>
|
||||
<groupId>com.telecominfraproject.wlan</groupId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>location-datastore-inmemory</artifactId>
|
||||
<groupId>com.telecominfraproject.wlan</groupId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>alarm-service-local</artifactId>
|
||||
<groupId>com.telecominfraproject.wlan</groupId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>alarm-datastore-inmemory</artifactId>
|
||||
<groupId>com.telecominfraproject.wlan</groupId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>status-service-local</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>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -27,8 +29,10 @@ import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
|
||||
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
|
||||
import com.telecominfraproject.wlan.core.model.pair.PairLongLong;
|
||||
import com.telecominfraproject.wlan.datastore.exceptions.DsConcurrentModificationException;
|
||||
import com.telecominfraproject.wlan.datastore.exceptions.DsDataValidationException;
|
||||
import com.telecominfraproject.wlan.equipment.EquipmentServiceInterface;
|
||||
import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration;
|
||||
import com.telecominfraproject.wlan.equipment.models.ChannelPowerLevel;
|
||||
import com.telecominfraproject.wlan.equipment.models.ElementRadioConfiguration;
|
||||
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
||||
import com.telecominfraproject.wlan.equipment.models.EquipmentCellSizeAttributesUpdateRequest;
|
||||
@@ -36,7 +40,9 @@ import com.telecominfraproject.wlan.equipment.models.EquipmentChannelsUpdateRequ
|
||||
import com.telecominfraproject.wlan.equipment.models.EquipmentDetails;
|
||||
import com.telecominfraproject.wlan.equipment.models.RadioConfiguration;
|
||||
import com.telecominfraproject.wlan.equipment.models.bulkupdate.rrm.EquipmentRrmBulkUpdateRequest;
|
||||
import com.telecominfraproject.wlan.location.service.LocationServiceInterface;
|
||||
import com.telecominfraproject.wlan.profile.ProfileServiceInterface;
|
||||
import com.telecominfraproject.wlan.location.models.Location;
|
||||
import com.telecominfraproject.wlan.status.StatusServiceInterface;
|
||||
|
||||
/**
|
||||
@@ -48,6 +54,9 @@ import com.telecominfraproject.wlan.status.StatusServiceInterface;
|
||||
public class EquipmentPortalController {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(EquipmentPortalController.class);
|
||||
|
||||
public static enum CHANNEL_NUMBER_TYPE {channelNumber, backupChannelNumber, manualChannelNumber,
|
||||
manualBackupChannelNumber};
|
||||
|
||||
@Value("${tip.wlan.portal.equipment.numRetryUpdate:10}")
|
||||
private int numRetryUpdate;
|
||||
@@ -71,6 +80,9 @@ public class EquipmentPortalController {
|
||||
|
||||
@Autowired
|
||||
private ProfileServiceInterface profileServiceInterface;
|
||||
|
||||
@Autowired
|
||||
private LocationServiceInterface locationServiceInterface;
|
||||
|
||||
@RequestMapping(value = "/equipment", method = RequestMethod.GET)
|
||||
public Equipment getEquipment(@RequestParam long equipmentId) {
|
||||
@@ -86,14 +98,25 @@ public class EquipmentPortalController {
|
||||
LOG.debug("Updating equipment {}", equipment.getId());
|
||||
|
||||
Equipment ret = null;
|
||||
Equipment existing = equipmentServiceInterface.getOrNull(equipment.getId());
|
||||
|
||||
for(int i=0; i<numRetryUpdate; i++) {
|
||||
try {
|
||||
if (equipment != null && existing != null && equipment.getLocationId() != existing.getLocationId()) {
|
||||
Location location = locationServiceInterface.get(equipment.getLocationId());
|
||||
Location existingLocation = locationServiceInterface.get(existing.getLocationId());
|
||||
|
||||
if (!Objects.equals(Location.getCountryCode(location), Location.getCountryCode(existingLocation))) {
|
||||
updateEquipmentWithDefaultChannels(equipment);
|
||||
}
|
||||
}
|
||||
validateChannelNum(equipment);
|
||||
|
||||
ret = equipmentServiceInterface.update(equipment);
|
||||
break;
|
||||
} catch (DsConcurrentModificationException e) {
|
||||
LOG.debug("Equipment was concurrently updated, retrying: {}", e.getMessage());
|
||||
Equipment existing = equipmentServiceInterface.getOrNull(equipment.getId());
|
||||
existing = equipmentServiceInterface.getOrNull(equipment.getId());
|
||||
equipment.setLastModifiedTimestamp(existing.getLastModifiedTimestamp());
|
||||
}
|
||||
}
|
||||
@@ -105,9 +128,115 @@ public class EquipmentPortalController {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void updateEquipmentWithDefaultChannels(Equipment equipment) {
|
||||
if (equipment.getDetails() instanceof ApElementConfiguration) {
|
||||
ApElementConfiguration apElementConfiguration = (ApElementConfiguration) equipment.getDetails();
|
||||
if (apElementConfiguration.getRadioMap() != null) {
|
||||
|
||||
for (RadioType radioType : apElementConfiguration.getRadioMap().keySet()) {
|
||||
ElementRadioConfiguration elementRadioConfig = apElementConfiguration.getRadioMap().get(radioType);
|
||||
|
||||
elementRadioConfig.setChannelNumber(ElementRadioConfiguration.getDefaultChannelNumber(radioType));
|
||||
elementRadioConfig.setBackupChannelNumber(ElementRadioConfiguration.getDefaultBackupChannelNumber(radioType));
|
||||
elementRadioConfig.setManualChannelNumber(ElementRadioConfiguration.getDefaultChannelNumber(radioType));
|
||||
elementRadioConfig.setManualBackupChannelNumber(ElementRadioConfiguration.getDefaultBackupChannelNumber(radioType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void validateChannelNum(Equipment equipment) {
|
||||
if (equipment != null && equipment.getDetails() instanceof ApElementConfiguration) {
|
||||
ApElementConfiguration apElementConfiguration = (ApElementConfiguration) equipment.getDetails();
|
||||
if (apElementConfiguration.getRadioMap() != null) {
|
||||
|
||||
for (RadioType radioType : apElementConfiguration.getRadioMap().keySet()) {
|
||||
ElementRadioConfiguration elementRadioConfig = apElementConfiguration.getRadioMap().get(radioType);
|
||||
List<Integer> allowedChannels = elementRadioConfig.getAllowedChannelsPowerLevels().stream().map(
|
||||
ChannelPowerLevel::getChannelNumber).collect(Collectors.toList());
|
||||
|
||||
if (allowedChannels != null && !allowedChannels.isEmpty()) {
|
||||
for (CHANNEL_NUMBER_TYPE channelType : CHANNEL_NUMBER_TYPE.values()) {
|
||||
checkAllowedChannels(equipment.getId(), elementRadioConfig, channelType, allowedChannels, radioType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Integer getChannelNumber( ElementRadioConfiguration elementRadioConfig, CHANNEL_NUMBER_TYPE channelType) {
|
||||
Integer channelNum = null;
|
||||
|
||||
switch (channelType) {
|
||||
case channelNumber: {
|
||||
channelNum = elementRadioConfig.getChannelNumber();
|
||||
break;
|
||||
}
|
||||
case backupChannelNumber: {
|
||||
channelNum = elementRadioConfig.getBackupChannelNumber();
|
||||
break;
|
||||
}
|
||||
case manualChannelNumber: {
|
||||
channelNum = elementRadioConfig.getManualChannelNumber();
|
||||
break;
|
||||
}
|
||||
case manualBackupChannelNumber: {
|
||||
channelNum = elementRadioConfig.getManualBackupChannelNumber();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return channelNum;
|
||||
}
|
||||
|
||||
private void checkAllowedChannels(long equipmentId, ElementRadioConfiguration elementRadioConfig, CHANNEL_NUMBER_TYPE channelType,
|
||||
List<Integer> allowedChannels, RadioType radioType) {
|
||||
Integer channelNum = getChannelNumber(elementRadioConfig, channelType);
|
||||
|
||||
checkAllowedChannels(equipmentId, channelNum, channelType, allowedChannels, radioType);
|
||||
}
|
||||
|
||||
private void checkAllowedChannels(long equipmentId, Integer channelNum, CHANNEL_NUMBER_TYPE channelType,
|
||||
List<Integer> allowedChannels, RadioType radioType) {
|
||||
if (channelNum != null && !allowedChannels.contains(channelNum)) {
|
||||
LOG.error("Failed to update Equipment {}. The {} ({}) is out of the allowed channels range {} for radioType {}",
|
||||
equipmentId, channelType, channelNum, allowedChannels, radioType);
|
||||
throw new DsDataValidationException("Failed to update Equipment. The " + channelType + "(" + channelNum +
|
||||
") is out of the allowed channels range " + allowedChannels + " for radioType " +
|
||||
RadioType.getRadioDisplayString(radioType));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/equipment/channel", method = RequestMethod.PUT)
|
||||
public Equipment updateEquipmentChannels(@RequestBody EquipmentChannelsUpdateRequest request) {
|
||||
LOG.debug("updateEquipmentChannels {}", request);
|
||||
|
||||
Map<RadioType, Integer> primaryChannels = request.getPrimaryChannels();
|
||||
Map<RadioType, Integer> backupChannels = request.getBackupChannels();
|
||||
long equipmentId = request.getEquipmentId();
|
||||
|
||||
Equipment existing = equipmentServiceInterface.getOrNull(equipmentId);
|
||||
if (existing != null && existing.getDetails() instanceof ApElementConfiguration) {
|
||||
ApElementConfiguration apElementConfiguration = (ApElementConfiguration) existing.getDetails();
|
||||
if (apElementConfiguration.getRadioMap() != null) {
|
||||
|
||||
for (RadioType radioType : apElementConfiguration.getRadioMap().keySet()) {
|
||||
ElementRadioConfiguration elementRadioConfig = apElementConfiguration.getRadioMap().get(radioType);
|
||||
List<Integer> allowedChannels = elementRadioConfig.getAllowedChannelsPowerLevels().stream().map(
|
||||
ChannelPowerLevel::getChannelNumber).collect(Collectors.toList());
|
||||
|
||||
if (allowedChannels != null && !allowedChannels.isEmpty()) {
|
||||
if (primaryChannels != null && primaryChannels.get(radioType) != null) {
|
||||
checkAllowedChannels(equipmentId, primaryChannels.get(radioType), CHANNEL_NUMBER_TYPE.channelNumber, allowedChannels, radioType);
|
||||
}
|
||||
if (backupChannels != null && backupChannels.get(radioType) != null) {
|
||||
checkAllowedChannels(equipmentId, backupChannels.get(radioType), CHANNEL_NUMBER_TYPE.backupChannelNumber, allowedChannels, radioType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return equipmentServiceInterface.updateChannels(request);
|
||||
}
|
||||
|
||||
@@ -302,6 +431,20 @@ public class EquipmentPortalController {
|
||||
@RequestMapping(value = "/equipment/rrmBulk", method=RequestMethod.PUT)
|
||||
public GenericResponse updateRrmBulk(@RequestBody EquipmentRrmBulkUpdateRequest request) {
|
||||
LOG.debug("updateRrmBulk {}", request);
|
||||
|
||||
//validate equipment before the bulk update
|
||||
Set<Long> equipmentIds = new HashSet<>();
|
||||
request.getItems().forEach(item -> equipmentIds.add(item.getEquipmentId()));
|
||||
List<Equipment> equipmentBeforeUpdate = equipmentServiceInterface.get(equipmentIds);
|
||||
Map<Long, Equipment> eqMap = new HashMap<>();
|
||||
equipmentBeforeUpdate.forEach(eq -> eqMap.put(eq.getId(), eq));
|
||||
|
||||
request.getItems().forEach(item -> {
|
||||
Equipment eq = eqMap.get(item.getEquipmentId());
|
||||
if(item.applyToEquipment(eq)) {
|
||||
validateChannelNum(eq);
|
||||
}
|
||||
});
|
||||
equipmentServiceInterface.updateRrmBulk(request);
|
||||
return new GenericResponse(true, "");
|
||||
}
|
||||
|
||||
@@ -173,6 +173,11 @@ public class FirmwarePortalController {
|
||||
return firmwareServiceInterface.getDefaultCustomerTrackSetting();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/customerTrack/default", method = RequestMethod.PUT)
|
||||
public CustomerFirmwareTrackSettings updateDefaultCustomerTrackSetting(@RequestBody CustomerFirmwareTrackSettings defaultSettings) {
|
||||
LOG.debug("calling updateDefaultCustomerTrackSetting({})", defaultSettings);
|
||||
return firmwareServiceInterface.updateDefaultCustomerTrackSetting(defaultSettings);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/customerTrack", method = RequestMethod.GET)
|
||||
public CustomerFirmwareTrackRecord getCustomerFirmwareTrackRecord(@RequestParam int customerId) {
|
||||
|
||||
@@ -1804,6 +1804,8 @@ components:
|
||||
type: boolean
|
||||
equipmentDiscovery:
|
||||
type: boolean
|
||||
dynamicRadiusProxyEnabled:
|
||||
type: boolean
|
||||
greTunnelConfigurations:
|
||||
type: array
|
||||
items:
|
||||
@@ -1867,6 +1869,9 @@ components:
|
||||
sharedSecret:
|
||||
type: string
|
||||
format: password
|
||||
radiusProxySecret:
|
||||
type: string
|
||||
format: password
|
||||
dynamicDiscovery:
|
||||
description: Dynamic discovery of HSP and IdPs (home service and identity providers). Regardless of configured value, this will only be set 'true' on the AP if useRadSec is also true.
|
||||
type: boolean
|
||||
@@ -3330,7 +3335,17 @@ components:
|
||||
type: integer
|
||||
format: int64
|
||||
|
||||
|
||||
ChannelBandwidthPerRadioTypeMap:
|
||||
properties:
|
||||
is5GHz:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
is5GHzU:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
is5GHzL:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
is2dot4GHz:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
|
||||
EquipmentAdminStatusData:
|
||||
type: object
|
||||
properties:
|
||||
@@ -4318,6 +4333,8 @@ components:
|
||||
- RADIO_CHANNEL
|
||||
channelNumberStatusDataMap:
|
||||
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
||||
channelBandwidthStatusDataMap:
|
||||
$ref: '#/components/schemas/ChannelBandwidthPerRadioTypeMap'
|
||||
txPowerDataMap:
|
||||
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
||||
|
||||
@@ -10354,7 +10371,7 @@ paths:
|
||||
get:
|
||||
tags:
|
||||
- Firmware Management
|
||||
summary: Get default settings for handling automatic firmware upgrades
|
||||
summary: Get default settings for handling automatic firmware upgrades, if it doesn't exist, create it
|
||||
operationId: getDefaultCustomerTrackSetting
|
||||
responses:
|
||||
200:
|
||||
@@ -10365,6 +10382,27 @@ paths:
|
||||
$ref: '#/components/schemas/CustomerFirmwareTrackSettings'
|
||||
500:
|
||||
$ref: '#/components/responses/GenericApiError'
|
||||
put:
|
||||
tags:
|
||||
- Firmware Management
|
||||
summary: Update default settings for handling automatic firmware upgrades, if it doesn't exist, create it
|
||||
operationId: updateDefaultCustomerTrackSetting
|
||||
requestBody:
|
||||
description: CustomerFirmwareTrackSettings
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CustomerFirmwareTrackSettings'
|
||||
responses:
|
||||
200:
|
||||
description: successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CustomerFirmwareTrackSettings'
|
||||
500:
|
||||
$ref: '#/components/responses/GenericApiError'
|
||||
|
||||
/portal/firmware/customerTrack:
|
||||
post:
|
||||
|
||||
@@ -0,0 +1,509 @@
|
||||
package com.telecominfraproject.wlan.portal.controller.equipment;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.telecominfraproject.wlan.alarm.AlarmServiceLocal;
|
||||
import com.telecominfraproject.wlan.alarm.controller.AlarmController;
|
||||
import com.telecominfraproject.wlan.alarm.datastore.inmemory.AlarmDatastoreInMemory;
|
||||
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherEmpty;
|
||||
import com.telecominfraproject.wlan.core.model.entity.CountryCode;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||
import com.telecominfraproject.wlan.datastore.exceptions.DsDataValidationException;
|
||||
import com.telecominfraproject.wlan.equipment.EquipmentServiceLocal;
|
||||
import com.telecominfraproject.wlan.equipment.controller.EquipmentController;
|
||||
import com.telecominfraproject.wlan.equipment.datastore.inmemory.EquipmentDatastoreInMemory;
|
||||
import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration;
|
||||
import com.telecominfraproject.wlan.equipment.models.ChannelPowerLevel;
|
||||
import com.telecominfraproject.wlan.equipment.models.ElementRadioConfiguration;
|
||||
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
||||
import com.telecominfraproject.wlan.equipment.models.EquipmentChannelsUpdateRequest;
|
||||
import com.telecominfraproject.wlan.equipment.models.RadioConfiguration;
|
||||
import com.telecominfraproject.wlan.location.datastore.LocationDatastore;
|
||||
import com.telecominfraproject.wlan.location.datastore.inmemory.LocationDatastoreInMemory;
|
||||
import com.telecominfraproject.wlan.location.models.Location;
|
||||
import com.telecominfraproject.wlan.location.models.LocationDetails;
|
||||
import com.telecominfraproject.wlan.location.models.LocationType;
|
||||
import com.telecominfraproject.wlan.location.service.LocationServiceController;
|
||||
import com.telecominfraproject.wlan.location.service.LocationServiceLocal;
|
||||
import com.telecominfraproject.wlan.profile.ProfileServiceLocal;
|
||||
import com.telecominfraproject.wlan.profile.controller.ProfileController;
|
||||
import com.telecominfraproject.wlan.profile.datastore.inmemory.ProfileDatastoreInMemory;
|
||||
import com.telecominfraproject.wlan.profile.models.ProfileByCustomerRequestFactory;
|
||||
import com.telecominfraproject.wlan.status.StatusServiceLocal;
|
||||
import com.telecominfraproject.wlan.status.controller.StatusController;
|
||||
import com.telecominfraproject.wlan.status.datastore.inmemory.StatusDatastoreInMemory;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@ActiveProfiles(profiles = {
|
||||
"integration_test",
|
||||
}) //NOTE: these profiles will be ADDED to the list of active profiles
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.NONE, classes = EquipmentPortalControllerTest.class)
|
||||
@Import(value = {
|
||||
EquipmentServiceLocal.class,
|
||||
EquipmentController.class,
|
||||
EquipmentDatastoreInMemory.class,
|
||||
EquipmentPortalController.class,
|
||||
LocationServiceLocal.class,
|
||||
LocationServiceController.class,
|
||||
LocationDatastoreInMemory.class,
|
||||
CloudEventDispatcherEmpty.class,
|
||||
AlarmServiceLocal.class,
|
||||
AlarmController.class,
|
||||
AlarmDatastoreInMemory.class,
|
||||
ProfileServiceLocal.class,
|
||||
ProfileDatastoreInMemory.class,
|
||||
ProfileController.class,
|
||||
ProfileByCustomerRequestFactory.class,
|
||||
StatusServiceLocal.class,
|
||||
StatusDatastoreInMemory.class,
|
||||
StatusController.class
|
||||
})
|
||||
public class EquipmentPortalControllerTest {
|
||||
private static AtomicLong locationIncrementer = new AtomicLong(1);
|
||||
private static AtomicLong equipmentIncrementer = new AtomicLong(1);
|
||||
private static Set<Long> locationIds = new HashSet<Long>();
|
||||
private static Set<Long> equipmentIds = new HashSet<Long>();
|
||||
|
||||
@Autowired private EquipmentPortalController equipmentPortalController;
|
||||
@Autowired private LocationDatastore locationDatastore;
|
||||
|
||||
@BeforeEach
|
||||
public void setup()
|
||||
{
|
||||
locationIds.clear();
|
||||
equipmentIds.clear();
|
||||
}
|
||||
|
||||
protected Location createLocation(int customerId, LocationType locationType, CountryCode countryCode) {
|
||||
Location location = new Location();
|
||||
location.setCustomerId(customerId);
|
||||
|
||||
// Setup location details with default CmapLocationActivityDetails
|
||||
LocationDetails details = LocationDetails.createWithDefaults();
|
||||
details.setCountryCode(countryCode);
|
||||
location.setDetails(details);
|
||||
|
||||
location.setName("Location-UT" + locationIncrementer.getAndIncrement());
|
||||
location.setLocationType(locationType);
|
||||
|
||||
Location created = locationDatastore.create(location);
|
||||
assertNotNull(created);
|
||||
|
||||
return created;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquipmentUpdateChannelNumValidation() {
|
||||
|
||||
Location location = createLocation(2, LocationType.SITE, CountryCode.US);
|
||||
|
||||
//Create new Equipment - success
|
||||
Equipment equipment = new Equipment();
|
||||
equipment.setName("testName-"+ equipmentIncrementer.getAndIncrement());
|
||||
equipment.setInventoryId("test-inv-"+equipmentIncrementer.getAndIncrement());
|
||||
equipment.setEquipmentType(EquipmentType.AP);
|
||||
equipment.setLocationId(location.getId());
|
||||
equipment.setDetails(ApElementConfiguration.createWithDefaults());
|
||||
|
||||
ElementRadioConfiguration element2dot4RadioConfig = ((ApElementConfiguration)equipment.getDetails()).getRadioMap().get(RadioType.is2dot4GHz);
|
||||
element2dot4RadioConfig.setAllowedChannelsPowerLevels(new HashSet<>());
|
||||
|
||||
for (int i = 1; i <= 11; i++) {
|
||||
ChannelPowerLevel cpl = new ChannelPowerLevel();
|
||||
cpl.setChannelNumber(i);
|
||||
cpl.setChannelWidth(20);
|
||||
cpl.setDfs(false);
|
||||
cpl.setPowerLevel(30);
|
||||
element2dot4RadioConfig.getAllowedChannelsPowerLevels().add(cpl);
|
||||
}
|
||||
|
||||
Equipment ret = equipmentPortalController.createEquipment(equipment);
|
||||
assertNotNull(ret);
|
||||
long equipmentId = ret.getId();
|
||||
|
||||
ret = equipmentPortalController.getEquipment(equipmentId);
|
||||
assertEqualEquipments(equipment, ret);
|
||||
|
||||
ElementRadioConfiguration retElement2dot4RadioConfig = ((ApElementConfiguration)ret.getDetails()).getRadioMap().get(RadioType.is2dot4GHz);
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_CHANNEL_NUMBER_2DOT4GHZ, retElement2dot4RadioConfig.getChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_BACKUP_CHANNEL_NUMBER_2DOT4GHZ, retElement2dot4RadioConfig.getBackupChannelNumber().intValue());
|
||||
|
||||
//Update success
|
||||
retElement2dot4RadioConfig.setChannelNumber(1);
|
||||
retElement2dot4RadioConfig.setManualChannelNumber(2);
|
||||
retElement2dot4RadioConfig.setBackupChannelNumber(3);
|
||||
retElement2dot4RadioConfig.setManualBackupChannelNumber(4);
|
||||
|
||||
Equipment updatedEquipment = equipmentPortalController.updateEquipment(ret);
|
||||
|
||||
Equipment retUpdate = equipmentPortalController.getEquipment(ret.getId());
|
||||
assertEqualEquipments(retUpdate, updatedEquipment);
|
||||
ElementRadioConfiguration ret2Element2dot4RadioConfig = ((ApElementConfiguration)retUpdate.getDetails()).getRadioMap().get(RadioType.is2dot4GHz);
|
||||
assertEquals(1, ret2Element2dot4RadioConfig.getChannelNumber().intValue());
|
||||
assertEquals(2, ret2Element2dot4RadioConfig.getManualChannelNumber().intValue());
|
||||
assertEquals(3, ret2Element2dot4RadioConfig.getBackupChannelNumber().intValue());
|
||||
assertEquals(4, ret2Element2dot4RadioConfig.getManualBackupChannelNumber().intValue());
|
||||
|
||||
//Update failure
|
||||
ret2Element2dot4RadioConfig.setChannelNumber(12);
|
||||
try {
|
||||
equipmentPortalController.updateEquipment(retUpdate);
|
||||
fail("EquipmentService update channelNumber failed");
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
ret2Element2dot4RadioConfig.setChannelNumber(6);
|
||||
ret2Element2dot4RadioConfig.setManualChannelNumber(13);
|
||||
try {
|
||||
equipmentPortalController.updateEquipment(retUpdate);
|
||||
fail("EquipmentService update manualChannelNumber failed");
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
ret2Element2dot4RadioConfig.setManualChannelNumber(7);
|
||||
ret2Element2dot4RadioConfig.setBackupChannelNumber(14);
|
||||
try {
|
||||
equipmentPortalController.updateEquipment(retUpdate);
|
||||
fail("EquipmentService update backupChannelNumber failed");
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
ret2Element2dot4RadioConfig.setBackupChannelNumber(8);
|
||||
ret2Element2dot4RadioConfig.setManualBackupChannelNumber(15);
|
||||
try {
|
||||
equipmentPortalController.updateEquipment(retUpdate);
|
||||
fail("EquipmentService update manualBackupChannelNumber failed");
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
//Tolerate null now
|
||||
ret2Element2dot4RadioConfig.setManualBackupChannelNumber(null);
|
||||
equipmentPortalController.updateEquipment(retUpdate);
|
||||
|
||||
// Clean up after test
|
||||
equipmentPortalController.deleteEquipment(equipmentId);
|
||||
locationDatastore.delete(location.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquipmentUpdateChannelNumValidationWithCorrection() {
|
||||
Location location1 = createLocation(2, LocationType.SITE, CountryCode.US);
|
||||
Location location2 = createLocation(2, LocationType.BUILDING, CountryCode.SA);
|
||||
|
||||
|
||||
//Create new Equipment - success
|
||||
Equipment equipment = new Equipment();
|
||||
equipment.setName("testName-"+equipmentIncrementer.getAndIncrement());
|
||||
equipment.setInventoryId("test-inv-"+equipmentIncrementer.getAndIncrement());
|
||||
equipment.setEquipmentType(EquipmentType.AP);
|
||||
equipment.setLocationId(location1.getId());
|
||||
|
||||
ApElementConfiguration apConfig = ApElementConfiguration.createWithDefaults();
|
||||
if (apConfig.getElementRadioConfiguration(RadioType.is5GHz) == null) {
|
||||
Map<RadioType, ElementRadioConfiguration> radioMapInit = apConfig.getRadioMap();
|
||||
Map<RadioType, RadioConfiguration> advRadioMapInit = apConfig.getAdvancedRadioMap();
|
||||
radioMapInit.put(RadioType.is5GHz, ElementRadioConfiguration.createWithDefaults(RadioType.is5GHz));
|
||||
apConfig.setRadioMap(radioMapInit);
|
||||
advRadioMapInit.put(RadioType.is5GHz, RadioConfiguration.createWithDefaults(RadioType.is5GHz));
|
||||
apConfig.setAdvancedRadioMap(advRadioMapInit);
|
||||
}
|
||||
|
||||
equipment.setDetails(apConfig);
|
||||
|
||||
ElementRadioConfiguration element5GRadioConfig = ((ApElementConfiguration)equipment.getDetails()).getRadioMap().get(RadioType.is5GHz);
|
||||
element5GRadioConfig.setAllowedChannelsPowerLevels(new HashSet<>());
|
||||
|
||||
for (int i = 36; i <= 64; i=i+4) {
|
||||
ChannelPowerLevel cpl = new ChannelPowerLevel();
|
||||
cpl.setChannelNumber(i);
|
||||
cpl.setChannelWidth(20);
|
||||
cpl.setDfs(false);
|
||||
cpl.setPowerLevel(30);
|
||||
element5GRadioConfig.getAllowedChannelsPowerLevels().add(cpl);
|
||||
}
|
||||
for (int i = 149; i <= 161; i=i+4) {
|
||||
ChannelPowerLevel cpl = new ChannelPowerLevel();
|
||||
cpl.setChannelNumber(i);
|
||||
cpl.setChannelWidth(20);
|
||||
cpl.setDfs(false);
|
||||
cpl.setPowerLevel(30);
|
||||
element5GRadioConfig.getAllowedChannelsPowerLevels().add(cpl);
|
||||
}
|
||||
|
||||
Equipment ret = equipmentPortalController.createEquipment(equipment);
|
||||
assertNotNull(ret);
|
||||
long equipmentId = ret.getId();
|
||||
|
||||
ret = equipmentPortalController.getEquipment(equipmentId);
|
||||
assertEqualEquipments(equipment, ret);
|
||||
|
||||
ElementRadioConfiguration retElement5GRadioConfig = ((ApElementConfiguration)ret.getDetails()).getRadioMap().get(RadioType.is5GHz);
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_CHANNEL_NUMBER_5GHZ, retElement5GRadioConfig.getChannelNumber().intValue());
|
||||
assertEquals( ElementRadioConfiguration.DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZ, retElement5GRadioConfig.getBackupChannelNumber().intValue());
|
||||
|
||||
//Update success
|
||||
retElement5GRadioConfig.setChannelNumber(149);
|
||||
retElement5GRadioConfig.setManualChannelNumber(52);
|
||||
retElement5GRadioConfig.setBackupChannelNumber(157);
|
||||
retElement5GRadioConfig.setManualBackupChannelNumber(60);
|
||||
|
||||
Equipment updatedEquipment = equipmentPortalController.updateEquipment(ret);
|
||||
|
||||
Equipment retUpdate = equipmentPortalController.getEquipment(ret.getId());
|
||||
assertEqualEquipments(retUpdate, updatedEquipment);
|
||||
ElementRadioConfiguration ret2Element5GRadioConfig = ((ApElementConfiguration)retUpdate.getDetails()).getRadioMap().get(RadioType.is5GHz);
|
||||
assertEquals(149, ret2Element5GRadioConfig.getChannelNumber().intValue());
|
||||
assertEquals(52, ret2Element5GRadioConfig.getManualChannelNumber().intValue());
|
||||
assertEquals(157, ret2Element5GRadioConfig.getBackupChannelNumber().intValue());
|
||||
assertEquals(60, ret2Element5GRadioConfig.getManualBackupChannelNumber().intValue());
|
||||
|
||||
//Update failure
|
||||
ret2Element5GRadioConfig.setChannelNumber(165);
|
||||
try {
|
||||
equipmentPortalController.updateEquipment(retUpdate);
|
||||
fail("EquipmentService update channelNumber failed");
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
ret2Element5GRadioConfig.setChannelNumber(157);
|
||||
ret2Element5GRadioConfig.setManualChannelNumber(165);
|
||||
try {
|
||||
equipmentPortalController.updateEquipment(retUpdate);
|
||||
fail("EquipmentService update manualChannelNumber failed");
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
ret2Element5GRadioConfig.setManualChannelNumber(44);
|
||||
ret2Element5GRadioConfig.setBackupChannelNumber(14);
|
||||
try {
|
||||
equipmentPortalController.updateEquipment(retUpdate);
|
||||
fail("EquipmentService update backupChannelNumber failed");
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
ret2Element5GRadioConfig.setBackupChannelNumber(36);
|
||||
ret2Element5GRadioConfig.setManualBackupChannelNumber(15);
|
||||
try {
|
||||
equipmentPortalController.updateEquipment(retUpdate);
|
||||
fail("EquipmentService update manualBackupChannelNumber failed");
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
ret2Element5GRadioConfig.setManualBackupChannelNumber(52);
|
||||
equipmentPortalController.updateEquipment(retUpdate);
|
||||
|
||||
Equipment ret2Update = equipmentPortalController.getEquipment(ret.getId());
|
||||
ElementRadioConfiguration ret3Element5GRadioConfig = ((ApElementConfiguration)ret2Update.getDetails()).getRadioMap().get(RadioType.is5GHz);
|
||||
assertEquals(157, ret3Element5GRadioConfig.getChannelNumber().intValue());
|
||||
assertEquals(44, ret3Element5GRadioConfig.getManualChannelNumber().intValue());
|
||||
assertEquals(36, ret3Element5GRadioConfig.getBackupChannelNumber().intValue());
|
||||
assertEquals(52, ret3Element5GRadioConfig.getManualBackupChannelNumber().intValue());
|
||||
|
||||
// CHANGE Country Code
|
||||
ret2Update.setLocationId(location2.getId());
|
||||
Equipment ret3Update = equipmentPortalController.updateEquipment(ret2Update);
|
||||
|
||||
ElementRadioConfiguration ret4Element5GRadioConfig = ((ApElementConfiguration) ret3Update.getDetails())
|
||||
.getRadioMap().get(RadioType.is5GHz);
|
||||
// These are auto-corrected values
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_CHANNEL_NUMBER_5GHZ, ret4Element5GRadioConfig.getChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_CHANNEL_NUMBER_5GHZ, ret4Element5GRadioConfig.getManualChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZ, ret4Element5GRadioConfig.getBackupChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZ, ret4Element5GRadioConfig.getManualBackupChannelNumber().intValue());
|
||||
|
||||
for (int i = 149; i <= 161; i = i + 4) {
|
||||
ChannelPowerLevel cpl = new ChannelPowerLevel();
|
||||
cpl.setChannelNumber(i);
|
||||
cpl.setChannelWidth(20);
|
||||
cpl.setDfs(false);
|
||||
cpl.setPowerLevel(30);
|
||||
ret4Element5GRadioConfig.getAllowedChannelsPowerLevels().remove(cpl);
|
||||
}
|
||||
|
||||
Equipment ret5Update = equipmentPortalController.updateEquipment(ret3Update);
|
||||
ElementRadioConfiguration ret5Element5GRadioConfig = ((ApElementConfiguration) ret5Update.getDetails())
|
||||
.getRadioMap().get(RadioType.is5GHz);
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_CHANNEL_NUMBER_5GHZ, ret5Element5GRadioConfig.getChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_CHANNEL_NUMBER_5GHZ, ret5Element5GRadioConfig.getManualChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZ, ret5Element5GRadioConfig.getBackupChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZ, ret5Element5GRadioConfig.getManualBackupChannelNumber().intValue());
|
||||
|
||||
// Clean up after test
|
||||
equipmentPortalController.deleteEquipment(equipmentId);
|
||||
locationDatastore.delete(location1.getId());
|
||||
locationDatastore.delete(location2.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChannelsUpdateChannelNumValidation() {
|
||||
Location location = createLocation(2, LocationType.SITE, CountryCode.US);
|
||||
|
||||
//Create test Equipment
|
||||
Equipment equipment = new Equipment();
|
||||
|
||||
equipment.setName("test_ChannelsUpdate");
|
||||
equipment.setLocationId(location.getId());
|
||||
equipment.setEquipmentType(EquipmentType.AP);
|
||||
equipment.setInventoryId("inv-" + equipment.getName());
|
||||
|
||||
ApElementConfiguration apConfig = ApElementConfiguration.createWithDefaults();
|
||||
equipment.setDetails(apConfig);
|
||||
|
||||
if (apConfig.getElementRadioConfiguration(RadioType.is5GHz) == null) {
|
||||
Map<RadioType, ElementRadioConfiguration> radioMap = apConfig.getRadioMap();
|
||||
radioMap.put(RadioType.is5GHz, ElementRadioConfiguration.createWithDefaults(RadioType.is5GHz));
|
||||
apConfig.setRadioMap(radioMap);
|
||||
}
|
||||
|
||||
ElementRadioConfiguration element2dot4RadioConfig = ((ApElementConfiguration)equipment.getDetails()).getRadioMap().get(RadioType.is2dot4GHz);
|
||||
element2dot4RadioConfig.setAllowedChannelsPowerLevels(new HashSet<>());
|
||||
|
||||
for (int i = 1; i <= 11; i++) {
|
||||
ChannelPowerLevel cpl = new ChannelPowerLevel();
|
||||
cpl.setChannelNumber(i);
|
||||
cpl.setChannelWidth(20);
|
||||
cpl.setDfs(false);
|
||||
cpl.setPowerLevel(30);
|
||||
element2dot4RadioConfig.getAllowedChannelsPowerLevels().add(cpl);
|
||||
}
|
||||
|
||||
ElementRadioConfiguration element5GRadioConfig = ((ApElementConfiguration)equipment.getDetails()).getRadioMap().get(RadioType.is5GHz);
|
||||
element5GRadioConfig.setAllowedChannelsPowerLevels(new HashSet<>());
|
||||
|
||||
for (int i = 36; i <= 64; i=i+4) {
|
||||
ChannelPowerLevel cpl = new ChannelPowerLevel();
|
||||
cpl.setChannelNumber(i);
|
||||
cpl.setChannelWidth(20);
|
||||
cpl.setDfs(false);
|
||||
cpl.setPowerLevel(30);
|
||||
element5GRadioConfig.getAllowedChannelsPowerLevels().add(cpl);
|
||||
}
|
||||
for (int i = 149; i <= 161; i=i+4) {
|
||||
ChannelPowerLevel cpl = new ChannelPowerLevel();
|
||||
cpl.setChannelNumber(i);
|
||||
cpl.setChannelWidth(20);
|
||||
cpl.setDfs(false);
|
||||
cpl.setPowerLevel(30);
|
||||
element5GRadioConfig.getAllowedChannelsPowerLevels().add(cpl);
|
||||
}
|
||||
|
||||
Equipment equipmentCreated = equipmentPortalController.createEquipment(equipment);
|
||||
|
||||
long equipmentId = equipmentCreated.getId();
|
||||
Equipment equipmentGet = equipmentPortalController.getEquipment(equipmentId);
|
||||
assertNotNull(equipmentGet);
|
||||
|
||||
ApElementConfiguration apElementConfiguration = (ApElementConfiguration)equipmentGet.getDetails();
|
||||
assertNotNull(apElementConfiguration);
|
||||
|
||||
Map<RadioType, ElementRadioConfiguration> radioMap = apElementConfiguration.getRadioMap();
|
||||
assertNotNull(radioMap);
|
||||
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_CHANNEL_NUMBER_2DOT4GHZ, radioMap.get(RadioType.is2dot4GHz).getChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_BACKUP_CHANNEL_NUMBER_2DOT4GHZ, radioMap.get(RadioType.is2dot4GHz).getBackupChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_CHANNEL_NUMBER_2DOT4GHZ, radioMap.get(RadioType.is2dot4GHz).getManualChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_BACKUP_CHANNEL_NUMBER_2DOT4GHZ, radioMap.get(RadioType.is2dot4GHz).getManualBackupChannelNumber().intValue());
|
||||
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_CHANNEL_NUMBER_5GHZ, radioMap.get(RadioType.is5GHz).getChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZ, radioMap.get(RadioType.is5GHz).getBackupChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_CHANNEL_NUMBER_5GHZ, radioMap.get(RadioType.is5GHz).getManualChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZ, radioMap.get(RadioType.is5GHz).getManualBackupChannelNumber().intValue());
|
||||
|
||||
Map<RadioType, Integer> primaryChannels = new EnumMap<>(RadioType.class);
|
||||
Map<RadioType, Integer> backupChannels = new EnumMap<>(RadioType.class);
|
||||
Map<RadioType, Boolean> autoChannelSelections = new EnumMap<>(RadioType.class);
|
||||
|
||||
primaryChannels.put(RadioType.is2dot4GHz, 1);
|
||||
primaryChannels.put(RadioType.is5GHz, 52);
|
||||
|
||||
backupChannels.put(RadioType.is2dot4GHz, 6);
|
||||
backupChannels.put(RadioType.is5GHz, 149);
|
||||
|
||||
autoChannelSelections.put(RadioType.is2dot4GHz, false);
|
||||
autoChannelSelections.put(RadioType.is5GHz, false);
|
||||
|
||||
EquipmentChannelsUpdateRequest channelsUpdateRequest = new EquipmentChannelsUpdateRequest();
|
||||
channelsUpdateRequest.setEquipmentId(equipmentId);
|
||||
channelsUpdateRequest.setPrimaryChannels(primaryChannels);
|
||||
channelsUpdateRequest.setBackupChannels(backupChannels);
|
||||
channelsUpdateRequest.setAutoChannelSelections(autoChannelSelections);
|
||||
|
||||
Equipment equipmentUpdate1 = equipmentPortalController.updateEquipmentChannels(channelsUpdateRequest);
|
||||
Equipment equipmentGetUpdate1 = equipmentPortalController.getEquipment(equipmentId);
|
||||
assertEqualEquipments(equipmentGetUpdate1, equipmentUpdate1);
|
||||
|
||||
apElementConfiguration = (ApElementConfiguration)equipmentGetUpdate1.getDetails();
|
||||
assertNotNull(apElementConfiguration);
|
||||
radioMap = apElementConfiguration.getRadioMap();
|
||||
assertNotNull(radioMap);
|
||||
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_CHANNEL_NUMBER_2DOT4GHZ, radioMap.get(RadioType.is2dot4GHz).getChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_BACKUP_CHANNEL_NUMBER_2DOT4GHZ, radioMap.get(RadioType.is2dot4GHz).getBackupChannelNumber().intValue());
|
||||
assertEquals(1, radioMap.get(RadioType.is2dot4GHz).getManualChannelNumber().intValue());
|
||||
assertEquals(6, radioMap.get(RadioType.is2dot4GHz).getManualBackupChannelNumber().intValue());
|
||||
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_CHANNEL_NUMBER_5GHZ, radioMap.get(RadioType.is5GHz).getChannelNumber().intValue());
|
||||
assertEquals(ElementRadioConfiguration.DEFAULT_BACKUP_CHANNEL_NUMBER_5GHZ, radioMap.get(RadioType.is5GHz).getBackupChannelNumber().intValue());
|
||||
assertEquals(52, radioMap.get(RadioType.is5GHz).getManualChannelNumber().intValue());
|
||||
assertEquals(149, radioMap.get(RadioType.is5GHz).getManualBackupChannelNumber().intValue());
|
||||
|
||||
primaryChannels.clear();
|
||||
primaryChannels.put(RadioType.is2dot4GHz, 30);
|
||||
primaryChannels.put(RadioType.is5GHz, 200);
|
||||
|
||||
backupChannels.clear();
|
||||
backupChannels.put(RadioType.is2dot4GHz, 20);
|
||||
backupChannels.put(RadioType.is5GHz, 300);
|
||||
|
||||
channelsUpdateRequest = new EquipmentChannelsUpdateRequest();
|
||||
channelsUpdateRequest.setEquipmentId(equipmentId);
|
||||
channelsUpdateRequest.setPrimaryChannels(primaryChannels);
|
||||
channelsUpdateRequest.setBackupChannels(backupChannels);
|
||||
channelsUpdateRequest.setAutoChannelSelections(autoChannelSelections);
|
||||
|
||||
try {
|
||||
Equipment equipmentUpdate2 = equipmentPortalController.updateEquipmentChannels(channelsUpdateRequest);
|
||||
} catch (DsDataValidationException e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
// Clean up after test
|
||||
equipmentPortalController.deleteEquipment(equipmentId);
|
||||
locationDatastore.delete(location.getId());
|
||||
}
|
||||
|
||||
private void assertEqualEquipments(
|
||||
Equipment expected,
|
||||
Equipment actual) {
|
||||
|
||||
assertEquals(expected.getName(), actual.getName());
|
||||
//TODO: add more fields to check here
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.telecominfraproject.wlan.profile.ethernetport.models;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.equipment.PushableConfiguration;
|
||||
import com.telecominfraproject.wlan.profile.models.ProfileDetails;
|
||||
import com.telecominfraproject.wlan.profile.models.ProfileType;
|
||||
import com.telecominfraproject.wlan.profile.ssid.models.SsidConfiguration;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author rsharma
|
||||
*/
|
||||
public class WiredEthernetPortConfiguration extends ProfileDetails implements PushableConfiguration<WiredEthernetPortConfiguration> {
|
||||
|
||||
private static final long serialVersionUID = 5326345492525165619L;
|
||||
|
||||
private String equipmentModel; // e.g., MR8300-CA, EC420-G1
|
||||
|
||||
private Set<WiredPort> ethPorts;
|
||||
|
||||
public WiredEthernetPortConfiguration() {
|
||||
// for Serialization
|
||||
}
|
||||
|
||||
public WiredEthernetPortConfiguration(String equipmentModel, Set<WiredPort> ethPorts) {
|
||||
this.equipmentModel = equipmentModel;
|
||||
this.ethPorts = ethPorts;
|
||||
}
|
||||
|
||||
public static WiredEthernetPortConfiguration createWithDefaults() {
|
||||
return new WiredEthernetPortConfiguration();
|
||||
}
|
||||
|
||||
public String getEquipmentModel() {
|
||||
return equipmentModel;
|
||||
}
|
||||
|
||||
public void setEquipmentModel(String equipmentModel) {
|
||||
this.equipmentModel = equipmentModel;
|
||||
}
|
||||
|
||||
public Set<WiredPort> getEthPorts() {
|
||||
return ethPorts;
|
||||
}
|
||||
|
||||
public void setEthPorts(Set<WiredPort> ethPorts) {
|
||||
this.ethPorts = ethPorts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsToBeUpdatedOnDevice(WiredEthernetPortConfiguration previousVersion) {
|
||||
if (previousVersion != null) {
|
||||
return !Objects.equals(this, previousVersion);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfileType getProfileType() {
|
||||
return ProfileType.wired_ethernet_port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof WiredEthernetPortConfiguration)) {
|
||||
return false;
|
||||
}
|
||||
WiredEthernetPortConfiguration that = (WiredEthernetPortConfiguration) o;
|
||||
return Objects.equals(getEquipmentModel(), that.getEquipmentModel()) &&
|
||||
Objects.equals(getEthPorts(), that.getEthPorts());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getEquipmentModel(), getEthPorts());
|
||||
}
|
||||
|
||||
@Override
|
||||
public WiredEthernetPortConfiguration clone() {
|
||||
WiredEthernetPortConfiguration ret = (WiredEthernetPortConfiguration)super.clone();
|
||||
|
||||
if (ethPorts != null) {
|
||||
ret.ethPorts = new HashSet<>(ethPorts);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.telecominfraproject.wlan.profile.ethernetport.models;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author rsharma
|
||||
*/
|
||||
public class WiredPort extends BaseJsonModel {
|
||||
|
||||
private static final long serialVersionUID = 6595665507927422135L;
|
||||
|
||||
private String name; //eth0 or eth1
|
||||
private String displayName; // LAN-1, WAN-0 etc
|
||||
private String ifName; // lan, wan etc
|
||||
private String ifType; // bridge/Nat
|
||||
private int vlanId; // native vlanId/tagged vlanId
|
||||
private boolean trunkEnabled; // trunk enabled or disabled
|
||||
private List<Integer> allowedVlanIds; // allowed vlanIds
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getIfName() {
|
||||
return ifName;
|
||||
}
|
||||
|
||||
public void setIfName(String ifName) {
|
||||
this.ifName = ifName;
|
||||
}
|
||||
|
||||
public String getIfType() {
|
||||
return ifType;
|
||||
}
|
||||
|
||||
public void setIfType(String ifType) {
|
||||
this.ifType = ifType;
|
||||
}
|
||||
|
||||
public int getVlanId() {
|
||||
return vlanId;
|
||||
}
|
||||
|
||||
public void setVlanId(int vlanId) {
|
||||
this.vlanId = vlanId;
|
||||
}
|
||||
|
||||
public boolean isTrunkEnabled() {
|
||||
return trunkEnabled;
|
||||
}
|
||||
|
||||
public void setTrunkEnabled(boolean trunkEnabled) {
|
||||
this.trunkEnabled = trunkEnabled;
|
||||
}
|
||||
|
||||
public List<Integer> getAllowedVlanIds() {
|
||||
return allowedVlanIds;
|
||||
}
|
||||
|
||||
public void setAllowedVlanIds(List<Integer> allowedVlanIds) {
|
||||
this.allowedVlanIds = allowedVlanIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof WiredPort)) {
|
||||
return false;
|
||||
}
|
||||
WiredPort wiredPort = (WiredPort) o;
|
||||
return getVlanId() == wiredPort.getVlanId() && isTrunkEnabled() == wiredPort.isTrunkEnabled()
|
||||
&& Objects.equals(getName(), wiredPort.getName())
|
||||
&& Objects.equals(getDisplayName(), wiredPort.getDisplayName())
|
||||
&& Objects.equals(getIfName(), wiredPort.getIfName())
|
||||
&& Objects.equals(getIfType(), wiredPort.getIfType())
|
||||
&& Objects.equals(getAllowedVlanIds(), wiredPort.getAllowedVlanIds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getName(), getDisplayName(), getIfName(), getIfType(), getVlanId(), isTrunkEnabled(), getAllowedVlanIds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public WiredPort clone() {
|
||||
WiredPort port = (WiredPort) super.clone();
|
||||
|
||||
if (getAllowedVlanIds() != null) {
|
||||
port.allowedVlanIds = new ArrayList<>(getAllowedVlanIds());
|
||||
}
|
||||
|
||||
return port;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.telecominfraproject.wlan.profile.ethernetport.models.WiredEthernetPortConfiguration;
|
||||
|
||||
/**
|
||||
* @author dtop
|
||||
* Utility class for dealing with profiles
|
||||
@@ -40,6 +42,26 @@ public class ProfileContainer {
|
||||
return ret.get(0);
|
||||
}
|
||||
|
||||
public Profile getChildOfTypeOrNullByEquipmentModel(long profileId, ProfileType childProfileType,
|
||||
String equipmentModel) {
|
||||
// The profile type of the profileId should be equipment_ap
|
||||
Profile apProfile = profileMap.get(profileId);
|
||||
if (apProfile != null && apProfile.getProfileType() == ProfileType.equipment_ap) {
|
||||
|
||||
List<Profile> profiles = getChildrenOfType(profileId, childProfileType);
|
||||
for (Profile ret : profiles) {
|
||||
WiredEthernetPortConfiguration config = (WiredEthernetPortConfiguration) ret.getDetails();
|
||||
if (config != null && config.getEquipmentModel() != null
|
||||
&& config.getEquipmentModel().equals(equipmentModel)) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Profile Id " + profileId + " is not of type equipment_ap");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Profile> getChildrenOfType(long profileId, ProfileType childProfileType) {
|
||||
Profile parent = profileMap.get(profileId);
|
||||
List<Profile> ret = new ArrayList<>();
|
||||
|
||||
@@ -62,6 +62,8 @@ public class ProfileType implements EnumWithId {
|
||||
passpoint_venue = new ProfileType(12,"passpoint_venue"),
|
||||
passpoint_osu_id_provider = new ProfileType(13,"passpoint_osu_id_provider"),
|
||||
ap_event_rate = new ProfileType(14,"ap_event_rate"),
|
||||
metrics = new ProfileType(15,"metrics"),
|
||||
wired_ethernet_port = new ProfileType(16, "wired_ethernet_port"),
|
||||
UNSUPPORTED = new ProfileType(-1, "UNSUPPORTED");
|
||||
|
||||
static {
|
||||
|
||||
@@ -28,6 +28,7 @@ public class ApNetworkConfiguration extends CommonNetworkConfiguration
|
||||
public static final Boolean DEFAULT_SYNTHETIC_CLIENT_ENABLED = Boolean.TRUE;
|
||||
public static final Boolean DEFAULT_LED_CONTROL_ENABLED = Boolean.TRUE;
|
||||
public static final Boolean DEFAULT_EQUIPMENT_DISCOVERY_ENABLED = Boolean.FALSE;
|
||||
public static final Boolean DEFAULT_DYNAMIC_RADIUS_PROXY_ENABLED = Boolean.FALSE;
|
||||
|
||||
/**
|
||||
* Added as a profile level setting that can be used to provide
|
||||
@@ -59,6 +60,7 @@ public class ApNetworkConfiguration extends CommonNetworkConfiguration
|
||||
setSyntheticClientEnabled(DEFAULT_SYNTHETIC_CLIENT_ENABLED);
|
||||
setLedControlEnabled(DEFAULT_LED_CONTROL_ENABLED);
|
||||
setEquipmentDiscovery(DEFAULT_EQUIPMENT_DISCOVERY_ENABLED);
|
||||
setDynamicRadiusProxyEnabled(DEFAULT_DYNAMIC_RADIUS_PROXY_ENABLED);
|
||||
|
||||
// initialize the profile level radio map settings parameter
|
||||
radioMap = new EnumMap<>(RadioType.class);
|
||||
|
||||
@@ -23,6 +23,7 @@ public abstract class CommonNetworkConfiguration extends ProfileDetails {
|
||||
private Boolean syntheticClientEnabled;
|
||||
private Boolean ledControlEnabled;
|
||||
private Boolean equipmentDiscovery;
|
||||
private Boolean dynamicRadiusProxyEnabled;
|
||||
|
||||
public CommonNetworkConfiguration() {
|
||||
}
|
||||
@@ -67,7 +68,6 @@ public abstract class CommonNetworkConfiguration extends ProfileDetails {
|
||||
this.vlanNative = bool;
|
||||
}
|
||||
|
||||
|
||||
public AutoOrManualString getNtpServer() {
|
||||
return ntpServer;
|
||||
}
|
||||
@@ -92,7 +92,6 @@ public abstract class CommonNetworkConfiguration extends ProfileDetails {
|
||||
this.syntheticClientEnabled = syntheticClientEnabled;
|
||||
}
|
||||
|
||||
|
||||
public Boolean isLedControlEnabled() {
|
||||
return ledControlEnabled;
|
||||
}
|
||||
@@ -108,6 +107,23 @@ public abstract class CommonNetworkConfiguration extends ProfileDetails {
|
||||
public void setRtlsSettings(RtlsSettings rtlsSettings) {
|
||||
this.rtlsSettings = rtlsSettings;
|
||||
}
|
||||
|
||||
public Boolean isDynamicRadiusProxyEnabled() {
|
||||
return dynamicRadiusProxyEnabled;
|
||||
}
|
||||
|
||||
public void setDynamicRadiusProxyEnabled(Boolean dynamicRadiusProxyEnabled) {
|
||||
this.dynamicRadiusProxyEnabled = dynamicRadiusProxyEnabled;
|
||||
}
|
||||
|
||||
public Boolean getEquipmentDiscovery() {
|
||||
return equipmentDiscovery;
|
||||
}
|
||||
|
||||
public void setEquipmentDiscovery(Boolean equipmentDiscovery) {
|
||||
this.equipmentDiscovery = equipmentDiscovery;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommonNetworkConfiguration clone() {
|
||||
@@ -124,7 +140,9 @@ public abstract class CommonNetworkConfiguration extends ProfileDetails {
|
||||
ret.setVlan(getVlan());
|
||||
ret.setVlanNative(isVlanNative());
|
||||
ret.setSyntheticClientEnabled(getSyntheticClientEnabled());
|
||||
|
||||
ret.setLedControlEnabled(isLedControlEnabled());
|
||||
ret.setEquipmentDiscovery(getEquipmentDiscovery());
|
||||
ret.setDynamicRadiusProxyEnabled(isDynamicRadiusProxyEnabled());
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -145,26 +163,10 @@ public abstract class CommonNetworkConfiguration extends ProfileDetails {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Boolean getEquipmentDiscovery() {
|
||||
return equipmentDiscovery;
|
||||
}
|
||||
|
||||
public void setEquipmentDiscovery(Boolean equipmentDiscovery) {
|
||||
this.equipmentDiscovery = equipmentDiscovery;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public Boolean getVlanNative() {
|
||||
return vlanNative;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(equipmentDiscovery, equipmentType, ledControlEnabled, networkConfigVersion, ntpServer, rtlsSettings,
|
||||
syntheticClientEnabled, syslogRelay, vlan, vlanNative);
|
||||
syntheticClientEnabled, syslogRelay, vlan, vlanNative, dynamicRadiusProxyEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,7 +185,8 @@ public abstract class CommonNetworkConfiguration extends ProfileDetails {
|
||||
&& Objects.equals(ntpServer, other.ntpServer) && Objects.equals(rtlsSettings, other.rtlsSettings)
|
||||
&& Objects.equals(syntheticClientEnabled, other.syntheticClientEnabled)
|
||||
&& Objects.equals(syslogRelay, other.syslogRelay) && vlan == other.vlan
|
||||
&& Objects.equals(vlanNative, other.vlanNative);
|
||||
&& Objects.equals(vlanNative, other.vlanNative)
|
||||
&& Objects.equals(dynamicRadiusProxyEnabled, other.dynamicRadiusProxyEnabled);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ public class RadiusProxyConfiguration extends BaseJsonModel implements PushableC
|
||||
private Boolean useRadSec;
|
||||
private String sharedSecret; // if useRadSec is false
|
||||
private String acctSharedSecret; // if useRadSec is false
|
||||
private String radiusProxySecret;
|
||||
private Boolean dynamicDiscovery; // dynamic discovery of HSP and IdPs (home service and identity providers).
|
||||
// regardless of configured value, this will only be set 'true' on the AP if useRadSec is also true.
|
||||
|
||||
@@ -145,6 +146,14 @@ public class RadiusProxyConfiguration extends BaseJsonModel implements PushableC
|
||||
public void setAcctSharedSecret(String acctSharedSecret) {
|
||||
this.acctSharedSecret = acctSharedSecret;
|
||||
}
|
||||
|
||||
public String getRadiusProxySecret() {
|
||||
return radiusProxySecret;
|
||||
}
|
||||
|
||||
public void setRadiusProxySecret(String radiusProxySecret) {
|
||||
this.radiusProxySecret = radiusProxySecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dynamicDiscovery
|
||||
@@ -174,7 +183,7 @@ public class RadiusProxyConfiguration extends BaseJsonModel implements PushableC
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(acctPort, acctServer, acctSharedSecret, caCert, clientCert, clientKey, dynamicDiscovery, name, passphrase, port, realm, server,
|
||||
sharedSecret, useRadSec);
|
||||
sharedSecret, useRadSec, radiusProxySecret);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,7 +200,8 @@ public class RadiusProxyConfiguration extends BaseJsonModel implements PushableC
|
||||
&& Objects.equals(clientCert, other.clientCert) && Objects.equals(clientKey, other.clientKey)
|
||||
&& Objects.equals(dynamicDiscovery, other.dynamicDiscovery) && Objects.equals(name, other.name) && Objects.equals(passphrase, other.passphrase)
|
||||
&& Objects.equals(port, other.port) && Objects.equals(realm, other.realm) && Objects.equals(server, other.server)
|
||||
&& Objects.equals(sharedSecret, other.sharedSecret) && Objects.equals(useRadSec, other.useRadSec);
|
||||
&& Objects.equals(sharedSecret, other.sharedSecret) && Objects.equals(useRadSec, other.useRadSec)
|
||||
&& Objects.equals(radiusProxySecret, other.radiusProxySecret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class PasspointProfile extends ProfileDetails implements PushableConfigur
|
||||
private boolean enable2pt4GHz;
|
||||
private boolean enable5GHz;
|
||||
|
||||
private List<Long> associatedAccessSsidProfileIds;
|
||||
private Set<Long> associatedAccessSsidProfileIds;
|
||||
|
||||
private Long osuSsidProfileId;
|
||||
|
||||
@@ -321,11 +321,11 @@ public class PasspointProfile extends ProfileDetails implements PushableConfigur
|
||||
this.passpointNetworkAuthenticationType = passpointNetworkAuthenticationType;
|
||||
}
|
||||
|
||||
public List<Long> getAssociatedAccessSsidProfileIds() {
|
||||
public Set<Long> getAssociatedAccessSsidProfileIds() {
|
||||
return associatedAccessSsidProfileIds;
|
||||
}
|
||||
|
||||
public void setAssociatedAccessSsidProfileIds(List<Long> associatedAccessSsidProfileIds) {
|
||||
public void setAssociatedAccessSsidProfileIds(Set<Long> associatedAccessSsidProfileIds) {
|
||||
this.associatedAccessSsidProfileIds = associatedAccessSsidProfileIds;
|
||||
}
|
||||
|
||||
|
||||
@@ -327,17 +327,16 @@ public class RfElementConfiguration extends BaseJsonModel {
|
||||
this.minAutoCellSize = minAutoCellSize;
|
||||
}
|
||||
|
||||
//Always return default value
|
||||
public Integer getMaxAutoCellSize() {
|
||||
if (maxAutoCellSize == null) {
|
||||
if (MAX_CELL_SIZE_MAP.containsKey(this.radioType)) {
|
||||
return MAX_CELL_SIZE_MAP.get(this.radioType);
|
||||
} else {
|
||||
return MAX_CELL_SIZE_MAP.get(RadioType.is2dot4GHz);
|
||||
}
|
||||
if (MAX_CELL_SIZE_MAP.containsKey(this.radioType)) {
|
||||
return MAX_CELL_SIZE_MAP.get(this.radioType);
|
||||
} else {
|
||||
return MAX_CELL_SIZE_MAP.get(RadioType.is2dot4GHz);
|
||||
}
|
||||
return maxAutoCellSize;
|
||||
}
|
||||
|
||||
// not allow user to configure
|
||||
public void setMaxAutoCellSize(Integer maxAutoCellSize) {
|
||||
this.maxAutoCellSize = maxAutoCellSize;
|
||||
}
|
||||
|
||||
@@ -93,4 +93,16 @@ public class RfConfigurationTests {
|
||||
assertEquals(Integer.valueOf(23), list2.get(2));
|
||||
assertEquals(Integer.valueOf(45), list2.get(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxAutoCellSize() {
|
||||
RfElementConfiguration rfConfig = RfElementConfiguration.createWithDefaults(RadioType.is5GHz);
|
||||
assertNotNull(rfConfig.getMaxAutoCellSize());
|
||||
|
||||
assertEquals(RfElementConfiguration.DEFAULT_MAX_CELL_SIZE_DB, rfConfig.getMaxAutoCellSize().intValue());
|
||||
|
||||
rfConfig.setMaxAutoCellSize(-93);
|
||||
//getMaxAutoCellSize always return default MaxAutoCellSize
|
||||
assertEquals(RfElementConfiguration.DEFAULT_MAX_CELL_SIZE_DB, rfConfig.getMaxAutoCellSize().intValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.telecominfraproject.wlan.profile.models.ProfileType;
|
||||
import com.telecominfraproject.wlan.profile.models.events.ProfileAddedEvent;
|
||||
import com.telecominfraproject.wlan.profile.models.events.ProfileChangedEvent;
|
||||
import com.telecominfraproject.wlan.profile.models.events.ProfileRemovedEvent;
|
||||
import com.telecominfraproject.wlan.profile.passpoint.models.PasspointProfile;
|
||||
|
||||
|
||||
/**
|
||||
@@ -209,6 +210,20 @@ public class ProfileController {
|
||||
LOG.error("Failed to update Profile, request contains unsupported value: {}", profile);
|
||||
throw new DsDataValidationException("Profile contains unsupported value");
|
||||
}
|
||||
|
||||
// WIFI-6855: To handle SSID-Passpoint association update when SSID profiles are updated
|
||||
// If the passpoint profile update is requested, but no change is made to the details, then skip the update
|
||||
if (profile.getProfileType().equals(ProfileType.passpoint)) {
|
||||
Profile existingProfile = profileDatastore.getOrNull(profile.getId());
|
||||
if (existingProfile != null) {
|
||||
PasspointProfile existingDetails = (PasspointProfile) existingProfile.getDetails();
|
||||
PasspointProfile newDetails = (PasspointProfile) profile.getDetails();
|
||||
if (existingDetails.equals(newDetails)) {
|
||||
LOG.info("No change was made to this profile, skip update on profile {}", profile.getId());
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Profile ret = profileDatastore.update(profile);
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.telecominfraproject.wlan.equipmentgateway.models.CEGWConfigChangeNoti
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWNewChannelRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCellSizeAttributesRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.service.EquipmentGatewayServiceInterface;
|
||||
import com.telecominfraproject.wlan.location.models.events.LocationChangedApImpactingEvent;
|
||||
import com.telecominfraproject.wlan.profile.ProfileServiceInterface;
|
||||
import com.telecominfraproject.wlan.profile.models.Profile;
|
||||
import com.telecominfraproject.wlan.profile.models.events.ProfileAddedEvent;
|
||||
@@ -92,7 +91,7 @@ public class EquipmentConfigPushTrigger extends StreamProcessor {
|
||||
|| ser.getDetails() instanceof EquipmentChannelsChangedEvent || ser.getDetails() instanceof EquipmentCellSizeAttributesChangedEvent
|
||||
|| ser.getDetails() instanceof EquipmentRemovedEvent || ser.getDetails() instanceof ProfileAddedEvent
|
||||
|| ser.getDetails() instanceof ProfileChangedEvent || ser.getDetails() instanceof ProfileRemovedEvent
|
||||
|| ser.getDetails() instanceof LocationChangedApImpactingEvent || ser.getDetails() instanceof EquipmentCustomerChangedEvent);
|
||||
|| ser.getDetails() instanceof EquipmentCustomerChangedEvent);
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
@@ -133,9 +132,6 @@ public class EquipmentConfigPushTrigger extends StreamProcessor {
|
||||
case "ProfileRemovedEvent":
|
||||
process((ProfileRemovedEvent) se);
|
||||
break;
|
||||
case "LocationChangedApImpactingEvent":
|
||||
process((LocationChangedApImpactingEvent) se);
|
||||
break;
|
||||
case "EquipmentCustomerChangedEvent":
|
||||
process((EquipmentCustomerChangedEvent) se);
|
||||
default:
|
||||
@@ -171,6 +167,7 @@ public class EquipmentConfigPushTrigger extends StreamProcessor {
|
||||
private void process(EquipmentRemovedEvent model) {
|
||||
LOG.debug("Processing EquipmentRemovedEvent");
|
||||
equipmentGatewayInterface.sendCommand(new CEGWCloseSessionRequest(model.getPayload().getInventoryId(), model.getEquipmentId()));
|
||||
cleanUpClientSessions(model.getPayload());
|
||||
}
|
||||
|
||||
private void process(ProfileAddedEvent model) {
|
||||
@@ -222,36 +219,6 @@ public class EquipmentConfigPushTrigger extends StreamProcessor {
|
||||
LOG.debug("Finished processing profile {}", profile.getId());
|
||||
}
|
||||
|
||||
private void process(LocationChangedApImpactingEvent model) {
|
||||
LOG.debug("Processing LocationChangedApImpactingEvent {}", model.getPayload().getId());
|
||||
|
||||
Set<Long> locationIds = new HashSet<>(Arrays.asList(model.getPayload().getId()));
|
||||
|
||||
// go through all equipmentIds that reside in the specified location and trigger change config notification on
|
||||
// them
|
||||
PaginationContext<PairLongLong> context = new PaginationContext<>(100);
|
||||
|
||||
while (!context.isLastPage()) {
|
||||
PaginationResponse<PairLongLong> page = equipmentServiceInterface.getEquipmentIdsByLocationIds(locationIds, context);
|
||||
context = page.getContext();
|
||||
|
||||
Set<Long> equipmentIds = new HashSet<>();
|
||||
page.getItems().forEach(p -> equipmentIds.add(p.getValue2()));
|
||||
|
||||
// retrieve full equipment objects to get the inventory id
|
||||
List<Equipment> equipmentForPage = equipmentServiceInterface.get(equipmentIds);
|
||||
|
||||
List<CEGWBaseCommand> commands = new ArrayList<>(equipmentForPage.size());
|
||||
equipmentForPage.forEach(eq -> commands.add(new CEGWConfigChangeNotification(eq.getInventoryId(), eq.getId())));
|
||||
|
||||
equipmentGatewayInterface.sendCommands(commands);
|
||||
LOG.debug("Page {} - sent {} commands to equipment gateway", context.getLastReturnedPageNumber(), commands.size());
|
||||
}
|
||||
|
||||
LOG.debug("Finished processing LocationChangedApImpactingEvent {}", model.getPayload().getId());
|
||||
|
||||
}
|
||||
|
||||
private void process(EquipmentCustomerChangedEvent model) {
|
||||
LOG.info("Processing EquipmentCustomerChangedEvent {}", model.getPayload().getId());
|
||||
|
||||
@@ -269,6 +236,11 @@ public class EquipmentConfigPushTrigger extends StreamProcessor {
|
||||
status.setCustomerId(equipment.getCustomerId());
|
||||
statusServiceInterface.update(status);
|
||||
}
|
||||
status = statusServiceInterface.getOrNull(existingEquipment.getCustomerId(), existingEquipment.getId(), StatusDataType.FIRMWARE);
|
||||
if (status != null) {
|
||||
status.setCustomerId(equipment.getCustomerId());
|
||||
statusServiceInterface.update(status);
|
||||
}
|
||||
|
||||
// Alarms has to move to new customerId as well
|
||||
List<Alarm> oldCustomerAlarms = alarmServiceInterface.get(existingEquipment.getCustomerId(), Set.of(existingEquipment.getId()), null);
|
||||
@@ -323,6 +295,21 @@ public class EquipmentConfigPushTrigger extends StreamProcessor {
|
||||
} else {
|
||||
LOG.info("There are no existing client sessions that are not already in Disconnected state.");
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanUpClientSessions(Equipment ce) {
|
||||
LOG.info("EquipmentConfigPushTrigger::cleanUpClientSessions for Equipment {}", ce);
|
||||
PaginationResponse<ClientSession> clientSessions = clientServiceInterface.getSessionsForCustomer(
|
||||
ce.getCustomerId(), Set.of(ce.getId()), Set.of(ce.getLocationId()), null, null,
|
||||
new PaginationContext<ClientSession>(100));
|
||||
|
||||
if (clientSessions.getItems().isEmpty() || clientSessions == null) {
|
||||
LOG.info("There are no existing client sessions to clean up.");
|
||||
return;
|
||||
}
|
||||
|
||||
clientSessions.getItems().stream().forEach(c -> clientServiceInterface.deleteSession(c.getCustomerId(), c.getEquipmentId(), c.getMacAddress()));
|
||||
|
||||
LOG.info("Cleaned up client sessions for deleted Equipment {}", ce.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.equipment.ChannelBandwidth;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||
import com.telecominfraproject.wlan.status.models.StatusDataType;
|
||||
import com.telecominfraproject.wlan.status.models.StatusDetails;
|
||||
@@ -12,6 +13,7 @@ public class EquipmentChannelStatusData extends StatusDetails {
|
||||
private static final long serialVersionUID = 470569467119609438L;
|
||||
|
||||
private Map<RadioType, Integer> channelNumberStatusDataMap = new EnumMap<>(RadioType.class);
|
||||
private Map<RadioType, ChannelBandwidth> channelBandwidthStatusDataMap = new EnumMap<>(RadioType.class);
|
||||
private Map<RadioType, Integer> txPowerDataMap = new EnumMap<>(RadioType.class);
|
||||
|
||||
|
||||
@@ -29,6 +31,7 @@ public class EquipmentChannelStatusData extends StatusDetails {
|
||||
{
|
||||
if (data !=null) {
|
||||
this.channelNumberStatusDataMap.putAll(data.channelNumberStatusDataMap);
|
||||
this.channelBandwidthStatusDataMap.putAll(data.channelBandwidthStatusDataMap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +39,10 @@ public class EquipmentChannelStatusData extends StatusDetails {
|
||||
return channelNumberStatusDataMap;
|
||||
}
|
||||
|
||||
public Map<RadioType, ChannelBandwidth> getChannelBandwidthStatusDataMap() {
|
||||
return channelBandwidthStatusDataMap;
|
||||
}
|
||||
|
||||
public Map<RadioType, Integer> getTxPowerDataMap() {
|
||||
return txPowerDataMap;
|
||||
}
|
||||
@@ -44,6 +51,10 @@ public class EquipmentChannelStatusData extends StatusDetails {
|
||||
this.channelNumberStatusDataMap = channelNumberStatusDataMap;
|
||||
}
|
||||
|
||||
public void setChannelBandwidthStatusDataMap(Map<RadioType, ChannelBandwidth> channelBandwidthStatusDataMap) {
|
||||
this.channelBandwidthStatusDataMap = channelBandwidthStatusDataMap;
|
||||
}
|
||||
|
||||
public void setTxPowerDataMap(Map<RadioType, Integer> txPowerDataMap) {
|
||||
this.txPowerDataMap = txPowerDataMap;
|
||||
}
|
||||
@@ -59,6 +70,14 @@ public class EquipmentChannelStatusData extends StatusDetails {
|
||||
});
|
||||
}
|
||||
|
||||
if (getChannelBandwidthStatusDataMap() != null) {
|
||||
result.setChannelBandwidthStatusDataMap(new EnumMap<>(RadioType.class));
|
||||
|
||||
this.channelBandwidthStatusDataMap.forEach((k, v) -> {
|
||||
result.channelBandwidthStatusDataMap.put(k, v);
|
||||
});
|
||||
}
|
||||
|
||||
if (getTxPowerDataMap() != null) {
|
||||
result.setTxPowerDataMap(new EnumMap<>(RadioType.class));
|
||||
|
||||
@@ -71,7 +90,7 @@ public class EquipmentChannelStatusData extends StatusDetails {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(channelNumberStatusDataMap, txPowerDataMap);
|
||||
return Objects.hash(channelNumberStatusDataMap, channelBandwidthStatusDataMap, txPowerDataMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -84,6 +103,7 @@ public class EquipmentChannelStatusData extends StatusDetails {
|
||||
return false;
|
||||
EquipmentChannelStatusData other = (EquipmentChannelStatusData) obj;
|
||||
return Objects.equals(channelNumberStatusDataMap, other.channelNumberStatusDataMap)
|
||||
&& Objects.equals(channelBandwidthStatusDataMap, other.channelBandwidthStatusDataMap)
|
||||
&& Objects.equals(txPowerDataMap, other.txPowerDataMap);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.telecominfraproject.wlan.status.equipment.report.models;
|
||||
|
||||
import com.telecominfraproject.wlan.status.models.StatusDataType;
|
||||
import com.telecominfraproject.wlan.status.models.StatusDetails;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author rsharma
|
||||
*/
|
||||
public class WiredEthernetPortStatusData extends StatusDetails {
|
||||
private static final long serialVersionUID = 1684955685155400122L;
|
||||
|
||||
// key is ifName, value is the list of wiredPortStatus that link to the ifName
|
||||
private Map<String, List<WiredPortStatus>> interfacePortStatusMap;
|
||||
|
||||
public WiredEthernetPortStatusData() {
|
||||
this.interfacePortStatusMap = new HashMap<>();
|
||||
}
|
||||
|
||||
public WiredEthernetPortStatusData(Map<String, List<WiredPortStatus>> interfacePortStatusMap) {
|
||||
this.interfacePortStatusMap = interfacePortStatusMap;
|
||||
}
|
||||
|
||||
public Map<String, List<WiredPortStatus>> getInterfacePortStatusMap() {
|
||||
return interfacePortStatusMap;
|
||||
}
|
||||
|
||||
public void setInterfacePortStatusMap(Map<String, List<WiredPortStatus>> interfacePortStatusMap) {
|
||||
this.interfacePortStatusMap = interfacePortStatusMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StatusDataType getStatusDataType() {
|
||||
return StatusDataType.WIRED_ETHERNET_PORT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof WiredEthernetPortStatusData)) {
|
||||
return false;
|
||||
}
|
||||
WiredEthernetPortStatusData that = (WiredEthernetPortStatusData) o;
|
||||
return Objects.equals(getInterfacePortStatusMap(), that.getInterfacePortStatusMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getInterfacePortStatusMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public WiredEthernetPortStatusData clone() {
|
||||
WiredEthernetPortStatusData data = (WiredEthernetPortStatusData) super.clone();
|
||||
|
||||
if (interfacePortStatusMap != null) {
|
||||
data.interfacePortStatusMap = new HashMap<>(interfacePortStatusMap);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.telecominfraproject.wlan.status.equipment.report.models;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author rsharma
|
||||
*/
|
||||
public class WiredPortStatus extends BaseJsonModel {
|
||||
|
||||
private static final long serialVersionUID = 5525006111579379607L;
|
||||
|
||||
private String name; // eth_port: eth0 or eth1
|
||||
private String originalIfName; // ifName when the AP came up (lan, wan etc.)
|
||||
private String currentIfName; // Current ifName (e.g. lan, wan etc.)
|
||||
private String ifType; // bridge/Nat/eth/vlan
|
||||
private int speed; // in MBPS
|
||||
private String duplex; // full, half
|
||||
private String operationalState; // Operational State
|
||||
private int vlanId; // tagged VlanId
|
||||
private boolean trunkEnabled; // trunk enabled or disabled
|
||||
private List<Integer> allowedVlanIds; // allowed vlanIds
|
||||
|
||||
public WiredPortStatus() {
|
||||
|
||||
}
|
||||
|
||||
public WiredPortStatus(String name, String originalIfName, String currentIfName, String ifType, int speed, String duplex,
|
||||
String operationalState, int vlanId, boolean trunkEnabled, List<Integer> allowedVlanIds) {
|
||||
this.name = name;
|
||||
this.originalIfName = originalIfName;
|
||||
this.currentIfName = currentIfName;
|
||||
this.ifType = ifType;
|
||||
this.speed = speed;
|
||||
this.duplex = duplex;
|
||||
this.operationalState = operationalState;
|
||||
this.vlanId = vlanId;
|
||||
this.trunkEnabled = trunkEnabled;
|
||||
this.allowedVlanIds = allowedVlanIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof WiredPortStatus)) {
|
||||
return false;
|
||||
}
|
||||
WiredPortStatus that = (WiredPortStatus) o;
|
||||
return getSpeed() == that.getSpeed() && Objects.equals(getName(), that.getName())
|
||||
&& Objects.equals(getOriginalIfName(), that.getOriginalIfName())
|
||||
&& Objects.equals(getCurrentIfName(), that.getCurrentIfName())
|
||||
&& Objects.equals(getIfType(), that.getIfType())
|
||||
&& Objects.equals(getDuplex(), that.getDuplex())
|
||||
&& Objects.equals(getOperationalState(), that.getOperationalState())
|
||||
&& getVlanId() == that.getVlanId()
|
||||
&& Objects.equals(getAllowedVlanIds(), that.getAllowedVlanIds())
|
||||
&& Objects.equals(isTrunkEnabled(), that.isTrunkEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getName(), getOriginalIfName(), getCurrentIfName(), getIfType(), getSpeed(), getDuplex(),
|
||||
getOperationalState(), getVlanId(), getAllowedVlanIds(), isTrunkEnabled());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getOriginalIfName() {
|
||||
return originalIfName;
|
||||
}
|
||||
|
||||
public void setOriginalIfName(String originalIfName) {
|
||||
this.originalIfName = originalIfName;
|
||||
}
|
||||
|
||||
public String getCurrentIfName() {
|
||||
return currentIfName;
|
||||
}
|
||||
|
||||
public void setCurrentIfName(String currentIfName) {
|
||||
this.currentIfName = currentIfName;
|
||||
}
|
||||
|
||||
public String getIfType() {
|
||||
return ifType;
|
||||
}
|
||||
|
||||
public void setIfType(String ifType) {
|
||||
this.ifType = ifType;
|
||||
}
|
||||
|
||||
public int getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed(int speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public String getDuplex() {
|
||||
return duplex;
|
||||
}
|
||||
|
||||
public void setDuplex(String duplex) {
|
||||
this.duplex = duplex;
|
||||
}
|
||||
|
||||
public String getOperationalState() {
|
||||
return operationalState;
|
||||
}
|
||||
|
||||
public void setOperationalState(String operationalState) {
|
||||
this.operationalState = operationalState;
|
||||
}
|
||||
|
||||
public int getVlanId() {
|
||||
return vlanId;
|
||||
}
|
||||
|
||||
public void setVlanId(int vlanId) {
|
||||
this.vlanId = vlanId;
|
||||
}
|
||||
|
||||
public List<Integer> getAllowedVlanIds() {
|
||||
return allowedVlanIds;
|
||||
}
|
||||
|
||||
public void setAllowedVlanIds(List<Integer> allowedVlanIds) {
|
||||
this.allowedVlanIds = allowedVlanIds;
|
||||
}
|
||||
|
||||
public boolean isTrunkEnabled() {
|
||||
return trunkEnabled;
|
||||
}
|
||||
|
||||
public void setTrunkEnabled(boolean trunkEnabled) {
|
||||
this.trunkEnabled = trunkEnabled;
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,11 @@ public class StatusDataType implements EnumWithId {
|
||||
/**
|
||||
* Protocol status
|
||||
*/
|
||||
PROTOCOL = new StatusDataType(4, "PROTOCOL", Set.of(StatusTrait.DeleteOnEquipmentDisconnect)) ,
|
||||
PROTOCOL = new StatusDataType(4, "PROTOCOL"
|
||||
// some of the properties of this status need to be preserved across equipment connections
|
||||
// example - reportedCfgDataVersion
|
||||
//, Set.of(StatusTrait.DeleteOnEquipmentDisconnect)
|
||||
) ,
|
||||
/**
|
||||
* Firmware upgrade status
|
||||
*/
|
||||
@@ -101,6 +105,9 @@ public class StatusDataType implements EnumWithId {
|
||||
*/
|
||||
EQUIPMENT_MANUFACTURER_DATA = new StatusDataType(17, "EQUIPMENT_MANUFACTURER_DATA", Set.of(StatusTrait.DeleteOnEquipmentDisconnect)),
|
||||
|
||||
// STATUS OF ETHERNET PORTS ON THE DEVICE
|
||||
WIRED_ETHERNET_PORT = new StatusDataType(18, "WIRED_ETHERNET_PORT", Set.of(StatusTrait.DeleteOnEquipmentDisconnect)),
|
||||
|
||||
UNSUPPORTED = new StatusDataType(-1, "UNSUPPORTED") ;
|
||||
|
||||
static {
|
||||
|
||||
@@ -257,7 +257,6 @@ public class SystemEventDatastoreInMemory extends BaseInMemoryDatastore implemen
|
||||
if (mdl.getEventTimestamp() > eqptStats.getLastEventTime()) {
|
||||
eqptStats.setLastEventTime(mdl.getEventTimestamp());
|
||||
}
|
||||
items.add(mdl);
|
||||
}
|
||||
|
||||
List<EquipmentEventStats> equipmentStats = new ArrayList<>();
|
||||
|
||||
@@ -3435,7 +3435,17 @@ components:
|
||||
type: integer
|
||||
format: int64
|
||||
|
||||
|
||||
ChannelBandwidthPerRadioTypeMap:
|
||||
properties:
|
||||
is5GHz:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
is5GHzU:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
is5GHzL:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
is2dot4GHz:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
|
||||
EquipmentAdminStatusData:
|
||||
type: object
|
||||
properties:
|
||||
@@ -4395,6 +4405,8 @@ components:
|
||||
- RADIO_CHANNEL
|
||||
channelNumberStatusDataMap:
|
||||
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
||||
channelBandwidthStatusDataMap:
|
||||
$ref: '#/components/schemas/ChannelBandwidthPerRadioTypeMap'
|
||||
txPowerDataMap:
|
||||
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user