aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Azure/Tango.AzureUtils
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2024-10-06 00:59:30 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2024-10-06 00:59:30 +0300
commitd278567561229b18bd68b4e02f8f841fc21ce3f1 (patch)
tree416e34443cbefcf4bab0d94c07b7ca351ce396bc /Software/Visual_Studio/Azure/Tango.AzureUtils
parent12566937e99f64f3e9b97f1bcd11d941de443d05 (diff)
downloadTango-d278567561229b18bd68b4e02f8f841fc21ce3f1.tar.gz
Tango-d278567561229b18bd68b4e02f8f841fc21ce3f1.zip
Added support for azure utils X4 firmware injection.
Diffstat (limited to 'Software/Visual_Studio/Azure/Tango.AzureUtils')
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils/Firmware/FirmwareManager.cs29
-rw-r--r--Software/Visual_Studio/Azure/Tango.AzureUtils/Storage/StorageManager.cs49
2 files changed, 61 insertions, 17 deletions
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Firmware/FirmwareManager.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Firmware/FirmwareManager.cs
index ac8e52a65..6ab2c4544 100644
--- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Firmware/FirmwareManager.cs
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Firmware/FirmwareManager.cs
@@ -12,6 +12,8 @@ using Microsoft.Azure.Management.Fluent;
using Tango.AzureUtils.Database;
using Tango.AzureUtils.Storage;
using Tango.BL;
+using Tango.BL.Entities;
+using Tango.BL.Enumerations;
using Tango.PMR.FirmwareUpgrade;
using Tango.PPC.Common.Publish;
@@ -30,7 +32,7 @@ namespace Tango.AzureUtils.Firmware
#region Firmware Injection
- public async Task InjectFirmwarePackage(IWebAppBase slot, String tfpFile, String versionTag)
+ public async Task InjectFirmwarePackage(IWebAppBase slot, MachineTypes machineType, String tfpFile, String versionTag)
{
OnProgress(AzureUtilsStage.Firmware, $"Validating TFP package...");
@@ -46,11 +48,24 @@ namespace Tango.AzureUtils.Firmware
throw new ValidationException($"The specified TFP package is invalid.\n{ex.FlattenMessage()}");
}
- var ppcVersion = await _databaseManager.GetLatestPPCVersion(slot, null);
+ TangoVersion version = null;
- if (Version.Parse(ppcVersion.FirmwareVersion) >= tfpPackage.GetMcuVersion())
+ if (machineType == MachineTypes.TS1800)
{
- await RequestConfirmation($"The specified firmware version is '{tfpPackage.GetMcuVersion()}' while latest version is '{ppcVersion.FirmwareVersion}'. Do you wish to continue?");
+ version = await _databaseManager.GetLatestPPCVersion(slot, null);
+ }
+ else if (machineType == MachineTypes.Eureka)
+ {
+ version = await _databaseManager.GetLatestEurekaVersion(slot, null);
+ }
+ else
+ {
+ throw new NotImplementedException("Machine type not supported for this action.");
+ }
+
+ if (Version.Parse(version.FirmwareVersion) >= tfpPackage.GetMcuVersion())
+ {
+ await RequestConfirmation($"The specified firmware version is '{tfpPackage.GetMcuVersion()}' while latest version is '{version.FirmwareVersion}'. Do you wish to continue?");
}
OnProgress(AzureUtilsStage.Firmware, $"Retrieving '{slot.Name}' settings...");
@@ -60,7 +75,7 @@ namespace Tango.AzureUtils.Firmware
var zipFile = TemporaryManager.CreateImaginaryFile(".zip");
- await _storageManager.DownloadLatestPPCVersion(slot, zipFile, versionTag);
+ await _storageManager.DownloadLatestVersion(slot, machineType, zipFile, versionTag);
OnProgress(AzureUtilsStage.Firmware, $"Replacing firmware_package.tfp...");
await Task.Factory.StartNew(() =>
@@ -84,12 +99,12 @@ namespace Tango.AzureUtils.Firmware
}
});
- await _storageManager.ReplaceLatestPPCVersion(slot, zipFile, versionTag);
+ await _storageManager.ReplaceLatestPPCVersion(slot, machineType, zipFile, versionTag);
OnProgress(AzureUtilsStage.Firmware, $"Updating firmware version on database...");
using (ObservablesContext db = ObservablesContext.CreateDefault(settings.ToDataSource()))
{
- var v = await db.TangoVersions.SingleOrDefaultAsync(x => x.Guid == ppcVersion.Guid);
+ var v = await db.TangoVersions.SingleOrDefaultAsync(x => x.Guid == version.Guid);
v.FirmwareVersion = tfpPackage.GetMcuVersion().ToString();
await db.SaveChangesAsync();
}
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Storage/StorageManager.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Storage/StorageManager.cs
index d16a3f90b..cb442b6b4 100644
--- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Storage/StorageManager.cs
+++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Storage/StorageManager.cs
@@ -10,6 +10,7 @@ using Microsoft.Azure.Management.Fluent;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Tango.AzureUtils.Database;
+using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.Core.IO;
@@ -355,54 +356,82 @@ namespace Tango.AzureUtils.Storage
}
}
- public async Task DownloadLatestPPCVersion(IWebAppBase app, String filePath, String versionTag)
+ public async Task DownloadLatestVersion(IWebAppBase app, MachineTypes machineType, String filePath, String versionTag)
{
OnProgress(AzureUtilsStage.Storage, $"Retrieving source and target settings...");
var settings = await app.GetMachineServiceSettingsAsync();
- var ppcVersion = await _databaseManager.GetLatestPPCVersion(app, versionTag);
- OnProgress(AzureUtilsStage.Storage, $"Downloading PPC version '{ppcVersion.Version}'...");
+ TangoVersion version = null;
+
+ if (machineType == MachineTypes.TS1800)
+ {
+ version = await _databaseManager.GetLatestPPCVersion(app, versionTag);
+ }
+ else if (machineType == MachineTypes.Eureka)
+ {
+ version = await _databaseManager.GetLatestEurekaVersion(app, versionTag);
+ }
+ else
+ {
+ throw new NotImplementedException("Machine type not supported for this action.");
+ }
+
+ OnProgress(AzureUtilsStage.Storage, $"Downloading {machineType.ToDescription()} version '{version.Version}'...");
var account = CloudStorageAccount.Parse(settings.STORAGE_ACCOUNT);
var client = account.CreateCloudBlobClient();
var container = client.GetContainerReference(settings.TANGO_VERSIONS_CONTAINER);
- var blob = container.GetBlockBlobReference(ppcVersion.BlobName);
+ var blob = container.GetBlockBlobReference(version.BlobName);
await blob.FetchAttributesAsync();
var length = blob.Properties.Length;
using (FileStreamWrapper st = new FileStreamWrapper(filePath, FileMode.Create, (progress) =>
{
- OnProgress(AzureUtilsStage.Storage, $"Downloading PPC version '{ppcVersion.VersionAndTag}'...", progress, length, false);
+ OnProgress(AzureUtilsStage.Storage, $"Downloading {machineType.ToDescription()} version '{version.VersionAndTag}'...", progress, length, false);
}))
{
await blob.DownloadToStreamAsync(st);
}
}
- public async Task ReplaceLatestPPCVersion(IWebAppBase app, String filePath, String versionTag)
+ public async Task ReplaceLatestPPCVersion(IWebAppBase app, MachineTypes machineType, String filePath, String versionTag)
{
OnProgress(AzureUtilsStage.Storage, $"Retrieving source and target settings...");
var settings = await app.GetMachineServiceSettingsAsync();
- var ppcVersion = await _databaseManager.GetLatestPPCVersion(app, versionTag);
- OnProgress(AzureUtilsStage.Storage, $"Uploading PPC version '{ppcVersion.VersionAndTag}'...");
+ TangoVersion version = null;
+
+ if (machineType == MachineTypes.TS1800)
+ {
+ version = await _databaseManager.GetLatestPPCVersion(app, versionTag);
+ }
+ else if (machineType == MachineTypes.Eureka)
+ {
+ version = await _databaseManager.GetLatestEurekaVersion(app, versionTag);
+ }
+ else
+ {
+ throw new NotImplementedException("Machine type not supported for this action.");
+ }
+
+ OnProgress(AzureUtilsStage.Storage, $"Uploading {machineType.ToDescription()} version '{version.VersionAndTag}'...");
var account = CloudStorageAccount.Parse(settings.STORAGE_ACCOUNT);
var client = account.CreateCloudBlobClient();
var container = client.GetContainerReference(settings.TANGO_VERSIONS_CONTAINER);
- var blob = container.GetBlockBlobReference(ppcVersion.BlobName);
+ var blob = container.GetBlockBlobReference(version.BlobName);
FileStreamWrapper st = null;
using (st = new FileStreamWrapper(filePath, FileMode.Open, (progress) =>
{
- OnProgress(AzureUtilsStage.Storage, $"Uploading PPC version '{ppcVersion.Version}'...", progress, st.Length, false);
+ OnProgress(AzureUtilsStage.Storage, $"Uploading {machineType.ToDescription()} version '{version.Version}'...", progress, st.Length, false);
}))
{
await blob.UploadFromStreamAsync(st);