mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-01 02:57:49 +00:00
WIFI-814: OSGW add support reboot, switch, and factory reset
Adding support for Ap reboot, switch, and factory reset commands to opensync gateway controller and ovsdb dao.
This commit is contained in:
@@ -339,7 +339,9 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
LOG.info("ConnectNodeInfo {}", connectNodeInfo);
|
||||
|
||||
if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_ACTIVE_KEY)) {
|
||||
reconcileFwVersionToTrack(ce, connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_ACTIVE_KEY), connectNodeInfo.model);
|
||||
reconcileFwVersionToTrack(ce,
|
||||
connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_ACTIVE_KEY),
|
||||
connectNodeInfo.model);
|
||||
} else {
|
||||
LOG.info("Cloud based firmware upgrade is not supported for this AP");
|
||||
}
|
||||
@@ -381,7 +383,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
Set<RadioType> radioTypes = radioProfileMap.keySet();
|
||||
|
||||
for (RadioType radioType : radioTypes) {
|
||||
// SSID Profile set in AP Profile
|
||||
// SSID Profile set in AP Profile
|
||||
Profile ssidProfile = new Profile();
|
||||
ssidProfile.setCustomerId(ce.getCustomerId());
|
||||
ssidProfile.setName(autoProvisionedSsid + radioType.name() + " for " + ce.getName());
|
||||
@@ -400,11 +402,11 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
ssidProfile = profileServiceInterface.create(ssidProfile);
|
||||
|
||||
apProfile.getChildProfileIds().add(ssidProfile.getId());
|
||||
|
||||
|
||||
// Update AP Profile with ssidProfile and rfProfile
|
||||
apProfile = profileServiceInterface.update(apProfile);
|
||||
}
|
||||
|
||||
|
||||
// RF Profile set in AP Profile
|
||||
Profile rfProfile = new Profile();
|
||||
rfProfile.setCustomerId(ce.getCustomerId());
|
||||
@@ -412,15 +414,15 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
RfConfiguration rfConfig = RfConfiguration.createWithDefaults();
|
||||
|
||||
// Override default values
|
||||
for (RadioType radioType: radioTypes) {
|
||||
rfConfig.getRfConfig(radioType).setRf(rfProfile.getName());
|
||||
for (RadioType radioType : radioTypes) {
|
||||
rfConfig.getRfConfig(radioType).setRf(rfProfile.getName());
|
||||
}
|
||||
|
||||
|
||||
rfProfile.setDetails(rfConfig);
|
||||
rfProfile = profileServiceInterface.create(rfProfile);
|
||||
|
||||
|
||||
apProfile.getChildProfileIds().add(rfProfile.getId());
|
||||
|
||||
|
||||
// Update AP Profile with ssidProfile and rfProfile
|
||||
apProfile = profileServiceInterface.update(apProfile);
|
||||
|
||||
@@ -484,16 +486,20 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
protocolStatusData.setReportedCC(CountryCode.ca);
|
||||
protocolStatusData.setReportedHwVersion(connectNodeInfo.platformVersion);
|
||||
if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_ACTIVE_KEY)) {
|
||||
protocolStatusData.setReportedSwVersion(connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_ACTIVE_KEY));
|
||||
} else if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_NAME_KEY)){
|
||||
protocolStatusData.setReportedSwVersion(connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_NAME_KEY));
|
||||
protocolStatusData.setReportedSwVersion(
|
||||
connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_ACTIVE_KEY));
|
||||
} else if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_NAME_KEY)) {
|
||||
protocolStatusData.setReportedSwVersion(
|
||||
connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_NAME_KEY));
|
||||
} else {
|
||||
protocolStatusData.setReportedSwVersion("Unknown");
|
||||
}
|
||||
if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_INACTIVE_KEY)) {
|
||||
protocolStatusData.setReportedSwAltVersion(connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_INACTIVE_KEY));
|
||||
}else if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_NAME_KEY)){
|
||||
protocolStatusData.setReportedSwVersion(connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_NAME_KEY));
|
||||
protocolStatusData.setReportedSwAltVersion(
|
||||
connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_INACTIVE_KEY));
|
||||
} else if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_NAME_KEY)) {
|
||||
protocolStatusData.setReportedSwVersion(
|
||||
connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_NAME_KEY));
|
||||
} else {
|
||||
protocolStatusData.setReportedSwVersion("Unknown");
|
||||
}
|
||||
@@ -522,26 +528,30 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
|
||||
EquipmentUpgradeStatusData fwUpgradeStatusData = (EquipmentUpgradeStatusData) statusRecord.getDetails();
|
||||
if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_ACTIVE_KEY)) {
|
||||
fwUpgradeStatusData.setActiveSwVersion(connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_ACTIVE_KEY));
|
||||
} else if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_NAME_KEY)){
|
||||
fwUpgradeStatusData.setActiveSwVersion(connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_NAME_KEY));
|
||||
fwUpgradeStatusData.setActiveSwVersion(
|
||||
connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_ACTIVE_KEY));
|
||||
} else if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_NAME_KEY)) {
|
||||
fwUpgradeStatusData
|
||||
.setActiveSwVersion(connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_NAME_KEY));
|
||||
} else {
|
||||
fwUpgradeStatusData.setActiveSwVersion("Unknown");
|
||||
}
|
||||
if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_INACTIVE_KEY)) {
|
||||
fwUpgradeStatusData.setAlternateSwVersion(connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_INACTIVE_KEY));
|
||||
} else if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_NAME_KEY)){
|
||||
fwUpgradeStatusData.setAlternateSwVersion(connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_NAME_KEY));
|
||||
fwUpgradeStatusData.setAlternateSwVersion(
|
||||
connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_INACTIVE_KEY));
|
||||
} else if (connectNodeInfo.versionMatrix.containsKey(OvsdbStringConstants.FW_IMAGE_NAME_KEY)) {
|
||||
fwUpgradeStatusData.setAlternateSwVersion(
|
||||
connectNodeInfo.versionMatrix.get(OvsdbStringConstants.FW_IMAGE_NAME_KEY));
|
||||
} else {
|
||||
fwUpgradeStatusData.setAlternateSwVersion("Unknown");
|
||||
}
|
||||
|
||||
|
||||
if (fwUpgradeStatusData.getUpgradeState() == null) {
|
||||
fwUpgradeStatusData.setUpgradeState(EquipmentUpgradeState.undefined);
|
||||
fwUpgradeStatusData.setUpgradeStartTime(null);
|
||||
fwUpgradeStatusData.setUpgradeState(EquipmentUpgradeState.undefined);
|
||||
fwUpgradeStatusData.setUpgradeStartTime(null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
statusRecord.setDetails(fwUpgradeStatusData);
|
||||
statusServiceInterface.update(statusRecord);
|
||||
|
||||
@@ -772,9 +782,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
profileServiceInterface.getProfileWithChildren(equipmentConfig.getProfileId()));
|
||||
|
||||
ret.setApProfile(profileContainer.getOrNull(equipmentConfig.getProfileId()));
|
||||
|
||||
ret.setRfProfile(
|
||||
profileContainer.getChildOfTypeOrNull(equipmentConfig.getProfileId(), ProfileType.rf));
|
||||
|
||||
ret.setRfProfile(profileContainer.getChildOfTypeOrNull(equipmentConfig.getProfileId(), ProfileType.rf));
|
||||
|
||||
ret.setSsidProfile(
|
||||
profileContainer.getChildrenOfType(equipmentConfig.getProfileId(), ProfileType.ssid));
|
||||
@@ -1260,16 +1269,27 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
}
|
||||
|
||||
int upgradeStatusFromAp = opensyncAPState.getUpgradeStatus();
|
||||
|
||||
EquipmentUpgradeState fwUpgradeState = OvsdbToWlanCloudTypeMappingUtility
|
||||
.getCloudEquipmentUpgradeStateFromOpensyncUpgradeStatus(upgradeStatusFromAp);
|
||||
EquipmentUpgradeState fwUpgradeState = null;
|
||||
FailureReason fwUpgradeFailureReason = null;
|
||||
|
||||
if (upgradeStatusFromAp < 0) {
|
||||
fwUpgradeFailureReason = OvsdbToWlanCloudTypeMappingUtility
|
||||
.getCloudEquipmentUpgradeFailureReasonFromOpensyncUpgradeStatus(upgradeStatusFromAp);
|
||||
if (opensyncAPState.getFirmwareUrl().equals(OvsdbStringConstants.OVSDB_AWLAN_AP_FACTORY_RESET)
|
||||
|| opensyncAPState.getFirmwareUrl().equals(OvsdbStringConstants.OVSDB_AWLAN_AP_FACTORY_RESET)
|
||||
|| opensyncAPState.getFirmwareUrl().equals(OvsdbStringConstants.OVSDB_AWLAN_AP_FACTORY_RESET)
|
||||
|| opensyncAPState.getFirmwareUrl().equals("")) {
|
||||
|
||||
fwUpgradeState = EquipmentUpgradeState.undefined;
|
||||
|
||||
} else {
|
||||
fwUpgradeState = OvsdbToWlanCloudTypeMappingUtility
|
||||
.getCloudEquipmentUpgradeStateFromOpensyncUpgradeStatus(upgradeStatusFromAp);
|
||||
|
||||
if (upgradeStatusFromAp < 0) {
|
||||
fwUpgradeFailureReason = OvsdbToWlanCloudTypeMappingUtility
|
||||
.getCloudEquipmentUpgradeFailureReasonFromOpensyncUpgradeStatus(upgradeStatusFromAp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Status protocolStatus = statusServiceInterface.getOrNull(customerId, equipmentId, StatusDataType.PROTOCOL);
|
||||
if (protocolStatus == null) {
|
||||
protocolStatus = new Status();
|
||||
@@ -1288,10 +1308,16 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
|
||||
if (opensyncAPState.getVersionMatrix().containsKey(OvsdbStringConstants.FW_IMAGE_ACTIVE_KEY)) {
|
||||
reportedFwImageName = opensyncAPState.getVersionMatrix().get(OvsdbStringConstants.FW_IMAGE_ACTIVE_KEY);
|
||||
} else {
|
||||
reportedFwImageName = opensyncAPState.getVersionMatrix().get(OvsdbStringConstants.FW_IMAGE_NAME_KEY);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (opensyncAPState.getVersionMatrix().containsKey(OvsdbStringConstants.FW_IMAGE_INACTIVE_KEY)) {
|
||||
reportedAltFwImageName = opensyncAPState.getVersionMatrix().get(OvsdbStringConstants.FW_IMAGE_INACTIVE_KEY);
|
||||
} else {
|
||||
reportedAltFwImageName = opensyncAPState.getVersionMatrix().get(OvsdbStringConstants.FW_IMAGE_NAME_KEY);
|
||||
|
||||
}
|
||||
|
||||
EquipmentProtocolStatusData protocolStatusData = (EquipmentProtocolStatusData) protocolStatus.getDetails();
|
||||
@@ -1334,7 +1360,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
.getDetails();
|
||||
if (reportedFwImageName != null) {
|
||||
if (!firmwareStatusData.getActiveSwVersion().equals(reportedFwImageName)
|
||||
|| !firmwareStatusData.getUpgradeState().equals(fwUpgradeState) || !firmwareStatusData.getAlternateSwVersion().equals(reportedAltFwImageName)) {
|
||||
|| !firmwareStatusData.getUpgradeState().equals(fwUpgradeState)
|
||||
|| !firmwareStatusData.getAlternateSwVersion().equals(reportedAltFwImageName)) {
|
||||
firmwareStatusData.setActiveSwVersion(reportedFwImageName);
|
||||
firmwareStatusData.setAlternateSwVersion(reportedAltFwImageName);
|
||||
firmwareStatusData.setUpgradeState(fwUpgradeState, fwUpgradeFailureReason);
|
||||
@@ -1364,7 +1391,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
.getDetails();
|
||||
if (reportedFwImageName != null) {
|
||||
if (!firmwareStatusData.getActiveSwVersion().equals(reportedFwImageName)
|
||||
|| !firmwareStatusData.getUpgradeState().equals(fwUpgradeState) || !firmwareStatusData.getAlternateSwVersion().equals(reportedAltFwImageName)) {
|
||||
|| !firmwareStatusData.getUpgradeState().equals(fwUpgradeState)
|
||||
|| !firmwareStatusData.getAlternateSwVersion().equals(reportedAltFwImageName)) {
|
||||
firmwareStatusData.setActiveSwVersion(reportedFwImageName);
|
||||
firmwareStatusData.setAlternateSwVersion(reportedAltFwImageName);
|
||||
firmwareStatusData.setUpgradeState(fwUpgradeState, fwUpgradeFailureReason);
|
||||
@@ -1394,7 +1422,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
EquipmentUpgradeStatusData firmwareStatusData = (EquipmentUpgradeStatusData) firmwareStatus
|
||||
.getDetails();
|
||||
if (reportedFwImageName != null) {
|
||||
if (!firmwareStatusData.getActiveSwVersion().equals(reportedFwImageName) || !firmwareStatusData.getAlternateSwVersion().equals(reportedAltFwImageName)
|
||||
if (!firmwareStatusData.getActiveSwVersion().equals(reportedFwImageName)
|
||||
|| !firmwareStatusData.getAlternateSwVersion().equals(reportedAltFwImageName)
|
||||
|| !firmwareStatusData.getUpgradeState().equals(fwUpgradeState)
|
||||
|| !firmwareStatusData.getReason().equals(fwUpgradeFailureReason)) {
|
||||
firmwareStatusData.setActiveSwVersion(reportedFwImageName);
|
||||
@@ -1424,8 +1453,10 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
.getDetails();
|
||||
if (reportedFwImageName != null) {
|
||||
if (!firmwareStatusData.getActiveSwVersion().equals(reportedFwImageName)
|
||||
|| !firmwareStatusData.getUpgradeState().equals(fwUpgradeState)) {
|
||||
|| !firmwareStatusData.getUpgradeState().equals(fwUpgradeState)
|
||||
|| !firmwareStatusData.getAlternateSwVersion().equals(reportedAltFwImageName)) {
|
||||
firmwareStatusData.setActiveSwVersion(reportedFwImageName);
|
||||
firmwareStatusData.setAlternateSwVersion(reportedAltFwImageName);
|
||||
firmwareStatusData.setUpgradeState(fwUpgradeState, fwUpgradeFailureReason);
|
||||
firmwareStatus.setDetails(firmwareStatusData);
|
||||
updates.add(firmwareStatus);
|
||||
@@ -1861,7 +1892,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (dhcpLeasedIps.containsKey("hostname")) {
|
||||
|
||||
@@ -1890,7 +1921,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
clientDhcpDetails.setGatewayIp(InetAddress.getByName(dhcpLeasedIps.get("gateway")));
|
||||
} catch (UnknownHostException e) {
|
||||
LOG.error("Invalid Gateway IP", e);
|
||||
|
||||
|
||||
try {
|
||||
clientDhcpDetails.setGatewayIp(InetAddress.getByAddress(dhcpLeasedIps.get("gateway").getBytes()));
|
||||
} catch (UnknownHostException e1) {
|
||||
@@ -1907,7 +1938,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
} catch (UnknownHostException e) {
|
||||
LOG.error("Invalid Subnet Mask", e);
|
||||
try {
|
||||
clientDhcpDetails.setGatewayIp(InetAddress.getByAddress(dhcpLeasedIps.get("subnet_mask").getBytes()));
|
||||
clientDhcpDetails
|
||||
.setGatewayIp(InetAddress.getByAddress(dhcpLeasedIps.get("subnet_mask").getBytes()));
|
||||
} catch (UnknownHostException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
LOG.error("Invalid Subnet Mask Address", e);
|
||||
@@ -1921,7 +1953,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
} catch (UnknownHostException e) {
|
||||
LOG.error("Invalid Primary DNS", e);
|
||||
try {
|
||||
clientDhcpDetails.setGatewayIp(InetAddress.getByAddress(dhcpLeasedIps.get("primary_dns").getBytes()));
|
||||
clientDhcpDetails
|
||||
.setGatewayIp(InetAddress.getByAddress(dhcpLeasedIps.get("primary_dns").getBytes()));
|
||||
} catch (UnknownHostException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
LOG.error("Invalid Primary DNS Address", e);
|
||||
@@ -1936,7 +1969,8 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
||||
} catch (UnknownHostException e) {
|
||||
LOG.error("Invalid Secondary DNS", e);
|
||||
try {
|
||||
clientDhcpDetails.setGatewayIp(InetAddress.getByAddress(dhcpLeasedIps.get("secondary_dns").getBytes()));
|
||||
clientDhcpDetails
|
||||
.setGatewayIp(InetAddress.getByAddress(dhcpLeasedIps.get("secondary_dns").getBytes()));
|
||||
} catch (UnknownHostException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
LOG.error("Invalid Seconary DNS Address", e);
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.util.function.Consumer;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.role.PortalUserRole;
|
||||
import com.telecominfraproject.wlan.core.model.service.GatewayType;
|
||||
import com.telecominfraproject.wlan.core.client.PingClient;
|
||||
import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
|
||||
@@ -41,6 +42,7 @@ import com.telecominfraproject.wlan.equipmentgateway.models.CEGWConfigChangeNoti
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWFirmwareDownloadRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWFirmwareFlashRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWRadioResetRequest;
|
||||
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;
|
||||
@@ -54,6 +56,7 @@ import com.telecominfraproject.wlan.routing.RoutingServiceInterface;
|
||||
import com.telecominfraproject.wlan.routing.models.EquipmentGatewayRecord;
|
||||
import com.telecominfraproject.wlan.routing.models.EquipmentRoutingRecord;
|
||||
import com.telecominfraproject.wlan.server.exceptions.ConfigurationException;
|
||||
import com.telecominfraproject.wlan.status.equipment.models.EquipmentResetMethod;
|
||||
|
||||
/**
|
||||
* Opensync Gateway Controller - integration code for cloud deployment
|
||||
@@ -191,6 +194,9 @@ public class OpensyncCloudGatewayController {
|
||||
case RadioReset:
|
||||
ret.add(processRadioReset(session, (CEGWRadioResetRequest) command));
|
||||
break;
|
||||
case RebootRequest:
|
||||
ret.add(processRadioReboot(session, (CEGWRebootRequest) command));
|
||||
break;
|
||||
case ClientBlocklistChangeNotification:
|
||||
ret.add(sendClientBlocklistChangeNotification(session,
|
||||
(CEGWClientBlocklistChangeNotification) command));
|
||||
@@ -224,6 +230,10 @@ public class OpensyncCloudGatewayController {
|
||||
return sendMessage(session, command.getInventoryId(), command);
|
||||
}
|
||||
|
||||
private EquipmentCommandResponse processRadioReboot(OvsdbSession session, CEGWRebootRequest command) {
|
||||
return sendMessage(session, command.getInventoryId(), command);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/defaults", method = RequestMethod.GET)
|
||||
public GatewayDefaults retrieveGatewayDefaults() {
|
||||
return new GatewayDefaults();
|
||||
@@ -339,6 +349,33 @@ public class OpensyncCloudGatewayController {
|
||||
response = new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand,
|
||||
"Received Command " + command.getCommandType() + " for " + inventoryId, command,
|
||||
registeredGateway.getHostname(), registeredGateway.getPort());
|
||||
} else if (command instanceof CEGWRebootRequest) {
|
||||
|
||||
CEGWRebootRequest rebootRequest = (CEGWRebootRequest) command;
|
||||
// Reboot the AP, Reset method specifies what kind of reboot, i.e.
|
||||
// Factory reset, reboot without changes, etc.
|
||||
EquipmentResetMethod resetMethod = rebootRequest.getPerformReset();
|
||||
switch (resetMethod) {
|
||||
case FactoryReset:
|
||||
response.setResultDetail(tipwlanOvsdbClient.processFactoryResetRequest(inventoryId));
|
||||
break;
|
||||
case NoReset:
|
||||
if (rebootRequest.isUseInactiveBank()) {
|
||||
response.setResultDetail(tipwlanOvsdbClient.processRebootRequest(inventoryId, true));
|
||||
} else {
|
||||
response.setResultDetail(tipwlanOvsdbClient.processRebootRequest(inventoryId, false));
|
||||
}
|
||||
break;
|
||||
case ConfigReset:
|
||||
case UNSUPPORTED: // for UNSUPPORTED or default just respond
|
||||
// with Unsupported Command
|
||||
default:
|
||||
response = new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand,
|
||||
"Received Command " + command.getCommandType() + " for " + inventoryId, command,
|
||||
registeredGateway.getHostname(), registeredGateway.getPort());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return response;
|
||||
|
||||
@@ -10,9 +10,9 @@ public interface OvsdbClientInterface {
|
||||
Set<String> getConnectedClientIds();
|
||||
|
||||
String changeRedirectorHost(String apId, String newRedirectorHost);
|
||||
|
||||
|
||||
String startDebugEngine(String apId, String gatewayHostname, Integer gatewayPort);
|
||||
|
||||
|
||||
String stopDebugEngine(String apId);
|
||||
|
||||
void processConfigChanged(String apId);
|
||||
@@ -25,4 +25,9 @@ public interface OvsdbClientInterface {
|
||||
String closeSession(String apId);
|
||||
|
||||
String processFirmwareFlash(String apId, String firmwareVersion, String username);
|
||||
|
||||
String processRebootRequest(String apId, boolean switchBanks);
|
||||
|
||||
String processFactoryResetRequest(String apId);
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.telecominfraproject.wlan.opensync.external.integration.models.Opensyn
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncAPVIFState;
|
||||
import com.telecominfraproject.wlan.opensync.external.integration.models.OpensyncWifiAssociatedClients;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.OvsdbDao;
|
||||
import com.telecominfraproject.wlan.opensync.ovsdb.dao.utilities.OvsdbStringConstants;
|
||||
import com.telecominfraproject.wlan.opensync.util.SslUtil;
|
||||
import com.telecominfraproject.wlan.profile.network.models.ApNetworkConfiguration;
|
||||
import com.vmware.ovsdb.callback.ConnectionCallback;
|
||||
@@ -752,37 +753,103 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
||||
LOG.debug("TipWlanOvsdbClient::startDebugEngine apId {} gatewayHostname {} gatewayPort {}", apId,
|
||||
gatewayHostname, gatewayPort);
|
||||
|
||||
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
|
||||
OvsdbClient ovsdbClient = session.getOvsdbClient();
|
||||
try {
|
||||
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
|
||||
OvsdbClient ovsdbClient = session.getOvsdbClient();
|
||||
|
||||
// TODO: need to establish what the command will be to start debug
|
||||
// logging, on the AP side
|
||||
// For now, use start_debug_engine
|
||||
// Map will have gateway_host and gateway_port for now
|
||||
// Delay/Duration TBD, just use 0s for now
|
||||
Map<String, String> payload = new HashMap<>();
|
||||
payload.put("gateway_hostname", gatewayHostname);
|
||||
payload.put("gateway_port", gatewayPort.toString());
|
||||
ovsdbDao.configureCommands(ovsdbClient, OvsdbDao.StartDebugEngineApCommand, payload, Long.valueOf(0L),
|
||||
Long.valueOf(0L));
|
||||
// TODO: need to establish what the command will be to start debug
|
||||
// logging, on the AP side
|
||||
// For now, use start_debug_engine
|
||||
// Map will have gateway_host and gateway_port for now
|
||||
// Delay/Duration TBD, just use 0s for now
|
||||
Map<String, String> payload = new HashMap<>();
|
||||
payload.put("gateway_hostname", gatewayHostname);
|
||||
payload.put("gateway_port", gatewayPort.toString());
|
||||
ovsdbDao.configureCommands(ovsdbClient, OvsdbDao.StartDebugEngineApCommand, payload, Long.valueOf(0L),
|
||||
Long.valueOf(0L));
|
||||
|
||||
LOG.debug("Started debug engine on AP {} with gateway {} port {}", apId, gatewayHostname, gatewayPort);
|
||||
return "Started debug engine on AP " + apId + " with gateway " + gatewayHostname + " port " + gatewayPort;
|
||||
LOG.debug("Started debug engine on AP {} with gateway {} port {}", apId, gatewayHostname, gatewayPort);
|
||||
return "Started debug engine on AP " + apId + " with gateway " + gatewayHostname + " port " + gatewayPort;
|
||||
} catch (Exception e) {
|
||||
LOG.error(
|
||||
"TipWlanOvsdbClient::startDebugEngine Failed to start debug engine on AP {} with gateway {} port {}",
|
||||
apId, gatewayHostname, gatewayPort, e);
|
||||
return "Failed to start debug engine on AP " + apId + " with gateway " + gatewayHostname + " port "
|
||||
+ gatewayPort;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String stopDebugEngine(String apId) {
|
||||
LOG.debug("TipWlanOvsdbClient::stopDebugEngine apId {}", apId);
|
||||
|
||||
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
|
||||
OvsdbClient ovsdbClient = session.getOvsdbClient();
|
||||
try {
|
||||
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
|
||||
OvsdbClient ovsdbClient = session.getOvsdbClient();
|
||||
|
||||
Map<String, String> payload = new HashMap<>();
|
||||
ovsdbDao.configureCommands(ovsdbClient, OvsdbDao.StopDebugEngineApCommand, payload, Long.valueOf(0L),
|
||||
Long.valueOf(0L));
|
||||
|
||||
LOG.debug("TipWlanOvsdbClient::stopDebugEngine Stop debug engine on AP {}", apId);
|
||||
return "Stop debug engine on AP " + apId;
|
||||
} catch (Exception e) {
|
||||
LOG.error("TipWlanOvsdbClient::stopDebugEngine Failed to request stop debug engine on AP {}", apId, e);
|
||||
return "Failed to request stop debug engine on AP " + apId;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String processRebootRequest(String apId, boolean switchBanks) {
|
||||
try {
|
||||
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
|
||||
OvsdbClient ovsdbClient = session.getOvsdbClient();
|
||||
|
||||
if (switchBanks) {
|
||||
LOG.debug("TipWlanOvsdbClient::processRebootRequest Switch software bank on AP {}", apId);
|
||||
|
||||
ovsdbDao.rebootOrResetAp(ovsdbClient, OvsdbStringConstants.OVSDB_AWLAN_AP_SWITCH_SOFTWARE_BANK);
|
||||
LOG.debug("TipWlanOvsdbClient::processRebootRequest triggered switch software bank on AP {}", apId);
|
||||
return "Switch software bank on AP " + apId;
|
||||
|
||||
} else {
|
||||
LOG.debug("TipWlanOvsdbClient::processRebootRequest Reboot AP {}", apId);
|
||||
|
||||
ovsdbDao.rebootOrResetAp(ovsdbClient, OvsdbStringConstants.OVSDB_AWLAN_AP_REBOOT);
|
||||
LOG.debug("TipWlanOvsdbClient::processRebootRequest triggered reboot of AP {}", apId);
|
||||
return "Reboot AP " + apId;
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (switchBanks) {
|
||||
LOG.debug("TipWlanOvsdbClient::processRebootRequest failed to trigger switch software bank on AP {}",
|
||||
apId, e);
|
||||
return "failed to trigger switch software bank on AP " + apId;
|
||||
} else {
|
||||
LOG.error("TipWlanOvsdbClient::processRebootRequest failed to trigger reboot of AP {}", apId, e);
|
||||
return "Failed to trigger reboot of AP " + apId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String processFactoryResetRequest(String apId) {
|
||||
|
||||
LOG.debug("TipWlanOvsdbClient::processFactoryResetRequest for AP {}", apId);
|
||||
|
||||
try {
|
||||
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
|
||||
OvsdbClient ovsdbClient = session.getOvsdbClient();
|
||||
ovsdbDao.rebootOrResetAp(ovsdbClient, OvsdbStringConstants.OVSDB_AWLAN_AP_FACTORY_RESET);
|
||||
LOG.debug("TipWlanOvsdbClient::processRebootRequest Triggered a factory reset of AP {}", apId);
|
||||
return "Triggered a factory reset of AP " + apId;
|
||||
} catch (Exception e) {
|
||||
LOG.error("TipWlanOvsdbClient::processRebootRequest failed to trigger a factory reset of AP {}", apId, e);
|
||||
return "failed to trigger a factory reset of AP " + apId;
|
||||
}
|
||||
|
||||
Map<String, String> payload = new HashMap<>();
|
||||
ovsdbDao.configureCommands(ovsdbClient, OvsdbDao.StopDebugEngineApCommand, payload, Long.valueOf(0L),
|
||||
Long.valueOf(0L));
|
||||
|
||||
LOG.debug("Stop debug engine on AP {}", apId);
|
||||
return "Stop debug engine on AP " + apId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1711,7 +1711,7 @@ public class OvsdbDao {
|
||||
// ;-)
|
||||
|
||||
RfConfiguration rfConfig = (RfConfiguration) opensyncAPConfig.getRfProfile().getDetails();
|
||||
|
||||
|
||||
ApElementConfiguration apElementConfiguration = (ApElementConfiguration) opensyncAPConfig.getCustomerEquipment()
|
||||
.getDetails();
|
||||
|
||||
@@ -3648,6 +3648,29 @@ public class OvsdbDao {
|
||||
}
|
||||
}
|
||||
|
||||
public void rebootOrResetAp(OvsdbClient ovsdbClient, String desiredApAction) {
|
||||
try {
|
||||
LOG.debug("rebootOrResetAp on AP perform {}.", desiredApAction, upgradeTimerSeconds);
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
Map<String, Value> updateColumns = new HashMap<>();
|
||||
updateColumns.put("firmware_url", new Atom<>(desiredApAction));
|
||||
Row row = new Row(updateColumns);
|
||||
operations.add(new Update(awlanNodeDbTable, row));
|
||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||
|
||||
OperationResult[] result = fResult.join();
|
||||
for (OperationResult r : result) {
|
||||
LOG.debug("Op Result {}", r);
|
||||
}
|
||||
} catch (OvsdbClientException e) {
|
||||
LOG.error("Could not trigger {}", desiredApAction, e);
|
||||
throw new RuntimeException(e);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void removeAllStatsConfigs(OvsdbClient ovsdbClient) {
|
||||
|
||||
LOG.info("Remove existing Wifi_Stats_Config table entries");
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.telecominfraproject.wlan.opensync.ovsdb.dao.utilities;
|
||||
|
||||
|
||||
public class OvsdbStringConstants {
|
||||
|
||||
|
||||
// freq_band
|
||||
public static final String OVSDB_FREQ_BAND_5G = "5G";
|
||||
public static final String OVSDB_FREQ_BAND_5GL = "5GL";
|
||||
@@ -13,5 +13,13 @@ public class OvsdbStringConstants {
|
||||
public static final String FW_IMAGE_NAME_KEY = "FW_IMAGE_NAME";
|
||||
public static final String FW_IMAGE_ACTIVE_KEY = "FW_IMAGE_ACTIVE";
|
||||
public static final String FW_IMAGE_INACTIVE_KEY = "FW_IMAGE_INACTIVE";
|
||||
|
||||
// AWLAN_Node values which can be placed in firmware_url column to trigger
|
||||
// behavior other than firmware download/flash
|
||||
public static final String OVSDB_AWLAN_AP_REBOOT = "reboot";
|
||||
public static final String OVSDB_AWLAN_AP_FACTORY_RESET = "factory";
|
||||
public static final String OVSDB_AWLAN_AP_SWITCH_SOFTWARE_BANK = "switch";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user