mirror of
https://github.com/Telecominfraproject/wlan-cloud-services.git
synced 2026-03-20 19:39:19 +00:00
Compare commits
22 Commits
WIFI-4415
...
WIFI-4732-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa77d3896d | ||
|
|
55c4671211 | ||
|
|
a540274210 | ||
|
|
56f43d8e7f | ||
|
|
607c1c815e | ||
|
|
f750d0cad2 | ||
|
|
1551babca2 | ||
|
|
70bd1f5eda | ||
|
|
88fa6ca8a5 | ||
|
|
e090bd6b00 | ||
|
|
aa1fbfd645 | ||
|
|
9ee24beb64 | ||
|
|
95a07188d5 | ||
|
|
6839ff3e97 | ||
|
|
299f59767e | ||
|
|
936aeae135 | ||
|
|
5b3d05bc21 | ||
|
|
ee3c62559a | ||
|
|
d3bb9f6e51 | ||
|
|
a1ebf265f9 | ||
|
|
64b1432251 | ||
|
|
e74570121c |
@@ -4982,10 +4982,6 @@ components:
|
||||
|
||||
ClientMetrics:
|
||||
properties:
|
||||
secondsSinceLastRecv:
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
numRxPackets:
|
||||
type: integer
|
||||
format: int64
|
||||
@@ -5026,12 +5022,6 @@ components:
|
||||
|
||||
sessionId:
|
||||
type: string
|
||||
|
||||
classificationName:
|
||||
type: string
|
||||
|
||||
channelBandWidth:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
|
||||
averageTxRate:
|
||||
type: number
|
||||
@@ -5048,21 +5038,11 @@ components:
|
||||
type: integer
|
||||
format: int64
|
||||
|
||||
rxLastRssi:
|
||||
description: The RSSI of last frame received.
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
numRxNoFcsErr:
|
||||
description: The number of received frames without FCS errors.
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
numRxData:
|
||||
description: The number of received data frames.
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
|
||||
rxBytes:
|
||||
description: The number of received bytes.
|
||||
type: integer
|
||||
|
||||
@@ -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(149);
|
||||
} 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
|
||||
@@ -932,9 +841,9 @@ public class EquipmentServiceRemoteTest extends BaseRemoteTest {
|
||||
assertEquals(11, radioMap.get(RadioType.is2dot4GHz).getManualBackupChannelNumber().intValue());
|
||||
|
||||
assertEquals(36, radioMap.get(RadioType.is5GHz).getChannelNumber().intValue());
|
||||
assertEquals(149, radioMap.get(RadioType.is5GHz).getBackupChannelNumber().intValue());
|
||||
assertEquals(44, radioMap.get(RadioType.is5GHz).getBackupChannelNumber().intValue());
|
||||
assertEquals(36, radioMap.get(RadioType.is5GHz).getManualChannelNumber().intValue());
|
||||
assertEquals(149, radioMap.get(RadioType.is5GHz).getManualBackupChannelNumber().intValue());
|
||||
assertEquals(44, radioMap.get(RadioType.is5GHz).getManualBackupChannelNumber().intValue());
|
||||
|
||||
Map<RadioType, Integer> primaryChannels = new EnumMap<>(RadioType.class);
|
||||
Map<RadioType, Integer> backupChannels = new EnumMap<>(RadioType.class);
|
||||
@@ -970,7 +879,7 @@ public class EquipmentServiceRemoteTest extends BaseRemoteTest {
|
||||
assertEquals(6, radioMap.get(RadioType.is2dot4GHz).getManualBackupChannelNumber().intValue());
|
||||
|
||||
assertEquals(36, radioMap.get(RadioType.is5GHz).getChannelNumber().intValue());
|
||||
assertEquals(149, radioMap.get(RadioType.is5GHz).getBackupChannelNumber().intValue());
|
||||
assertEquals(44, radioMap.get(RadioType.is5GHz).getBackupChannelNumber().intValue());
|
||||
assertEquals(40, radioMap.get(RadioType.is5GHz).getManualChannelNumber().intValue());
|
||||
assertEquals(48, radioMap.get(RadioType.is5GHz).getManualBackupChannelNumber().intValue());
|
||||
|
||||
@@ -980,7 +889,7 @@ public class EquipmentServiceRemoteTest extends BaseRemoteTest {
|
||||
|
||||
backupChannels.clear();
|
||||
backupChannels.put(RadioType.is2dot4GHz, 6);
|
||||
backupChannels.put(RadioType.is5GHz, 44);
|
||||
backupChannels.put(RadioType.is5GHz, 149);
|
||||
|
||||
autoChannelSelections.clear();
|
||||
autoChannelSelections.put(RadioType.is2dot4GHz, true);
|
||||
@@ -1007,7 +916,7 @@ public class EquipmentServiceRemoteTest extends BaseRemoteTest {
|
||||
assertEquals(6, radioMap.get(RadioType.is2dot4GHz).getManualBackupChannelNumber().intValue());
|
||||
|
||||
assertEquals(161, radioMap.get(RadioType.is5GHz).getChannelNumber().intValue());
|
||||
assertEquals(44, radioMap.get(RadioType.is5GHz).getBackupChannelNumber().intValue());
|
||||
assertEquals(149, radioMap.get(RadioType.is5GHz).getBackupChannelNumber().intValue());
|
||||
assertEquals(40, radioMap.get(RadioType.is5GHz).getManualChannelNumber().intValue());
|
||||
assertEquals(48, radioMap.get(RadioType.is5GHz).getManualBackupChannelNumber().intValue());
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -263,14 +260,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 +294,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 +536,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, "");
|
||||
|
||||
@@ -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, "");
|
||||
}
|
||||
|
||||
@@ -5175,9 +5175,6 @@ components:
|
||||
properties:
|
||||
model_type:
|
||||
type: string
|
||||
secondsSinceLastRecv:
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
numRxPackets:
|
||||
type: integer
|
||||
@@ -5216,12 +5213,6 @@ components:
|
||||
rssi:
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
classificationName:
|
||||
type: string
|
||||
|
||||
channelBandWidth:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
|
||||
averageTxRate:
|
||||
type: number
|
||||
@@ -5238,21 +5229,11 @@ components:
|
||||
type: integer
|
||||
format: int64
|
||||
|
||||
rxLastRssi:
|
||||
description: The RSSI of last frame received.
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
numRxNoFcsErr:
|
||||
description: The number of received frames without FCS errors.
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
numRxData:
|
||||
description: The number of received data frames.
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
rxBytes:
|
||||
description: The number of received bytes.
|
||||
type: integer
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -116,7 +116,7 @@ public class RfElementConfiguration extends BaseJsonModel {
|
||||
ret.setMinAutoCellSize(MIN_CELL_SIZE_MAP.get(radioType));
|
||||
ret.setMaxAutoCellSize(MAX_CELL_SIZE_MAP.get(radioType));
|
||||
if (radioType == RadioType.is5GHz || radioType == RadioType.is5GHzL || radioType == RadioType.is5GHzU) {
|
||||
ret.setChannelBandwidth(ChannelBandwidth.is80MHz);
|
||||
ret.setChannelBandwidth(ChannelBandwidth.is40MHz);
|
||||
ret.setRadioMode(RadioMode.modeAC);
|
||||
} else {
|
||||
ret.setChannelBandwidth(ChannelBandwidth.is20MHz);
|
||||
|
||||
@@ -269,6 +269,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);
|
||||
|
||||
@@ -114,10 +114,6 @@ public abstract class BaseServiceMetricDatastoreTest {
|
||||
serviceMetric.setEquipmentId(testSequence.incrementAndGet());
|
||||
serviceMetric.setClientMac(testSequence.incrementAndGet());
|
||||
serviceMetric.setCreatedTimestamp(baseTimestamp - 100000 + testSequence.incrementAndGet());
|
||||
|
||||
ClientMetrics details2 = new ClientMetrics();
|
||||
details2.setClassificationName("qr_"+apNameIdx);
|
||||
serviceMetric.setDetails(details2);
|
||||
|
||||
apNameIdx++;
|
||||
|
||||
@@ -132,10 +128,6 @@ public abstract class BaseServiceMetricDatastoreTest {
|
||||
serviceMetric.setEquipmentId(testSequence.incrementAndGet());
|
||||
serviceMetric.setClientMac(testSequence.incrementAndGet());
|
||||
serviceMetric.setCreatedTimestamp(baseTimestamp + testSequence.incrementAndGet());
|
||||
|
||||
ClientMetrics details2 = new ClientMetrics();
|
||||
details2.setClassificationName("qr_"+apNameIdx);
|
||||
serviceMetric.setDetails(details2);
|
||||
|
||||
apNameIdx++;
|
||||
|
||||
@@ -150,10 +142,6 @@ public abstract class BaseServiceMetricDatastoreTest {
|
||||
serviceMetric.setEquipmentId(testSequence.incrementAndGet());
|
||||
serviceMetric.setClientMac(testSequence.incrementAndGet());
|
||||
serviceMetric.setCreatedTimestamp(baseTimestamp - 100000 + testSequence.incrementAndGet());
|
||||
|
||||
ClientMetrics details2 = new ClientMetrics();
|
||||
details2.setClassificationName("qr_"+apNameIdx);
|
||||
serviceMetric.setDetails(details2);
|
||||
|
||||
apNameIdx++;
|
||||
|
||||
@@ -200,43 +188,18 @@ public abstract class BaseServiceMetricDatastoreTest {
|
||||
assertTrue(page6.getContext().isLastPage());
|
||||
assertTrue(page7.getContext().isLastPage());
|
||||
|
||||
List<String> expectedPage3Strings = new ArrayList<>(Arrays.asList(new String[]{"qr_20", "qr_21", "qr_22", "qr_23", "qr_24", "qr_25", "qr_26", "qr_27", "qr_28", "qr_29" }));
|
||||
List<String> actualPage3Strings = new ArrayList<>();
|
||||
page3.getItems().stream().forEach( ce -> actualPage3Strings.add(((ClientMetrics) ce.getDetails()).getClassificationName()) );
|
||||
|
||||
assertEquals(expectedPage3Strings, actualPage3Strings);
|
||||
|
||||
//test first page of the results with empty sort order -> default sort order (by createdTimestamp ascending)
|
||||
PaginationResponse<ServiceMetric> page1EmptySort = testInterface.getForCustomer(fromTime, toTime, customerId_1, null, null, null, null, Collections.emptyList(), context);
|
||||
assertEquals(10, page1EmptySort.getItems().size());
|
||||
|
||||
List<String> expectedPage1EmptySortStrings = new ArrayList<>(Arrays.asList(new String[]{"qr_0", "qr_1", "qr_2", "qr_3", "qr_4", "qr_5", "qr_6", "qr_7", "qr_8", "qr_9" }));
|
||||
List<String> actualPage1EmptySortStrings = new ArrayList<>();
|
||||
page1EmptySort.getItems().stream().forEach( ce -> actualPage1EmptySortStrings.add(((ClientMetrics) ce.getDetails()).getClassificationName() ) );
|
||||
|
||||
assertEquals(expectedPage1EmptySortStrings, actualPage1EmptySortStrings);
|
||||
|
||||
//test first page of the results with null sort order -> default sort order (by createdTimestamp ascending)
|
||||
PaginationResponse<ServiceMetric> page1NullSort = testInterface.getForCustomer(fromTime, toTime, customerId_1, null, null, null, null, null, context);
|
||||
assertEquals(10, page1NullSort.getItems().size());
|
||||
|
||||
List<String> expectedPage1NullSortStrings = new ArrayList<>(Arrays.asList(new String[]{"qr_0", "qr_1", "qr_2", "qr_3", "qr_4", "qr_5", "qr_6", "qr_7", "qr_8", "qr_9" }));
|
||||
List<String> actualPage1NullSortStrings = new ArrayList<>();
|
||||
page1NullSort.getItems().stream().forEach( ce -> actualPage1NullSortStrings.add(((ClientMetrics) ce.getDetails()).getClassificationName() ) );
|
||||
|
||||
assertEquals(expectedPage1NullSortStrings, actualPage1NullSortStrings);
|
||||
|
||||
|
||||
//test first page of the results with sort descending order by a equipmentId property
|
||||
PaginationResponse<ServiceMetric> page1SingleSortDesc = testInterface.getForCustomer(fromTime, toTime, customerId_1, null, null, null, null, Collections.singletonList(new ColumnAndSort("equipmentId", SortOrder.desc)), context);
|
||||
assertEquals(10, page1SingleSortDesc.getItems().size());
|
||||
|
||||
List<String> expectedPage1SingleSortDescStrings = getPagination_expectedPage1SingleSortDescStrings();
|
||||
List<String> actualPage1SingleSortDescStrings = new ArrayList<>();
|
||||
page1SingleSortDesc.getItems().stream().forEach( ce -> actualPage1SingleSortDescStrings.add(((ClientMetrics) ce.getDetails()).getClassificationName() ) );
|
||||
|
||||
assertEquals(expectedPage1SingleSortDescStrings, actualPage1SingleSortDescStrings);
|
||||
|
||||
used_equipmentIds.forEach(eqId -> testInterface.delete(customerId_1, eqId, System.currentTimeMillis()));
|
||||
used_equipmentIds.forEach(eqId -> testInterface.delete(customerId_2, eqId, System.currentTimeMillis()));
|
||||
|
||||
@@ -336,9 +299,8 @@ public abstract class BaseServiceMetricDatastoreTest {
|
||||
serviceMetric.setCreatedTimestamp(baseTimestamp - testSequence.incrementAndGet());
|
||||
|
||||
ClientMetrics details2 = new ClientMetrics();
|
||||
details2.setClassificationName("qr_"+apNameIdx);
|
||||
serviceMetric.setDetails(details2);
|
||||
|
||||
|
||||
testInterface.create(serviceMetric);
|
||||
|
||||
//third metric - neighbour
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.telecominfraproject.wlan.servicemetric.client.models;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.ChannelBandwidth;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDataType;
|
||||
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDetails;
|
||||
@@ -18,19 +16,14 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
|
||||
private static final long serialVersionUID = 7242365268669169773L;
|
||||
|
||||
private Integer secondsSinceLastRecv;
|
||||
|
||||
private Long numRxPackets;
|
||||
private Long numTxPackets;
|
||||
private Long numRxBytes;
|
||||
private Long numTxBytes;
|
||||
private Integer txRetries;
|
||||
private Integer rxDuplicatePackets;
|
||||
private int[] rates;
|
||||
private Integer snr;
|
||||
private Integer rssi;
|
||||
private String classificationName;
|
||||
ChannelBandwidth channelBandWidth;
|
||||
|
||||
private Double averageTxRate;
|
||||
private Double averageRxRate;
|
||||
@@ -38,21 +31,11 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
private Long numTxFramesTransmitted;
|
||||
private Long numRxFramesReceived;
|
||||
|
||||
/**
|
||||
* The RSSI of last frame received.
|
||||
*/
|
||||
private Integer rxLastRssi;
|
||||
|
||||
/**
|
||||
* The number of received frames without FCS errors.
|
||||
*/
|
||||
private Integer numRxNoFcsErr;
|
||||
|
||||
/**
|
||||
* The number of received data frames.
|
||||
*/
|
||||
private Integer numRxData;
|
||||
|
||||
/**
|
||||
* The number of received bytes.
|
||||
*/
|
||||
@@ -90,13 +73,7 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
|
||||
@Override
|
||||
public ClientMetrics clone() {
|
||||
ClientMetrics ret = (ClientMetrics) super.clone();
|
||||
|
||||
if(this.rates!=null){
|
||||
ret.rates = this.rates.clone();
|
||||
}
|
||||
|
||||
return ret;
|
||||
return (ClientMetrics) super.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,15 +89,14 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
}
|
||||
ClientMetrics other = (ClientMetrics) obj;
|
||||
return Objects.equals(averageRxRate, other.averageRxRate) && Objects.equals(averageTxRate, other.averageTxRate)
|
||||
&& this.channelBandWidth == other.channelBandWidth && Objects.equals(classificationName, other.classificationName)
|
||||
&& Objects.equals(numRxBytes, other.numRxBytes) && Objects.equals(numRxData, other.numRxData)
|
||||
&& Objects.equals(numRxBytes, other.numRxBytes)
|
||||
&& Objects.equals(numRxFramesReceived, other.numRxFramesReceived) && Objects.equals(numRxNoFcsErr, other.numRxNoFcsErr)
|
||||
&& Objects.equals(numRxPackets, other.numRxPackets) && Objects.equals(numRxRetry, other.numRxRetry)
|
||||
&& Objects.equals(numTxBytes, other.numTxBytes) && Objects.equals(numTxDataRetries, other.numTxDataRetries)
|
||||
&& Objects.equals(numTxDropped, other.numTxDropped) && Objects.equals(numTxFramesTransmitted, other.numTxFramesTransmitted)
|
||||
&& Objects.equals(numTxPackets, other.numTxPackets) && this.radioType == other.radioType
|
||||
&& Arrays.equals(rates, other.rates) && Objects.equals(rssi, other.rssi) && Objects.equals(rxBytes, other.rxBytes)
|
||||
&& Objects.equals(rxDuplicatePackets, other.rxDuplicatePackets) && Objects.equals(rxLastRssi, other.rxLastRssi)
|
||||
&& Objects.equals(rssi, other.rssi) && Objects.equals(rxBytes, other.rxBytes)
|
||||
&& Objects.equals(rxDuplicatePackets, other.rxDuplicatePackets)
|
||||
&& Objects.equals(snr, other.snr) && Objects.equals(txRetries, other.txRetries);
|
||||
}
|
||||
|
||||
@@ -128,10 +104,6 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
return numRxBytes;
|
||||
}
|
||||
|
||||
public Integer getNumRxData() {
|
||||
return numRxData;
|
||||
}
|
||||
|
||||
public Integer getNumRxNoFcsErr() {
|
||||
return numRxNoFcsErr;
|
||||
}
|
||||
@@ -164,10 +136,6 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
return radioType;
|
||||
}
|
||||
|
||||
public int[] getRates() {
|
||||
return rates;
|
||||
}
|
||||
|
||||
public Integer getRssi() {
|
||||
return rssi;
|
||||
}
|
||||
@@ -180,10 +148,6 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
return rxDuplicatePackets;
|
||||
}
|
||||
|
||||
public Integer getRxLastRssi() {
|
||||
return rxLastRssi;
|
||||
}
|
||||
|
||||
public Integer getSnr() {
|
||||
return snr;
|
||||
}
|
||||
@@ -196,12 +160,11 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + Arrays.hashCode(this.rates);
|
||||
result = prime * result + Objects.hash(averageRxRate, averageTxRate, channelBandWidth,
|
||||
classificationName, numRxBytes, numRxData, numRxFramesReceived,
|
||||
result = prime * result + Objects.hash(averageRxRate, averageTxRate,
|
||||
numRxBytes, numRxFramesReceived,
|
||||
numRxNoFcsErr, numRxPackets, numRxRetry, numTxBytes,
|
||||
numTxDataRetries, numTxDropped, numTxFramesTransmitted, numTxPackets,
|
||||
radioType, rssi, rxBytes, rxDuplicatePackets, rxLastRssi, snr, txRetries);
|
||||
radioType, rssi, rxBytes, rxDuplicatePackets, snr, txRetries);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -210,7 +173,7 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
if (super.hasUnsupportedValue()) {
|
||||
return true;
|
||||
}
|
||||
if (RadioType.isUnsupported(radioType) || (ChannelBandwidth.isUnsupported(this.channelBandWidth))) {
|
||||
if (RadioType.isUnsupported(radioType)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -220,10 +183,6 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
this.numRxBytes = numRxBytes;
|
||||
}
|
||||
|
||||
public void setNumRxData(Integer numRxData) {
|
||||
this.numRxData = numRxData;
|
||||
}
|
||||
|
||||
public void setNumRxNoFcsErr(Integer numRxNoFcsErr) {
|
||||
this.numRxNoFcsErr = numRxNoFcsErr;
|
||||
}
|
||||
@@ -256,10 +215,6 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
this.radioType = radioType;
|
||||
}
|
||||
|
||||
public void setRates(int[] rates) {
|
||||
this.rates = rates;
|
||||
}
|
||||
|
||||
public void setRssi(Integer rssi) {
|
||||
this.rssi = rssi;
|
||||
}
|
||||
@@ -272,10 +227,6 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
this.rxDuplicatePackets = rxDuplicatePackets;
|
||||
}
|
||||
|
||||
public void setRxLastRssi(Integer rxLastRssi) {
|
||||
this.rxLastRssi = rxLastRssi;
|
||||
}
|
||||
|
||||
public void setSnr(Integer snr) {
|
||||
this.snr = snr;
|
||||
}
|
||||
@@ -300,22 +251,6 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
this.numRxFramesReceived = numRxFramesReceived;
|
||||
}
|
||||
|
||||
public String getClassificationName() {
|
||||
return classificationName;
|
||||
}
|
||||
|
||||
public void setClassificationName(String classificationName) {
|
||||
this.classificationName = classificationName;
|
||||
}
|
||||
|
||||
public ChannelBandwidth getChannelBandWidth() {
|
||||
return channelBandWidth;
|
||||
}
|
||||
|
||||
public void setChannelBandWidth(ChannelBandwidth channelBandWidth) {
|
||||
this.channelBandWidth = channelBandWidth;
|
||||
}
|
||||
|
||||
public Double getAverageTxRate() {
|
||||
return averageTxRate;
|
||||
}
|
||||
@@ -332,14 +267,6 @@ public class ClientMetrics extends ServiceMetricDetails {
|
||||
this.averageRxRate = averageRxRate;
|
||||
}
|
||||
|
||||
public Integer getSecondsSinceLastRecv() {
|
||||
return secondsSinceLastRecv;
|
||||
}
|
||||
|
||||
public void setSecondsSinceLastRecv(Integer secondsSinceLastRecv) {
|
||||
this.secondsSinceLastRecv = secondsSinceLastRecv;
|
||||
}
|
||||
|
||||
public Integer getPeriodLengthSec() {
|
||||
return periodLengthSec;
|
||||
}
|
||||
|
||||
@@ -127,10 +127,6 @@ public class ServiceMetricServiceRemoteTest extends BaseRemoteTest {
|
||||
serviceMetric.setClientMac(getNextEquipmentId());
|
||||
serviceMetric.setCreatedTimestamp(baseTimestamp - 100000 + getNextEquipmentId());
|
||||
|
||||
ClientMetrics details2 = new ClientMetrics();
|
||||
details2.setClassificationName("qr_"+apNameIdx);
|
||||
serviceMetric.setDetails(details2);
|
||||
|
||||
apNameIdx++;
|
||||
|
||||
remoteInterface.create(serviceMetric);
|
||||
@@ -144,10 +140,6 @@ public class ServiceMetricServiceRemoteTest extends BaseRemoteTest {
|
||||
serviceMetric.setClientMac(getNextEquipmentId());
|
||||
serviceMetric.setCreatedTimestamp(baseTimestamp + getNextEquipmentId());
|
||||
|
||||
ClientMetrics details2 = new ClientMetrics();
|
||||
details2.setClassificationName("qr_"+apNameIdx);
|
||||
serviceMetric.setDetails(details2);
|
||||
|
||||
apNameIdx++;
|
||||
|
||||
remoteInterface.create(serviceMetric);
|
||||
@@ -161,10 +153,6 @@ public class ServiceMetricServiceRemoteTest extends BaseRemoteTest {
|
||||
serviceMetric.setClientMac(getNextEquipmentId());
|
||||
serviceMetric.setCreatedTimestamp(baseTimestamp - 100000 + getNextEquipmentId());
|
||||
|
||||
ClientMetrics details2 = new ClientMetrics();
|
||||
details2.setClassificationName("qr_"+apNameIdx);
|
||||
serviceMetric.setDetails(details2);
|
||||
|
||||
apNameIdx++;
|
||||
|
||||
remoteInterface.create(serviceMetric);
|
||||
@@ -209,43 +197,18 @@ public class ServiceMetricServiceRemoteTest extends BaseRemoteTest {
|
||||
assertTrue(page6.getContext().isLastPage());
|
||||
assertTrue(page7.getContext().isLastPage());
|
||||
|
||||
List<String> expectedPage3Strings = new ArrayList<>(Arrays.asList(new String[]{"qr_20", "qr_21", "qr_22", "qr_23", "qr_24", "qr_25", "qr_26", "qr_27", "qr_28", "qr_29" }));
|
||||
List<String> actualPage3Strings = new ArrayList<>();
|
||||
page3.getItems().stream().forEach( ce -> actualPage3Strings.add(((ClientMetrics) ce.getDetails()).getClassificationName()) );
|
||||
|
||||
assertEquals(expectedPage3Strings, actualPage3Strings);
|
||||
|
||||
//test first page of the results with empty sort order -> default sort order (by createdTimestamp ascending)
|
||||
PaginationResponse<ServiceMetric> page1EmptySort = remoteInterface.getForCustomer(fromTime, toTime, customerId_1, null, null, null, null, Collections.emptyList(), context);
|
||||
assertEquals(10, page1EmptySort.getItems().size());
|
||||
|
||||
List<String> expectedPage1EmptySortStrings = new ArrayList<>(Arrays.asList(new String[]{"qr_0", "qr_1", "qr_2", "qr_3", "qr_4", "qr_5", "qr_6", "qr_7", "qr_8", "qr_9" }));
|
||||
List<String> actualPage1EmptySortStrings = new ArrayList<>();
|
||||
page1EmptySort.getItems().stream().forEach( ce -> actualPage1EmptySortStrings.add(((ClientMetrics) ce.getDetails()).getClassificationName() ) );
|
||||
|
||||
assertEquals(expectedPage1EmptySortStrings, actualPage1EmptySortStrings);
|
||||
|
||||
//test first page of the results with null sort order -> default sort order (by createdTimestamp ascending)
|
||||
PaginationResponse<ServiceMetric> page1NullSort = remoteInterface.getForCustomer(fromTime, toTime, customerId_1, null, null, null, null, null, context);
|
||||
assertEquals(10, page1NullSort.getItems().size());
|
||||
|
||||
List<String> expectedPage1NullSortStrings = new ArrayList<>(Arrays.asList(new String[]{"qr_0", "qr_1", "qr_2", "qr_3", "qr_4", "qr_5", "qr_6", "qr_7", "qr_8", "qr_9" }));
|
||||
List<String> actualPage1NullSortStrings = new ArrayList<>();
|
||||
page1NullSort.getItems().stream().forEach( ce -> actualPage1NullSortStrings.add(((ClientMetrics) ce.getDetails()).getClassificationName() ) );
|
||||
|
||||
assertEquals(expectedPage1NullSortStrings, actualPage1NullSortStrings);
|
||||
|
||||
|
||||
//test first page of the results with sort descending order by a equipmentId property
|
||||
PaginationResponse<ServiceMetric> page1SingleSortDesc = remoteInterface.getForCustomer(fromTime, toTime, customerId_1, null, null, null, null, Collections.singletonList(new ColumnAndSort("equipmentId", SortOrder.desc)), context);
|
||||
assertEquals(10, page1SingleSortDesc.getItems().size());
|
||||
|
||||
List<String> expectedPage1SingleSortDescStrings = new ArrayList< >(Arrays.asList(new String[]{"qr_49", "qr_48", "qr_47", "qr_46", "qr_45", "qr_44", "qr_43", "qr_42", "qr_41", "qr_40" }));
|
||||
List<String> actualPage1SingleSortDescStrings = new ArrayList<>();
|
||||
page1SingleSortDesc.getItems().stream().forEach( ce -> actualPage1SingleSortDescStrings.add(((ClientMetrics) ce.getDetails()).getClassificationName() ) );
|
||||
|
||||
assertEquals(expectedPage1SingleSortDescStrings, actualPage1SingleSortDescStrings);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +301,6 @@ public class ServiceMetricServiceRemoteTest extends BaseRemoteTest {
|
||||
serviceMetric.setCreatedTimestamp(baseTimestamp - getNextEquipmentId());
|
||||
|
||||
ClientMetrics details2 = new ClientMetrics();
|
||||
details2.setClassificationName("qr_"+apNameIdx);
|
||||
serviceMetric.setDetails(details2);
|
||||
|
||||
remoteInterface.create(serviceMetric);
|
||||
|
||||
@@ -213,11 +213,7 @@ components:
|
||||
- SGI# Short Guard Interval
|
||||
|
||||
ClientMetrics:
|
||||
properties:
|
||||
secondsSinceLastRecv:
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
properties:
|
||||
numRxPackets:
|
||||
type: integer
|
||||
format: int64
|
||||
@@ -256,12 +252,6 @@ components:
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
classificationName:
|
||||
type: string
|
||||
|
||||
channelBandWidth:
|
||||
$ref: '#/components/schemas/ChannelBandwidth'
|
||||
|
||||
averageTxRate:
|
||||
type: number
|
||||
format: double
|
||||
@@ -277,22 +267,11 @@ components:
|
||||
type: integer
|
||||
format: int64
|
||||
|
||||
rxLastRssi:
|
||||
description: The RSSI of last frame received.
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
numRxNoFcsErr:
|
||||
description: The number of received frames without FCS errors.
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
numRxData:
|
||||
description: The number of received data frames.
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
|
||||
rxBytes:
|
||||
description: The number of received bytes.
|
||||
type: integer
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,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 {
|
||||
|
||||
Reference in New Issue
Block a user