Skip to content

Commit 9a83127

Browse files
committed
2 parents 9b534b7 + a03c42d commit 9a83127

File tree

9 files changed

+137
-13
lines changed

9 files changed

+137
-13
lines changed

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
@@ -36,7 +36,7 @@ public class AzureRmRecoveryServicesBackupIaasVmItem : AzureRmRecoveryServicesBa
3636
/// <summary>
3737
/// Protection State of the item
3838
/// </summary>
39-
public ItemStatus ProtectionState { get; set; }
39+
public ItemProtectionState ProtectionState { get; set; }
4040

4141
/// <summary>
4242
/// Last Backup Status for the item
@@ -60,7 +60,7 @@ public AzureRmRecoveryServicesBackupIaasVmItem(ProtectedItemResource protectedIt
6060
AzureIaaSVMProtectedItem protectedItem = (AzureIaaSVMProtectedItem)protectedItemResource.Properties;
6161
LastBackupStatus = protectedItem.LastBackupStatus;
6262
ProtectionPolicyName = policyName;
63-
ProtectionState = EnumUtils.GetEnum<ItemStatus>(protectedItem.ProtectionState);
63+
ProtectionState = EnumUtils.GetEnum<ItemProtectionState>(protectedItem.ProtectionState);
6464
ProtectionStatus = EnumUtils.GetEnum<ItemProtectionStatus>(protectedItem.ProtectionStatus);
6565
VirtualMachineId = protectedItem.VirtualMachineId;
6666
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public enum ItemParams
7171
ParameterSetName,
7272
Container,
7373
ProtectionStatus,
74-
Status,
74+
ProtectionState,
7575
DeleteBackupData,
7676
ExpiryDate,
7777
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public enum ItemProtectionStatus
7272
Unhealthy,
7373
}
7474

75-
public enum ItemStatus
75+
public enum ItemProtectionState
7676
{
7777
IRPending = 1,
7878
ProtectionError,

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,4 +431,7 @@ Please contact Microsoft for further assistant.</value>
431431
<data name="UnsupportedContainerType" xml:space="preserve">
432432
<value>Unsupported containerType: {0}</value>
433433
</data>
434+
<data name="UnExpectedBackupManagementTypeException" xml:space="preserve">
435+
<value>Unexpected BackupManagementType - expected:{0}, current:{1}</value>
436+
</data>
434437
</root>

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public BaseRecoveryServicesJobResponse DisableProtection()
162162
}
163163

164164
properties.PolicyId = string.Empty;
165-
properties.ProtectionState = ItemStatus.ProtectionStopped.ToString();
165+
properties.ProtectionState = ItemProtectionState.ProtectionStopped.ToString();
166166

