Skip to content

Commit b2dbb27

Browse files
committed
Merge branch 'dev1' into mkheranidev1
2 parents 6c2edcf + ec9c647 commit b2dbb27

File tree

10 files changed

+441
-330
lines changed

10 files changed

+441
-330
lines changed

setup/azurecmdfiles.wxi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,6 +2023,9 @@
20232023
<Component Id="cmpB5BF9FBFFC4EDD83B9F7135CF42CB617" Guid="*">
20242024
<File Id="fil64AAA98F94DB6985D3A60FF7570C5E4A" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\Microsoft.Azure.Commands.RecoveryServices.Backup.dll" />
20252025
</Component>
2026+
<Component Id="cmpC9D832735AB0EF3B4F1309E307393863" Guid="*">
2027+
<File Id="filD8627CE27070E2BB01C54678020911BB" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\Microsoft.Azure.Commands.RecoveryServices.Backup.dll-help.xml" />
2028+
</Component>
20262029
<Component Id="cmp7E42CC4AEA15FEF46E621AD38CC09F5A" Guid="*">
20272030
<File Id="filB3BB12CA661C1C8E6E7BE93BD77D781D" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RecoveryServices.Backup\Microsoft.Azure.Commands.RecoveryServices.Backup.format.ps1xml" />
20282031
</Component>
@@ -5721,6 +5724,7 @@
57215724
<ComponentRef Id="cmp787B2B1E92B4AEF145134D74C17913C9" />
57225725
<ComponentRef Id="cmpE5C4E7687DB1C6113A30F1D9CE41182F" />
57235726
<ComponentRef Id="cmpB5BF9FBFFC4EDD83B9F7135CF42CB617" />
5727+
<ComponentRef Id="cmpC9D832735AB0EF3B4F1309E307393863" />
57245728
<ComponentRef Id="cmp7E42CC4AEA15FEF46E621AD38CC09F5A" />
57255729
<ComponentRef Id="cmpB7B864E9C70EE65B799C79119DF7E80B" />
57265730
<ComponentRef Id="cmp298EE60DD6AAA12C33CA9E9EDDE4D674" />

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public static List<AzureRmRecoveryServicesBackupPolicyBase> GetPolicyModelList(
178178

179179
#region Item
180180

181-
public static AzureRmRecoveryServicesBackupItemBase GetItemModel(ProtectedItemResource protectedItem, AzureRmRecoveryServicesBackupContainerBase container)
181+
public static AzureRmRecoveryServicesBackupItemBase GetItemModel(ProtectedItemResource protectedItem)
182182
{
183183
AzureRmRecoveryServicesBackupItemBase itemModel = null;
184184

@@ -195,25 +195,33 @@ public static AzureRmRecoveryServicesBackupItemBase GetItemModel(ProtectedItemRe
195195
HelperUtils.ParseUri(policyId);
196196
policyName = HelperUtils.GetPolicyNameFromPolicyId(keyValueDict, policyId);
197197
}
198-
itemModel = new AzureRmRecoveryServicesBackupIaasVmItem(protectedItem, container, policyName);
198+
199+
string containerUri = HelperUtils.GetContainerUri(
200+
HelperUtils.ParseUri(protectedItem.Id),
201+
protectedItem.Id);
202+
203+
itemModel = new AzureRmRecoveryServicesBackupIaasVmItem(
204+
protectedItem,
205+
IdUtils.GetNameFromUri(containerUri),
206+
Cmdlets.Models.ContainerType.AzureVM,
207+
policyName);
199208
}
200209
}
201210

202211
return itemModel;
203212
}
204213

205-
public static List<AzureRmRecoveryServicesBackupItemBase> GetItemModelList(IEnumerable<ProtectedItemResource> protectedItems, AzureRmRecoveryServicesBackupContainerBase container)
214+
public static List<AzureRmRecoveryServicesBackupItemBase> GetItemModelList(IEnumerable<ProtectedItemResource> protectedItems)
206215
{
207216
List<AzureRmRecoveryServicesBackupItemBase> itemModels = new List<AzureRmRecoveryServicesBackupItemBase>();
208217

209218
foreach (var protectedItem in protectedItems)
210219
{
211-
itemModels.Add(GetItemModel(protectedItem, container));
220+
itemModels.Add(GetItemModel(protectedItem));
212221
}
213222

214223
return itemModels;
215224
}
216-
217225
#endregion
218226
}
219227
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/AzureVmModels/AzureRmRecoveryServicesAzureVmItem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public class AzureRmRecoveryServicesBackupIaasVmItem : AzureRmRecoveryServicesBa
5454
public AzureRmRecoveryServicesBackupIaasVmItemExtendedInfo ExtendedInfo { get; set; }
5555

