[NETEXP-2959] Redo processBlinkRequest() logic

This commit is contained in:
Thomas-Leung2021
2021-09-20 17:34:50 -04:00
parent 40277e3799
commit 6a75356441
5 changed files with 19 additions and 26 deletions

View File

@@ -35,6 +35,7 @@ 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;
@@ -42,7 +43,6 @@ 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;
@@ -174,8 +174,8 @@ public class OpensyncCloudGatewayController {
case CheckRouting:
ret.add(checkEquipmentRouting(session, (CEGWRouteCheck) command));
break;
case LedRequest:
ret.add(processLedRequest(session, (CEGWLedRequest) command));
case BlinkRequest:
ret.add(processBlinkRequest(session, (CEGWBlinkRequest) command));
break;
case ChangeRedirectorHost:
ret.add(processChangeRedirector(session, (CEGWChangeRedirectorHost) command));
@@ -319,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 CEGWLedRequest) {
String resultDetails = tipwlanOvsdbClient.processLedRequest(inventoryId, ((CEGWLedRequest)command).getLedStatus());
if (command instanceof CEGWBlinkRequest) {
String resultDetails = tipwlanOvsdbClient.processBlinkRequest(inventoryId, ((CEGWBlinkRequest)command).getBlinkAllLEDs());
response.setResultDetail(resultDetails);
} else if (command instanceof CEGWConfigChangeNotification) {
tipwlanOvsdbClient.processConfigChanged(inventoryId);
@@ -421,7 +421,7 @@ public class OpensyncCloudGatewayController {
return sendMessage(session, command.getInventoryId(), command);
}
private EquipmentCommandResponse processLedRequest(OvsdbSession session, CEGWLedRequest command) {
private EquipmentCommandResponse processBlinkRequest(OvsdbSession session, CEGWBlinkRequest command) {
return sendMessage(session, command.getInventoryId(), command);
}

View File

@@ -19,7 +19,7 @@ public interface OvsdbClientInterface {
String stopDebugEngine(String apId);
String processLedRequest(String apId, LedStatus ledStatus);
String processBlinkRequest(String apId, boolean blinkAllLEDs);
void processConfigChanged(String apId);

View File

@@ -9,7 +9,6 @@ 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;
@@ -291,13 +290,13 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
return ovsdbDao.changeRedirectorAddress(ovsdbSession.getOvsdbClient(), apId, newRedirectorAddress);
}
public String processLedRequest(String apId, LedStatus ledStatus) {
public String processBlinkRequest(String apId, boolean blinkAllLEDs) {
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
if (ovsdbSession == null) {
throw new IllegalStateException("AP with id " + apId + " is not connected");
}
return ovsdbDao.processLedRequest(ovsdbSession.getOvsdbClient(), apId, ledStatus);
return ovsdbDao.processBlinkRequest(ovsdbSession.getOvsdbClient(), apId, blinkAllLEDs);
}
@Override

View File

@@ -90,8 +90,8 @@ public class OvsdbDao extends OvsdbDaoBase {
public void configureNode(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) {
configureNtpServer(ovsdbClient, opensyncAPConfig);
configureSyslog(ovsdbClient, opensyncAPConfig);
processLedRequest(ovsdbClient, opensyncAPConfig.getCustomerEquipment().getInventoryId(),
((ApElementConfiguration) opensyncAPConfig.getCustomerEquipment().getDetails()).getLedStatus());
processBlinkRequest(ovsdbClient, opensyncAPConfig.getCustomerEquipment().getInventoryId(),
((ApElementConfiguration) opensyncAPConfig.getCustomerEquipment().getDetails()).isBlinkAllLEDs());
}
void configureNtpServer(OvsdbClient ovsdbClient, OpensyncAPConfig opensyncAPConfig) {
@@ -242,8 +242,8 @@ public class OvsdbDao extends OvsdbDaoBase {
ovsdbStats.updateEventReportingInterval(ovsdbClient, collectionIntervalSecEvent);
}
public String processLedRequest(OvsdbClient ovsdbClient, String apId, LedStatus sad) {
return ovsdbNodeConfig.processLedRequest(ovsdbClient, apId, sad);
public String processBlinkRequest(OvsdbClient ovsdbClient, String apId, boolean blinkAllLEDs) {
return ovsdbNodeConfig.processBlinkRequest(ovsdbClient, apId, blinkAllLEDs);
}
}

View File

@@ -121,25 +121,19 @@ public class OvsdbNodeConfig extends OvsdbDaoBase {
}
public String processLedRequest(OvsdbClient ovsdbClient, String apId, LedStatus ledStatus) {
public String processBlinkRequest(OvsdbClient ovsdbClient, String apId, boolean blinkAllLEDs) {
String ret = null;
try {
LOG.debug("processLEDRequest set LEDs status to {}", ledStatus);
LOG.debug("processLEDRequest set LEDs status to {}", blinkAllLEDs);
Map<String, Value> columns = new HashMap<>();
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 {
if (blinkAllLEDs) {
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_state"));
}
List<Operation> operations = new ArrayList<>();
operations.add(new Update(nodeConfigTable, List.of(new Condition("module", Function.EQUALS, new Atom<>("led"))), new Row(columns)));