mirror of
https://github.com/Telecominfraproject/wlan-cloud-services.git
synced 2026-03-20 22:39:22 +00:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80cd0abd58 | ||
|
|
4555ff339b | ||
|
|
04a13877d1 | ||
|
|
e148bab291 | ||
|
|
9ad3cec4af | ||
|
|
dc0b838f83 | ||
|
|
7cac7fff3f | ||
|
|
b48340b709 | ||
|
|
44b3836758 | ||
|
|
4f0b032549 | ||
|
|
5ba0c4c242 | ||
|
|
304e80332a | ||
|
|
9fd3e73398 | ||
|
|
b9db744aee | ||
|
|
1eee65d284 | ||
|
|
75c943211a | ||
|
|
d0a0ed59fe | ||
|
|
a200fcc12e | ||
|
|
1f6996abb2 | ||
|
|
1ebaa4a539 | ||
|
|
f1e1bdffd7 | ||
|
|
37f5872552 | ||
|
|
367b9ec428 | ||
|
|
87ca619ad5 | ||
|
|
622f78f681 | ||
|
|
faeb65d8d6 | ||
|
|
34841a3a04 | ||
|
|
4fc8bc4018 | ||
|
|
cce36019fe | ||
|
|
4596280090 | ||
|
|
caaa8fb4e3 | ||
|
|
b957c8bf72 | ||
|
|
b797cc392f | ||
|
|
5fc9715649 | ||
|
|
0a66897e48 | ||
|
|
8d77fcb090 | ||
|
|
256d9fbd16 | ||
|
|
39e14da2e6 |
@@ -52,6 +52,18 @@
|
|||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<artifactId>equipment-service-local</artifactId>
|
||||||
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<artifactId>equipment-datastore-inmemory</artifactId>
|
||||||
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
@@ -26,12 +27,17 @@ import com.telecominfraproject.wlan.alarm.models.Alarm;
|
|||||||
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
|
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
|
||||||
import com.telecominfraproject.wlan.alarm.models.AlarmCounts;
|
import com.telecominfraproject.wlan.alarm.models.AlarmCounts;
|
||||||
import com.telecominfraproject.wlan.alarm.models.AlarmDetails;
|
import com.telecominfraproject.wlan.alarm.models.AlarmDetails;
|
||||||
|
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherEmpty;
|
||||||
|
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
|
||||||
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
|
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
|
||||||
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
|
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
|
||||||
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
|
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
|
||||||
import com.telecominfraproject.wlan.core.model.pagination.SortOrder;
|
import com.telecominfraproject.wlan.core.model.pagination.SortOrder;
|
||||||
import com.telecominfraproject.wlan.datastore.exceptions.DsConcurrentModificationException;
|
import com.telecominfraproject.wlan.datastore.exceptions.DsConcurrentModificationException;
|
||||||
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
|
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
|
||||||
|
import com.telecominfraproject.wlan.equipment.EquipmentServiceLocal;
|
||||||
|
import com.telecominfraproject.wlan.equipment.datastore.inmemory.EquipmentDatastoreInMemory;
|
||||||
|
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
||||||
import com.telecominfraproject.wlan.remote.tests.BaseRemoteTest;
|
import com.telecominfraproject.wlan.remote.tests.BaseRemoteTest;
|
||||||
import com.telecominfraproject.wlan.status.models.StatusCode;
|
import com.telecominfraproject.wlan.status.models.StatusCode;
|
||||||
|
|
||||||
@@ -44,10 +50,16 @@ import com.telecominfraproject.wlan.status.models.StatusCode;
|
|||||||
"integration_test",
|
"integration_test",
|
||||||
"no_ssl","http_digest_auth","rest-template-single-user-per-service-digest-auth",
|
"no_ssl","http_digest_auth","rest-template-single-user-per-service-digest-auth",
|
||||||
}) //NOTE: these profiles will be ADDED to the list of active profiles
|
}) //NOTE: these profiles will be ADDED to the list of active profiles
|
||||||
|
@Import(value = {
|
||||||
|
EquipmentServiceLocal.class,
|
||||||
|
EquipmentDatastoreInMemory.class,
|
||||||
|
CloudEventDispatcherEmpty.class
|
||||||
|
})
|
||||||
public class AlarmServiceRemoteTest extends BaseRemoteTest {
|
public class AlarmServiceRemoteTest extends BaseRemoteTest {
|
||||||
|
|
||||||
|
|
||||||
@Autowired AlarmServiceRemote remoteInterface;
|
@Autowired AlarmServiceRemote remoteInterface;
|
||||||
|
@Autowired EquipmentServiceLocal equipmentServicelocal;
|
||||||
|
|
||||||
@Before public void urlSetup(){
|
@Before public void urlSetup(){
|
||||||
configureBaseUrl("tip.wlan.alarmServiceBaseUrl");
|
configureBaseUrl("tip.wlan.alarmServiceBaseUrl");
|
||||||
@@ -505,8 +517,10 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
|
|||||||
public void testAlarmCountsRetrieval() {
|
public void testAlarmCountsRetrieval() {
|
||||||
//create some Alarms
|
//create some Alarms
|
||||||
Alarm mdl;
|
Alarm mdl;
|
||||||
int customerId_1 = getNextCustomerId();
|
final int customerId_1 = getNextCustomerId();
|
||||||
int customerId_2 = getNextCustomerId();
|
final int customerId_2 = getNextCustomerId();
|
||||||
|
final long equipmentId_1 = createEquipmentObject(customerId_1).getId();
|
||||||
|
|
||||||
|
|
||||||
int apNameIdx = 0;
|
int apNameIdx = 0;
|
||||||
Set<Long> equipmentIds = new HashSet<>();
|
Set<Long> equipmentIds = new HashSet<>();
|
||||||
@@ -514,8 +528,8 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
|
|||||||
Set<Long> equipmentIds_AccessPointIsUnreachable = new HashSet<>();
|
Set<Long> equipmentIds_AccessPointIsUnreachable = new HashSet<>();
|
||||||
|
|
||||||
for(int i = 0; i< 50; i++){
|
for(int i = 0; i< 50; i++){
|
||||||
mdl = createAlarmObject();
|
mdl = createAlarmObject(customerId_1, createEquipmentObject(customerId_1).getId());
|
||||||
mdl.setCustomerId(customerId_1);
|
mdl.setEquipmentId(createEquipmentObject(customerId_1).getId());
|
||||||
mdl.setScopeId("qr_"+apNameIdx);
|
mdl.setScopeId("qr_"+apNameIdx);
|
||||||
if((i%2) == 0) {
|
if((i%2) == 0) {
|
||||||
mdl.setAlarmCode(AlarmCode.CPUUtilization);
|
mdl.setAlarmCode(AlarmCode.CPUUtilization);
|
||||||
@@ -530,16 +544,14 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
|
|||||||
remoteInterface.create(mdl);
|
remoteInterface.create(mdl);
|
||||||
}
|
}
|
||||||
|
|
||||||
mdl = createAlarmObject();
|
mdl = createAlarmObject(customerId_1, equipmentId_1);
|
||||||
mdl.setCustomerId(customerId_1);
|
mdl.setCustomerId(customerId_1);
|
||||||
mdl.setEquipmentId(0);
|
|
||||||
mdl.setAlarmCode(AlarmCode.GenericError);
|
mdl.setAlarmCode(AlarmCode.GenericError);
|
||||||
|
|
||||||
remoteInterface.create(mdl);
|
remoteInterface.create(mdl);
|
||||||
|
|
||||||
for(int i = 0; i< 50; i++){
|
for(int i = 0; i< 50; i++){
|
||||||
mdl = createAlarmObject();
|
mdl = createAlarmObject(customerId_2, createEquipmentObject(customerId_2).getId());
|
||||||
mdl.setCustomerId(customerId_2);
|
|
||||||
mdl.setScopeId("qr_"+apNameIdx);
|
mdl.setScopeId("qr_"+apNameIdx);
|
||||||
mdl.setAcknowledged(false);
|
mdl.setAcknowledged(false);
|
||||||
mdl.setAlarmCode(AlarmCode.GenericError);
|
mdl.setAlarmCode(AlarmCode.GenericError);
|
||||||
@@ -651,18 +663,33 @@ public class AlarmServiceRemoteTest extends BaseRemoteTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Alarm createAlarmObject() {
|
private Alarm createAlarmObject() {
|
||||||
Alarm result = new Alarm();
|
int customerId = getNextCustomerId();
|
||||||
result.setCustomerId(getNextCustomerId());
|
return createAlarmObject(customerId, createEquipmentObject(customerId).getId());
|
||||||
result.setEquipmentId(getNextEquipmentId());
|
}
|
||||||
|
|
||||||
|
private Alarm createAlarmObject(int customerId, long equipmentId) {
|
||||||
|
Alarm result = new Alarm();
|
||||||
|
result.setCustomerId(customerId);
|
||||||
result.setAlarmCode(AlarmCode.AccessPointIsUnreachable);
|
result.setAlarmCode(AlarmCode.AccessPointIsUnreachable);
|
||||||
result.setCreatedTimestamp(System.currentTimeMillis());
|
result.setCreatedTimestamp(System.currentTimeMillis());
|
||||||
|
result.setEquipmentId(equipmentId);
|
||||||
|
|
||||||
result.setScopeId("test-scope-" + result.getEquipmentId());
|
result.setScopeId("test-scope-" + result.getEquipmentId());
|
||||||
|
|
||||||
AlarmDetails details = new AlarmDetails();
|
AlarmDetails details = new AlarmDetails();
|
||||||
details.setMessage("test-details-" + result.getEquipmentId());
|
details.setMessage("test-details-" + result.getEquipmentId());
|
||||||
result.setDetails(details );
|
result.setDetails(details );
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Equipment createEquipmentObject(int customerId)
|
||||||
|
{
|
||||||
|
Equipment equipment = new Equipment();
|
||||||
|
equipment.setName("testName");
|
||||||
|
equipment.setInventoryId("test-inv");
|
||||||
|
equipment.setEquipmentType(EquipmentType.AP);
|
||||||
|
equipment.setCustomerId(customerId);
|
||||||
|
return equipmentServicelocal.create(equipment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,12 +34,29 @@
|
|||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<artifactId>equipment-service-interface</artifactId>
|
||||||
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<artifactId>alarm-datastore-inmemory</artifactId>
|
<artifactId>alarm-datastore-inmemory</artifactId>
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<artifactId>equipment-service-local</artifactId>
|
||||||
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<artifactId>equipment-datastore-inmemory</artifactId>
|
||||||
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
|
|||||||
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
|
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
|
||||||
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
|
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
|
||||||
import com.telecominfraproject.wlan.datastore.exceptions.DsDataValidationException;
|
import com.telecominfraproject.wlan.datastore.exceptions.DsDataValidationException;
|
||||||
|
import com.telecominfraproject.wlan.equipment.EquipmentServiceInterface;
|
||||||
import com.telecominfraproject.wlan.systemevent.models.SystemEvent;
|
import com.telecominfraproject.wlan.systemevent.models.SystemEvent;
|
||||||
|
|
||||||
import com.telecominfraproject.wlan.alarm.datastore.AlarmDatastore;
|
import com.telecominfraproject.wlan.alarm.datastore.AlarmDatastore;
|
||||||
@@ -48,6 +49,7 @@ public class AlarmController {
|
|||||||
|
|
||||||
@Autowired private AlarmDatastore alarmDatastore;
|
@Autowired private AlarmDatastore alarmDatastore;
|
||||||
@Autowired private CloudEventDispatcherInterface cloudEventDispatcher;
|
@Autowired private CloudEventDispatcherInterface cloudEventDispatcher;
|
||||||
|
@Autowired private EquipmentServiceInterface equipmentServiceInterface;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,6 +68,14 @@ public class AlarmController {
|
|||||||
LOG.error("Failed to create Alarm, request contains unsupported value: {}", alarm);
|
LOG.error("Failed to create Alarm, request contains unsupported value: {}", alarm);
|
||||||
throw new DsDataValidationException("Alarm contains unsupported value");
|
throw new DsDataValidationException("Alarm contains unsupported value");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (alarm.getEquipmentId() != 0)
|
||||||
|
{
|
||||||
|
if (equipmentServiceInterface.getOrNull(alarm.getEquipmentId()) == null)
|
||||||
|
{
|
||||||
|
throw new DsDataValidationException(String.format("Unable to create alarm for non-existant equipment ID: %d", alarm.getEquipmentId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
long ts = alarm.getCreatedTimestamp();
|
long ts = alarm.getCreatedTimestamp();
|
||||||
if (ts == 0) {
|
if (ts == 0) {
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ import org.springframework.test.context.ActiveProfiles;
|
|||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherEmpty;
|
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherEmpty;
|
||||||
|
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
|
||||||
|
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.Equipment;
|
||||||
import com.telecominfraproject.wlan.alarm.datastore.inmemory.AlarmDatastoreInMemory;
|
import com.telecominfraproject.wlan.alarm.datastore.inmemory.AlarmDatastoreInMemory;
|
||||||
import com.telecominfraproject.wlan.alarm.models.Alarm;
|
import com.telecominfraproject.wlan.alarm.models.Alarm;
|
||||||
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
|
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
|
||||||
@@ -39,10 +43,14 @@ import com.telecominfraproject.wlan.alarm.models.AlarmDetails;
|
|||||||
CloudEventDispatcherEmpty.class,
|
CloudEventDispatcherEmpty.class,
|
||||||
AlarmDatastoreInMemory.class,
|
AlarmDatastoreInMemory.class,
|
||||||
AlarmControllerTest.Config.class,
|
AlarmControllerTest.Config.class,
|
||||||
|
EquipmentServiceLocal.class,
|
||||||
|
EquipmentController.class,
|
||||||
|
EquipmentDatastoreInMemory.class
|
||||||
})
|
})
|
||||||
public class AlarmControllerTest {
|
public class AlarmControllerTest {
|
||||||
|
|
||||||
@Autowired private AlarmController alarmController;
|
@Autowired private AlarmController alarmController;
|
||||||
|
@Autowired EquipmentServiceLocal equipmentServicelocal;
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@@ -59,8 +67,9 @@ public class AlarmControllerTest {
|
|||||||
|
|
||||||
//Create new Alarm - success
|
//Create new Alarm - success
|
||||||
Alarm alarm = new Alarm();
|
Alarm alarm = new Alarm();
|
||||||
alarm.setCustomerId((int) testSequence.getAndIncrement());
|
int customerId = (int) testSequence.getAndIncrement();
|
||||||
alarm.setEquipmentId(testSequence.getAndIncrement());
|
alarm.setCustomerId(customerId);
|
||||||
|
alarm.setEquipmentId(createEquipmentObject(customerId).getId());
|
||||||
alarm.setAlarmCode(AlarmCode.AccessPointIsUnreachable);
|
alarm.setAlarmCode(AlarmCode.AccessPointIsUnreachable);
|
||||||
alarm.setCreatedTimestamp(System.currentTimeMillis());
|
alarm.setCreatedTimestamp(System.currentTimeMillis());
|
||||||
|
|
||||||
@@ -91,5 +100,14 @@ public class AlarmControllerTest {
|
|||||||
assertEquals(expected.getDetails(), actual.getDetails());
|
assertEquals(expected.getDetails(), actual.getDetails());
|
||||||
//TODO: add more fields to check here
|
//TODO: add more fields to check here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Equipment createEquipmentObject(int customerId)
|
||||||
|
{
|
||||||
|
Equipment equipment = new Equipment();
|
||||||
|
equipment.setName("testName");
|
||||||
|
equipment.setInventoryId("test-inv");
|
||||||
|
equipment.setEquipmentType(EquipmentType.AP);
|
||||||
|
equipment.setCustomerId(customerId);
|
||||||
|
return equipmentServicelocal.create(equipment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -349,12 +349,6 @@
|
|||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<artifactId>equipment-alarms-sp</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<artifactId>adoption-metrics-sp</artifactId>
|
<artifactId>adoption-metrics-sp</artifactId>
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
|||||||
@@ -250,12 +250,6 @@
|
|||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<artifactId>equipment-alarms-sp</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<artifactId>adoption-metrics-sp</artifactId>
|
<artifactId>adoption-metrics-sp</artifactId>
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
|||||||
@@ -336,12 +336,6 @@
|
|||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<artifactId>equipment-alarms-sp</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<artifactId>adoption-metrics-sp</artifactId>
|
<artifactId>adoption-metrics-sp</artifactId>
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
package com.telecominfraproject.wlan.startuptasks;
|
package com.telecominfraproject.wlan.startuptasks;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Inet4Address;
|
import java.net.Inet4Address;
|
||||||
import java.net.Inet6Address;
|
import java.net.Inet6Address;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.NoSuchFileException;
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
|
|||||||
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
|
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
|
||||||
|
|
||||||
import com.telecominfraproject.wlan.client.datastore.ClientDatastore;
|
import com.telecominfraproject.wlan.client.datastore.ClientDatastore;
|
||||||
|
import com.telecominfraproject.wlan.client.info.models.ClientSessionCounts;
|
||||||
import com.telecominfraproject.wlan.client.models.Client;
|
import com.telecominfraproject.wlan.client.models.Client;
|
||||||
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
||||||
|
|
||||||
@@ -108,6 +109,13 @@ public class ClientDatastoreCassandra implements ClientDatastore {
|
|||||||
|
|
||||||
return clientSessionDAO.getSessionsForCustomer(customerId, equipmentIds, locationIds, macSubstring, sortBy, context);
|
return clientSessionDAO.getSessionsForCustomer(customerId, equipmentIds, locationIds, macSubstring, sortBy, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientSessionCounts getSessionCounts(int customerId) {
|
||||||
|
// Not yet supported.
|
||||||
|
ClientSessionCounts counts = new ClientSessionCounts();
|
||||||
|
return counts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.telecominfraproject.wlan.client.datastore.inmemory;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -15,6 +16,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
|
|
||||||
import com.telecominfraproject.wlan.client.datastore.ClientDatastore;
|
import com.telecominfraproject.wlan.client.datastore.ClientDatastore;
|
||||||
import com.telecominfraproject.wlan.client.info.models.ClientInfoDetails;
|
import com.telecominfraproject.wlan.client.info.models.ClientInfoDetails;
|
||||||
|
import com.telecominfraproject.wlan.client.info.models.ClientSessionCounts;
|
||||||
import com.telecominfraproject.wlan.client.models.Client;
|
import com.telecominfraproject.wlan.client.models.Client;
|
||||||
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
||||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||||
@@ -512,4 +514,56 @@ public class ClientDatastoreInMemory extends BaseInMemoryDatastore implements Cl
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientSessionCounts getSessionCounts(int customerId) {
|
||||||
|
ClientSessionCounts counts = new ClientSessionCounts();
|
||||||
|
counts.setCustomerId(customerId);
|
||||||
|
|
||||||
|
long totalCount = 0;
|
||||||
|
Map<String, Long> perEquipmentMap = new HashMap<>();
|
||||||
|
Map<String, Long> perOuiMap = new HashMap<>();
|
||||||
|
Map<String, Long> perRadioMap = new HashMap<>();
|
||||||
|
|
||||||
|
for (ClientSession session : idToClientSessionMap.values()) {
|
||||||
|
if (session.getCustomerId() == customerId) {
|
||||||
|
totalCount++;
|
||||||
|
String equipmentIdString = Long.toString(session.getEquipmentId());
|
||||||
|
Long cnt = perEquipmentMap.get(equipmentIdString);
|
||||||
|
if (cnt == null) {
|
||||||
|
cnt = 0L;
|
||||||
|
} else {
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
perEquipmentMap.put(equipmentIdString, cnt);
|
||||||
|
|
||||||
|
if (session.getOui() != null) {
|
||||||
|
cnt = perOuiMap.get(session.getOui());
|
||||||
|
if (cnt == null) {
|
||||||
|
cnt = 0L;
|
||||||
|
} else {
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
perOuiMap.put(session.getOui(), cnt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (session.getDetails() != null && session.getDetails().getRadioType() != null) {
|
||||||
|
String radioTypeString = session.getDetails().getRadioType().toString();
|
||||||
|
cnt = perRadioMap.get(radioTypeString);
|
||||||
|
if (cnt == null) {
|
||||||
|
cnt = 0L;
|
||||||
|
} else {
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
perRadioMap.put(radioTypeString, cnt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
counts.setTotalCount(totalCount);
|
||||||
|
counts.setEquipmentCounts(perEquipmentMap);
|
||||||
|
counts.setOuiCounts(perOuiMap);
|
||||||
|
counts.setRadioCounts(perRadioMap);
|
||||||
|
return counts;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.telecominfraproject.wlan.client.info.models.ClientSessionCounts;
|
||||||
import com.telecominfraproject.wlan.client.models.Client;
|
import com.telecominfraproject.wlan.client.models.Client;
|
||||||
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
||||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||||
@@ -105,5 +106,12 @@ public interface ClientDatastore {
|
|||||||
*/
|
*/
|
||||||
PaginationResponse<ClientSession> getSessionsForCustomer(int customerId, Set<Long> equipmentIds, Set<Long> locationIds, String macSubstring, List<ColumnAndSort> sortBy, PaginationContext<ClientSession> context);
|
PaginationResponse<ClientSession> getSessionsForCustomer(int customerId, Set<Long> equipmentIds, Set<Long> locationIds, String macSubstring, List<ColumnAndSort> sortBy, PaginationContext<ClientSession> context);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Client Session counts for the given customerId.
|
||||||
|
*
|
||||||
|
* @param customerId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ClientSessionCounts getSessionCounts(int customerId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
|
||||||
|
package com.telecominfraproject.wlan.client.info.models;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total and per-oui/equipment/radio counts of the Client Sessions
|
||||||
|
*/
|
||||||
|
public class ClientSessionCounts extends BaseJsonModel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 7697349699510565184L;
|
||||||
|
|
||||||
|
private int customerId;
|
||||||
|
/**
|
||||||
|
* Total count of all client sessions for the customer Id.
|
||||||
|
*/
|
||||||
|
private long totalCount;
|
||||||
|
/**
|
||||||
|
* Counts of client sessions per equipment Id.
|
||||||
|
*/
|
||||||
|
private Map<String, Long> equipmentCounts = new HashMap<>();
|
||||||
|
/**
|
||||||
|
* Counts of client sessions per OUI.
|
||||||
|
*/
|
||||||
|
private Map<String, Long> ouiCounts = new HashMap<>();
|
||||||
|
/**
|
||||||
|
* Counts of client sessions per Radio Type.
|
||||||
|
*/
|
||||||
|
private Map<String, Long> radioCounts = new HashMap<>();
|
||||||
|
|
||||||
|
public int getCustomerId() {
|
||||||
|
return customerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomerId(int customerId) {
|
||||||
|
this.customerId = customerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalCount() {
|
||||||
|
return totalCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalCount(long totalCount) {
|
||||||
|
this.totalCount = totalCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Long> getEquipmentCounts() {
|
||||||
|
return equipmentCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEquipmentCounts(Map<String, Long> equipmentCounts) {
|
||||||
|
this.equipmentCounts = equipmentCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Long> getOuiCounts() {
|
||||||
|
return ouiCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOuiCounts(Map<String, Long> ouiCounts) {
|
||||||
|
this.ouiCounts = ouiCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Long> getRadioCounts() {
|
||||||
|
return radioCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRadioCounts(Map<String, Long> radioCounts) {
|
||||||
|
this.radioCounts = radioCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientSessionCounts clone() {
|
||||||
|
ClientSessionCounts ret = (ClientSessionCounts) super.clone();
|
||||||
|
if (equipmentCounts != null) {
|
||||||
|
ret.equipmentCounts = new HashMap<>(equipmentCounts);
|
||||||
|
}
|
||||||
|
if (ouiCounts != null) {
|
||||||
|
ret.ouiCounts = new HashMap<>(ouiCounts);
|
||||||
|
}
|
||||||
|
if (radioCounts != null) {
|
||||||
|
ret.radioCounts = new HashMap<>(radioCounts);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,6 +8,8 @@ import com.telecominfraproject.wlan.core.model.json.interfaces.HasCustomerId;
|
|||||||
|
|
||||||
public class ClientSession extends BaseJsonModel implements HasCustomerId {
|
public class ClientSession extends BaseJsonModel implements HasCustomerId {
|
||||||
|
|
||||||
|
private static final String UNKNOWN_OUI = "ffffff";
|
||||||
|
|
||||||
private static final long serialVersionUID = -7714023056859882994L;
|
private static final long serialVersionUID = -7714023056859882994L;
|
||||||
|
|
||||||
private MacAddress macAddress;
|
private MacAddress macAddress;
|
||||||
@@ -16,6 +18,7 @@ public class ClientSession extends BaseJsonModel implements HasCustomerId {
|
|||||||
private long locationId;
|
private long locationId;
|
||||||
private ClientSessionDetails details;
|
private ClientSessionDetails details;
|
||||||
private long lastModifiedTimestamp;
|
private long lastModifiedTimestamp;
|
||||||
|
private String oui;
|
||||||
|
|
||||||
public long getEquipmentId() {
|
public long getEquipmentId() {
|
||||||
return equipmentId;
|
return equipmentId;
|
||||||
@@ -47,6 +50,12 @@ public class ClientSession extends BaseJsonModel implements HasCustomerId {
|
|||||||
|
|
||||||
public void setMacAddress(MacAddress macAddress) {
|
public void setMacAddress(MacAddress macAddress) {
|
||||||
this.macAddress = macAddress;
|
this.macAddress = macAddress;
|
||||||
|
if (macAddress != null && macAddress.isGlobalAddress()) {
|
||||||
|
this.oui = macAddress.toOuiString();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.oui = UNKNOWN_OUI;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLastModifiedTimestamp() {
|
public long getLastModifiedTimestamp() {
|
||||||
@@ -65,6 +74,14 @@ public class ClientSession extends BaseJsonModel implements HasCustomerId {
|
|||||||
this.details = details;
|
this.details = details;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getOui() {
|
||||||
|
return oui;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOui(String oui) {
|
||||||
|
this.oui = oui;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClientSession clone() {
|
public ClientSession clone() {
|
||||||
ClientSession ret = (ClientSession) super.clone();
|
ClientSession ret = (ClientSession) super.clone();
|
||||||
@@ -79,7 +96,7 @@ public class ClientSession extends BaseJsonModel implements HasCustomerId {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(customerId, details, equipmentId, locationId, lastModifiedTimestamp, macAddress);
|
return Objects.hash(customerId, details, equipmentId, locationId, lastModifiedTimestamp, macAddress, oui);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -95,7 +112,8 @@ public class ClientSession extends BaseJsonModel implements HasCustomerId {
|
|||||||
&& equipmentId == other.equipmentId
|
&& equipmentId == other.equipmentId
|
||||||
&& locationId == other.locationId
|
&& locationId == other.locationId
|
||||||
&& lastModifiedTimestamp == other.lastModifiedTimestamp
|
&& lastModifiedTimestamp == other.lastModifiedTimestamp
|
||||||
&& Objects.equals(macAddress, other.macAddress);
|
&& Objects.equals(macAddress, other.macAddress)
|
||||||
|
&& Objects.equals(oui, other.oui);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import com.telecominfraproject.wlan.core.model.json.GenericResponse;
|
|||||||
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
|
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
|
||||||
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
|
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
|
||||||
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
|
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
|
||||||
|
import com.telecominfraproject.wlan.client.info.models.ClientSessionCounts;
|
||||||
import com.telecominfraproject.wlan.client.models.Client;
|
import com.telecominfraproject.wlan.client.models.Client;
|
||||||
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
||||||
|
|
||||||
@@ -144,4 +144,12 @@ public interface ClientServiceInterface {
|
|||||||
*/
|
*/
|
||||||
PaginationResponse<ClientSession> getSessionsForCustomer(int customerId, Set<Long> equipmentIds, Set<Long> locationIds, String macSubstring, List<ColumnAndSort> sortBy, PaginationContext<ClientSession> context);
|
PaginationResponse<ClientSession> getSessionsForCustomer(int customerId, Set<Long> equipmentIds, Set<Long> locationIds, String macSubstring, List<ColumnAndSort> sortBy, PaginationContext<ClientSession> context);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Client Session counts for the given customerId.
|
||||||
|
*
|
||||||
|
* @param customerId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ClientSessionCounts getSessionCounts(int customerId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ package com.telecominfraproject.wlan.client;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.telecominfraproject.wlan.client.controller.ClientController;
|
import com.telecominfraproject.wlan.client.controller.ClientController;
|
||||||
import com.telecominfraproject.wlan.client.controller.ClientController.ListOfClientSessions;
|
import com.telecominfraproject.wlan.client.controller.ClientController.ListOfClientSessions;
|
||||||
|
import com.telecominfraproject.wlan.client.info.models.ClientSessionCounts;
|
||||||
import com.telecominfraproject.wlan.client.models.Client;
|
import com.telecominfraproject.wlan.client.models.Client;
|
||||||
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
||||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||||
@@ -26,7 +25,6 @@ import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
|
|||||||
public class ClientServiceLocal implements ClientServiceInterface {
|
public class ClientServiceLocal implements ClientServiceInterface {
|
||||||
|
|
||||||
@Autowired private ClientController clientController;
|
@Autowired private ClientController clientController;
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ClientServiceLocal.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Client create(Client client) {
|
public Client create(Client client) {
|
||||||
@@ -109,5 +107,10 @@ public class ClientServiceLocal implements ClientServiceInterface {
|
|||||||
public GenericResponse deleteSessions(long createdBeforeTimestamp) {
|
public GenericResponse deleteSessions(long createdBeforeTimestamp) {
|
||||||
return clientController.deleteSessions(createdBeforeTimestamp);
|
return clientController.deleteSessions(createdBeforeTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientSessionCounts getSessionCounts(int customerId) {
|
||||||
|
return clientController.getSessionCounts(customerId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.springframework.http.HttpMethod;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.telecominfraproject.wlan.client.info.models.ClientSessionCounts;
|
||||||
import com.telecominfraproject.wlan.client.models.Client;
|
import com.telecominfraproject.wlan.client.models.Client;
|
||||||
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
||||||
import com.telecominfraproject.wlan.core.client.BaseRemoteClient;
|
import com.telecominfraproject.wlan.core.client.BaseRemoteClient;
|
||||||
@@ -365,5 +366,21 @@ public class ClientServiceRemote extends BaseRemoteClient implements ClientServi
|
|||||||
return baseUrl;
|
return baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClientSessionCounts getSessionCounts(int customerId) {
|
||||||
|
LOG.debug("calling getSessionCounts( {} )", customerId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResponseEntity<ClientSessionCounts> responseEntity = restTemplate.exchange(getBaseUrl() + "/session/countsForCustomer?customerId={customerId}",
|
||||||
|
HttpMethod.GET, null, ClientSessionCounts.class, customerId);
|
||||||
|
|
||||||
|
ClientSessionCounts result = responseEntity.getBody();
|
||||||
|
LOG.debug("getSessionCounts({}) returns {} ", customerId, result);
|
||||||
|
return result;
|
||||||
|
} catch (Exception exp) {
|
||||||
|
LOG.error("getSessionCounts({}) exception ", customerId, exp);
|
||||||
|
throw exp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.telecominfraproject.wlan.client.datastore.ClientDatastore;
|
import com.telecominfraproject.wlan.client.datastore.ClientDatastore;
|
||||||
|
import com.telecominfraproject.wlan.client.info.models.ClientSessionCounts;
|
||||||
import com.telecominfraproject.wlan.client.models.Client;
|
import com.telecominfraproject.wlan.client.models.Client;
|
||||||
import com.telecominfraproject.wlan.client.models.events.ClientAddedEvent;
|
import com.telecominfraproject.wlan.client.models.events.ClientAddedEvent;
|
||||||
import com.telecominfraproject.wlan.client.models.events.ClientBlockListChangedEvent;
|
import com.telecominfraproject.wlan.client.models.events.ClientBlockListChangedEvent;
|
||||||
@@ -430,6 +432,13 @@ public class ClientController {
|
|||||||
|
|
||||||
return new GenericResponse(true, "");
|
return new GenericResponse(true, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/session/countsForCustomer")
|
||||||
|
public ClientSessionCounts getSessionCounts(@RequestParam int customerId) {
|
||||||
|
ClientSessionCounts ret = clientDatastore.getSessionCounts(customerId);
|
||||||
|
LOG.debug("countsForCustomer({}) {}", customerId, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
private void publishEvent(SystemEvent event) {
|
private void publishEvent(SystemEvent event) {
|
||||||
if (event == null) {
|
if (event == null) {
|
||||||
|
|||||||
@@ -2856,6 +2856,9 @@ components:
|
|||||||
sharedSecret:
|
sharedSecret:
|
||||||
type: string
|
type: string
|
||||||
format: password
|
format: password
|
||||||
|
dynamicDiscovery:
|
||||||
|
description: Dynamic discovery of HSP and IdPs (home service and identity providers). Regardless of configured value, this will only be set 'true' on the AP if useRadSec is also true.
|
||||||
|
type: boolean
|
||||||
example:
|
example:
|
||||||
model_type: RadiusProxyConfiguration
|
model_type: RadiusProxyConfiguration
|
||||||
caCert:
|
caCert:
|
||||||
@@ -3159,6 +3162,14 @@ components:
|
|||||||
- wpa2OnlyPSK
|
- wpa2OnlyPSK
|
||||||
- wpa2OnlyRadius
|
- wpa2OnlyRadius
|
||||||
- wep
|
- wep
|
||||||
|
- wpaEAP
|
||||||
|
- wpa2EAP
|
||||||
|
- wpa2OnlyEAP
|
||||||
|
- wpa3OnlySAE
|
||||||
|
- wpa3MixedSAE
|
||||||
|
- wpa3OnlyEAP
|
||||||
|
- wpa3MixedEAP
|
||||||
|
- wpa3OnlyEAP192
|
||||||
|
|
||||||
RadioBasedSsidConfigurationMap:
|
RadioBasedSsidConfigurationMap:
|
||||||
properties:
|
properties:
|
||||||
@@ -4387,7 +4398,9 @@ components:
|
|||||||
- RADIO_CHANNEL
|
- RADIO_CHANNEL
|
||||||
channelNumberStatusDataMap:
|
channelNumberStatusDataMap:
|
||||||
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
||||||
|
txPowerDataMap:
|
||||||
|
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
||||||
|
|
||||||
#
|
#
|
||||||
# Equipment configuration data models
|
# Equipment configuration data models
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -189,7 +189,6 @@
|
|||||||
|
|
||||||
<module>../provisioning-sp</module>
|
<module>../provisioning-sp</module>
|
||||||
<module>../dashboard-sp</module>
|
<module>../dashboard-sp</module>
|
||||||
<module>../equipment-alarms-sp</module>
|
|
||||||
<module>../adoption-metrics-sp</module>
|
<module>../adoption-metrics-sp</module>
|
||||||
|
|
||||||
<module>../single-process-streams</module>
|
<module>../single-process-streams</module>
|
||||||
|
|||||||
1
equipment-alarms-sp/.gitignore
vendored
1
equipment-alarms-sp/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
/target/
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<artifactId>tip-wlan-cloud-root-pom</artifactId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
<relativePath>../../wlan-cloud-root</relativePath>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>equipment-alarms-sp</artifactId>
|
|
||||||
<name>equipment-alarms-sp</name>
|
|
||||||
<description>Stream Processors for raising/clearing equipment alarms based on reported metrics.</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<artifactId>base-stream-consumer</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<artifactId>service-metric-models</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<artifactId>system-event-models</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<artifactId>alarm-service-interface</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<artifactId>status-service-interface</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<artifactId>equipment-service-interface</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- unit tests dependencies -->
|
|
||||||
<dependency>
|
|
||||||
<artifactId>single-process-streams</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>status-service-local</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<artifactId>equipment-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-datastore-inmemory</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<artifactId>equipment-datastore-inmemory</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<artifactId>cloud-event-dispatcher-empty</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,187 +0,0 @@
|
|||||||
package com.telecominfraproject.wlan.streams.equipmentalarms;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
import com.telecominfraproject.wlan.alarm.models.Alarm;
|
|
||||||
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
|
|
||||||
import com.telecominfraproject.wlan.servicemetric.apnode.models.ApNodeMetrics;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <br>This context keeps track of information needed for raising/clearing the alarms with the following codes:
|
|
||||||
* <ul>
|
|
||||||
* <li>AlarmCode.CPUTemperature
|
|
||||||
* <li>AlarmCode.CPUUtilization
|
|
||||||
* <li>AlarmCode.MemoryUtilization
|
|
||||||
* <li>AlarmCode.NoMetricsReceived
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @author dtop
|
|
||||||
*/
|
|
||||||
public class EquipmentAlarmsContext {
|
|
||||||
|
|
||||||
private final int customerId;
|
|
||||||
private final long equipmentId;
|
|
||||||
private final Map<AlarmCode, Alarm> existingAlarms = new ConcurrentHashMap<>();
|
|
||||||
private final long timeBucketMs;
|
|
||||||
private final int temperatureThresholdInC;
|
|
||||||
private final int cpuUtilThresholdPct;
|
|
||||||
private final int memoryUtilThresholdPct;
|
|
||||||
|
|
||||||
private final Map<Long, Integer> cpuTempSamples = new ConcurrentHashMap<>();
|
|
||||||
private final Map<Long, Integer> cpuUtilSamples = new ConcurrentHashMap<>();
|
|
||||||
private final Map<Long, Integer> memoryUtilSamples = new ConcurrentHashMap<>();
|
|
||||||
private final Map<Long, Long> metricReceivedTimestamps = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
private long totalAvailableMemoryKb;
|
|
||||||
private final long contextCreationTimestampMs = System.currentTimeMillis();
|
|
||||||
|
|
||||||
public EquipmentAlarmsContext(int customerId, long equipmentId, List<Alarm> existingAlarmsList, long timeBucketMs, int temperatureThresholdInC, int cpuUtilThresholdPct, int memoryUtilThresholdPct) {
|
|
||||||
this.customerId = customerId;
|
|
||||||
this.equipmentId = equipmentId;
|
|
||||||
existingAlarmsList.forEach(a -> this.existingAlarms.put(a.getAlarmCode(), a));
|
|
||||||
this.timeBucketMs = timeBucketMs;
|
|
||||||
this.temperatureThresholdInC = temperatureThresholdInC;
|
|
||||||
this.cpuUtilThresholdPct = cpuUtilThresholdPct;
|
|
||||||
this.memoryUtilThresholdPct = memoryUtilThresholdPct;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTotalAvailableMemoryKb() {
|
|
||||||
return totalAvailableMemoryKb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalAvailableMemoryKb(long totalAvailableMemoryKb) {
|
|
||||||
this.totalAvailableMemoryKb = totalAvailableMemoryKb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCustomerId() {
|
|
||||||
return customerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getEquipmentId() {
|
|
||||||
return equipmentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<AlarmCode, Alarm> getExistingAlarms() {
|
|
||||||
return existingAlarms;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void addDataSamples(long timestamp, ApNodeMetrics model) {
|
|
||||||
// add new samples
|
|
||||||
if(model.getApPerformance()!=null ) {
|
|
||||||
if(model.getApPerformance().getCpuTemperature()!=null) {
|
|
||||||
cpuTempSamples.put(timestamp, model.getApPerformance().getCpuTemperature());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(model.getApPerformance().getAvgCpuUtilized()!=null) {
|
|
||||||
cpuUtilSamples.put(timestamp, model.getApPerformance().getAvgCpuUtilized().intValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(model.getApPerformance().getFreeMemory()!=null && totalAvailableMemoryKb>0) {
|
|
||||||
memoryUtilSamples.put(timestamp, 100 - (int) (model.getApPerformance().getFreeMemory() * 100 / totalAvailableMemoryKb));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//we are using our own timestamp in here in case AP's time is out of sync - we do not want to raise connectivity alarm in that case
|
|
||||||
Long currentTs = System.currentTimeMillis();
|
|
||||||
metricReceivedTimestamps.put(currentTs, currentTs);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeOldDataSamples() {
|
|
||||||
// remove samples older than timeBucketMs
|
|
||||||
long timeThresholdMs = System.currentTimeMillis() - timeBucketMs;
|
|
||||||
cpuTempSamples.entrySet().removeIf( t -> t.getKey() < timeThresholdMs );
|
|
||||||
cpuUtilSamples.entrySet().removeIf( t -> t.getKey() < timeThresholdMs );
|
|
||||||
memoryUtilSamples.entrySet().removeIf( t -> t.getKey() < timeThresholdMs );
|
|
||||||
metricReceivedTimestamps.entrySet().removeIf( t -> t.getKey() < timeThresholdMs );
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAlarmNeedsToBeRaised(AlarmCode alarmCode) {
|
|
||||||
|
|
||||||
if(existingAlarms.containsKey(alarmCode) || System.currentTimeMillis() < contextCreationTimestampMs + timeBucketMs) {
|
|
||||||
//no need to check for thresholds - alarm is either already present, or it is too early to tell because the first time bucket has not been filled yet
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean ret = false;
|
|
||||||
AtomicInteger sum = new AtomicInteger();
|
|
||||||
AtomicInteger count = new AtomicInteger();
|
|
||||||
|
|
||||||
//check alarms against thresholds
|
|
||||||
if(alarmCode.getId() == AlarmCode.NoMetricsReceived.getId()) {
|
|
||||||
ret = metricReceivedTimestamps.isEmpty();
|
|
||||||
} else if(alarmCode.getId() == AlarmCode.CPUTemperature.getId()) {
|
|
||||||
cpuTempSamples.values().forEach(v -> { sum.addAndGet(v); count.incrementAndGet(); });
|
|
||||||
if(count.get() > 0) {
|
|
||||||
int avg = sum.get() / count.get();
|
|
||||||
ret = avg >= temperatureThresholdInC ;
|
|
||||||
}
|
|
||||||
} else if(alarmCode.getId() == AlarmCode.CPUUtilization.getId()) {
|
|
||||||
cpuUtilSamples.values().forEach(v -> { sum.addAndGet(v); count.incrementAndGet(); });
|
|
||||||
if(count.get() > 0) {
|
|
||||||
int avg = sum.get() / count.get();
|
|
||||||
ret = avg >= cpuUtilThresholdPct ;
|
|
||||||
}
|
|
||||||
} else if(alarmCode.getId() == AlarmCode.MemoryUtilization.getId()) {
|
|
||||||
memoryUtilSamples.values().forEach(v -> { sum.addAndGet(v); count.incrementAndGet(); });
|
|
||||||
if(count.get() > 0) {
|
|
||||||
int avg = sum.get() / count.get();
|
|
||||||
ret = avg >= memoryUtilThresholdPct ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAlarmNeedsToBeCleared(AlarmCode alarmCode) {
|
|
||||||
|
|
||||||
if(!existingAlarms.containsKey(alarmCode) || System.currentTimeMillis() < contextCreationTimestampMs + timeBucketMs) {
|
|
||||||
//no need to check for thresholds - alarm is either not present, or it is too early to tell because the first time bucket has not been filled yet
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean ret = false;
|
|
||||||
AtomicInteger sum = new AtomicInteger();
|
|
||||||
AtomicInteger count = new AtomicInteger();
|
|
||||||
|
|
||||||
//check alarms against thresholds
|
|
||||||
if(alarmCode.getId() == AlarmCode.NoMetricsReceived.getId()) {
|
|
||||||
ret = !metricReceivedTimestamps.isEmpty();
|
|
||||||
} else if(alarmCode.getId() == AlarmCode.CPUTemperature.getId()) {
|
|
||||||
cpuTempSamples.values().forEach(v -> { sum.addAndGet(v); count.incrementAndGet(); });
|
|
||||||
if(count.get() > 0) {
|
|
||||||
int avg = sum.get() / count.get();
|
|
||||||
ret = avg < temperatureThresholdInC ;
|
|
||||||
} else {
|
|
||||||
//no new data available, but the alarm exists -> clear the alarm
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
} else if(alarmCode.getId() == AlarmCode.CPUUtilization.getId()) {
|
|
||||||
cpuUtilSamples.values().forEach(v -> { sum.addAndGet(v); count.incrementAndGet(); });
|
|
||||||
if(count.get() > 0) {
|
|
||||||
int avg = sum.get() / count.get();
|
|
||||||
ret = avg < cpuUtilThresholdPct ;
|
|
||||||
} else {
|
|
||||||
//no new data available, but the alarm exists -> clear the alarm
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
} else if(alarmCode.getId() == AlarmCode.MemoryUtilization.getId()) {
|
|
||||||
memoryUtilSamples.values().forEach(v -> { sum.addAndGet(v); count.incrementAndGet(); });
|
|
||||||
if(count.get() > 0) {
|
|
||||||
int avg = sum.get() / count.get();
|
|
||||||
ret = avg < memoryUtilThresholdPct ;
|
|
||||||
} else {
|
|
||||||
//no new data available, but the alarm exists -> clear the alarm
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,322 +0,0 @@
|
|||||||
package com.telecominfraproject.wlan.streams.equipmentalarms;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.telecominfraproject.wlan.alarm.AlarmServiceInterface;
|
|
||||||
import com.telecominfraproject.wlan.alarm.models.Alarm;
|
|
||||||
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
|
|
||||||
import com.telecominfraproject.wlan.alarm.models.AlarmDetails;
|
|
||||||
import com.telecominfraproject.wlan.alarm.models.AlarmScopeType;
|
|
||||||
import com.telecominfraproject.wlan.alarm.models.OriginatorType;
|
|
||||||
import com.telecominfraproject.wlan.core.model.json.BaseJsonModel;
|
|
||||||
import com.telecominfraproject.wlan.core.model.streams.QueuedStreamMessage;
|
|
||||||
import com.telecominfraproject.wlan.equipment.EquipmentServiceInterface;
|
|
||||||
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
|
||||||
import com.telecominfraproject.wlan.servicemetric.apnode.models.ApNodeMetrics;
|
|
||||||
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
|
|
||||||
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetricDetails;
|
|
||||||
import com.telecominfraproject.wlan.status.StatusServiceInterface;
|
|
||||||
import com.telecominfraproject.wlan.status.equipment.report.models.OperatingSystemPerformance;
|
|
||||||
import com.telecominfraproject.wlan.status.models.Status;
|
|
||||||
import com.telecominfraproject.wlan.status.models.StatusCode;
|
|
||||||
import com.telecominfraproject.wlan.status.models.StatusDataType;
|
|
||||||
import com.telecominfraproject.wlan.stream.StreamProcessor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author dtop
|
|
||||||
* <br> This stream processor is listening for APNodeMetrics, aggregating them in sliding windows of 5 minutes and raising/clearing alarms based on preconfigured thresholds.
|
|
||||||
* <br> "No metrics received" alarm is raised when no APNodeMetrics have been received for the equipment in the last interval, cleared when APNodeMetrics appear again
|
|
||||||
* <br> "Temperature too high" alarm is raised when average temperature over the last interval goes above the configured threshold of 80C, cleared when average temperature goes below the threshold
|
|
||||||
* <br> "CPU utilization is too high" alarm is raised when average CPU utilization on AP over the last interval goes above the configured threshold of 80%, cleared when average CPU utilization goes below the threshold
|
|
||||||
* <br> "Memory utilization is too high" alarm is raised when average RAM utilization on AP over the last interval goes above the configured threshold of 70%, cleared when average RAM utilization goes below the threshold
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class EquipmentAlarmsProcessor extends StreamProcessor {
|
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(EquipmentAlarmsProcessor.class);
|
|
||||||
|
|
||||||
@Value("${tip.wlan.wlanServiceMetricsTopic:wlan_service_metrics}")
|
|
||||||
private String wlanServiceMetricsTopic;
|
|
||||||
|
|
||||||
@Value("${tip.wlan.equipmentAlarmProcessor.timeBucketMs:300000}") //5 minutes aggregation buckets
|
|
||||||
private long timeBucketMs;
|
|
||||||
|
|
||||||
@Value("${tip.wlan.equipmentAlarmProcessor.checkAlarmsIntervalMs:15000}") //check for raising/clearing alarms every 15 seconds
|
|
||||||
private long checkAlarmsIntervalMs;
|
|
||||||
|
|
||||||
@Value("${tip.wlan.equipmentAlarmProcessor.temperatureThresholdInC:80}")
|
|
||||||
private int temperatureThresholdInC;
|
|
||||||
|
|
||||||
@Value("${tip.wlan.equipmentAlarmProcessor.cpuUtilThresholdPct:80}")
|
|
||||||
private int cpuUtilThresholdPct;
|
|
||||||
|
|
||||||
@Value("${tip.wlan.equipmentAlarmProcessor.memoryUtilThresholdPct:70}")
|
|
||||||
private int memoryUtilThresholdPct;
|
|
||||||
|
|
||||||
|
|
||||||
private final ConcurrentHashMap<Long, EquipmentAlarmsContext> contextPerEquipmentIdMap = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
private final Set<AlarmCode> alarmCodeSet = new HashSet<>();
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AlarmServiceInterface alarmServiceInterface;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private StatusServiceInterface statusServiceInterface;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EquipmentServiceInterface equipmentServiceInterface;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean acceptMessage(QueuedStreamMessage message) {
|
|
||||||
boolean ret = message.getTopic().equals(wlanServiceMetricsTopic);
|
|
||||||
|
|
||||||
if(ret && ( message.getModel() instanceof ServiceMetric) ) {
|
|
||||||
|
|
||||||
ServiceMetric sm = (ServiceMetric) message.getModel();
|
|
||||||
ret = ret &&
|
|
||||||
(
|
|
||||||
sm.getDetails() instanceof ApNodeMetrics
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.trace("acceptMessage {}", ret);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void processMessage(QueuedStreamMessage message) {
|
|
||||||
|
|
||||||
ServiceMetric mdl = (ServiceMetric) message.getModel();
|
|
||||||
ServiceMetricDetails smd = mdl.getDetails();
|
|
||||||
LOG.debug("Processing {}", mdl);
|
|
||||||
|
|
||||||
switch ( smd.getClass().getSimpleName() ) {
|
|
||||||
case "ApNodeMetrics":
|
|
||||||
process(mdl.getCustomerId(), mdl.getCreatedTimestamp(), mdl.getEquipmentId(), (ApNodeMetrics) smd);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
process(mdl);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(int customerId, long timestamp, long equipmentId, ApNodeMetrics model) {
|
|
||||||
LOG.debug("Processing ApNodeMetrics");
|
|
||||||
//get context for the equipmentId
|
|
||||||
EquipmentAlarmsContext context = contextPerEquipmentIdMap.get(equipmentId);
|
|
||||||
if(context == null) {
|
|
||||||
|
|
||||||
//When creating EquipmentAlarmsContext - read currently raised alarms of the types we're interested, keep it in memory.
|
|
||||||
//Only this SP is responsible for raising/clearing those alarms for this particular equipment
|
|
||||||
List<Alarm> existingAlarms = alarmServiceInterface.get(customerId, Collections.singleton(equipmentId), alarmCodeSet);
|
|
||||||
|
|
||||||
//All alarms that are handled by this stream processor logically exist only once-per-alarmCode-per-equipment.
|
|
||||||
//Ensure that there is only one alarm per alarmCode per equipment (the latest one), remove all others.
|
|
||||||
//This is needed to recover from some corner-case scenarios that can happen with the distributed datastores (for example split-brain).
|
|
||||||
existingAlarms = cleanUpDuplicateAlarms(existingAlarms);
|
|
||||||
|
|
||||||
context = new EquipmentAlarmsContext(customerId, equipmentId, existingAlarms, timeBucketMs, temperatureThresholdInC, cpuUtilThresholdPct, memoryUtilThresholdPct);
|
|
||||||
context = contextPerEquipmentIdMap.putIfAbsent(equipmentId, context);
|
|
||||||
if(context == null) {
|
|
||||||
context = contextPerEquipmentIdMap.get(equipmentId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//find out TotalAvailableMemory in kb, which is available as part of the OperatingSystemPerformance status object
|
|
||||||
//we look for it separately because this status may not be populated when the first service_metrics_collection_config are coming in
|
|
||||||
if(context.getTotalAvailableMemoryKb()==0L) {
|
|
||||||
Status osPerformanceStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.OS_PERFORMANCE);
|
|
||||||
if(osPerformanceStatus!=null) {
|
|
||||||
OperatingSystemPerformance osPerformance = (OperatingSystemPerformance) osPerformanceStatus.getDetails();
|
|
||||||
if(osPerformance !=null && osPerformance.getTotalAvailableMemoryKb() > 0) {
|
|
||||||
context.setTotalAvailableMemoryKb(osPerformance.getTotalAvailableMemoryKb());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update counters on the context
|
|
||||||
context.addDataSamples(timestamp, model);
|
|
||||||
|
|
||||||
LOG.debug("Processed {}", model);
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Alarm> cleanUpDuplicateAlarms(List<Alarm> existingAlarms) {
|
|
||||||
|
|
||||||
Map<AlarmCode, Alarm> alarmsToKeep= new HashMap<>();
|
|
||||||
|
|
||||||
//find out the latest existing alarms for each alarmCode
|
|
||||||
existingAlarms.forEach(a -> {
|
|
||||||
Alarm eA = alarmsToKeep.get(a.getAlarmCode());
|
|
||||||
if(eA == null) {
|
|
||||||
eA = a;
|
|
||||||
alarmsToKeep.put(a.getAlarmCode(), a);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(eA.getCreatedTimestamp() < a.getCreatedTimestamp() ) {
|
|
||||||
alarmsToKeep.put(a.getAlarmCode(), a);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
List<Alarm> alarmsToRemove = new ArrayList<>(existingAlarms);
|
|
||||||
alarmsToRemove.removeAll(alarmsToKeep.values());
|
|
||||||
|
|
||||||
alarmsToRemove.forEach(a -> {
|
|
||||||
try {
|
|
||||||
alarmServiceInterface.delete(a.getCustomerId(), a.getEquipmentId(), a.getAlarmCode(), a.getCreatedTimestamp());
|
|
||||||
} catch(Exception e) {
|
|
||||||
LOG.debug("Alarm was already deleted: {}", a);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return new ArrayList<>(alarmsToKeep.values());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void process(BaseJsonModel model) {
|
|
||||||
LOG.warn("Unprocessed model: {}", model);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
private void postCreate() {
|
|
||||||
|
|
||||||
Thread equipmentAlarmsThread = new Thread( new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
LOG.info("Starting equipmentAlarmsThread");
|
|
||||||
while(true) {
|
|
||||||
LOG.trace("Checking if alarms need to be raised");
|
|
||||||
|
|
||||||
//take a snapshot of existing contexts for this iteration of alarm checks
|
|
||||||
List<EquipmentAlarmsContext> contexts = new ArrayList<>(contextPerEquipmentIdMap.values());
|
|
||||||
|
|
||||||
HashSet<Long> equipmentIdsFromContexts = new HashSet<>();
|
|
||||||
contexts.forEach(ctx -> equipmentIdsFromContexts.add(ctx.getEquipmentId()));
|
|
||||||
|
|
||||||
//get a list of equipment records for the current contexts
|
|
||||||
HashSet<Long> existingEquipmentIds = new HashSet<>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
List<Equipment> existingEquipment = equipmentServiceInterface.get(equipmentIdsFromContexts);
|
|
||||||
existingEquipment.forEach(e -> existingEquipmentIds.add(e.getId()));
|
|
||||||
} catch(Exception e) {
|
|
||||||
LOG.error("Error when retrieving existing equipment", e);
|
|
||||||
sleep(checkAlarmsIntervalMs);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for(EquipmentAlarmsContext context : contexts ) {
|
|
||||||
|
|
||||||
if(!existingEquipmentIds.contains(context.getEquipmentId())) {
|
|
||||||
//equipment was removed, let's delete the context and remove all existing alarms for that equipmentId
|
|
||||||
try {
|
|
||||||
contextPerEquipmentIdMap.remove(context.getEquipmentId());
|
|
||||||
alarmServiceInterface.delete(context.getCustomerId(), context.getEquipmentId());
|
|
||||||
} catch(Exception e) {
|
|
||||||
LOG.error("Error when removing stale alarms for deleted equipment", e);
|
|
||||||
}
|
|
||||||
//nothing else to do for this context
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.removeOldDataSamples();
|
|
||||||
|
|
||||||
alarmCodeSet.forEach(alarmCode -> {
|
|
||||||
try {
|
|
||||||
//check alarms against thresholds
|
|
||||||
//if alarm needs to be raised - check if it is currently present, and if not - raise it, and add it to the context
|
|
||||||
if(context.isAlarmNeedsToBeRaised(alarmCode)) {
|
|
||||||
Alarm alarm = new Alarm();
|
|
||||||
alarm.setCustomerId(context.getCustomerId());
|
|
||||||
alarm.setEquipmentId(context.getEquipmentId());
|
|
||||||
alarm.setAlarmCode(alarmCode);
|
|
||||||
alarm.setOriginatorType(OriginatorType.AP);
|
|
||||||
alarm.setSeverity(alarmCode.getSeverity());
|
|
||||||
alarm.setScopeType(AlarmScopeType.EQUIPMENT);
|
|
||||||
alarm.setScopeId("" + context.getEquipmentId());
|
|
||||||
AlarmDetails alarmDetails = new AlarmDetails();
|
|
||||||
alarmDetails.setMessage(alarmCode.getDescription());
|
|
||||||
alarmDetails.setAffectedEquipmentIds(Collections.singletonList(context.getEquipmentId()));
|
|
||||||
alarm.setDetails(alarmDetails);
|
|
||||||
|
|
||||||
alarm = alarmServiceInterface.create(alarm);
|
|
||||||
context.getExistingAlarms().put(alarmCode, alarm);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(context.isAlarmNeedsToBeCleared(alarmCode)) {
|
|
||||||
//if alarm needs to be cleared - check if it is currently present, and if it is - clear it, and remove it from the context
|
|
||||||
Alarm alarm = context.getExistingAlarms().remove(alarmCode);
|
|
||||||
if(alarm!=null) {
|
|
||||||
//All alarms that are handled by this stream processor logically exist only once-per-alarmCode-per-equipment.
|
|
||||||
//In order to self-heal from the corner cases with the datastore where more than one alarm with the same alarmCode
|
|
||||||
// is raised per equipment (for example when the datastore experienced a split-brain scenario), we would remove
|
|
||||||
// all alarms with the specified alarmCode for this equipment.
|
|
||||||
//Most of the time the existingAlarms list below would contain only one alarm.
|
|
||||||
//
|
|
||||||
List<Alarm> existingAlarms = alarmServiceInterface.get(alarm.getCustomerId(), Collections.singleton(alarm.getEquipmentId()), Collections.singleton(alarmCode));
|
|
||||||
existingAlarms.forEach(a -> {
|
|
||||||
try {
|
|
||||||
alarmServiceInterface.delete(a.getCustomerId(), a.getEquipmentId(), a.getAlarmCode(), a.getCreatedTimestamp());
|
|
||||||
} catch(Exception e) {
|
|
||||||
LOG.debug("Alarm was already deleted: {}", alarm);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(Exception e) {
|
|
||||||
LOG.error("Error when processing context for customer {}", context.getCustomerId(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.trace("Done alarms check");
|
|
||||||
|
|
||||||
sleep(checkAlarmsIntervalMs);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, "equipmentAlarmsThread");
|
|
||||||
|
|
||||||
equipmentAlarmsThread.setDaemon(true);
|
|
||||||
equipmentAlarmsThread.start();
|
|
||||||
|
|
||||||
//populate alarm codes this SP is responsible for
|
|
||||||
alarmCodeSet.add(AlarmCode.NoMetricsReceived);
|
|
||||||
alarmCodeSet.add(AlarmCode.CPUTemperature);
|
|
||||||
alarmCodeSet.add(AlarmCode.CPUUtilization);
|
|
||||||
alarmCodeSet.add(AlarmCode.MemoryUtilization);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void sleep(long ms) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(ms);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,342 +0,0 @@
|
|||||||
package com.telecominfraproject.wlan.streams.equipmentalarms;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.context.annotation.Import;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
import com.telecominfraproject.wlan.alarm.AlarmServiceInterface;
|
|
||||||
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.alarm.models.Alarm;
|
|
||||||
import com.telecominfraproject.wlan.alarm.models.AlarmCode;
|
|
||||||
import com.telecominfraproject.wlan.cloudeventdispatcher.CloudEventDispatcherEmpty;
|
|
||||||
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
|
|
||||||
import com.telecominfraproject.wlan.equipment.EquipmentServiceInterface;
|
|
||||||
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.Equipment;
|
|
||||||
import com.telecominfraproject.wlan.servicemetric.apnode.models.ApNodeMetrics;
|
|
||||||
import com.telecominfraproject.wlan.servicemetric.apnode.models.ApPerformance;
|
|
||||||
import com.telecominfraproject.wlan.servicemetric.models.ServiceMetric;
|
|
||||||
import com.telecominfraproject.wlan.status.StatusServiceLocal;
|
|
||||||
import com.telecominfraproject.wlan.status.controller.StatusController;
|
|
||||||
import com.telecominfraproject.wlan.status.datastore.inmemory.StatusDatastoreInMemory;
|
|
||||||
import com.telecominfraproject.wlan.stream.StreamInterface;
|
|
||||||
import com.telecominfraproject.wlan.stream.StreamMessageDispatcher;
|
|
||||||
import com.telecominfraproject.wlan.streams.simple.SimpleStreamsConfig;
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@SpringBootTest(webEnvironment = WebEnvironment.NONE, classes = EquipmentAlarmsProcessor.class)
|
|
||||||
@Import(value = { EquipmentAlarmsProcessor.class, SimpleStreamsConfig.class, StreamMessageDispatcher.class,
|
|
||||||
AlarmServiceLocal.class, AlarmController.class, AlarmDatastoreInMemory.class,
|
|
||||||
StatusServiceLocal.class, StatusController.class, StatusDatastoreInMemory.class,
|
|
||||||
EquipmentServiceLocal.class, EquipmentController.class, EquipmentDatastoreInMemory.class,
|
|
||||||
CloudEventDispatcherEmpty.class,
|
|
||||||
//EquipmentAlarmsProcessorTests.Config.class,
|
|
||||||
})
|
|
||||||
@Ignore("make these tests more robust, there are intermittent failures")
|
|
||||||
/*
|
|
||||||
expected: <0> but was: <1>
|
|
||||||
org.opentest4j.AssertionFailedError: expected: <0> but was: <1>
|
|
||||||
at com.telecominfraproject.wlan.streams.equipmentalarms.EquipmentAlarmsProcessorTests.testAccessPointIsUnreachableAlarm(EquipmentAlarmsProcessorTests.java:313)
|
|
||||||
|
|
||||||
*/
|
|
||||||
public class EquipmentAlarmsProcessorTests {
|
|
||||||
|
|
||||||
private static final long testTimeBucketMs = 200;
|
|
||||||
private static final long testCheckAlarmsIntervalMs = 50;
|
|
||||||
|
|
||||||
static {
|
|
||||||
System.setProperty("tip.wlan.equipmentAlarmProcessor.checkAlarmsIntervalMs", "" + testCheckAlarmsIntervalMs);
|
|
||||||
System.setProperty("tip.wlan.equipmentAlarmProcessor.timeBucketMs", "" + testTimeBucketMs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired @Qualifier("metricStreamInterface")
|
|
||||||
StreamInterface<ServiceMetric> metricStreamInterface;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
EquipmentAlarmsProcessor equipmentAlarmsProcessor;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
AlarmServiceInterface alarmService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
EquipmentServiceInterface equipmentService;
|
|
||||||
|
|
||||||
protected static final AtomicLong testSequence = new AtomicLong(1);
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public static class Config {
|
|
||||||
|
|
||||||
//Another way of configuring dependencies (instead of mentioning them in the pom.xml with the test scope) :
|
|
||||||
// @Bean
|
|
||||||
// AlarmServiceInterface getAlarmServiceInterface() {
|
|
||||||
// return new AlarmServiceInterface() {
|
|
||||||
// ...
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Bean
|
|
||||||
// StatusServiceInterface getStatusServiceInterface() {
|
|
||||||
// return new StatusServiceInterface() {
|
|
||||||
// ...
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCPUTemperatureAlarm() {
|
|
||||||
int customerId = getNextCustomerId();
|
|
||||||
|
|
||||||
Equipment equipment = new Equipment();
|
|
||||||
equipment.setCustomerId(customerId);
|
|
||||||
equipment.setEquipmentType(EquipmentType.AP);
|
|
||||||
equipment.setInventoryId("testCPUTemperatureAlarm");
|
|
||||||
equipment.setName(equipment.getInventoryId());
|
|
||||||
equipment = equipmentService.create(equipment);
|
|
||||||
long equipmentId = equipment.getId();
|
|
||||||
|
|
||||||
ServiceMetric record = new ServiceMetric(customerId , equipmentId );
|
|
||||||
//create metric a bit in the future so that it gets picked up by the processor and not simply discarded
|
|
||||||
record.setCreatedTimestamp(System.currentTimeMillis() + 2 * testTimeBucketMs);
|
|
||||||
|
|
||||||
ApNodeMetrics apNodeMetrics = new ApNodeMetrics();
|
|
||||||
record.setDetails(apNodeMetrics);
|
|
||||||
|
|
||||||
ApPerformance apPerformance = new ApPerformance();
|
|
||||||
apNodeMetrics.setApPerformance(apPerformance);
|
|
||||||
|
|
||||||
//we will force the CPUTemperature alarm to be raised
|
|
||||||
apPerformance.setCpuTemperature(85);
|
|
||||||
|
|
||||||
apPerformance.setCpuUtilized(new int[] { 70, 70 });
|
|
||||||
|
|
||||||
apPerformance.setFreeMemory(30000000);
|
|
||||||
|
|
||||||
//publish metric that should trigger alarm for the CPU Temperature
|
|
||||||
metricStreamInterface.publish(record );
|
|
||||||
|
|
||||||
//wait for the metric to be processed
|
|
||||||
sleep(2 * testTimeBucketMs);
|
|
||||||
|
|
||||||
//verify that alarm was raised
|
|
||||||
List<Alarm> alarms = alarmService.get(customerId, Collections.singleton(equipmentId), Collections.singleton(AlarmCode.CPUTemperature));
|
|
||||||
assertEquals(1, alarms.size());
|
|
||||||
|
|
||||||
//Now create a metric that should clear the alarm
|
|
||||||
ServiceMetric recordToClearAlarm = record.clone();
|
|
||||||
recordToClearAlarm.setCreatedTimestamp(System.currentTimeMillis() + 2* testTimeBucketMs );
|
|
||||||
((ApNodeMetrics)recordToClearAlarm.getDetails()).getApPerformance().setCpuTemperature(70);
|
|
||||||
|
|
||||||
//publish metric that should clear the alarm for the CPU Temperature
|
|
||||||
metricStreamInterface.publish(recordToClearAlarm);
|
|
||||||
|
|
||||||
//wait for the metric to be processed
|
|
||||||
sleep(2 * testTimeBucketMs);
|
|
||||||
|
|
||||||
//verify that alarm was cleared
|
|
||||||
alarms = alarmService.get(customerId, Collections.singleton(equipmentId), Collections.singleton(AlarmCode.CPUTemperature));
|
|
||||||
assertEquals(0, alarms.size());
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCPUTemperatureAlarm_NoEquipment() {
|
|
||||||
int customerId = getNextCustomerId();
|
|
||||||
long equipmentId = -5;
|
|
||||||
|
|
||||||
ServiceMetric record = new ServiceMetric(customerId , equipmentId );
|
|
||||||
//create metric a bit in the future so that it gets picked up by the processor and not simply discarded
|
|
||||||
record.setCreatedTimestamp(System.currentTimeMillis() + 2 * testTimeBucketMs);
|
|
||||||
|
|
||||||
ApNodeMetrics apNodeMetrics = new ApNodeMetrics();
|
|
||||||
record.setDetails(apNodeMetrics);
|
|
||||||
|
|
||||||
ApPerformance apPerformance = new ApPerformance();
|
|
||||||
apNodeMetrics.setApPerformance(apPerformance);
|
|
||||||
|
|
||||||
//we will force the CPUTemperature alarm to be raised
|
|
||||||
apPerformance.setCpuTemperature(85);
|
|
||||||
|
|
||||||
apPerformance.setCpuUtilized(new int[] { 70, 70 });
|
|
||||||
|
|
||||||
apPerformance.setFreeMemory(30000000);
|
|
||||||
|
|
||||||
//publish metric that should trigger alarm for the CPU Temperature
|
|
||||||
metricStreamInterface.publish(record );
|
|
||||||
|
|
||||||
//wait for the metric to be processed
|
|
||||||
sleep(2 * testTimeBucketMs);
|
|
||||||
|
|
||||||
//verify that alarm was not raised - because equipment for that alarm does not exist
|
|
||||||
List<Alarm> alarms = alarmService.get(customerId, Collections.singleton(equipmentId), Collections.singleton(AlarmCode.CPUTemperature));
|
|
||||||
assertEquals(0, alarms.size());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCPUUtilizationAlarm() {
|
|
||||||
int customerId = getNextCustomerId();
|
|
||||||
|
|
||||||
Equipment equipment = new Equipment();
|
|
||||||
equipment.setCustomerId(customerId);
|
|
||||||
equipment.setEquipmentType(EquipmentType.AP);
|
|
||||||
equipment.setInventoryId("testCPUUtilizationAlarm");
|
|
||||||
equipment.setName(equipment.getInventoryId());
|
|
||||||
equipment = equipmentService.create(equipment);
|
|
||||||
long equipmentId = equipment.getId();
|
|
||||||
|
|
||||||
ServiceMetric record = new ServiceMetric(customerId , equipmentId );
|
|
||||||
//create metric a bit in the future so that it gets picked up by the processor and not simply discarded
|
|
||||||
record.setCreatedTimestamp(System.currentTimeMillis() + 2 * testTimeBucketMs);
|
|
||||||
|
|
||||||
ApNodeMetrics apNodeMetrics = new ApNodeMetrics();
|
|
||||||
record.setDetails(apNodeMetrics);
|
|
||||||
|
|
||||||
ApPerformance apPerformance = new ApPerformance();
|
|
||||||
apNodeMetrics.setApPerformance(apPerformance);
|
|
||||||
|
|
||||||
apPerformance.setCpuTemperature(55);
|
|
||||||
|
|
||||||
//we will force the CPUUtilization alarm to be raised
|
|
||||||
apPerformance.setCpuUtilized(new int[] { 90, 90 });
|
|
||||||
|
|
||||||
apPerformance.setFreeMemory(30000000);
|
|
||||||
|
|
||||||
//publish metric that should trigger alarm for the CPU Utilization
|
|
||||||
metricStreamInterface.publish(record );
|
|
||||||
|
|
||||||
//wait for the metric to be processed
|
|
||||||
sleep(2 * testTimeBucketMs);
|
|
||||||
|
|
||||||
//verify that alarm was raised
|
|
||||||
List<Alarm> alarms = alarmService.get(customerId, Collections.singleton(equipmentId), Collections.singleton(AlarmCode.CPUUtilization));
|
|
||||||
assertEquals(1, alarms.size());
|
|
||||||
|
|
||||||
//Now create a metric that should clear the alarm
|
|
||||||
ServiceMetric recordToClearAlarm = record.clone();
|
|
||||||
recordToClearAlarm.setCreatedTimestamp(System.currentTimeMillis() + 2* testTimeBucketMs );
|
|
||||||
((ApNodeMetrics)recordToClearAlarm.getDetails()).getApPerformance().setCpuUtilized(new int[] { 50, 50 });
|
|
||||||
|
|
||||||
//publish metric that should clear the alarm for the CPU Utilization
|
|
||||||
metricStreamInterface.publish(recordToClearAlarm);
|
|
||||||
|
|
||||||
//wait for the metric to be processed
|
|
||||||
sleep(2 * testTimeBucketMs);
|
|
||||||
|
|
||||||
//verify that alarm was cleared
|
|
||||||
alarms = alarmService.get(customerId, Collections.singleton(equipmentId), Collections.singleton(AlarmCode.CPUUtilization));
|
|
||||||
assertEquals(0, alarms.size());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAccessPointIsUnreachableAlarm() {
|
|
||||||
int customerId = getNextCustomerId();
|
|
||||||
|
|
||||||
Equipment equipment = new Equipment();
|
|
||||||
equipment.setCustomerId(customerId);
|
|
||||||
equipment.setEquipmentType(EquipmentType.AP);
|
|
||||||
equipment.setInventoryId("testAccessPointIsUnreachableAlarm");
|
|
||||||
equipment.setName(equipment.getInventoryId());
|
|
||||||
equipment = equipmentService.create(equipment);
|
|
||||||
long equipmentId = equipment.getId();
|
|
||||||
|
|
||||||
ServiceMetric record = new ServiceMetric(customerId , equipmentId );
|
|
||||||
//create metric a bit in the future so that it gets picked up by the processor and not simply discarded
|
|
||||||
record.setCreatedTimestamp(System.currentTimeMillis() + testTimeBucketMs);
|
|
||||||
|
|
||||||
ApNodeMetrics apNodeMetrics = new ApNodeMetrics();
|
|
||||||
record.setDetails(apNodeMetrics);
|
|
||||||
|
|
||||||
ApPerformance apPerformance = new ApPerformance();
|
|
||||||
apNodeMetrics.setApPerformance(apPerformance);
|
|
||||||
|
|
||||||
apPerformance.setCpuTemperature(55);
|
|
||||||
|
|
||||||
//we will force the CPUUtilization alarm to be raised
|
|
||||||
apPerformance.setCpuUtilized(new int[] { 50, 50 });
|
|
||||||
|
|
||||||
apPerformance.setFreeMemory(30000000);
|
|
||||||
|
|
||||||
//publish metric that should not trigger AccessPointIsUnreachable alarm
|
|
||||||
metricStreamInterface.publish(record );
|
|
||||||
|
|
||||||
//wait for the metric to be processed
|
|
||||||
sleep(testTimeBucketMs);
|
|
||||||
|
|
||||||
//verify that alarm was not raised
|
|
||||||
List<Alarm> alarms = alarmService.get(customerId, Collections.singleton(equipmentId), Collections.singleton(AlarmCode.AccessPointIsUnreachable));
|
|
||||||
assertEquals(0, alarms.size());
|
|
||||||
|
|
||||||
//Now wait for the alarm to be raised because no service_metrics_collection_config were posted
|
|
||||||
sleep(testTimeBucketMs);
|
|
||||||
|
|
||||||
//verify that alarm was raised
|
|
||||||
for(int i = 0; i < 50; i++) {
|
|
||||||
alarms = alarmService.get(customerId, Collections.singleton(equipmentId), Collections.singleton(AlarmCode.AccessPointIsUnreachable));
|
|
||||||
if(!alarms.isEmpty()) {
|
|
||||||
break;
|
|
||||||
}else {
|
|
||||||
sleep(5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertEquals(1, alarms.size());
|
|
||||||
|
|
||||||
//Now create a metric that should clear the alarm
|
|
||||||
ServiceMetric recordToClearAlarm = record.clone();
|
|
||||||
recordToClearAlarm.setCreatedTimestamp(System.currentTimeMillis() + testTimeBucketMs );
|
|
||||||
|
|
||||||
//publish metric that should clear the AccessPointIsUnreachable alarm
|
|
||||||
metricStreamInterface.publish(recordToClearAlarm);
|
|
||||||
|
|
||||||
//wait for the metric to be processed
|
|
||||||
sleep(testTimeBucketMs);
|
|
||||||
|
|
||||||
//verify that alarm was cleared
|
|
||||||
for(int i = 0; i < 50; i++) {
|
|
||||||
alarms = alarmService.get(customerId, Collections.singleton(equipmentId), Collections.singleton(AlarmCode.AccessPointIsUnreachable));
|
|
||||||
if(alarms.isEmpty()) {
|
|
||||||
break;
|
|
||||||
}else {
|
|
||||||
sleep(5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertEquals(0, alarms.size());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNextCustomerId() {
|
|
||||||
return (int) testSequence.incrementAndGet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getNextEquipmentId() {
|
|
||||||
return testSequence.incrementAndGet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sleep(long ms) {
|
|
||||||
try {
|
|
||||||
Thread.sleep( ms );
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<configuration>
|
|
||||||
<conversionRule conversionWord="filteredStack"
|
|
||||||
converterClass="com.telecominfraproject.wlan.server.exceptions.logback.ExceptionCompressingConverter" />
|
|
||||||
|
|
||||||
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n%filteredStack%nopex</pattern>
|
|
||||||
<!-- See http://logback.qos.ch/manual/layouts.html for details -->
|
|
||||||
<!-- %ex{5} - add at the end to display only 5 levels of the exception stack trace -->
|
|
||||||
<!-- %nopex - add at the end to not display any of the exception stack traces -->
|
|
||||||
<!-- %ex{full} - add at the end to display all the levels of the exception stack trace -->
|
|
||||||
</encoder>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
details: http://logback.qos.ch/manual/configuration.html#auto_configuration
|
|
||||||
|
|
||||||
runtime configuration, if need to override the defaults:
|
|
||||||
-Dlogging.config=file:///home/ec2-user/opensync/logback.xml
|
|
||||||
|
|
||||||
for log configuration debugging - use
|
|
||||||
-Dlogback.statusListenerClass=ch.qos.logback.core.status.OnConsoleStatusListener
|
|
||||||
|
|
||||||
log levels:
|
|
||||||
OFF ERROR WARN INFO DEBUG TRACE
|
|
||||||
-->
|
|
||||||
<logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR"/>
|
|
||||||
<logger name="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" level="INFO"/>
|
|
||||||
<logger name="org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer" level="INFO"/>
|
|
||||||
<logger name="org.springframework.security.web.authentication.preauth" level="OFF"/>
|
|
||||||
<logger name="com.netflix.servo.tag.aws.AwsInjectableTag" level="OFF"/>
|
|
||||||
|
|
||||||
<logger name="com.telecominfraproject" level="WARN"/>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<logger name="com.telecominfraproject.wlan.streams.simple" level="TRACE"/>
|
|
||||||
<logger name="com.telecominfraproject.wlan.streams.equipmentalarms" level="TRACE"/>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<root level="WARN">
|
|
||||||
<appender-ref ref="stdout"/>
|
|
||||||
</root>
|
|
||||||
|
|
||||||
</configuration>
|
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
package com.telecominfraproject.wlan.equipmentgateway.models;
|
package com.telecominfraproject.wlan.equipmentgateway.models;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import com.telecominfraproject.wlan.core.model.equipment.LEDColour;
|
import com.telecominfraproject.wlan.core.model.equipment.LEDColour;
|
||||||
|
|
||||||
public class CEGWBlinkRequest extends EquipmentCommand {
|
public class CEGWBlinkRequest extends EquipmentCommand {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3464950479960821571L;
|
private static final long serialVersionUID = 3464950479960821571L;
|
||||||
|
|
||||||
|
private boolean blinkAllLEDs;
|
||||||
private int numCycles;
|
private int numCycles;
|
||||||
private int colour1DurationMs;
|
private int colour1DurationMs;
|
||||||
private int colour2DurationMs;
|
private int colour2DurationMs;
|
||||||
@@ -28,6 +31,14 @@ public class CEGWBlinkRequest extends EquipmentCommand {
|
|||||||
public CEGWBlinkRequest() {
|
public CEGWBlinkRequest() {
|
||||||
super(CEGWCommandType.BlinkRequest, null, 0);
|
super(CEGWCommandType.BlinkRequest, null, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getBlinkAllLEDs() {
|
||||||
|
return this.blinkAllLEDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlinkAllLEDs(boolean blinkAllLEDs) {
|
||||||
|
this.blinkAllLEDs = blinkAllLEDs;
|
||||||
|
}
|
||||||
|
|
||||||
public int getNumCycles() {
|
public int getNumCycles() {
|
||||||
return numCycles;
|
return numCycles;
|
||||||
@@ -79,4 +90,25 @@ public class CEGWBlinkRequest extends EquipmentCommand {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = super.hashCode();
|
||||||
|
result = prime * result + Objects.hash(blinkAllLEDs, colour1, colour1DurationMs, colour2, colour2DurationMs, numCycles);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (!super.equals(obj))
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
CEGWBlinkRequest other = (CEGWBlinkRequest) obj;
|
||||||
|
return blinkAllLEDs == other.blinkAllLEDs && colour1 == other.colour1 && colour1DurationMs == other.colour1DurationMs && colour2 == other.colour2
|
||||||
|
&& colour2DurationMs == other.colour2DurationMs && numCycles == other.numCycles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,6 +346,7 @@ components:
|
|||||||
- off
|
- off
|
||||||
|
|
||||||
CEGWBlinkRequest:
|
CEGWBlinkRequest:
|
||||||
|
description: Turn all LEDs on the AP to blinking, or turn off. The blinkAllLEDs attribute is the only currently supported functionality on the AP.
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/components/schemas/CEGWBaseCommand'
|
- $ref: '#/components/schemas/CEGWBaseCommand'
|
||||||
properties:
|
properties:
|
||||||
@@ -357,6 +358,8 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- CEGWBlinkRequest
|
- CEGWBlinkRequest
|
||||||
|
blinkAllLEDs:
|
||||||
|
type: boolean
|
||||||
colour1:
|
colour1:
|
||||||
$ref: '#/components/schemas/LEDColour'
|
$ref: '#/components/schemas/LEDColour'
|
||||||
colour2:
|
colour2:
|
||||||
@@ -375,6 +378,7 @@ components:
|
|||||||
inventoryId: inv-1
|
inventoryId: inv-1
|
||||||
model_type: CEGWBlinkRequest
|
model_type: CEGWBlinkRequest
|
||||||
commandType: BlinkRequest
|
commandType: BlinkRequest
|
||||||
|
blinkAllLEDs: true
|
||||||
colour1: blue
|
colour1: blue
|
||||||
colour2: red
|
colour2: red
|
||||||
colour1DurationMs: 1000
|
colour1DurationMs: 1000
|
||||||
|
|||||||
@@ -191,18 +191,18 @@ public class ManufacturerServiceRemoteTest extends BaseRemoteTest {
|
|||||||
Set<String> ouiList = new HashSet<>();
|
Set<String> ouiList = new HashSet<>();
|
||||||
ouiList.add(oui1);
|
ouiList.add(oui1);
|
||||||
ouiListSearchResult = remoteInterface.getManufacturerDetailsForOuiSet(ouiList);
|
ouiListSearchResult = remoteInterface.getManufacturerDetailsForOuiSet(ouiList);
|
||||||
assertTrue(ouiListSearchResult.size() == 1);
|
assertTrue(ouiListSearchResult.size() == 2);
|
||||||
assertTrue(ouiListSearchResult.get(oui1).equals(ret1));
|
assertTrue(ouiListSearchResult.get(oui1).equals(ret1));
|
||||||
|
|
||||||
ouiList.add(oui2);
|
ouiList.add(oui2);
|
||||||
ouiListSearchResult = remoteInterface.getManufacturerDetailsForOuiSet(ouiList);
|
ouiListSearchResult = remoteInterface.getManufacturerDetailsForOuiSet(ouiList);
|
||||||
assertTrue(ouiListSearchResult.size() == 2);
|
assertTrue(ouiListSearchResult.size() == 3);
|
||||||
assertTrue(ouiListSearchResult.get(oui1).equals(ret1));
|
assertTrue(ouiListSearchResult.get(oui1).equals(ret1));
|
||||||
assertTrue(ouiListSearchResult.get(oui2).equals(ret2));
|
assertTrue(ouiListSearchResult.get(oui2).equals(ret2));
|
||||||
|
|
||||||
ouiList.add(oui3);
|
ouiList.add(oui3);
|
||||||
ouiListSearchResult = remoteInterface.getManufacturerDetailsForOuiSet(ouiList);
|
ouiListSearchResult = remoteInterface.getManufacturerDetailsForOuiSet(ouiList);
|
||||||
assertTrue(ouiListSearchResult.size() == 3);
|
assertTrue(ouiListSearchResult.size() == 4);
|
||||||
assertTrue(ouiListSearchResult.get(oui1).equals(ret1));
|
assertTrue(ouiListSearchResult.get(oui1).equals(ret1));
|
||||||
assertTrue(ouiListSearchResult.get(oui2).equals(ret2));
|
assertTrue(ouiListSearchResult.get(oui2).equals(ret2));
|
||||||
assertTrue(ouiListSearchResult.get(oui3).equals(ret3));
|
assertTrue(ouiListSearchResult.get(oui3).equals(ret3));
|
||||||
@@ -211,7 +211,7 @@ public class ManufacturerServiceRemoteTest extends BaseRemoteTest {
|
|||||||
ouiList.add(String.format("%06d", i));
|
ouiList.add(String.format("%06d", i));
|
||||||
}
|
}
|
||||||
ouiListSearchResult = remoteInterface.getManufacturerDetailsForOuiSet(ouiList);
|
ouiListSearchResult = remoteInterface.getManufacturerDetailsForOuiSet(ouiList);
|
||||||
assertEquals(3,ouiListSearchResult.size());
|
assertEquals(4,ouiListSearchResult.size());
|
||||||
assertTrue(ouiListSearchResult.get(oui1).equals(ret1));
|
assertTrue(ouiListSearchResult.get(oui1).equals(ret1));
|
||||||
assertTrue(ouiListSearchResult.get(oui2).equals(ret2));
|
assertTrue(ouiListSearchResult.get(oui2).equals(ret2));
|
||||||
assertTrue(ouiListSearchResult.get(oui3).equals(ret3));
|
assertTrue(ouiListSearchResult.get(oui3).equals(ret3));
|
||||||
|
|||||||
@@ -35,7 +35,10 @@ import com.telecominfraproject.wlan.manufacturer.models.ManufacturerOuiDetails;
|
|||||||
public class ManufacturerController {
|
public class ManufacturerController {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(ManufacturerController.class);
|
private static final Logger LOG = LoggerFactory.getLogger(ManufacturerController.class);
|
||||||
|
|
||||||
|
private static final int GLOBE_BIT = (0x1 << 1);
|
||||||
|
private static final ManufacturerOuiDetails PRIVATE_MAC_RESPONSE = new ManufacturerOuiDetails();
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ManufacturerDatastoreInterface manufacturerDatastore;
|
private ManufacturerDatastoreInterface manufacturerDatastore;
|
||||||
|
|
||||||
@@ -43,6 +46,11 @@ public class ManufacturerController {
|
|||||||
private static final long serialVersionUID = -8035392255039609079L;
|
private static final long serialVersionUID = -8035392255039609079L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
PRIVATE_MAC_RESPONSE.setOui("ffffff");
|
||||||
|
PRIVATE_MAC_RESPONSE.setManufacturerName("Unknown (Private Address)");
|
||||||
|
PRIVATE_MAC_RESPONSE.setManufacturerAlias("Unknown");
|
||||||
|
}
|
||||||
@PostMapping(value = "/oui")
|
@PostMapping(value = "/oui")
|
||||||
public ManufacturerOuiDetails createOuiDetails(@RequestBody ManufacturerOuiDetails ouiDetails) {
|
public ManufacturerOuiDetails createOuiDetails(@RequestBody ManufacturerOuiDetails ouiDetails) {
|
||||||
LOG.debug("Creating OUI details {} ", ouiDetails);
|
LOG.debug("Creating OUI details {} ", ouiDetails);
|
||||||
@@ -76,9 +84,7 @@ public class ManufacturerController {
|
|||||||
@GetMapping(value = "/oui")
|
@GetMapping(value = "/oui")
|
||||||
public ManufacturerOuiDetails getByOui(@RequestParam String oui) {
|
public ManufacturerOuiDetails getByOui(@RequestParam String oui) {
|
||||||
LOG.debug("Retrieving OUI details for OUI {} ", oui);
|
LOG.debug("Retrieving OUI details for OUI {} ", oui);
|
||||||
|
ManufacturerOuiDetails ret = isGlobalAddress(oui) ? manufacturerDatastore.getByOui(oui) : PRIVATE_MAC_RESPONSE;
|
||||||
ManufacturerOuiDetails ret = manufacturerDatastore.getByOui(oui);
|
|
||||||
|
|
||||||
LOG.debug("Retrieved OUI details {} ", ret);
|
LOG.debug("Retrieved OUI details {} ", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -157,7 +163,11 @@ public class ManufacturerController {
|
|||||||
public Map<String, ManufacturerOuiDetails> getManufacturerDetailsForOuiList(
|
public Map<String, ManufacturerOuiDetails> getManufacturerDetailsForOuiList(
|
||||||
@RequestParam List<String> ouiList) {
|
@RequestParam List<String> ouiList) {
|
||||||
LOG.debug("calling getManufacturerDetailsForOuiList ");
|
LOG.debug("calling getManufacturerDetailsForOuiList ");
|
||||||
return manufacturerDatastore.getManufacturerDetailsForOuiList(ouiList);
|
Map<String, ManufacturerOuiDetails> manufMap = manufacturerDatastore.getManufacturerDetailsForOuiList(ouiList);
|
||||||
|
|
||||||
|
ouiList.forEach(oui -> {if (!isGlobalAddress(oui)) manufMap.put(oui, PRIVATE_MAC_RESPONSE);});
|
||||||
|
manufMap.put(PRIVATE_MAC_RESPONSE.getOui(), PRIVATE_MAC_RESPONSE);
|
||||||
|
return manufMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping(value = "/oui/alias")
|
@PutMapping(value = "/oui/alias")
|
||||||
@@ -180,4 +190,14 @@ public class ManufacturerController {
|
|||||||
LOG.debug("Retrieving alias values that begin with {}", prefix);
|
LOG.debug("Retrieving alias values that begin with {}", prefix);
|
||||||
return manufacturerDatastore.getAliasValuesThatBeginWith(prefix, maxResults);
|
return manufacturerDatastore.getAliasValuesThatBeginWith(prefix, maxResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isGlobalAddress(String oui) {
|
||||||
|
if (oui != null && oui.length() == 6) {
|
||||||
|
// we only need to check the first Byte of the OUI
|
||||||
|
Integer hex = Integer.parseInt(oui.substring(0, 2), 16);
|
||||||
|
byte firstByte = hex.byteValue();
|
||||||
|
return (firstByte & GLOBE_BIT) == 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,51 @@
|
|||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- test dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<artifactId>equipment-service-local</artifactId>
|
||||||
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<artifactId>equipment-service</artifactId>
|
||||||
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<artifactId>equipment-datastore-inmemory</artifactId>
|
||||||
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<artifactId>cloud-event-dispatcher-empty</artifactId>
|
||||||
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<artifactId>profile-service-local</artifactId>
|
||||||
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<artifactId>profile-service</artifactId>
|
||||||
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<artifactId>profile-datastore-inmemory</artifactId>
|
||||||
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package com.telecominfraproject.wlan.portal.controller.equipmentgateway;
|
package com.telecominfraproject.wlan.portal.controller.equipmentgateway;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -13,6 +14,7 @@ import com.telecominfraproject.wlan.core.model.json.GenericResponse;
|
|||||||
import com.telecominfraproject.wlan.equipment.EquipmentServiceInterface;
|
import com.telecominfraproject.wlan.equipment.EquipmentServiceInterface;
|
||||||
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
||||||
import com.telecominfraproject.wlan.equipment.models.RadioChannelChangeSettings;
|
import com.telecominfraproject.wlan.equipment.models.RadioChannelChangeSettings;
|
||||||
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWBlinkRequest;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCommandResultCode;
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCommandResultCode;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWFirmwareDownloadRequest;
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWFirmwareDownloadRequest;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWNewChannelRequest;
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWNewChannelRequest;
|
||||||
@@ -30,7 +32,7 @@ import com.telecominfraproject.wlan.status.equipment.models.EquipmentResetMethod
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/portal")
|
@RequestMapping(value = "/portal")
|
||||||
public class EquipmentGatewayPortalController {
|
public class EquipmentGatewayPortalController {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(EquipmentGatewayPortalController.class);
|
private static final Logger LOG = LoggerFactory.getLogger(EquipmentGatewayPortalController.class);
|
||||||
|
|
||||||
@@ -49,94 +51,113 @@ public class EquipmentGatewayPortalController {
|
|||||||
|
|
||||||
Equipment equipment = equipmentServiceInterface.get(equipmentId);
|
Equipment equipment = equipmentServiceInterface.get(equipmentId);
|
||||||
FirmwareVersion fwVersion = firmwareServiceInterface.getFirmwareVersion(firmwareVersionId);
|
FirmwareVersion fwVersion = firmwareServiceInterface.getFirmwareVersion(firmwareVersionId);
|
||||||
|
|
||||||
CEGWFirmwareDownloadRequest fwDownloadRequest = new CEGWFirmwareDownloadRequest(equipment.getInventoryId(),
|
CEGWFirmwareDownloadRequest fwDownloadRequest =
|
||||||
equipment.getId(), fwVersion.getVersionName(), fwVersion.getFilename());
|
new CEGWFirmwareDownloadRequest(equipment.getInventoryId(), equipment.getId(), fwVersion.getVersionName(), fwVersion.getFilename());
|
||||||
|
|
||||||
EquipmentCommandResponse response = equipmentGatewayServiceInterface.sendCommand(fwDownloadRequest);
|
EquipmentCommandResponse response = equipmentGatewayServiceInterface.sendCommand(fwDownloadRequest);
|
||||||
LOG.debug("FW Download Response {}", response);
|
LOG.debug("FW Download Response {}", response);
|
||||||
|
|
||||||
if(response.getResultCode() == CEGWCommandResultCode.Success) {
|
if (response.getResultCode() == CEGWCommandResultCode.Success) {
|
||||||
return new GenericResponse(true,"");
|
return new GenericResponse(true, "");
|
||||||
} else {
|
} else {
|
||||||
return new GenericResponse(false, "Failed to request firmware update: "+ response.getResultCode() + " " + response.getResultDetail());
|
return new GenericResponse(false, "Failed to request firmware update: " + response.getResultCode() + " " + response.getResultDetail());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/equipmentGateway/requestChannelChange", method = RequestMethod.POST)
|
@RequestMapping(value = "/equipmentGateway/requestChannelChange", method = RequestMethod.POST)
|
||||||
public GenericResponse requestChannelChange(@RequestParam long equipmentId, @RequestBody RadioChannelChangeSettings radioChannelChangeSettings) {
|
public GenericResponse requestChannelChange(@RequestParam long equipmentId, @RequestBody RadioChannelChangeSettings radioChannelChangeSettings) {
|
||||||
LOG.debug("requestChannelChange {} {}", equipmentId);
|
LOG.debug("requestChannelChange {} {}", equipmentId);
|
||||||
|
|
||||||
Equipment equipment = equipmentServiceInterface.get(equipmentId);
|
Equipment equipment = equipmentServiceInterface.get(equipmentId);
|
||||||
|
|
||||||
CEGWNewChannelRequest newChannelRequest = new CEGWNewChannelRequest(equipment.getInventoryId(), equipmentId, radioChannelChangeSettings.getBackupChannel(), radioChannelChangeSettings.getPrimaryChannel());
|
CEGWNewChannelRequest newChannelRequest = new CEGWNewChannelRequest(equipment.getInventoryId(), equipmentId,
|
||||||
|
radioChannelChangeSettings.getBackupChannel(), radioChannelChangeSettings.getPrimaryChannel());
|
||||||
|
|
||||||
EquipmentCommandResponse response = equipmentGatewayServiceInterface.sendCommand(newChannelRequest);
|
EquipmentCommandResponse response = equipmentGatewayServiceInterface.sendCommand(newChannelRequest);
|
||||||
LOG.debug("Channel Change Response {}", response);
|
LOG.debug("Channel Change Response {}", response);
|
||||||
|
|
||||||
if(response.getResultCode() == CEGWCommandResultCode.Success) {
|
if (response.getResultCode() == CEGWCommandResultCode.Success) {
|
||||||
return new GenericResponse(true,"");
|
return new GenericResponse(true, "");
|
||||||
} else {
|
} else {
|
||||||
return new GenericResponse(false, "Failed to initiate channel change: "+ response.getResultCode() + " " + response.getResultDetail());
|
return new GenericResponse(false, "Failed to initiate channel change: " + response.getResultCode() + " " + response.getResultDetail());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/equipmentGateway/requestApReboot", method = RequestMethod.POST)
|
@RequestMapping(value = "/equipmentGateway/requestApReboot", method = RequestMethod.POST)
|
||||||
public GenericResponse requestApReboot(@RequestParam long equipmentId) {
|
public GenericResponse requestApReboot(@RequestParam long equipmentId) {
|
||||||
LOG.debug("requestApReboot {}", equipmentId);
|
LOG.debug("requestApReboot {}", equipmentId);
|
||||||
|
|
||||||
Equipment equipment = equipmentServiceInterface.get(equipmentId);
|
Equipment equipment = equipmentServiceInterface.get(equipmentId);
|
||||||
// No config change, just plain reboot
|
// No config change, just plain reboot
|
||||||
CEGWRebootRequest apRebootRequest = new CEGWRebootRequest(equipment.getInventoryId(),
|
CEGWRebootRequest apRebootRequest = new CEGWRebootRequest(equipment.getInventoryId(), equipment.getId(), false, EquipmentResetMethod.NoReset);
|
||||||
equipment.getId(), false, EquipmentResetMethod.NoReset);
|
|
||||||
|
|
||||||
EquipmentCommandResponse response = equipmentGatewayServiceInterface.sendCommand(apRebootRequest);
|
EquipmentCommandResponse response = equipmentGatewayServiceInterface.sendCommand(apRebootRequest);
|
||||||
LOG.debug("AP reboot response {}", response);
|
LOG.debug("AP reboot response {}", response);
|
||||||
|
|
||||||
if(response.getResultCode() == CEGWCommandResultCode.Success) {
|
if (response.getResultCode() == CEGWCommandResultCode.Success) {
|
||||||
return new GenericResponse(true,"");
|
return new GenericResponse(true, "");
|
||||||
} else {
|
} else {
|
||||||
return new GenericResponse(false, "Failed to trigger AP reboot: "+ response.getResultCode() + " " + response.getResultDetail());
|
return new GenericResponse(false, "Failed to trigger AP reboot: " + response.getResultCode() + " " + response.getResultDetail());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/equipmentGateway/requestApSwitchSoftwareBank", method = RequestMethod.POST)
|
@RequestMapping(value = "/equipmentGateway/requestApSwitchSoftwareBank", method = RequestMethod.POST)
|
||||||
public GenericResponse requestApSwitchSoftwareBank(@RequestParam long equipmentId) {
|
public GenericResponse requestApSwitchSoftwareBank(@RequestParam long equipmentId) {
|
||||||
LOG.debug("requestApSwitchSoftwareBank {}", equipmentId);
|
LOG.debug("requestApSwitchSoftwareBank {}", equipmentId);
|
||||||
|
|
||||||
Equipment equipment = equipmentServiceInterface.get(equipmentId);
|
Equipment equipment = equipmentServiceInterface.get(equipmentId);
|
||||||
// Reboot, switch active/inactive software bank
|
// Reboot, switch active/inactive software bank
|
||||||
CEGWRebootRequest apSwitchSoftwareBank = new CEGWRebootRequest(equipment.getInventoryId(),
|
CEGWRebootRequest apSwitchSoftwareBank = new CEGWRebootRequest(equipment.getInventoryId(), equipment.getId(), true, EquipmentResetMethod.NoReset);
|
||||||
equipment.getId(), true, EquipmentResetMethod.NoReset);
|
|
||||||
|
|
||||||
EquipmentCommandResponse response = equipmentGatewayServiceInterface.sendCommand(apSwitchSoftwareBank);
|
EquipmentCommandResponse response = equipmentGatewayServiceInterface.sendCommand(apSwitchSoftwareBank);
|
||||||
LOG.debug("AP switch software bank response {}", response);
|
LOG.debug("AP switch software bank response {}", response);
|
||||||
|
|
||||||
if(response.getResultCode() == CEGWCommandResultCode.Success) {
|
if (response.getResultCode() == CEGWCommandResultCode.Success) {
|
||||||
return new GenericResponse(true,"");
|
return new GenericResponse(true, "");
|
||||||
} else {
|
} else {
|
||||||
return new GenericResponse(false, "Failed to trigger AP switch software bank: "+ response.getResultCode() + " " + response.getResultDetail());
|
return new GenericResponse(false, "Failed to trigger AP switch software bank: " + response.getResultCode() + " " + response.getResultDetail());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/equipmentGateway/requestApFactoryReset", method = RequestMethod.POST)
|
@RequestMapping(value = "/equipmentGateway/requestApFactoryReset", method = RequestMethod.POST)
|
||||||
public GenericResponse requestApFactoryReset(@RequestParam long equipmentId) {
|
public GenericResponse requestApFactoryReset(@RequestParam long equipmentId) {
|
||||||
LOG.debug("requestApFactoryReset {}", equipmentId);
|
LOG.debug("requestApFactoryReset {}", equipmentId);
|
||||||
|
|
||||||
Equipment equipment = equipmentServiceInterface.get(equipmentId);
|
Equipment equipment = equipmentServiceInterface.get(equipmentId);
|
||||||
// Reboot Ap with factory settings
|
// Reboot Ap with factory settings
|
||||||
CEGWRebootRequest apFactoryReset = new CEGWRebootRequest(equipment.getInventoryId(),
|
CEGWRebootRequest apFactoryReset = new CEGWRebootRequest(equipment.getInventoryId(), equipment.getId(), false, EquipmentResetMethod.FactoryReset);
|
||||||
equipment.getId(), false, EquipmentResetMethod.FactoryReset);
|
|
||||||
|
|
||||||
EquipmentCommandResponse response = equipmentGatewayServiceInterface.sendCommand(apFactoryReset);
|
EquipmentCommandResponse response = equipmentGatewayServiceInterface.sendCommand(apFactoryReset);
|
||||||
LOG.debug("AP factory reset response {}", response);
|
LOG.debug("AP factory reset response {}", response);
|
||||||
|
|
||||||
if(response.getResultCode() == CEGWCommandResultCode.Success) {
|
if (response.getResultCode() == CEGWCommandResultCode.Success) {
|
||||||
return new GenericResponse(true,"");
|
return new GenericResponse(true, "");
|
||||||
} else {
|
} else {
|
||||||
return new GenericResponse(false, "Failed to trigger AP factory reset: "+ response.getResultCode() + " " + response.getResultDetail());
|
return new GenericResponse(false, "Failed to trigger AP factory reset: " + response.getResultCode() + " " + response.getResultDetail());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/equipmentGateway/requestApBlinkLEDs", method = RequestMethod.POST)
|
||||||
|
public GenericResponse requestApBlinkLEDs(@RequestParam long equipmentId, @RequestParam boolean blinkAllLEDs) {
|
||||||
|
String action = "stop blinking LEDs on AP ";
|
||||||
|
if (blinkAllLEDs) action = "start blinking LEDs on AP ";
|
||||||
|
Equipment equipment = equipmentServiceInterface.get(equipmentId);
|
||||||
|
LOG.debug("Request {} for AP {}", action, equipment.getInventoryId());
|
||||||
|
|
||||||
|
// Turn LEDs on Ap on or off based on blinkAllLEDs value
|
||||||
|
CEGWBlinkRequest apBlinkLEDs = new CEGWBlinkRequest(equipment.getInventoryId(), equipment.getId());
|
||||||
|
apBlinkLEDs.setBlinkAllLEDs(blinkAllLEDs);
|
||||||
|
|
||||||
|
EquipmentCommandResponse response = equipmentGatewayServiceInterface.sendCommand(apBlinkLEDs);
|
||||||
|
LOG.debug("{} response {}", action,response);
|
||||||
|
|
||||||
|
|
||||||
|
if (response.getResultCode() == CEGWCommandResultCode.Success) {
|
||||||
|
return new GenericResponse(true, "");
|
||||||
|
} else {
|
||||||
|
return new GenericResponse(false, "Failed to " + action + " for AP: " + response.getResultCode() + " " + response.getResultDetail());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,55 +158,66 @@ public class ProfilePortalController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/profile/equipmentCounts", method = RequestMethod.GET)
|
@RequestMapping(value = "/profile/equipmentCounts", method = RequestMethod.GET)
|
||||||
public ListOfPairLongLong getCountsOfEquipmentThatUseProfiles(@RequestParam Set<Long> profileIdSet) {
|
public ListOfPairLongLong getCountsOfEquipmentThatUseProfiles(@RequestParam Set<Long> profileIdSet) {
|
||||||
LOG.debug("getCountsOfEquipmentThatUseProfiles({})", profileIdSet);
|
LOG.debug("getCountsOfEquipmentThatUseProfiles({})", profileIdSet);
|
||||||
|
|
||||||
//first get top-level profiles for the supplied set - only top-level profiles are linked to equipment
|
Map<Long, AtomicInteger> profileIdToCountMap = new HashMap<Long, AtomicInteger>();
|
||||||
List<PairLongLong> topLevelProfiles = this.profileServiceInterface.getTopLevelProfiles(profileIdSet);
|
profileIdSet.forEach(profileId -> profileIdToCountMap.put(profileId, new AtomicInteger(0)));
|
||||||
|
|
||||||
|
//Maps child at all top level profiles that reference it. A top level profile references itself int this map
|
||||||
|
Map<Long, List<Long>> childProfileToTopProfileMap = new HashMap<Long, List<Long>>();
|
||||||
|
|
||||||
|
List<PairLongLong> topLevelProfileList = profileServiceInterface.getTopLevelProfiles(profileIdSet);
|
||||||
|
Set<Long> topProfileIdSet= new HashSet<Long>();
|
||||||
|
|
||||||
|
topLevelProfileList.forEach(pair ->
|
||||||
|
{
|
||||||
|
if (childProfileToTopProfileMap.putIfAbsent(
|
||||||
|
pair.getValue1(),
|
||||||
|
new ArrayList<Long>() {{ add(pair.getValue2());}}
|
||||||
|
) != null)
|
||||||
|
{
|
||||||
|
childProfileToTopProfileMap.compute(pair.getValue1(), (k,v) ->
|
||||||
|
new ArrayList<Long>() {{
|
||||||
|
addAll(v);
|
||||||
|
add(pair.getValue2());}});
|
||||||
|
}
|
||||||
|
topProfileIdSet.add(pair.getValue2());
|
||||||
|
});
|
||||||
|
|
||||||
|
Map<Long, AtomicInteger> topProfileToEquipmentCountMap = new HashMap<>();
|
||||||
|
topProfileIdSet.forEach(p -> topProfileToEquipmentCountMap.put(p, new AtomicInteger()));
|
||||||
|
|
||||||
|
PaginationContext<PairLongLong> context = new PaginationContext<>(500);
|
||||||
|
equipmentServiceInterface.getEquipmentIdsByProfileIds(topProfileIdSet, context);
|
||||||
|
|
||||||
|
while(!context.isLastPage()) {
|
||||||
|
PaginationResponse<PairLongLong> page = equipmentServiceInterface.getEquipmentIdsByProfileIds(topProfileIdSet, context );
|
||||||
|
context = page.getContext();
|
||||||
|
|
||||||
|
page.getItems().forEach(p -> {
|
||||||
|
AtomicInteger cnt = topProfileToEquipmentCountMap.get(p.getValue1());
|
||||||
|
if(cnt!=null) {
|
||||||
|
cnt.incrementAndGet();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
LOG.debug("Page {} - counted {} equipmentids", context.getLastReturnedPageNumber(), context.getTotalItemsReturned());
|
||||||
|
}
|
||||||
|
|
||||||
|
// assemble profile count for return, using child to top level profile id map
|
||||||
|
childProfileToTopProfileMap.forEach((childKey,TopLevelIdList) ->
|
||||||
|
{
|
||||||
|
for (Long topProfileId : TopLevelIdList)
|
||||||
|
{
|
||||||
|
profileIdToCountMap.get(childKey).addAndGet(topProfileToEquipmentCountMap.get(topProfileId).get());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//package results to get equipment counts for the original profile ids
|
||||||
ListOfPairLongLong ret = new ListOfPairLongLong();
|
ListOfPairLongLong ret = new ListOfPairLongLong();
|
||||||
|
profileIdToCountMap.forEach((id, count) -> ret.add(new PairLongLong(id, count.get())));
|
||||||
|
|
||||||
//map each supplied profile to its top-level parent
|
|
||||||
Map<Long, Long> profileIdToTopProfileIdMap = new HashMap<>();
|
|
||||||
topLevelProfiles.forEach(pair -> profileIdToTopProfileIdMap.put(pair.getValue1(), pair.getValue2()));
|
|
||||||
|
|
||||||
//gather top-level profile ids
|
|
||||||
Set<Long> topProfileIds = new HashSet<>();
|
|
||||||
topLevelProfiles.forEach(pair -> topProfileIds.add(pair.getValue2()));
|
|
||||||
|
|
||||||
|
|
||||||
//TODO: this may be more efficiently done by a specialized count method on equipment datastore
|
|
||||||
|
|
||||||
//now get pages of equipmentIds that refer to the top-level profiles and count the equipmentIds
|
|
||||||
PaginationContext<PairLongLong> context = new PaginationContext<>(500);
|
|
||||||
this.equipmentServiceInterface.getEquipmentIdsByProfileIds(topProfileIds, context );
|
|
||||||
|
|
||||||
//prepare map of top-level profileId to the count of equipmentIds
|
|
||||||
Map<Long, AtomicInteger> topProfileIdToEquipmentCountsMap = new HashMap<>();
|
|
||||||
topProfileIds.forEach(p -> topProfileIdToEquipmentCountsMap.put(p, new AtomicInteger()));
|
|
||||||
|
|
||||||
while(!context.isLastPage()) {
|
|
||||||
PaginationResponse<PairLongLong> page = equipmentServiceInterface.getEquipmentIdsByProfileIds(topProfileIds, context );
|
|
||||||
context = page.getContext();
|
|
||||||
|
|
||||||
page.getItems().forEach(p -> {
|
|
||||||
AtomicInteger cnt = topProfileIdToEquipmentCountsMap.get(p.getValue1());
|
|
||||||
if(cnt!=null) {
|
|
||||||
cnt.incrementAndGet();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
LOG.debug("Page {} - counted {} equipmentids", context.getLastReturnedPageNumber(), context.getTotalItemsReturned());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//package results to get equipment counts for the original profile ids
|
|
||||||
profileIdToTopProfileIdMap.forEach((p, tp) -> ret.add(new PairLongLong(p, topProfileIdToEquipmentCountsMap.get(tp).intValue())));
|
|
||||||
|
|
||||||
LOG.debug("getCountsOfEquipmentThatUseProfiles({}) return {}", profileIdSet, ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1865,6 +1865,9 @@ components:
|
|||||||
sharedSecret:
|
sharedSecret:
|
||||||
type: string
|
type: string
|
||||||
format: password
|
format: password
|
||||||
|
dynamicDiscovery:
|
||||||
|
description: Dynamic discovery of HSP and IdPs (home service and identity providers). Regardless of configured value, this will only be set 'true' on the AP if useRadSec is also true.
|
||||||
|
type: boolean
|
||||||
example:
|
example:
|
||||||
model_type: RadiusProxyConfiguration
|
model_type: RadiusProxyConfiguration
|
||||||
caCert:
|
caCert:
|
||||||
@@ -2263,7 +2266,8 @@ components:
|
|||||||
- wpa3OnlySAE
|
- wpa3OnlySAE
|
||||||
- wpa3MixedSAE
|
- wpa3MixedSAE
|
||||||
- wpa3OnlyEAP
|
- wpa3OnlyEAP
|
||||||
- wpa3MixedEAP
|
- wpa3MixedEAP
|
||||||
|
- wpa3OnlyEAP192
|
||||||
|
|
||||||
RadioBasedSsidConfigurationMap:
|
RadioBasedSsidConfigurationMap:
|
||||||
properties:
|
properties:
|
||||||
@@ -4305,6 +4309,8 @@ components:
|
|||||||
- RADIO_CHANNEL
|
- RADIO_CHANNEL
|
||||||
channelNumberStatusDataMap:
|
channelNumberStatusDataMap:
|
||||||
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
||||||
|
txPowerDataMap:
|
||||||
|
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
||||||
|
|
||||||
#
|
#
|
||||||
# Objects related to Client sessions
|
# Objects related to Client sessions
|
||||||
@@ -14238,6 +14244,36 @@ paths:
|
|||||||
$ref: '#/components/schemas/GenericResponse'
|
$ref: '#/components/schemas/GenericResponse'
|
||||||
500:
|
500:
|
||||||
$ref: '#/components/responses/GenericApiError'
|
$ref: '#/components/responses/GenericApiError'
|
||||||
|
|
||||||
|
/portal/equipmentGateway/requestApBlinkLEDs:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- Equipment Gateway
|
||||||
|
summary: Request to enable or disable the blinking of LEDs on the AP
|
||||||
|
operationId: requestApBlinkLEDs
|
||||||
|
parameters:
|
||||||
|
- name: equipmentId
|
||||||
|
in: query
|
||||||
|
description: Equipment id for AP on which the enabling or disabling of blinking LEDs is requested.
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
- name: blinkAllLEDs
|
||||||
|
in: query
|
||||||
|
description: enable (true) or disable (false) the LEDs blinking state.
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/GenericResponse'
|
||||||
|
500:
|
||||||
|
$ref: '#/components/responses/GenericApiError'
|
||||||
|
|
||||||
/portal/equipmentGateway/requestChannelChange:
|
/portal/equipmentGateway/requestChannelChange:
|
||||||
post:
|
post:
|
||||||
|
|||||||
@@ -0,0 +1,201 @@
|
|||||||
|
package com.telecominfraproject.wlan.portal.controller.profile;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
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.cloudeventdispatcher.CloudEventDispatcherEmpty;
|
||||||
|
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
|
||||||
|
import com.telecominfraproject.wlan.core.model.pair.PairLongLong;
|
||||||
|
import com.telecominfraproject.wlan.equipment.EquipmentServiceLocal;
|
||||||
|
import com.telecominfraproject.wlan.equipment.controller.EquipmentController;
|
||||||
|
import com.telecominfraproject.wlan.equipment.datastore.EquipmentDatastore;
|
||||||
|
import com.telecominfraproject.wlan.equipment.datastore.inmemory.EquipmentDatastoreInMemory;
|
||||||
|
import com.telecominfraproject.wlan.equipment.models.Equipment;
|
||||||
|
import com.telecominfraproject.wlan.portal.controller.profile.ProfilePortalController.ListOfPairLongLong;
|
||||||
|
import com.telecominfraproject.wlan.profile.ProfileServiceLocal;
|
||||||
|
import com.telecominfraproject.wlan.profile.controller.ProfileController;
|
||||||
|
import com.telecominfraproject.wlan.profile.datastore.ProfileDatastore;
|
||||||
|
import com.telecominfraproject.wlan.profile.datastore.inmemory.ProfileDatastoreInMemory;
|
||||||
|
import com.telecominfraproject.wlan.profile.models.Profile;
|
||||||
|
import com.telecominfraproject.wlan.profile.models.ProfileByCustomerRequestFactory;
|
||||||
|
import com.telecominfraproject.wlan.profile.models.ProfileType;
|
||||||
|
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@ActiveProfiles(profiles = {
|
||||||
|
"integration_test",
|
||||||
|
}) //NOTE: these profiles will be ADDED to the list of active profiles
|
||||||
|
@SpringBootTest(webEnvironment = WebEnvironment.NONE, classes = ProfilePortalControllerTest.class)
|
||||||
|
@Import(value = {
|
||||||
|
EquipmentServiceLocal.class,
|
||||||
|
EquipmentController.class,
|
||||||
|
EquipmentDatastoreInMemory.class,
|
||||||
|
ProfileServiceLocal.class,
|
||||||
|
ProfileController.class,
|
||||||
|
ProfileDatastoreInMemory.class,
|
||||||
|
ProfileByCustomerRequestFactory.class,
|
||||||
|
CloudEventDispatcherEmpty.class,
|
||||||
|
ProfilePortalController.class
|
||||||
|
})
|
||||||
|
public class ProfilePortalControllerTest {
|
||||||
|
private static AtomicLong profileIncrementer = new AtomicLong(1);
|
||||||
|
private static AtomicLong equipmentIncrementer = new AtomicLong(1);
|
||||||
|
private static Set<Long> profileIds = new HashSet<Long>();
|
||||||
|
private static Set<Long> equipmentIds = new HashSet<Long>();
|
||||||
|
|
||||||
|
@Autowired private ProfilePortalController profilePortalController;
|
||||||
|
@Autowired private EquipmentDatastore equipmentDatastore;
|
||||||
|
@Autowired private ProfileDatastore profileDatastore;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void setup()
|
||||||
|
{
|
||||||
|
profileIds.clear();
|
||||||
|
equipmentIds.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getCountsOfEquipmentThatUseProfilesTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
Profile parentProfile_1 = createProfile(); // 3 equipment
|
||||||
|
Profile parentProfile_2 = createProfile(); // 2 equipment
|
||||||
|
Profile parentProfile_3 = createProfile(); // 1 equipment
|
||||||
|
|
||||||
|
Profile ssidProfile_1 = createSsidProfile(); // linked to parent ids: 1 = 3 expected count
|
||||||
|
Profile ssidProfile_2 = createSsidProfile(); // linked to parent ids: 1,2 = 5 expected count
|
||||||
|
Profile ssidProfile_3 = createSsidProfile(); // linked to parent ids: 3 = 1 expected count
|
||||||
|
|
||||||
|
Profile captivePortalProfile_1 = createCaptivePortalProfile(); // linked to 4 -> 1 = 3 expected count
|
||||||
|
Profile captivePortalProfile_2 = createCaptivePortalProfile(); // linked to 5 and 6 -> 5 + 1 = 6 expected count
|
||||||
|
|
||||||
|
Profile radiusProfile_1 = createRadiusProfile(); // 7, 8 -> 4, 5, 6 -> 1 , 2 , 3 -> 6 expected
|
||||||
|
Profile radiusProfile_2 = createRadiusProfile(); // 0 expected
|
||||||
|
|
||||||
|
// link ssid to AP profiles
|
||||||
|
linkChildToParent(ssidProfile_1.getId(), parentProfile_1.getId());
|
||||||
|
linkChildToParent(ssidProfile_2.getId(), parentProfile_1.getId());
|
||||||
|
linkChildToParent(ssidProfile_2.getId(), parentProfile_2.getId());
|
||||||
|
linkChildToParent(ssidProfile_3.getId(), parentProfile_3.getId());
|
||||||
|
|
||||||
|
//link captive portal profiles to ssid profiles
|
||||||
|
linkChildToParent(captivePortalProfile_1.getId(), ssidProfile_1.getId());
|
||||||
|
linkChildToParent(captivePortalProfile_2.getId(), ssidProfile_2.getId());
|
||||||
|
linkChildToParent(captivePortalProfile_2.getId(), ssidProfile_3.getId());
|
||||||
|
|
||||||
|
//link radius profiles to captive portal profiles
|
||||||
|
linkChildToParent(radiusProfile_1.getId(), captivePortalProfile_1.getId());
|
||||||
|
linkChildToParent(radiusProfile_1.getId(), captivePortalProfile_2.getId());
|
||||||
|
|
||||||
|
createEquipment(parentProfile_1.getId());
|
||||||
|
createEquipment(parentProfile_1.getId());
|
||||||
|
createEquipment(parentProfile_1.getId());
|
||||||
|
createEquipment(parentProfile_2.getId());
|
||||||
|
createEquipment(parentProfile_2.getId());
|
||||||
|
createEquipment(parentProfile_3.getId());
|
||||||
|
|
||||||
|
ListOfPairLongLong ret = profilePortalController.getCountsOfEquipmentThatUseProfiles(profileIds);
|
||||||
|
|
||||||
|
List<PairLongLong> expectedReturn = new ArrayList<PairLongLong>() {{
|
||||||
|
add(new PairLongLong(parentProfile_1.getId(), 3));
|
||||||
|
add(new PairLongLong(parentProfile_2.getId(), 2));
|
||||||
|
add(new PairLongLong(parentProfile_3.getId(), 1));
|
||||||
|
add(new PairLongLong(ssidProfile_1.getId(), 3));
|
||||||
|
add(new PairLongLong(ssidProfile_2.getId(), 5));
|
||||||
|
add(new PairLongLong(ssidProfile_3.getId(), 1));
|
||||||
|
add(new PairLongLong(captivePortalProfile_1.getId(), 3));
|
||||||
|
add(new PairLongLong(captivePortalProfile_2.getId(), 6));
|
||||||
|
add(new PairLongLong(radiusProfile_1.getId(), 6));
|
||||||
|
add(new PairLongLong(radiusProfile_2.getId(), 0));
|
||||||
|
}};
|
||||||
|
|
||||||
|
expectedReturn.forEach(pair -> assertTrue(ret.contains(pair)));
|
||||||
|
equipmentIds.forEach(id -> equipmentDatastore.delete(id));
|
||||||
|
profileIds.forEach(id -> profileDatastore.delete(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Profile createProfile()
|
||||||
|
{
|
||||||
|
Profile profile = new Profile();
|
||||||
|
profile.setName("test" + profileIncrementer.getAndIncrement());
|
||||||
|
profile.setProfileType(ProfileType.equipment_ap);
|
||||||
|
profile.setCustomerId(2);
|
||||||
|
|
||||||
|
Profile created = profileDatastore.create(profile);
|
||||||
|
profileIds.add(created.getId());
|
||||||
|
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Profile createSsidProfile()
|
||||||
|
{
|
||||||
|
Profile profile = new Profile();
|
||||||
|
profile.setName("test" + profileIncrementer.getAndIncrement());
|
||||||
|
profile.setProfileType(ProfileType.ssid);
|
||||||
|
profile.setCustomerId(2);
|
||||||
|
|
||||||
|
Profile created = profileDatastore.create(profile);
|
||||||
|
profileIds.add(created.getId());
|
||||||
|
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Profile createCaptivePortalProfile()
|
||||||
|
{
|
||||||
|
Profile profile = new Profile();
|
||||||
|
profile.setName("test" + profileIncrementer.getAndIncrement());
|
||||||
|
profile.setProfileType(ProfileType.captive_portal);
|
||||||
|
profile.setCustomerId(2);
|
||||||
|
|
||||||
|
Profile created = profileDatastore.create(profile);
|
||||||
|
profileIds.add(created.getId());
|
||||||
|
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Profile createRadiusProfile()
|
||||||
|
{
|
||||||
|
Profile profile = new Profile();
|
||||||
|
profile.setName("test" + profileIncrementer.getAndIncrement());
|
||||||
|
profile.setProfileType(ProfileType.radius);
|
||||||
|
profile.setCustomerId(2);
|
||||||
|
|
||||||
|
Profile created = profileDatastore.create(profile);
|
||||||
|
profileIds.add(created.getId());
|
||||||
|
|
||||||
|
return created;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void linkChildToParent(long childId, long parentId)
|
||||||
|
{
|
||||||
|
Profile parentProfile = profileDatastore.get(parentId);
|
||||||
|
parentProfile.getChildProfileIds().add(childId);
|
||||||
|
|
||||||
|
profileDatastore.update(parentProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Equipment createEquipment(long profileId)
|
||||||
|
{
|
||||||
|
Equipment equipment = new Equipment();
|
||||||
|
equipment.setCustomerId(2);
|
||||||
|
equipment.setEquipmentType(EquipmentType.AP);
|
||||||
|
equipment.setName("test" + equipmentIncrementer.getAndIncrement());
|
||||||
|
equipment.setProfileId(profileId);
|
||||||
|
return equipmentDatastore.create(equipment);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -69,15 +69,15 @@ public class PortalUserDAO extends BaseJdbcDao {
|
|||||||
private static final Set<String> columnsToSkipForInsert = new HashSet<>(Arrays.asList(COL_ID));
|
private static final Set<String> columnsToSkipForInsert = new HashSet<>(Arrays.asList(COL_ID));
|
||||||
private static final Set<String> columnsToSkipForUpdate = new HashSet<>(Arrays.asList(COL_ID, "createdTimestamp"));
|
private static final Set<String> columnsToSkipForUpdate = new HashSet<>(Arrays.asList(COL_ID, "createdTimestamp"));
|
||||||
|
|
||||||
private static final String TABLE_NAME = "portal_user";
|
public static final String TABLE_NAME = "portal_user";
|
||||||
private static final String TABLE_PREFIX = "s.";
|
public static final String TABLE_PREFIX = "s.";
|
||||||
private static final String ALL_COLUMNS;
|
public static final String ALL_COLUMNS;
|
||||||
|
|
||||||
private static final Set<String> ALL_COLUMNS_LOWERCASE = new HashSet<>();
|
public static final Set<String> ALL_COLUMNS_LOWERCASE = new HashSet<>();
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
//use this for queries where multiple tables are involved
|
//use this for queries where multiple tables are involved
|
||||||
private static final String ALL_COLUMNS_WITH_PREFIX;
|
public static final String ALL_COLUMNS_WITH_PREFIX;
|
||||||
|
|
||||||
private static final String ALL_COLUMNS_FOR_INSERT;
|
private static final String ALL_COLUMNS_FOR_INSERT;
|
||||||
private static final String BIND_VARS_FOR_INSERT;
|
private static final String BIND_VARS_FOR_INSERT;
|
||||||
@@ -162,8 +162,8 @@ public class PortalUserDAO extends BaseJdbcDao {
|
|||||||
|
|
||||||
private static final String SQL_GET_ALL_IN_SET = "select " + ALL_COLUMNS + " from "+TABLE_NAME + " where "+ COL_ID +" in ";
|
private static final String SQL_GET_ALL_IN_SET = "select " + ALL_COLUMNS + " from "+TABLE_NAME + " where "+ COL_ID +" in ";
|
||||||
|
|
||||||
private static final String SQL_PAGING_SUFFIX = " LIMIT ? OFFSET ? ";
|
public static final String SQL_PAGING_SUFFIX = " LIMIT ? OFFSET ? ";
|
||||||
private static final String SORT_SUFFIX = "";
|
public static final String SORT_SUFFIX = "";
|
||||||
|
|
||||||
|
|
||||||
private static final RowMapper<PortalUser> portalUserRowMapper = new PortalUserRowMapper();
|
private static final RowMapper<PortalUser> portalUserRowMapper = new PortalUserRowMapper();
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public class RadiusProxyConfiguration extends BaseJsonModel implements PushableC
|
|||||||
private Boolean useRadSec;
|
private Boolean useRadSec;
|
||||||
private String sharedSecret; // if useRadSec is false
|
private String sharedSecret; // if useRadSec is false
|
||||||
private String acctSharedSecret; // if useRadSec is false
|
private String acctSharedSecret; // if useRadSec is false
|
||||||
|
private Boolean dynamicDiscovery; // dynamic discovery of HSP and IdPs (home service and identity providers).
|
||||||
|
// regardless of configured value, this will only be set 'true' on the AP if useRadSec is also true.
|
||||||
|
|
||||||
private RadiusProxyConfiguration() {
|
private RadiusProxyConfiguration() {
|
||||||
|
|
||||||
@@ -70,6 +72,7 @@ public class RadiusProxyConfiguration extends BaseJsonModel implements PushableC
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Integer getPort() {
|
public Integer getPort() {
|
||||||
|
if (port == null) return -1;
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,6 +89,7 @@ public class RadiusProxyConfiguration extends BaseJsonModel implements PushableC
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Integer getAcctPort() {
|
public Integer getAcctPort() {
|
||||||
|
if (acctPort == null) return -1;
|
||||||
return acctPort;
|
return acctPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +122,7 @@ public class RadiusProxyConfiguration extends BaseJsonModel implements PushableC
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getUseRadSec() {
|
public Boolean getUseRadSec() {
|
||||||
|
if (useRadSec == null) return false;
|
||||||
return useRadSec;
|
return useRadSec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,6 +146,21 @@ public class RadiusProxyConfiguration extends BaseJsonModel implements PushableC
|
|||||||
this.acctSharedSecret = acctSharedSecret;
|
this.acctSharedSecret = acctSharedSecret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the dynamicDiscovery
|
||||||
|
*/
|
||||||
|
public Boolean getDynamicDiscovery() {
|
||||||
|
if (dynamicDiscovery == null) return false;
|
||||||
|
return dynamicDiscovery;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dynamicDiscovery the dynamicDiscovery to set
|
||||||
|
*/
|
||||||
|
public void setDynamicDiscovery(Boolean dynamicDiscovery) {
|
||||||
|
this.dynamicDiscovery = dynamicDiscovery;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean needsToBeUpdatedOnDevice(RadiusProxyConfiguration previousVersion) {
|
public boolean needsToBeUpdatedOnDevice(RadiusProxyConfiguration previousVersion) {
|
||||||
return !Objects.deepEquals(this, previousVersion);
|
return !Objects.deepEquals(this, previousVersion);
|
||||||
@@ -153,8 +173,8 @@ public class RadiusProxyConfiguration extends BaseJsonModel implements PushableC
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(acctPort, acctServer, acctSharedSecret, caCert, clientCert, clientKey, name, passphrase, port, realm, server, sharedSecret,
|
return Objects.hash(acctPort, acctServer, acctSharedSecret, caCert, clientCert, clientKey, dynamicDiscovery, name, passphrase, port, realm, server,
|
||||||
useRadSec);
|
sharedSecret, useRadSec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -168,9 +188,10 @@ public class RadiusProxyConfiguration extends BaseJsonModel implements PushableC
|
|||||||
RadiusProxyConfiguration other = (RadiusProxyConfiguration) obj;
|
RadiusProxyConfiguration other = (RadiusProxyConfiguration) obj;
|
||||||
return Objects.equals(acctPort, other.acctPort) && Objects.equals(acctServer, other.acctServer)
|
return Objects.equals(acctPort, other.acctPort) && Objects.equals(acctServer, other.acctServer)
|
||||||
&& Objects.equals(acctSharedSecret, other.acctSharedSecret) && Objects.equals(caCert, other.caCert)
|
&& Objects.equals(acctSharedSecret, other.acctSharedSecret) && Objects.equals(caCert, other.caCert)
|
||||||
&& Objects.equals(clientCert, other.clientCert) && Objects.equals(clientKey, other.clientKey) && Objects.equals(name, other.name)
|
&& Objects.equals(clientCert, other.clientCert) && Objects.equals(clientKey, other.clientKey)
|
||||||
&& Objects.equals(passphrase, other.passphrase) && Objects.equals(port, other.port) && Objects.equals(realm, other.realm)
|
&& Objects.equals(dynamicDiscovery, other.dynamicDiscovery) && Objects.equals(name, other.name) && Objects.equals(passphrase, other.passphrase)
|
||||||
&& Objects.equals(server, other.server) && Objects.equals(sharedSecret, other.sharedSecret) && Objects.equals(useRadSec, other.useRadSec);
|
&& Objects.equals(port, other.port) && Objects.equals(realm, other.realm) && Objects.equals(server, other.server)
|
||||||
|
&& Objects.equals(sharedSecret, other.sharedSecret) && Objects.equals(useRadSec, other.useRadSec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -370,11 +370,9 @@ public class SsidConfiguration extends ProfileDetails implements PushableConfigu
|
|||||||
|
|
||||||
public static enum SecureMode {
|
public static enum SecureMode {
|
||||||
|
|
||||||
open(0L), wpaPSK(1L), wpa2PSK(2L), wpaRadius(3L), wpa2Radius(4L), wpa2OnlyPSK(5L), wpa2OnlyRadius(6L), wep(
|
open(0L), wpaPSK(1L), wpa2PSK(2L), wpaRadius(3L), wpa2Radius(4L), wpa2OnlyPSK(5L), wpa2OnlyRadius(6L), wep(7L),
|
||||||
7L), wpaEAP(8L), wpa2EAP(
|
wpaEAP(8L), wpa2EAP(9L), wpa2OnlyEAP(10L), wpa3OnlySAE(11L), wpa3MixedSAE(12L), wpa3OnlyEAP(13L), wpa3MixedEAP(14L),
|
||||||
9L), wpa2OnlyEAP(10L), wpa3OnlySAE(11L), wpa3MixedSAE(12L), wpa3OnlyEAP(13L), wpa3MixedEAP(14L),
|
wpa3OnlyEAP192(15L), UNSUPPORTED(-1L);
|
||||||
|
|
||||||
UNSUPPORTED(-1L);
|
|
||||||
|
|
||||||
private final long id;
|
private final long id;
|
||||||
private static final Map<Long, SecureMode> ELEMENTS = new HashMap<>();
|
private static final Map<Long, SecureMode> ELEMENTS = new HashMap<>();
|
||||||
@@ -415,7 +413,7 @@ public class SsidConfiguration extends ProfileDetails implements PushableConfigu
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWPA3_Enterprise_or_Personal(SecureMode mode) {
|
public static boolean isWPA3_Enterprise_or_Personal(SecureMode mode) {
|
||||||
return mode == wpa3OnlySAE || mode == wpa3OnlyEAP;
|
return mode == wpa3OnlySAE || mode == wpa3OnlyEAP || mode == wpa3OnlyEAP192;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -491,6 +491,9 @@ components:
|
|||||||
sharedSecret:
|
sharedSecret:
|
||||||
type: string
|
type: string
|
||||||
format: password
|
format: password
|
||||||
|
dynamicDiscovery:
|
||||||
|
description: Dynamic discovery of HSP and IdPs (home service and identity providers). Regardless of configured value, this will only be set 'true' on the AP if useRadSec is also true.
|
||||||
|
type: boolean
|
||||||
example:
|
example:
|
||||||
model_type: RadiusProxyConfiguration
|
model_type: RadiusProxyConfiguration
|
||||||
caCert:
|
caCert:
|
||||||
@@ -1021,6 +1024,7 @@ components:
|
|||||||
- wpa3MixedSAE
|
- wpa3MixedSAE
|
||||||
- wpa3OnlyEAP
|
- wpa3OnlyEAP
|
||||||
- wpa3MixedEAP
|
- wpa3MixedEAP
|
||||||
|
- wpa3OnlyEAP192
|
||||||
|
|
||||||
RadioBasedSsidConfigurationMap:
|
RadioBasedSsidConfigurationMap:
|
||||||
properties:
|
properties:
|
||||||
|
|||||||
@@ -53,12 +53,6 @@
|
|||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<artifactId>equipment-alarms-sp</artifactId>
|
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<artifactId>adoption-metrics-sp</artifactId>
|
<artifactId>adoption-metrics-sp</artifactId>
|
||||||
<groupId>com.telecominfraproject.wlan</groupId>
|
<groupId>com.telecominfraproject.wlan</groupId>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class EquipmentChannelStatusData extends StatusDetails {
|
|||||||
private static final long serialVersionUID = 470569467119609438L;
|
private static final long serialVersionUID = 470569467119609438L;
|
||||||
|
|
||||||
private Map<RadioType, Integer> channelNumberStatusDataMap = new EnumMap<>(RadioType.class);
|
private Map<RadioType, Integer> channelNumberStatusDataMap = new EnumMap<>(RadioType.class);
|
||||||
|
private Map<RadioType, Integer> txPowerDataMap = new EnumMap<>(RadioType.class);
|
||||||
|
|
||||||
|
|
||||||
public EquipmentChannelStatusData()
|
public EquipmentChannelStatusData()
|
||||||
@@ -34,10 +35,18 @@ public class EquipmentChannelStatusData extends StatusDetails {
|
|||||||
public Map<RadioType, Integer> getChannelNumberStatusDataMap() {
|
public Map<RadioType, Integer> getChannelNumberStatusDataMap() {
|
||||||
return channelNumberStatusDataMap;
|
return channelNumberStatusDataMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<RadioType, Integer> getTxPowerDataMap() {
|
||||||
|
return txPowerDataMap;
|
||||||
|
}
|
||||||
|
|
||||||
public void setChannelNumberStatusDataMap(Map<RadioType, Integer> channelNumberStatusDataMap) {
|
public void setChannelNumberStatusDataMap(Map<RadioType, Integer> channelNumberStatusDataMap) {
|
||||||
this.channelNumberStatusDataMap = channelNumberStatusDataMap;
|
this.channelNumberStatusDataMap = channelNumberStatusDataMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTxPowerDataMap(Map<RadioType, Integer> txPowerDataMap) {
|
||||||
|
this.txPowerDataMap = txPowerDataMap;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EquipmentChannelStatusData clone() {
|
public EquipmentChannelStatusData clone() {
|
||||||
@@ -49,19 +58,33 @@ public class EquipmentChannelStatusData extends StatusDetails {
|
|||||||
result.channelNumberStatusDataMap.put(k, v);
|
result.channelNumberStatusDataMap.put(k, v);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getTxPowerDataMap() != null) {
|
||||||
|
result.setTxPowerDataMap(new EnumMap<>(RadioType.class));
|
||||||
|
|
||||||
|
this.txPowerDataMap.forEach((k, v) -> {
|
||||||
|
result.txPowerDataMap.put(k, v);
|
||||||
|
});
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public int hashCode() {
|
||||||
EquipmentChannelStatusData other = (EquipmentChannelStatusData) obj;
|
return Objects.hash(channelNumberStatusDataMap, txPowerDataMap);
|
||||||
return Objects.equals(channelNumberStatusDataMap, other.channelNumberStatusDataMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public boolean equals(Object obj) {
|
||||||
return Objects.hash(channelNumberStatusDataMap);
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
EquipmentChannelStatusData other = (EquipmentChannelStatusData) obj;
|
||||||
|
return Objects.equals(channelNumberStatusDataMap, other.channelNumberStatusDataMap)
|
||||||
|
&& Objects.equals(txPowerDataMap, other.txPowerDataMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2864,6 +2864,9 @@ components:
|
|||||||
sharedSecret:
|
sharedSecret:
|
||||||
type: string
|
type: string
|
||||||
format: password
|
format: password
|
||||||
|
dynamicDiscovery:
|
||||||
|
description: Dynamic discovery of HSP and IdPs (home service and identity providers). Regardless of configured value, this will only be set 'true' on the AP if useRadSec is also true.
|
||||||
|
type: boolean
|
||||||
example:
|
example:
|
||||||
model_type: RadiusProxyConfiguration
|
model_type: RadiusProxyConfiguration
|
||||||
caCert:
|
caCert:
|
||||||
@@ -3169,6 +3172,14 @@ components:
|
|||||||
- wpa2OnlyPSK
|
- wpa2OnlyPSK
|
||||||
- wpa2OnlyRadius
|
- wpa2OnlyRadius
|
||||||
- wep
|
- wep
|
||||||
|
- wpaEAP
|
||||||
|
- wpa2EAP
|
||||||
|
- wpa2OnlyEAP
|
||||||
|
- wpa3OnlySAE
|
||||||
|
- wpa3MixedSAE
|
||||||
|
- wpa3OnlyEAP
|
||||||
|
- wpa3MixedEAP
|
||||||
|
- wpa3OnlyEAP192
|
||||||
|
|
||||||
RadioBasedSsidConfigurationMap:
|
RadioBasedSsidConfigurationMap:
|
||||||
properties:
|
properties:
|
||||||
@@ -4398,6 +4409,8 @@ components:
|
|||||||
- RADIO_CHANNEL
|
- RADIO_CHANNEL
|
||||||
channelNumberStatusDataMap:
|
channelNumberStatusDataMap:
|
||||||
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
||||||
|
txPowerDataMap:
|
||||||
|
$ref: '#/components/schemas/IntegerPerRadioTypeMap'
|
||||||
|
|
||||||
#
|
#
|
||||||
# Equipment configuration data models
|
# Equipment configuration data models
|
||||||
|
|||||||
Reference in New Issue
Block a user