Skip to content

Commit af55393

Browse files
authored
[Az.RecoveryServices.Backup] Fixed issues with StorageConfig (#16003)
* fixed issues with StorageConfig added NodesList and AutoProtectionPolicy to Get-AzRecoveryServicesBackupProtectableItem Cmdlets fixed GetItemsForContainerParamSet to support fetching the MAB backup item fixed Get-AzRecoveryServicesBackupContainer to support BackupManagementType MAB instead of MARS [Breaking Change Warning] Get-AzRecoveryServicesBackupJob, Get-AzRecoveryServicesBackupContainer and Get-AzRecoveryServicesBackupProtectableItem commands will only support BackupManagementType MAB instead of MARS alias re-recorded the test ContainerTests * update breaking version * updated ChangeLog.md
1 parent 9878e5d commit af55393

File tree

57 files changed

+44123
-73559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+44123
-73559
lines changed

src/RecoveryServices/RecoveryServices.Backup.Helpers/Conversions/ConversionHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ public static List<ProtectableItemBase> GetProtectableItemModelList(IEnumerable<
669669
List<ProtectableItemBase> itemModels = new List<ProtectableItemBase>();
670670

671671
foreach (var protectableItem in protectableItems)
672-
{
672+
{
673673
itemModels.Add(GetProtectableItemModel(protectableItem));
674674
}
675675

src/RecoveryServices/RecoveryServices.Backup.Helpers/RecoveryServices.Backup.Helpers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.9-preview" />
15+
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.2.0-preview" />
1616
<PackageReference Include="TimeZoneConverter" Version="3.0.0" />
1717
</ItemGroup>
1818

src/RecoveryServices/RecoveryServices.Backup.Models/AzureVmWorkloadModels/AzureVmWorkloadContainer.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public class AzureVmWorkloadContainer : AzureContainer
3737
/// </summary>
3838
public string HealthStatus { get; set; }
3939

40+
/// <summary>
41+
/// Gets or sets host server name of the container.
42+
/// </summary>
43+
public string ServerName { get; set; }
44+
4045
/// <summary>
4146
/// Gets or sets additional details of a workload container.
4247
/// </summary>
@@ -56,6 +61,12 @@ public AzureVmWorkloadContainer(ProtectionContainerResource protectionContainerR
5661
Id = protectionContainerResource.Id;
5762
SourceResourceId = protectionContainer.SourceResourceId;
5863
HealthStatus = protectionContainer.HealthStatus;
64+
65+
if(protectionContainer.ExtendedInfo != null)
66+
{
67+
ServerName = protectionContainer.ExtendedInfo.HostServerName;
68+
}
69+
5970
ExtendedInfo = new List<AzureVmWorkloadContainerExtendedInfo>();
6071
WorkloadsPresent = "";
6172
foreach (var inquiryDetail in protectionContainer.ExtendedInfo.InquiryInfo.InquiryDetails)

src/RecoveryServices/RecoveryServices.Backup.Models/AzureVmWorkloadModels/AzureWorkloadProtectableItem.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.Azure.Management.RecoveryServices.Backup.Models;
16+
using System.Collections.Generic;
1617
using CmdletModel = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models;
1718

1819
namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models
@@ -63,6 +64,11 @@ public class AzureWorkloadProtectableItem : ProtectableItemBase
6364
/// </summary>
6465
public bool? IsAutoProtected { get; set; }
6566

67+
/// <summary>
68+
/// Auto protection policy for protectable item
69+
/// </summary>
70+
public string AutoProtectionPolicy { get; set; }
71+
6672
/// <summary>
6773
/// for instance or AG, indicates number of DB's present
6874
/// </summary>
@@ -78,6 +84,11 @@ public class AzureWorkloadProtectableItem : ProtectableItemBase
7884
/// </summary>
7985
public PreBackupValidation Prebackupvalidation { get; set; }
8086

87+
/// <summary>
88+
/// NodesList for SQLAG protectable objects
89+
/// </summary>
90+
public IList<DistributedNodesInfo> NodesList { get; set; }
91+
8192
/// <summary>
8293
/// Constructor. Takes the service client object representing the protected item
8394
/// and converts it in to the PS protected item model
@@ -100,7 +111,8 @@ public AzureWorkloadProtectableItem(WorkloadProtectableItemResource workloadProt
100111
Subinquireditemcount = protectedItem.Subinquireditemcount;
101112
Subprotectableitemcount = protectedItem.Subprotectableitemcount;
102113
Prebackupvalidation = protectedItem.Prebackupvalidation;
103-
ProtectableItemType = workloadProtectableItemResource.Properties.GetType().ToString();
114+
ProtectableItemType = workloadProtectableItemResource.Properties.GetType().ToString();
115+
104116
if (workloadProtectableItemResource.Properties.GetType() == typeof(AzureVmWorkloadSQLAvailabilityGroupProtectableItem))
105117
{
106118
ProtectableItemType = CmdletModel.ProtectableItemType.SQLAvailabilityGroup.ToString();
@@ -112,7 +124,7 @@ public AzureWorkloadProtectableItem(WorkloadProtectableItemResource workloadProt
112124
else if (workloadProtectableItemResource.Properties.GetType() == typeof(AzureVmWorkloadSQLDatabaseProtectableItem))
113125
{
114126
ProtectableItemType = CmdletModel.ProtectableItemType.SQLDataBase.ToString();
115-
}
127+
}
116128
}
117129
}
118130
}

src/RecoveryServices/RecoveryServices.Backup.Models/CommonModels/Enums.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public enum BackupManagementType
8787
MAB,
8888

8989
/// <summary>
90-
/// represents that the BackupManagementType is Not Applicable.
90+
/// Represents that the BackupManagementType is Not Applicable.
9191
/// </summary>
9292
NA
9393
}

src/RecoveryServices/RecoveryServices.Backup.Models/RecoveryServices.Backup.Models.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.9-preview" />
15+
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.2.0-preview" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

src/RecoveryServices/RecoveryServices.Backup.Providers/AzureWorkloadProviderHelper.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,19 +620,32 @@ public void TriggerInquiry(string vaultName, string vaultResourceGroupName,
620620
}
621621
}
622622

623-
public List<ItemBase> GetMABProtectedItems(string vaultName, string resourceGroupName)
623+
public List<ItemBase> GetMABProtectedItems(string vaultName, string resourceGroupName, ContainerBase container = null)
624624
{
625625
ODataQuery<ProtectedItemQueryObject> queryParams =
626626
new ODataQuery<ProtectedItemQueryObject>(
627-
q => q.BackupManagementType == ServiceClientModel.BackupManagementType.MAB);
628-
627+
q => q.BackupManagementType == ServiceClientModel.BackupManagementType.MAB);
629628

630629
List<ProtectedItemResource> protectedItems = ServiceClientAdapter.ListProtectedItem(
631630
queryParams,
632631
null,
633632
vaultName: vaultName,
634633
resourceGroupName: resourceGroupName);
635634

635+
// filter by Container Name if given
636+
if (container != null)
637+
{
638+
protectedItems = protectedItems.Where(protectedItem =>
639+
{
640+
Dictionary<CmdletModel.UriEnums, string> dictionary = HelperUtils.ParseUri(protectedItem.Id);
641+
string containerUri = HelperUtils.GetContainerUri(dictionary, protectedItem.Id);
642+
643+
var delimIndex = containerUri.IndexOf(';');
644+
string containerName = containerUri.Substring(delimIndex + 1);
645+
return containerName.ToLower().Equals(container.Name.ToLower());
646+
}).ToList();
647+
}
648+
636649
return ConversionHelpers.GetItemModelList(protectedItems);
637650
}
638651
}