5656
public AzureRmRecoveryServicesBackupIaasVmItem(ProtectedItemResource protectedItemResource,
57-
AzureRmRecoveryServicesBackupContainerBase container, string policyName)
58-
: base(protectedItemResource, container)
57+
string containerName, ContainerType containerType, string policyName)
58+
: base(protectedItemResource, containerName, containerType)
5959
{
6060
AzureIaaSVMProtectedItem protectedItem = (AzureIaaSVMProtectedItem)protectedItemResource.Properties;
6161
LastBackupStatus = protectedItem.LastBackupStatus;

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/BaseObjects.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ public AzureRmRecoveryServicesBackupContainerContext(ContainerType containerType
5050
{
5151
ContainerType = containerType;
5252
}
53+
54+
public AzureRmRecoveryServicesBackupContainerContext(string backupManagementType)
55+
: base(backupManagementType)
56+
{
57+
58+
}
5359
}
5460

5561
public class AzureRmRecoveryServicesBackupEngineContext : AzureRmRecoveryServicesBackupManagementContext
@@ -117,11 +123,11 @@ public AzureRmRecoveryServicesBackupItemContext()
117123
}
118124

119125
public AzureRmRecoveryServicesBackupItemContext(ProtectedItem protectedItem,
120-
AzureRmRecoveryServicesBackupContainerBase container)
121-
: base(container.ContainerType, protectedItem.BackupManagementType)
126+
string containerName, ContainerType containerType)
127+
: base(containerType, protectedItem.BackupManagementType)
122128
{
123129
WorkloadType = ConversionUtils.GetPsWorkloadType(protectedItem.WorkloadType);
124-
ContainerName = container.Name;
130+
ContainerName = containerName;
125131
}
126132
}
127133

@@ -146,8 +152,8 @@ public class AzureRmRecoveryServicesBackupItemBase : AzureRmRecoveryServicesBack
146152
public DateTime? LatestRecoveryPoint { get; set; }
147153

148154
public AzureRmRecoveryServicesBackupItemBase(ProtectedItemResource protectedItemResource,
149-
AzureRmRecoveryServicesBackupContainerBase container)
150-
: base((ProtectedItem)protectedItemResource.Properties, container)
155+
string containerName, ContainerType containerType)
156+
: base((ProtectedItem)protectedItemResource.Properties, containerName, containerType)
151157
{
152158
ProtectedItem protectedItem = (ProtectedItem)protectedItemResource.Properties;
153159
Name = protectedItemResource.Name;

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/CmdletParamEnums.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,6 @@ public enum ItemParams
7373
ProtectionStatus,
7474
ProtectionState,
7575
DeleteBackupData,
76+
BackupManagementType,
7677
}
7778
}

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/Providers/IaasVmPsBackupProvider.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public List<AzureRmRecoveryServicesBackupContainerBase> ListProtectionContainers
397397
{
398398
queryParams.RegistrationStatus = status.ToString();
399399
}
400-
400+
401401
var listResponse = HydraAdapter.ListContainers(queryParams);
402402

403403
List<AzureRmRecoveryServicesBackupContainerBase> containerModels = ConversionHelpers.GetContainerModelList(listResponse);
@@ -449,12 +449,15 @@ public List<AzureRmRecoveryServicesBackupItemBase> ListProtectedItems()
449449
} while (skipToken != null);
450450

451451
// 1. Filter by container
452-
protectedItems = protectedItems.Where(protectedItem =>
452+
if (container != null)
453453
{
454-
Dictionary<UriEnums, string> dictionary = HelperUtils.ParseUri(protectedItem.Id);
455-
string containerUri = HelperUtils.GetContainerUri(dictionary, protectedItem.Id);
456-
return containerUri.Contains(container.Name);
457-
}).ToList();
454+
protectedItems = protectedItems.Where(protectedItem =>
455+
{
456+
Dictionary<UriEnums, string> dictionary = HelperUtils.ParseUri(protectedItem.Id);
457+
string containerUri = HelperUtils.GetContainerUri(dictionary, protectedItem.Id);
458+
return containerUri.Contains(container.Name);
459+
}).ToList();
460+
}
458461

459462
List<ProtectedItemResponse> protectedItemGetResponses = new List<ProtectedItemResponse>();
460463

@@ -482,7 +485,7 @@ public List<AzureRmRecoveryServicesBackupItemBase> ListProtectedItems()
482485
}
483486
}
484487

485-
List<AzureRmRecoveryServicesBackupItemBase> itemModels = ConversionHelpers.GetItemModelList(protectedItems, container);
488+
List<AzureRmRecoveryServicesBackupItemBase> itemModels = ConversionHelpers.GetItemModelList(protectedItems);
486489

