mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-02 03:28:00 +00:00
Merged in NETEXP-2959 (pull request #9)
[NETEXP-2959] add support to turn LED on/off via AP profile on gateway Approved-by: mike.hansen
This commit is contained in:
committed by
Thomas-Leung2021
parent
7e0da1505e
commit
40277e3799
@@ -9,7 +9,6 @@ import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoField;
|
||||
import java.time.temporal.TemporalField;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.EnumMap;
|
||||
@@ -48,6 +47,7 @@ import com.telecominfraproject.wlan.client.session.models.ClientSession;
|
||||
import com.telecominfraproject.wlan.client.session.models.ClientSessionDetails;
|
||||
import com.telecominfraproject.wlan.core.model.entity.CountryCode;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.EquipmentType;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.LedStatus;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.WiFiSessionUtility;
|
||||
@@ -112,7 +112,6 @@ import com.telecominfraproject.wlan.status.equipment.models.EquipmentProtocolSta
|
||||
import com.telecominfraproject.wlan.status.equipment.models.EquipmentUpgradeState;
|
||||
import com.telecominfraproject.wlan.status.equipment.models.EquipmentUpgradeState.FailureReason;
|
||||
import com.telecominfraproject.wlan.status.equipment.models.EquipmentUpgradeStatusData;
|
||||
import com.telecominfraproject.wlan.status.equipment.models.LedStatus;
|
||||
import com.telecominfraproject.wlan.status.equipment.models.VLANStatusData;
|
||||
import com.telecominfraproject.wlan.status.equipment.report.models.ActiveBSSID;
|
||||
import com.telecominfraproject.wlan.status.equipment.report.models.ActiveBSSIDs;
|
||||
@@ -2438,18 +2437,20 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
|
||||
Status eqAdminStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.EQUIPMENT_ADMIN);
|
||||
|
||||
LedStatus ledStatus = null;
|
||||
for (Map<String, String> nsa : nodeStateAttributes) {
|
||||
if (nsa.get("module").equals("led")) {
|
||||
if (nsa.get("key").equals("led_blink") && nsa.get("value").equals("on")) {
|
||||
ledStatus = LedStatus.led_blink;
|
||||
} else if (nsa.get("key").equals("led_off") && nsa.get("value").equals("off")) {
|
||||
ledStatus = LedStatus.led_off;
|
||||
} else {
|
||||
ledStatus = LedStatus.UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
LedStatus ledStatus = null;
|
||||
for (Map<String, String> nsa : nodeStateAttributes) {
|
||||
if (nsa.get("module").equals("led")) {
|
||||
if (nsa.get("key").equals("led_state") && nsa.get("value").equals("on")) {
|
||||
ledStatus = LedStatus.led_on;
|
||||
} else if (nsa.get("key").equals("led_state") && nsa.get("value").equals("off")) {
|
||||
ledStatus = LedStatus.led_off;
|
||||
} else if (nsa.get("key").equals("led_blink")) {
|
||||
ledStatus = LedStatus.led_blink;
|
||||
} else {
|
||||
ledStatus = LedStatus.UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ledStatus != null) {
|
||||
if (eqAdminStatus != null) {
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.springframework.security.web.bind.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.telecominfraproject.wlan.core.client.PingClient;
|
||||
@@ -36,7 +35,6 @@ import com.telecominfraproject.wlan.core.server.container.ConnectorProperties;
|
||||
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
|
||||
import com.telecominfraproject.wlan.equipment.models.CellSizeAttributes;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWBaseCommand;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWBlinkRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWChangeRedirectorHost;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWClientBlocklistChangeNotification;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCloseSessionRequest;
|
||||
@@ -44,6 +42,7 @@ import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCommandResultCod
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWConfigChangeNotification;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWFirmwareDownloadRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWFirmwareFlashRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWLedRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWNewChannelRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCellSizeAttributesRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWRadioResetRequest;
|
||||
@@ -51,7 +50,6 @@ import com.telecominfraproject.wlan.equipmentgateway.models.CEGWRebootRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWRouteCheck;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWStartDebugEngine;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWStopDebugEngine;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGatewayCommand;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.EquipmentCommand;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.EquipmentCommandResponse;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.GatewayDefaults;
|
||||
@@ -176,8 +174,8 @@ public class OpensyncCloudGatewayController {
|
||||
case CheckRouting:
|
||||
ret.add(checkEquipmentRouting(session, (CEGWRouteCheck) command));
|
||||
break;
|
||||
case BlinkRequest:
|
||||
ret.add(processBlinkRequest(session, (CEGWBlinkRequest) command));
|
||||
case LedRequest:
|
||||
ret.add(processLedRequest(session, (CEGWLedRequest) command));
|
||||
break;
|
||||
case ChangeRedirectorHost:
|
||||
ret.add(processChangeRedirector(session, (CEGWChangeRedirectorHost) command));
|
||||
@@ -321,8 +319,8 @@ public class OpensyncCloudGatewayController {
|
||||
new EquipmentCommandResponse(CEGWCommandResultCode.Success, "Received Command " + command.getCommandType() + " for " + inventoryId, command,
|
||||
registeredGateway == null ? null : registeredGateway.getHostname(), registeredGateway == null ? -1 : registeredGateway.getPort());
|
||||
|
||||
if (command instanceof CEGWBlinkRequest) {
|
||||
String resultDetails = tipwlanOvsdbClient.processBlinkRequest(inventoryId, ((CEGWBlinkRequest)command).getBlinkAllLEDs());
|
||||
if (command instanceof CEGWLedRequest) {
|
||||
String resultDetails = tipwlanOvsdbClient.processLedRequest(inventoryId, ((CEGWLedRequest)command).getLedStatus());
|
||||
response.setResultDetail(resultDetails);
|
||||
} else if (command instanceof CEGWConfigChangeNotification) {
|
||||
tipwlanOvsdbClient.processConfigChanged(inventoryId);
|
||||
@@ -423,7 +421,7 @@ public class OpensyncCloudGatewayController {
|
||||
return sendMessage(session, command.getInventoryId(), command);
|
||||
}
|
||||
|
||||
private EquipmentCommandResponse processBlinkRequest(OvsdbSession session, CEGWBlinkRequest command) {
|
||||
private EquipmentCommandResponse processLedRequest(OvsdbSession session, CEGWLedRequest command) {
|
||||
|
||||
return sendMessage(session, command.getInventoryId(), command);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.equipment.LedStatus;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||
import com.telecominfraproject.wlan.equipment.models.CellSizeAttributes;
|
||||
@@ -18,7 +19,7 @@ public interface OvsdbClientInterface {
|
||||
|
||||
String stopDebugEngine(String apId);
|
||||
|
||||
String processBlinkRequest(String apId, boolean blinkAllLEDs);
|
||||
String processLedRequest(String apId, LedStatus ledStatus);
|
||||
|
||||
void processConfigChanged(String apId);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.netflix.servo.monitor.MonitorConfig;
|
||||
import com.netflix.servo.monitor.Monitors;
|
||||
import com.netflix.servo.tag.TagList;
|
||||
import com.telecominfraproject.wlan.cloudmetrics.CloudMetricsTags;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.LedStatus;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||
import com.telecominfraproject.wlan.equipment.models.CellSizeAttributes;
|
||||
@@ -290,13 +291,13 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
return ovsdbDao.changeRedirectorAddress(ovsdbSession.getOvsdbClient(), apId, newRedirectorAddress);
|
||||
}
|
||||
|
||||
public String processBlinkRequest(String apId, boolean blinkAllLEDs) {
|
||||
public String processLedRequest(String apId, LedStatus ledStatus) {
|
||||
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
|
||||
if (ovsdbSession == null) {
|
||||
throw new IllegalStateException("AP with id " + apId + " is not connected");
|
||||
}
|
||||
|
||||
return ovsdbDao.processBlinkRequest(ovsdbSession.getOvsdbClient(), apId, blinkAllLEDs);
|
||||
return ovsdbDao.processLedRequest(ovsdbSession.getOvsdbClient(), apId, ledStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.equipment.LedStatus;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
|
||||
import com.telecominfraproject.wlan.core.model.equipment.RadioType;
|
||||
import com.telecominfraproject.wlan.equipment.models.ApElementConfiguration;
|
||||
@@ -89,8 +90,8 @@ public class OvsdbDao extends OvsdbDaoBase {
|
||||
public void configureNode(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) {
|
||||
configureNtpServer(ovsdbClient, opensyncAPConfig);
|
||||
configureSyslog(ovsdbClient, opensyncAPConfig);
|
||||
processBlinkRequest(ovsdbClient, opensyncAPConfig.getCustomerEquipment().getInventoryId(),
|
||||
((ApElementConfiguration) opensyncAPConfig.getCustomerEquipment().getDetails()).isBlinkAllLEDs());
|
||||
processLedRequest(ovsdbClient, opensyncAPConfig.getCustomerEquipment().getInventoryId(),
|
||||
((ApElementConfiguration) opensyncAPConfig.getCustomerEquipment().getDetails()).getLedStatus());
|
||||
}
|
||||
|
||||
void configureNtpServer(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) {
|
||||
@@ -241,8 +242,8 @@ public class OvsdbDao extends OvsdbDaoBase {
|
||||
ovsdbStats.updateEventReportingInterval(ovsdbClient, collectionIntervalSecEvent);
|
||||
}
|
||||
|
||||
public String processBlinkRequest(OvsdbClient ovsdbClient, String apId, boolean blinkAllLEDs) {
|
||||
return ovsdbNodeConfig.processBlinkRequest(ovsdbClient,apId,blinkAllLEDs);
|
||||
public String processLedRequest(OvsdbClient ovsdbClient, String apId, LedStatus sad) {
|
||||
return ovsdbNodeConfig.processLedRequest(ovsdbClient, apId, sad);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.concurrent.TimeoutException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.equipment.LedStatus;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPConfig;
|
||||
import com.telecominfraproject.wlan.profile.network.models.ApNetworkConfiguration;
|
||||
import com.vmware.ovsdb.exception.OvsdbClientException;
|
||||
@@ -120,21 +121,25 @@ public class OvsdbNodeConfig extends OvsdbDaoBase {
|
||||
|
||||
}
|
||||
|
||||
public String processBlinkRequest(OvsdbClient ovsdbClient, String apId, boolean blinkAllLEDs) {
|
||||
public String processLedRequest(OvsdbClient ovsdbClient, String apId, LedStatus ledStatus) {
|
||||
|
||||
String ret = null;
|
||||
try {
|
||||
|
||||
LOG.debug("processBlinkRequest set BlinkLEDs to {}", blinkAllLEDs);
|
||||
LOG.debug("processLEDRequest set LEDs status to {}", ledStatus);
|
||||
Map<String, Value> columns = new HashMap<>();
|
||||
if (blinkAllLEDs) {
|
||||
if (ledStatus == LedStatus.led_on) {
|
||||
columns.put("module", new Atom<>("led"));
|
||||
columns.put("key", new Atom<>("led_state"));
|
||||
columns.put("value", new Atom<>("on"));
|
||||
} else if (ledStatus == LedStatus.led_off || ledStatus == LedStatus.UNKNOWN){
|
||||
columns.put("module", new Atom<>("led"));
|
||||
columns.put("key", new Atom<>("led_state"));
|
||||
columns.put("value", new Atom<>("off"));
|
||||
} else {
|
||||
columns.put("module", new Atom<>("led"));
|
||||
columns.put("key", new Atom<>("led_blink"));
|
||||
columns.put("value", new Atom<>("on"));
|
||||
} else {
|
||||
columns.put("module", new Atom<>("led"));
|
||||
columns.put("key", new Atom<>("led_off"));
|
||||
columns.put("value", new Atom<>("off"));
|
||||
}
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
operations.add(new Update(nodeConfigTable, List.of(new Condition("module", Function.EQUALS, new Atom<>("led"))), new Row(columns)));
|
||||
|
||||
Reference in New Issue
Block a user