Skip to content

Fixing bugs in restore and get\list recoverypoint cmdlet for enrcyptedVM #2806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cf10d6f
1.Added backup support for Azure SQL workload
pragrawa Jun 27, 2016
5618713
Removing SubType in csproj, format ps1 xml indent Correction and addi…
pragrawa Jun 27, 2016
12c9695
Adding summary to public functions for Azure sql
swatimadhukargit Jun 29, 2016
c7de968
Indentation in RecoveryPointConversion.cs and summary fix in AzureSq…
swatimadhukargit Jun 29, 2016
4920654
Merge pull request #343 from MabOneSdk/swatim-release01
swatimadhukargit Jun 29, 2016
47084a0
Uncommenting RecoveryServices.Backup test assembly, update error mess…
pragrawa Jun 29, 2016
a675b57
[RS Backup] Addressed review comments, fixed a few minor bugs
Jun 29, 2016
92778a7
[RS Backup] Adding csproj reference to Commands.RecoveryServices in T…
Jun 29, 2016
bb1489c
[RS Backup] Onboarding RS Backup Tests project onto test targets
Jun 29, 2016
b5cdf94
[RS Backup] Added RecoveryServices module to test setup
Jun 30, 2016
183cc60
Resolved merge conflicts - taken current changes againt the rbac hotf…
Jun 30, 2016
4ec4e3b
[RS Backup] Universal time fix in test
Jun 30, 2016
8f604a8
[RS Backup] Universal time fix in job tests
Jun 30, 2016
7373974
Excluding change for blocking blob storage account for restore
pragrawa Jun 30, 2016
75e0965
Merge branch 'release-01' of https://github.com/MabOneSdk/azure-power…
pragrawa Jun 30, 2016
31a8ab0
[RS Backup] Removed hardcoded location in vault tests
Jun 30, 2016
88d5e4d
Merge branch 'release-01' of https://github.com/MabOneSdk/azure-power…
Jun 30, 2016
d3a0349
[RS Backup] Returning single location instead of array of locations i…
Jun 30, 2016
f25a74c
[RS Backup] Making the vault location parameter local to test functions
Jun 30, 2016
268dd34
[RS Backup] Fixing a test issue - using absolute path when doing path…
Jun 30, 2016
7788f02
[RS Backup] bug fix - Get Recovery Point Id is returning incorrect Co…
Jul 1, 2016
9031dae
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
pragrawa Jul 1, 2016
923ee99
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
pragrawa Jul 2, 2016
b37107a
Fixing restore and recovery bugs https://microsoft.visualstudio.com/w…
mkherani Aug 9, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ public static List<RecoveryPointBase> GetPSAzureRecoveryPoints(

Dictionary<UriEnums, string> uriDict = HelperUtils.ParseUri(item.Id);
string containerUri = HelperUtils.GetContainerUri(uriDict, item.Id);
string protectedItemName = HelperUtils.GetProtectedItemUri(uriDict, item.Id);
string protectedItemUri = HelperUtils.GetProtectedItemUri(uriDict, item.Id);

string containerName = IdUtils.GetNameFromUri(containerUri);
string protectedItemName = IdUtils.GetNameFromUri(protectedItemUri);

List<RecoveryPointBase> result = new List<RecoveryPointBase>();
foreach (ServiceClientModel.RecoveryPointResource rp in rpList.RecoveryPointList.RecoveryPoints)
Expand All @@ -61,7 +64,7 @@ public static List<RecoveryPointBase> GetPSAzureRecoveryPoints(
RecoveryPointId = rp.Name,
BackupManagementType = item.BackupManagementType,
ItemName = protectedItemName,
ContainerName = containerUri,
ContainerName = containerName,
ContainerType = item.ContainerType,
RecoveryPointTime = recPointTime,
RecoveryPointType = recPoint.RecoveryPointType,
Expand All @@ -74,20 +77,7 @@ public static List<RecoveryPointBase> GetPSAzureRecoveryPoints(
recPoint.IsSourceVMEncrypted.Value : false,
IlrSessionActive = recPoint.IsInstantILRSessionActive,
};

if (rpBase.EncryptionEnabled)
{
rpBase.KeyAndSecretDetails = new KeyAndSecretDetails()
{
SecretUrl = recPoint.KeyAndSecret.BekDetails.SecretUrl,
KeyUrl = recPoint.KeyAndSecret.KekDetails.KeyUrl,
SecretData = recPoint.KeyAndSecret.BekDetails.SecretData,
KeyBackupData = recPoint.KeyAndSecret.KekDetails.KeyBackupData,
KeyVaultId = recPoint.KeyAndSecret.KekDetails.KeyVaultId,
SecretVaultId = recPoint.KeyAndSecret.BekDetails.SecretVaultId,
};
}


result.Add(rpBase);
}

Expand All @@ -106,7 +96,7 @@ public static List<RecoveryPointBase> GetPSAzureRecoveryPoints(
RecoveryPointId = rp.Name,
BackupManagementType = item.BackupManagementType,
ItemName = protectedItemName,
ContainerName = containerUri,
ContainerName = containerName,
ContainerType = item.ContainerType,
RecoveryPointTime = recPointTime,
RecoveryPointType = recPoint.RecoveryPointType,
Expand Down Expand Up @@ -169,9 +159,11 @@ public static RecoveryPointBase GetPSAzureRecoveryPoints(
EncryptionEnabled = recPoint.IsSourceVMEncrypted.HasValue ?
recPoint.IsSourceVMEncrypted.Value : false,
IlrSessionActive = recPoint.IsInstantILRSessionActive,
SourceResourceId = item.SourceResourceId,
SourceVMStorageType = recPoint.SourceVMStorageType,
};

if (vmResult.EncryptionEnabled)
if (vmResult.EncryptionEnabled && recPoint.KeyAndSecret != null)
{
vmResult.KeyAndSecretDetails = new KeyAndSecretDetails()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ public CmdletModel.RecoveryPointBase GetRecoveryPointDetails()
queryFilter.StartDate = CommonHelpers.GetDateTimeStringForService(startDate);
queryFilter.EndDate = CommonHelpers.GetDateTimeStringForService(endDate);
RecoveryPointListResponse rpListResponse = null;

rpListResponse = ServiceClientAdapter.GetRecoveryPoints(containerUri, protectedItemName, queryFilter);
return RecoveryPointConversions.GetPSAzureRecoveryPoints(rpListResponse, item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
using Microsoft.Azure.Commands.RecoveryServices.Backup.Helpers;
using Microsoft.Azure.Commands.RecoveryServices.Backup.Properties;
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
using System;
using System.Collections.Generic;
using System.IO;

namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.ServiceClientAdapterNS
Expand All @@ -35,16 +37,19 @@ public BaseRecoveryServicesJobResponse RestoreDisk(AzureVmRecoveryPoint rp, stri
{
string resourceGroupName = BmsAdapter.GetResourceGroupName();
string resourceName = BmsAdapter.GetResourceName();
string vaultLocation = BmsAdapter.GetResourceLocation();
string containerName = rp.ContainerName;
string protectedItemName = rp.ItemName;
string vaultLocation = BmsAdapter.GetResourceLocation();

Dictionary<UriEnums, string> uriDict = HelperUtils.ParseUri(rp.Id);
string containerUri = HelperUtils.GetContainerUri(uriDict, rp.Id);
string protectedItemUri = HelperUtils.GetProtectedItemUri(uriDict, rp.Id);

string recoveryPointId = rp.RecoveryPointId;
//validtion block
if(storageAccountLocation != vaultLocation)
{
throw new Exception(Resources.RestoreDiskIncorrectRegion);
}
string vmType = containerName.Split(';')[1].Equals("iaasvmcontainer", StringComparison.OrdinalIgnoreCase)
string vmType = containerUri.Split(';')[1].Equals("iaasvmcontainer", StringComparison.OrdinalIgnoreCase)
? "Classic" : "Compute";
string strType = storageAccountType.Equals("Microsoft.ClassicStorage/StorageAccounts",
StringComparison.OrdinalIgnoreCase) ? "Classic" : "Compute";
Expand All @@ -63,18 +68,6 @@ public BaseRecoveryServicesJobResponse RestoreDisk(AzureVmRecoveryPoint rp, stri
SourceResourceId = rp.SourceResourceId,
};

if (rp.EncryptionEnabled)
{
restoreRequest.EncryptionDetails = new EncryptionDetails()
{
EncryptionEnabled = rp.EncryptionEnabled,
KekUrl = rp.KeyAndSecretDetails.KeyUrl,
KekVaultId = rp.KeyAndSecretDetails.KeyVaultId,
SecretKeyUrl = rp.KeyAndSecretDetails.SecretUrl,
SecretKeyVaultId = rp.KeyAndSecretDetails.SecretVaultId,
};
}

TriggerRestoreRequest triggerRestoreRequest = new TriggerRestoreRequest();
triggerRestoreRequest.Item = new RestoreRequestResource();
triggerRestoreRequest.Item.Properties = new RestoreRequest();
Expand All @@ -85,8 +78,8 @@ public BaseRecoveryServicesJobResponse RestoreDisk(AzureVmRecoveryPoint rp, stri
resourceName,
BmsAdapter.GetCustomRequestHeaders(),
AzureFabricName,
containerName,
protectedItemName,
containerUri,
protectedItemUri,
recoveryPointId,
triggerRestoreRequest,
BmsAdapter.CmdletCancellationToken).Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
<Project>{5ee72c53-1720-4309-b54b-5fb79703195f}</Project>
<Name>Commands.Common</Name>
</ProjectReference>
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Helpers\Commands.RecoveryServices.Backup.Helpers.csproj">
<Project>{0e1d3f36-e6c8-4764-8c7d-6f9ee537490c}</Project>
<Name>Commands.RecoveryServices.Backup.Helpers</Name>
</ProjectReference>
<ProjectReference Include="..\Commands.RecoveryServices.Backup.Models\Commands.RecoveryServices.Backup.Models.csproj">
<Project>{30b92759-50b3-494e-b9f0-ec9a2ce9d57b}</Project>
<Name>Commands.RecoveryServices.Backup.Models</Name>
Expand Down