FirmwareFlash and FirmwareDownload support in Dao and Gateway. Contingent on AP support, currently sends command but doesn't actually upgrade for download, and Flash doesn't have a trigger point on AP

This commit is contained in:
Mike Hansen
2020-06-18 15:39:22 -04:00
parent 467562d578
commit 3690111d08
4 changed files with 109 additions and 12 deletions

View File

@@ -268,15 +268,21 @@ public class OpensyncCloudGatewayController {
// TODO: after the demo introduce a specialized command for this!
String newRedirectorAddress = ((CEGWStartDebugEngine) command).getGatewayHostname();
connectusOvsdbClient.changeRedirectorAddress(inventoryId, newRedirectorAddress);
//TODO: add support for additional commands below
// TODO: add support for additional commands below
} else if (command instanceof CEGWFirmwareFlashRequest) {
response = new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand,
"Received Command " + command.getCommandType() + " for " + inventoryId, command,
registeredGateway.getHostname(), registeredGateway.getPort());
String firmwareVersion = ((CEGWFirmwareFlashRequest) command).getFirmwareVersion();
connectusOvsdbClient.processFlashFirmware(inventoryId, firmwareVersion);
} else if (command instanceof CEGWFirmwareDownloadRequest) {
response = new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand,
"Received Command " + command.getCommandType() + " for " + inventoryId, command,
registeredGateway.getHostname(), registeredGateway.getPort());
String filepath = ((CEGWFirmwareDownloadRequest) command).getFilePath();
String firmwareVersion = ((CEGWFirmwareDownloadRequest) command).getFirmwareVersion();
String username = ((CEGWFirmwareDownloadRequest) command).getUsername();
String validationCode = ((CEGWFirmwareDownloadRequest) command).getUsername();
connectusOvsdbClient.processFirmwareDownload(inventoryId, filepath, firmwareVersion, username,
validationCode);
} else if (command instanceof CEGWRadioResetRequest) {
response = new EquipmentCommandResponse(CEGWCommandResultCode.UnsupportedCommand,
"Received Command " + command.getCommandType() + " for " + inventoryId, command,

View File

@@ -10,5 +10,10 @@ public interface ConnectusOvsdbClientInterface {
void processConfigChanged(String apId);
String processFirmwareDownload(String apId, String firmwareUrl, String firmwareVersion, String username,
String validationCode);
String processFlashFirmware(String apId, String firmwareVersion);
String closeSession(String apId);
}

View File

@@ -416,4 +416,38 @@ public class ConnectusOvsdbClient implements ConnectusOvsdbClientInterface {
LOG.debug("Closed session to " + apId);
return "Closed session to " + apId;
}
@Override
public String processFirmwareDownload(String apId, String firmwareUrl, String firmwareVersion, String username,
String validationCode) {
try {
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
ovsdbDao.configureFirmwareDownload(session.getOvsdbClient(), apId, firmwareUrl, firmwareVersion, username,
validationCode);
} catch (Exception e) {
LOG.error("Failed to initialize firmware download to " + apId + " " + e.getLocalizedMessage());
return "Failed to initialize firmware download to " + apId + " " + e.getLocalizedMessage();
}
LOG.debug("Initialized firmware download to " + apId);
return "Initialized firmware download to " + apId;
}
@Override
public String processFlashFirmware(String apId, String firmwareVersion) {
try {
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
ovsdbDao.flashFirmware(session.getOvsdbClient(), apId, firmwareVersion);
} catch (Exception e) {
LOG.error("Failed to flash firmware version {} on AP {} ", firmwareVersion, apId, e);
return "Failed to flash firmware version " + firmwareVersion + " on AP " + apId + "\n"
+ e.getLocalizedMessage();
}
LOG.debug("Flashed firmware version {} on AP {}", firmwareVersion, apId);
return "Flashed firmware version " + firmwareVersion + " on AP " + apId;
}
}

View File

@@ -65,6 +65,7 @@ import com.vmware.ovsdb.protocol.operation.notation.Value;
import com.vmware.ovsdb.protocol.operation.result.InsertResult;
import com.vmware.ovsdb.protocol.operation.result.OperationResult;
import com.vmware.ovsdb.protocol.operation.result.SelectResult;
import com.vmware.ovsdb.protocol.operation.result.UpdateResult;
import com.vmware.ovsdb.service.OvsdbClient;
@Component
@@ -2721,4 +2722,55 @@ public class OvsdbDao {
return newRedirectorAddress;
}
public void configureFirmwareDownload(OvsdbClient ovsdbClient, String apId, String firmwareUrl,
String firmwareVersion, String username, String validationCode) throws Exception {
LOG.debug("configureFirmwareDownload for {} to version {} url {}", apId, firmwareVersion, firmwareUrl);
List<Operation> operations = new ArrayList<>();
Map<String, Value> updateColumns = new HashMap<>();
updateColumns.put("firmware_pass", new Atom<>(validationCode));
updateColumns.put("firmware_version", new Atom<>(firmwareVersion));
// Until AP enables Upgrade Manager this does nothing
updateColumns.put("firmware_url", new Atom<>(firmwareUrl));
Row row = new Row(updateColumns);
operations.add(new Update(awlanNodeDbTable, row));
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
for (OperationResult r : result) {
LOG.debug("Op Result {}", r);
}
}
public void flashFirmware(OvsdbClient ovsdbClient, String apId, String firmwareVersion) throws Exception {
LOG.debug("flashFirmware for {} to version {}", apId, firmwareVersion);
// TODO: This needs to be implemented when the AP has Firmware Upgrade
// List<Operation> operations = new ArrayList<>();
// Map<String, Value> updateColumns = new HashMap<>();
//
// updateColumns.put("firmware_version", new Atom<>(firmwareVersion));
// Enabled.
// Row row = new Row(updateColumns);
// operations.add(new Update(awlanNodeDbTable, row));
//
//
// CompletableFuture<OperationResult[]> fResult =
// ovsdbClient.transact(ovsdbName, operations);
// OperationResult[] result = fResult.get(ovsdbTimeoutSec,
// TimeUnit.SECONDS);
// for (OperationResult r : result) {
// LOG.debug("Op Result {}", r);
//
// }
}
}