src/RecoveryServices/RecoveryServices.Backup.Providers/PsBackupProviderManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public IPsBackupProvider GetProviderInstance
7373
}
7474
break;
7575
case ContainerType.Windows:
76-
if (backupManagementType == BackupManagementType.MARS)
76+
if (backupManagementType == BackupManagementType.MARS || backupManagementType == BackupManagementType.MAB)
7777
{
7878
providerType = PsBackupProviderTypes.Mab;
7979
}

src/RecoveryServices/RecoveryServices.Backup.Providers/RecoveryServices.Backup.Providers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.9-preview" />
15+
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.2.0-preview" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

src/RecoveryServices/RecoveryServices.Backup.ServiceClientAdapter/BMSAPIs/ContainerAPIs.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,28 @@ public IEnumerable<ProtectionContainerResource> ListContainers(
7272
return HelperUtils.GetPagedList(listAsync, listNextAsync);
7373
}
7474

75+
/// <summary>
76+
/// Fetches a particular protection container in the vault
77+
/// </summary>
78+
/// <param name="vaultName"></param>
79+
/// <param name="resourceGroupName"></param>
80+
/// <param name="containerName"></param>
81+
/// <returns></returns>
82+
public ProtectionContainerResource GetContainer(
83+
string vaultName = null,
84+
string resourceGroupName = null,
85+
string containerName = null)
86+
{
87+
ProtectionContainerResource container = BmsAdapter.Client.ProtectionContainers.GetWithHttpMessagesAsync(
88+
vaultName ?? BmsAdapter.GetResourceName(),
89+
resourceGroupName ?? BmsAdapter.GetResourceGroupName(),
90+
AzureFabricName,
91+
containerName,
92+
cancellationToken: BmsAdapter.CmdletCancellationToken).Result.Body;
93+
94+
return container;
95+
}
96+
7597
/// <summary>
7698
/// Fetches backup engines in the vault according to the query params
7799
/// </summary>

0 commit comments

Comments
 (0)