diff options
| author | Roy <Roy.mail.net@gmail.com> | 2022-10-28 01:53:10 +0300 |
|---|---|---|
| committer | Roy <Roy.mail.net@gmail.com> | 2022-10-28 01:53:10 +0300 |
| commit | 6cfab959098ae0bd78aad7a3e69c20eda31da2a9 (patch) | |
| tree | eb76a9e754112ce67b20998216802d997d5f70e7 /Software/Visual_Studio/Azure | |
| parent | 00bed963c45e4de37a6e688c59e0ecc2964d0a11 (diff) | |
| download | Tango-6cfab959098ae0bd78aad7a3e69c20eda31da2a9.tar.gz Tango-6cfab959098ae0bd78aad7a3e69c20eda31da2a9.zip | |
Azure Utils for Twine Studio.
Diffstat (limited to 'Software/Visual_Studio/Azure')
8 files changed, 104 insertions, 40 deletions
diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml index 6eb78c808..209a4c1aa 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml @@ -10,7 +10,7 @@ d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=azure:IWebAppBase, IsDesignTimeCreatable=False}" x:Name="control" > <Grid> <StackPanel TextElement.FontSize="10"> - <controls:TableGrid RowHeight="30"> + <controls:TableGrid RowHeight="20"> <TextBlock FontWeight="SemiBold">ADDRESS:</TextBlock> <ItemsControl ItemsSource="{Binding ElementName=control,Path=HostNames}"/> @@ -65,6 +65,9 @@ <TextBlock FontWeight="SemiBold">Tango FSE Version:</TextBlock> <TextBlock Text="{Binding ElementName=control,Path=FseVersion.Version}"></TextBlock> + <TextBlock FontWeight="SemiBold">Twine Studio Version:</TextBlock> + <TextBlock Text="{Binding ElementName=control,Path=TwineStudioVersion.Version}"></TextBlock> + <TextBlock FontWeight="SemiBold">Machine Service Version:</TextBlock> <TextBlock Text="{Binding ElementName=control,Path=MachineServiceVersion}"></TextBlock> </controls:TableGrid> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs index aab9361f8..a6b0d12d7 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Controls/WebAppPropertiesControl.xaml.cs @@ -17,6 +17,7 @@ using System.Windows.Shapes; using Tango.AzureUtils.Database; using Tango.AzureUtils.FTP; using Tango.BL.Entities; +using Tango.BL.Enumerations; namespace Tango.AzureUtils.UI.Controls { @@ -57,6 +58,18 @@ namespace Tango.AzureUtils.UI.Controls public static readonly DependencyProperty FseVersionProperty = DependencyProperty.Register("FseVersion", typeof(FseVersion), typeof(WebAppPropertiesControl), new PropertyMetadata(null)); + + + public FseVersion TwineStudioVersion + { + get { return (FseVersion)GetValue(TwineStudioVersionProperty); } + set { SetValue(TwineStudioVersionProperty, value); } + } + public static readonly DependencyProperty TwineStudioVersionProperty = + DependencyProperty.Register("TwineStudioVersion", typeof(FseVersion), typeof(WebAppPropertiesControl), new PropertyMetadata(null)); + + + public MachineStudioVersion MachineStudioVersion { get { return (MachineStudioVersion)GetValue(MachineStudioVersionProperty); } @@ -113,7 +126,8 @@ namespace Tango.AzureUtils.UI.Controls var databaseManager = new DatabaseManager(azure); TangoVersion = await databaseManager.GetLatestPPCVersion(app); MachineStudioVersion = await databaseManager.GetLatestMachineStudioVersion(app); - FseVersion = await databaseManager.GetLatestFSEVersion(app); + FseVersion = await databaseManager.GetLatestFSEVersion(app, FSEBuildVariants.FSE); + TwineStudioVersion = await databaseManager.GetLatestFSEVersion(app, FSEBuildVariants.TwineStudio); FtpManager ftpManager = new FtpManager(azure); MachineServiceVersion = await ftpManager.GetMachineServiceVersion(app); diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/MainWindow.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/MainWindow.xaml index d23fd41d8..16a742df9 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/MainWindow.xaml +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/MainWindow.xaml @@ -6,7 +6,7 @@ xmlns:views="clr-namespace:Tango.AzureUtils.UI.Views" xmlns:local="clr-namespace:Tango.AzureUtils.UI" mc:Ignorable="d" - Title="Azure Utils" Height="950" Width="1280" WindowStartupLocation="CenterScreen"> + Title="Azure Utils" Height="800" Width="1280" WindowStartupLocation="CenterScreen"> <Grid> <views:MainView/> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentUpgradeView.xaml b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentUpgradeView.xaml index 0bc763c35..2dfab2ff6 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentUpgradeView.xaml +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils.UI/Views/EnvironmentUpgradeView.xaml @@ -49,6 +49,8 @@ <CheckBox Click="OnConfigChanged" Margin="0 5 0 0" IsChecked="{Binding Config.UpgradePPCDatabaseVersion}" >Upgrade PPC Database Version</CheckBox> <CheckBox Click="OnConfigChanged" Margin="0 5 0 0" IsChecked="{Binding Config.CopyFSEStorageBlobs}" >Upgrade FSE Blob Storage</CheckBox> <CheckBox Click="OnConfigChanged" Margin="0 5 0 0" IsChecked="{Binding Config.UpgradeFSEDatabaseVersion}" >Upgrade FSE Database Version</CheckBox> + <CheckBox Click="OnConfigChanged" Margin="0 5 0 0" IsChecked="{Binding Config.CopyTwineStudioStorageBlobs}" >Upgrade Twine Studio Blob Storage</CheckBox> + <CheckBox Click="OnConfigChanged" Margin="0 5 0 0" IsChecked="{Binding Config.UpgradeTwineStudioDatabaseVersion}" >Upgrade Twine Studio Database Version</CheckBox> <CheckBox Click="OnConfigChanged" Margin="0 5 0 0" IsChecked="{Binding Config.CopyMachineServiceFiles}" >Upgrade Machine Service</CheckBox> </StackPanel> </GroupBox> diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Database/DatabaseManager.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Database/DatabaseManager.cs index 2a94e95b0..836e66c9f 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Database/DatabaseManager.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Database/DatabaseManager.cs @@ -14,6 +14,7 @@ using Microsoft.Azure.Management.Sql.Fluent; using Microsoft.Azure.Management.Sql.Fluent.Models; using Tango.BL; using Tango.BL.Entities; +using Tango.BL.Enumerations; using Tango.Core; using Tango.Core.DB; using Tango.Core.Helpers; @@ -243,13 +244,13 @@ namespace Tango.AzureUtils.Database } } - public async Task UpgradeFSEVersion(IWebAppBase sourceApp, IWebAppBase targetApp) + public async Task UpgradeFSEVersion(IWebAppBase sourceApp, IWebAppBase targetApp, FSEBuildVariants build) { - var latestFSEVersion = await GetLatestFSEVersion(sourceApp); + var latestFSEVersion = await GetLatestFSEVersion(sourceApp, build); var targetDataSource = (await targetApp.GetMachineServiceSettingsAsync()).ToDataSource(); - OnProgress(AzureUtilsStage.Database, $"Adding FSE database entry for version '{latestFSEVersion.Version}'..."); + OnProgress(AzureUtilsStage.Database, $"Adding {build} database entry for version '{latestFSEVersion.Version}'..."); using (var db = ObservablesContext.CreateDefault(targetDataSource)) { @@ -352,9 +353,9 @@ namespace Tango.AzureUtils.Database } } - public async Task<FseVersion> GetLatestFSEVersion(IWebAppBase app) + public async Task<FseVersion> GetLatestFSEVersion(IWebAppBase app, FSEBuildVariants build) { - OnProgress(AzureUtilsStage.Database, $"Getting latest FSE version on '{app.Name}'..."); + OnProgress(AzureUtilsStage.Database, $"Getting latest {build} version on '{app.Name}'..."); MachineServiceSettings settings = null; @@ -373,7 +374,7 @@ namespace Tango.AzureUtils.Database using (var db = ObservablesContext.CreateDefault(dataSource)) { - var versions = await db.FseVersions.ToListAsync(); + var versions = await db.FseVersions.Where(x => x.BuildVariant == (int)build).ToListAsync(); var latest_version = versions.OrderByDescending(x => Version.Parse(x.Version)).FirstOrDefault(); return latest_version; } @@ -432,27 +433,27 @@ namespace Tango.AzureUtils.Database } } - public async Task ValidateFSEDatabaseUpgrade(IWebAppBase sourceApp, IWebAppBase targetApp) + public async Task ValidateFSEDatabaseUpgrade(IWebAppBase sourceApp, IWebAppBase targetApp, FSEBuildVariants build) { - OnProgress(AzureUtilsStage.Validating, "Validating FSE database upgrade..."); + OnProgress(AzureUtilsStage.Validating, $"Validating {build} database upgrade..."); var sourceSettings = await sourceApp.GetMachineServiceSettingsAsync(); var targetSettings = await targetApp.GetMachineServiceSettingsAsync(); - var latestSourceFSEVersion = await GetLatestFSEVersion(sourceApp); + var latestSourceFSEVersion = await GetLatestFSEVersion(sourceApp, build); //Check if there is any source FSE version. if (latestSourceFSEVersion == null) { - throw new ValidationException("Could not locate a FSE version entry on the source database."); + throw new ValidationException($"Could not locate a {build} version entry on the source database."); } - var latestTargetFSEVersion = await GetLatestFSEVersion(targetApp); + var latestTargetFSEVersion = await GetLatestFSEVersion(targetApp, build); //Check target latest FSE version is older if there is any. if (latestTargetFSEVersion != null && Version.Parse(latestSourceFSEVersion.Version) <= Version.Parse(latestTargetFSEVersion.Version)) { - throw new ValidationException($"FSE source version is '{latestSourceFSEVersion.Version}' while target version is '{latestTargetFSEVersion.Version}'."); + throw new ValidationException($"{build} source version is '{latestSourceFSEVersion.Version}' while target version is '{latestTargetFSEVersion.Version}'."); } } diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Environment/EnvironmentManager.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Environment/EnvironmentManager.cs index 8c6c745a9..ece5f04cd 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Environment/EnvironmentManager.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Environment/EnvironmentManager.cs @@ -21,6 +21,7 @@ using Tango.AzureUtils.Deployment; using Tango.AzureUtils.FTP; using Tango.AzureUtils.Storage; using Tango.BL; +using Tango.BL.Enumerations; using Tango.Core; using Tango.Core.DB; using Tango.PMR.FirmwareUpgrade; @@ -332,8 +333,8 @@ namespace Tango.AzureUtils.Environment { try { - await _storageManager.ValidateFSEStorageUpgrade(sourceApp, targetApp); - await _storageManager.UpgradeFSEStorage(sourceApp, targetApp); + await _storageManager.ValidateFSEStorageUpgrade(sourceApp, targetApp, FSEBuildVariants.FSE); + await _storageManager.UpgradeFSEStorage(sourceApp, targetApp, FSEBuildVariants.FSE); } catch (Exception ex) { @@ -341,6 +342,20 @@ namespace Tango.AzureUtils.Environment } } + //Add Twine Studio storage versions. + if (config.CopyTwineStudioStorageBlobs) + { + try + { + await _storageManager.ValidateFSEStorageUpgrade(sourceApp, targetApp, FSEBuildVariants.TwineStudio); + await _storageManager.UpgradeFSEStorage(sourceApp, targetApp, FSEBuildVariants.TwineStudio); + } + catch (Exception ex) + { + await RequestConfirmation($"Issues encountered with upgrading Twine Studio storage versions.\n{ex.FlattenMessage()}\nDo you wish to continue?"); + } + } + //Upgrade machine studio database version. if (config.UpgradeMachineStudioDatabaseVersion) { @@ -374,8 +389,8 @@ namespace Tango.AzureUtils.Environment { try { - await _databaseManager.ValidateFSEDatabaseUpgrade(sourceApp, targetApp); - await _databaseManager.UpgradeFSEVersion(sourceApp, targetApp); + await _databaseManager.ValidateFSEDatabaseUpgrade(sourceApp, targetApp, FSEBuildVariants.FSE); + await _databaseManager.UpgradeFSEVersion(sourceApp, targetApp, FSEBuildVariants.FSE); } catch (Exception ex) { @@ -383,6 +398,20 @@ namespace Tango.AzureUtils.Environment } } + //Upgrade FSE database version. + if (config.UpgradeTwineStudioDatabaseVersion) + { + try + { + await _databaseManager.ValidateFSEDatabaseUpgrade(sourceApp, targetApp, FSEBuildVariants.TwineStudio); + await _databaseManager.UpgradeFSEVersion(sourceApp, targetApp, FSEBuildVariants.TwineStudio); + } + catch (Exception ex) + { + await RequestConfirmation($"Issues encountered with upgrading Twine Studio database versions.\n{ex.FlattenMessage()}\nDo you wish to continue?"); + } + } + //Copy Website files. if (config.CopyMachineServiceFiles) @@ -419,7 +448,13 @@ namespace Tango.AzureUtils.Environment //Add FSE storage versions. if (config.CopyFSEStorageBlobs) { - await _storageManager.ValidateFSEStorageUpgrade(sourceApp, targetApp); + await _storageManager.ValidateFSEStorageUpgrade(sourceApp, targetApp, FSEBuildVariants.FSE); + } + + //Add Twine Studio storage versions. + if (config.CopyTwineStudioStorageBlobs) + { + await _storageManager.ValidateFSEStorageUpgrade(sourceApp, targetApp, FSEBuildVariants.TwineStudio); } //Upgrade machine studio database version. @@ -437,7 +472,13 @@ namespace Tango.AzureUtils.Environment //Upgrade FSE database version. if (config.UpgradeFSEDatabaseVersion) { - await _databaseManager.ValidateFSEDatabaseUpgrade(sourceApp, targetApp); + await _databaseManager.ValidateFSEDatabaseUpgrade(sourceApp, targetApp, FSEBuildVariants.FSE); + } + + //Upgrade Twine Studio database version. + if (config.UpgradeTwineStudioDatabaseVersion) + { + await _databaseManager.ValidateFSEDatabaseUpgrade(sourceApp, targetApp, FSEBuildVariants.TwineStudio); } } @@ -525,7 +566,7 @@ namespace Tango.AzureUtils.Environment } catch (Exception ex) { - await RequestConfirmation($"Error occurred while trying to remove machine studio storage blobs.\n{ex.FlattenMessage()}\nDo you wish to continue?"); + await RequestConfirmation($"Error occurred while trying to remove machine studio storage blobs.\n{ex.FlattenMessage()}\nDo you wish to continue?"); } try diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Environment/UpgradeEnvironmentConfiguration.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Environment/UpgradeEnvironmentConfiguration.cs index 1d7b9de16..6243b65a0 100644 --- a/Software/Visual_Studio/Azure/Tango.AzureUtils/Environment/UpgradeEnvironmentConfiguration.cs +++ b/Software/Visual_Studio/Azure/Tango.AzureUtils/Environment/UpgradeEnvironmentConfiguration.cs @@ -8,14 +8,16 @@ namespace Tango.AzureUtils.Environment { public class UpgradeEnvironmentConfiguration { - public bool SynchronizeDatabaseSchema { get; set; } = true; - public bool SynchronizeDatabaseData { get; set; } = true; - public bool CopyMachineStudioStorageBlobs { get; set; } = true; - public bool UpgradeMachineStudioDatabaseVersion { get; set; } = true; - public bool CopyPPCStorageBlobs { get; set; } = true; - public bool UpgradePPCDatabaseVersion { get; set; } = true; - public bool CopyFSEStorageBlobs { get; set; } = true; - public bool UpgradeFSEDatabaseVersion { get; set; } = true; - public bool CopyMachineServiceFiles { get; set; } = true; + public bool SynchronizeDatabaseSchema { get; set; } + public bool SynchronizeDatabaseData { get; set; } + public bool CopyMachineStudioStorageBlobs { get; set; } + public bool UpgradeMachineStudioDatabaseVersion { get; set; } + public bool CopyPPCStorageBlobs { get; set; } + public bool UpgradePPCDatabaseVersion { get; set; } + public bool CopyFSEStorageBlobs { get; set; } + public bool UpgradeFSEDatabaseVersion { get; set; } + public bool CopyTwineStudioStorageBlobs { get; set; } + public bool UpgradeTwineStudioDatabaseVersion { get; set; } + public bool CopyMachineServiceFiles { get; set; } } } diff --git a/Software/Visual_Studio/Azure/Tango.AzureUtils/Storage/StorageManager.cs b/Software/Visual_Studio/Azure/Tango.AzureUtils/Storage/StorageManager.cs index db4403cc9..5ff7af246 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.Enumerations; using Tango.Core.IO; namespace Tango.AzureUtils.Storage @@ -109,16 +110,16 @@ namespace Tango.AzureUtils.Storage }); } - public async Task UpgradeFSEStorage(IWebAppBase sourceApp, IWebAppBase targetApp) + public async Task UpgradeFSEStorage(IWebAppBase sourceApp, IWebAppBase targetApp, FSEBuildVariants build) { OnProgress(AzureUtilsStage.Storage, $"Retrieving source and target settings..."); var sourceSettings = await sourceApp.GetMachineServiceSettingsAsync(); var targetSettings = await targetApp.GetMachineServiceSettingsAsync(); - var latestFSEVersion = await _databaseManager.GetLatestFSEVersion(sourceApp); + var latestFSEVersion = await _databaseManager.GetLatestFSEVersion(sourceApp, build); - OnProgress(AzureUtilsStage.Storage, $"Upgrading FSE version storage..."); + OnProgress(AzureUtilsStage.Storage, $"Upgrading {build} version storage..."); var sourceAccount = CloudStorageAccount.Parse(sourceSettings.STORAGE_ACCOUNT); var sourceClient = sourceAccount.CreateCloudBlobClient(); @@ -231,15 +232,15 @@ namespace Tango.AzureUtils.Storage } } - public async Task ValidateFSEStorageUpgrade(IWebAppBase sourceApp, IWebAppBase targetApp) + public async Task ValidateFSEStorageUpgrade(IWebAppBase sourceApp, IWebAppBase targetApp, FSEBuildVariants build) { - OnProgress(AzureUtilsStage.Validating, "Validating FSE storage upgrade..."); + OnProgress(AzureUtilsStage.Validating, $"Validating {build} storage upgrade..."); var sourceSettings = await sourceApp.GetMachineServiceSettingsAsync(); var targetSettings = await targetApp.GetMachineServiceSettingsAsync(); - var latestSourceFSEVersion = await _databaseManager.GetLatestFSEVersion(sourceApp); - var latestTargetFSEVersion = await _databaseManager.GetLatestFSEVersion(targetApp); + var latestSourceFSEVersion = await _databaseManager.GetLatestFSEVersion(sourceApp, build); + var latestTargetFSEVersion = await _databaseManager.GetLatestFSEVersion(targetApp, build); var targetAccount = CloudStorageAccount.Parse(targetSettings.STORAGE_ACCOUNT); var targetClient = targetAccount.CreateCloudBlobClient(); @@ -250,14 +251,14 @@ namespace Tango.AzureUtils.Storage var targetFSEBlob = targetFSEContainer.GetBlockBlobReference(latestSourceFSEVersion.BlobName); if (await targetFSEBlob.ExistsAsync()) { - throw new ValidationException($"FSE Block blob '{latestSourceFSEVersion.BlobName}' already exists on the target storage."); + throw new ValidationException($"{build} Block blob '{latestSourceFSEVersion.BlobName}' already exists on the target storage."); } //Check FSE installer blob not exists on the target. var targetFSEInstallerBlob = targetFSEContainer.GetBlockBlobReference(latestSourceFSEVersion.InstallerBlobName); if (await targetFSEInstallerBlob.ExistsAsync()) { - throw new ValidationException($"FSE Block blob '{latestSourceFSEVersion.InstallerBlobName}' already exists on the target storage."); + throw new ValidationException($"{build} Block blob '{latestSourceFSEVersion.InstallerBlobName}' already exists on the target storage."); } } |