167167
ProtectedItemCreateOrUpdateRequest hydraRequest = new ProtectedItemCreateOrUpdateRequest()
168168
{
@@ -374,9 +374,16 @@ public ProtectionPolicyResponse ModifyPolicy()
374374

375375
public List<AzureRmRecoveryServicesBackupContainerBase> ListProtectionContainers()
376376
{
377+
Models.ContainerType containerType = (Models.ContainerType)this.ProviderData.ProviderParameters[ContainerParams.ContainerType];
378+
Models.BackupManagementType? backupManagementTypeNullable = (Models.BackupManagementType?)this.ProviderData.ProviderParameters[ContainerParams.BackupManagementType];
377379
string name = (string)this.ProviderData.ProviderParameters[ContainerParams.Name];
378-
ContainerRegistrationStatus status = (ContainerRegistrationStatus)this.ProviderData.ProviderParameters[ContainerParams.Status];
379380
string resourceGroupName = (string)this.ProviderData.ProviderParameters[ContainerParams.ResourceGroupName];
381+
ContainerRegistrationStatus status = (ContainerRegistrationStatus)this.ProviderData.ProviderParameters[ContainerParams.Status];
382+
383+
if (backupManagementTypeNullable.HasValue)
384+
{
385+
ValidateAzureVMBackupManagementType(backupManagementTypeNullable.Value);
386+
}
380387

381388
ProtectionContainerListQueryParams queryParams = new ProtectionContainerListQueryParams();
382389

@@ -418,7 +425,7 @@ public List<AzureRmRecoveryServicesBackupItemBase> ListProtectedItems()
418425
string name = (string)this.ProviderData.ProviderParameters[ItemParams.AzureVMName];
419426
ItemProtectionStatus protectionStatus =
420427
(ItemProtectionStatus)this.ProviderData.ProviderParameters[ItemParams.ProtectionStatus];
421-
ItemStatus status = (ItemStatus)this.ProviderData.ProviderParameters[ItemParams.Status];
428+
ItemProtectionState status = (ItemProtectionState)this.ProviderData.ProviderParameters[ItemParams.ProtectionState];
422429
Models.WorkloadType workloadType =
423430
(Models.WorkloadType)this.ProviderData.ProviderParameters[ItemParams.WorkloadType];
424431

@@ -658,6 +665,16 @@ private void ValidateAzureVMContainerType(Microsoft.Azure.Commands.RecoveryServi
658665
}
659666
}
660667

668+
private void ValidateAzureVMBackupManagementType(Models.BackupManagementType backupManagementType)
669+
{
670+
if (backupManagementType != Models.BackupManagementType.AzureVM)
671+
{
672+
throw new ArgumentException(string.Format(Resources.UnExpectedBackupManagementTypeException,
673+
Models.BackupManagementType.AzureVM.ToString(),
674+
backupManagementType.ToString()));
675+
}
676+
}
677+
661678
private void ValidateAzureVMProtectionPolicy(AzureRmRecoveryServicesBackupPolicyBase policy)
662679
{
663680
if (policy == null || policy.GetType() != typeof(AzureRmRecoveryServicesIaasVmPolicy))

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ function Test-GetItemScenario
3737
Assert-AreEqual $item.Name "iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1";
3838

3939
# VAR-4: Get items for container with Status filter
40-
$item = Get-AzureRmRecoveryServicesBackupItem -Container $namedContainer -WorkloadType "AzureVM" -Status "IRPending";
40+
$item = Get-AzureRmRecoveryServicesBackupItem -Container $namedContainer -WorkloadType "AzureVM" -ProtectionState "IRPending";
4141
Assert-AreEqual $item.Name "iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1";
4242

4343
# VAR-5: Get items for container with friendly name and ProtectionStatus filters
4444
$item = Get-AzureRmRecoveryServicesBackupItem -Container $namedContainer -WorkloadType "AzureVM" -Name "mkheraniRMVM1" -ProtectionStatus "Healthy";
4545
Assert-AreEqual $item.Name "iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1";
4646

4747
# VAR-6: Get items for container with friendly name and Status filters
48-
$item = Get-AzureRmRecoveryServicesBackupItem -Container $namedContainer -WorkloadType "AzureVM" -Name "mkheraniRMVM1" -Status "IRPending";
48+
$item = Get-AzureRmRecoveryServicesBackupItem -Container $namedContainer -WorkloadType "AzureVM" -Name "mkheraniRMVM1" -ProtectionState "IRPending";
4949
Assert-AreEqual $item.Name "iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1";
5050

5151
# VAR-7: Get items for container with Status and ProtectionStatus filters
52-
$item = Get-AzureRmRecoveryServicesBackupItem -Container $namedContainer -WorkloadType "AzureVM" -Status "IRPending" -ProtectionStatus "Healthy";
52+
$item = Get-AzureRmRecoveryServicesBackupItem -Container $namedContainer -WorkloadType "AzureVM" -ProtectionState "IRPending" -ProtectionStatus "Healthy";
5353
Assert-AreEqual $item.Name "iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1";
5454

5555
# VAR-8: Get items for container with friendly name, Status and ProtectionStatus filters
56-
$item = Get-AzureRmRecoveryServicesBackupItem -Container $namedContainer -WorkloadType "AzureVM" -Name "mkheraniRMVM1" -Status "IRPending" -ProtectionStatus "Healthy";
56+
$item = Get-AzureRmRecoveryServicesBackupItem -Container $namedContainer -WorkloadType "AzureVM" -Name "mkheraniRMVM1" -ProtectionState "IRPending" -ProtectionStatus "Healthy";
5757
Assert-AreEqual $item.Name "iaasvmcontainerv2;mkheranirmvm1;mkheranirmvm1";
5858
}
5959

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class GetAzureRmRecoveryServicesBackupItem : RecoveryServicesBackupCmdlet
4343

4444
[Parameter(Mandatory = false, HelpMessage = ParamHelpMsg.Item.Status)]
4545
[ValidateNotNullOrEmpty]
46-
public ItemStatus Status { get; set; }
46+
public ItemProtectionState ProtectionState { get; set; }
4747

4848
[Parameter(Mandatory = true, HelpMessage = ParamHelpMsg.Common.WorkloadType)]
4949
[ValidateNotNullOrEmpty]
@@ -60,7 +60,7 @@ public override void ExecuteCmdlet()
6060
{ItemParams.Container, Container},
6161
{ItemParams.AzureVMName, Name},
6262
{ItemParams.ProtectionStatus, ProtectionStatus},
63-
{ItemParams.Status, Status},
63+
{ItemParams.ProtectionState, ProtectionState},
6464
{ItemParams.WorkloadType, WorkloadType},
6565
}, HydraAdapter);
6666

