mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-27 07:13:35 +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:
@@ -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