487490
if (!string.IsNullOrEmpty(name))
488491
{

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup/Cmdlets/Item/GetAzureRmRecoveryServicesItem.cs

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,33 @@ namespace Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets
2626
/// <summary>
2727
/// Get list of items
2828
/// </summary>
29-
[Cmdlet(VerbsCommon.Get, "AzureRmRecoveryServicesBackupItem"), OutputType(typeof(AzureRmRecoveryServicesBackupItemBase))]
29+
[Cmdlet(VerbsCommon.Get, "AzureRmRecoveryServicesBackupItem", DefaultParameterSetName = GetItemsForContainerParamSet), OutputType(typeof(AzureRmRecoveryServicesBackupItemBase))]
3030
public class GetAzureRmRecoveryServicesBackupItem : RecoveryServicesBackupCmdletBase
3131
{
32-
[Parameter(Mandatory = true, HelpMessage = ParamHelpMsg.Item.Container)]
32+
internal const string GetItemsForContainerParamSet = "GetItemsForContainer";
33+
internal const string GetItemsForVaultParamSet = "GetItemsForVault";
34+
35+
[Parameter(Mandatory = true, Position = 1, HelpMessage = ParamHelpMsg.Item.Container, ParameterSetName = GetItemsForContainerParamSet)]
3336
[ValidateNotNullOrEmpty]
3437
public AzureRmRecoveryServicesBackupContainerBase Container { get; set; }
3538

36-
[Parameter(Mandatory = false, HelpMessage = ParamHelpMsg.Item.AzureVMName)]
39+
[Parameter(Mandatory = true, Position = 1, HelpMessage = ParamHelpMsg.Common.BackupManagementType, ParameterSetName = GetItemsForVaultParamSet)]
40+
[ValidateNotNullOrEmpty]
41+
public BackupManagementType BackupManagementType { get; set; }
42+
43+
[Parameter(Mandatory = false, Position = 2, HelpMessage = ParamHelpMsg.Item.AzureVMName)]
3744
[ValidateNotNullOrEmpty]
3845
public string Name { get; set; }
3946

40-
[Parameter(Mandatory = false, HelpMessage = ParamHelpMsg.Item.ProtectionStatus)]
47+
[Parameter(Mandatory = false, Position = 3, HelpMessage = ParamHelpMsg.Item.ProtectionStatus)]
4148
[ValidateNotNullOrEmpty]
4249
public ItemProtectionStatus ProtectionStatus { get; set; }
4350

44-
[Parameter(Mandatory = false, HelpMessage = ParamHelpMsg.Item.Status)]
51+
[Parameter(Mandatory = false, Position = 4, HelpMessage = ParamHelpMsg.Item.Status)]
4552
[ValidateNotNullOrEmpty]
4653
public ItemProtectionState ProtectionState { get; set; }
4754

48-
[Parameter(Mandatory = true, HelpMessage = ParamHelpMsg.Common.WorkloadType)]
55+
[Parameter(Mandatory = true, Position = 5, HelpMessage = ParamHelpMsg.Common.WorkloadType)]
4956
[ValidateNotNullOrEmpty]
5057
public WorkloadType WorkloadType { get; set; }
5158

@@ -58,14 +65,25 @@ public override void ExecuteCmdlet()
5865
PsBackupProviderManager providerManager = new PsBackupProviderManager(new Dictionary<System.Enum, object>()
5966
{
6067
{ItemParams.Container, Container},
68+
{ItemParams.BackupManagementType, BackupManagementType},
6169
{ItemParams.AzureVMName, Name},
6270
{ItemParams.ProtectionStatus, ProtectionStatus},
6371
{ItemParams.ProtectionState, ProtectionState},
6472
{ItemParams.WorkloadType, WorkloadType},
6573
}, HydraAdapter);
6674

67-
IPsBackupProvider psBackupProvider = providerManager.GetProviderInstance(WorkloadType,
75+
IPsBackupProvider psBackupProvider = null;
76+
77+
if (this.ParameterSetName == GetItemsForVaultParamSet)
78+
{
79+
psBackupProvider = providerManager.GetProviderInstance(WorkloadType, BackupManagementType);
80+
}
81+
else
82+
{
83+
psBackupProvider = providerManager.GetProviderInstance(WorkloadType,
6884
(Container as AzureRmRecoveryServicesBackupManagementContext).BackupManagementType);
85+
}
86+
6987
var itemModels = psBackupProvider.ListProtectedItems();
7088

7189
if (itemModels.Count == 1)

0 commit comments

Comments
 (0)