src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup/Microsoft.Azure.Commands.RecoveryServices.Backup.format.ps1xml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,100 @@
191191
</TableRowEntries>
192192
</TableControl>
193193
</View>
194+
<View>
195+
<Name>Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.AzureRmRecoveryServicesBackupIaasVmContainer</Name>
196+
<ViewSelectedBy>
197+
<TypeName>Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.AzureRmRecoveryServicesBackupIaasVmContainer</TypeName>
198+
</ViewSelectedBy>
199+
<TableControl>
200+
<TableHeaders>
201+
<TableColumnHeader>
202+
<Label>Name</Label>
203+
<Width>40</Width>
204+
</TableColumnHeader>
205+
<TableColumnHeader>
206+
<Label>ResourceGroupName</Label>
207+
<Width>40</Width>
208+
</TableColumnHeader>
209+
<TableColumnHeader>
210+
<Label>Status</Label>
211+
<Width>20</Width>
212+
</TableColumnHeader>
213+
<TableColumnHeader>
214+
<Label>ContainerType</Label>
215+
<Width>20</Width>
216+
</TableColumnHeader>
217+
</TableHeaders>
218+
<TableRowEntries>
219+
<TableRowEntry>
220+
<TableColumnItems>
221+
<TableColumnItem>
222+
<PropertyName>Name</PropertyName>
223+
</TableColumnItem>
224+
<TableColumnItem>
225+
<PropertyName>ResourceGroupName</PropertyName>
226+
</TableColumnItem>
227+
<TableColumnItem>
228+
<PropertyName>Status</PropertyName>
229+
</TableColumnItem>
230+
<TableColumnItem>
231+
<PropertyName>ContainerType</PropertyName>
232+
</TableColumnItem>
233+
</TableColumnItems>
234+
</TableRowEntry>
235+
</TableRowEntries>
236+
</TableControl>
237+
</View>
238+
<View>
239+
<Name>Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.AzureRmRecoveryServicesBackupIaasVmItem</Name>
240+
<ViewSelectedBy>
241+
<TypeName>Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.AzureRmRecoveryServicesBackupIaasVmItem</TypeName>
242+
</ViewSelectedBy>
243+
<TableControl>
244+
<TableHeaders>
245+
<TableColumnHeader>
246+
<Label>Name</Label>
247+
<Width>40</Width>
248+
</TableColumnHeader>
249+
<TableColumnHeader>
250+
<Label>ContainerType</Label>
251+
<Width>20</Width>
252+
</TableColumnHeader>
253+
<TableColumnHeader>
254+
<Label>ContainerUniqueName</Label>
255+
<Width>40</Width>
256+
</TableColumnHeader>
257+
<TableColumnHeader>
258+
<Label>WorkloadType</Label>
259+
<Width>20</Width>
260+
</TableColumnHeader>
261+
<TableColumnHeader>
262+
<Label>ProtectionStatus</Label>
263+
<Width>20</Width>
264+
</TableColumnHeader>
265+
</TableHeaders>
266+
<TableRowEntries>
267+
<TableRowEntry>
268+
<TableColumnItems>
269+
<TableColumnItem>
270+
<PropertyName>Name</PropertyName>
271+
</TableColumnItem>
272+
<TableColumnItem>
273+
<PropertyName>ContainerType</PropertyName>
274+
</TableColumnItem>
275+
<TableColumnItem>
276+
<PropertyName>ContainerName</PropertyName>
277+
</TableColumnItem>
278+
<TableColumnItem>
279+
<PropertyName>WorkloadType</PropertyName>
280+
</TableColumnItem>
281+
<TableColumnItem>
282+
<PropertyName>ProtectionStatus</PropertyName>
283+
</TableColumnItem>
284+
</TableColumnItems>
285+
</TableRowEntry>
286+
</TableRowEntries>
287+
</TableControl>
288+
</View>
194289
</ViewDefinitions>
195290
</Configuration>

0 commit comments

Comments
 (0)