Skip to content

Commit f714328

Browse files
author
dragonfly91
committed
Fix for bug "Should not allow other BackupManagementTypes when ContainerType is AzureVM"
1 parent cc6c69d commit f714328

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

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: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

@@ -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))

0 commit comments

Comments
 (0)