From 018e0a02e9ecd41f0015421aff98ab79221c3cbb Mon Sep 17 00:00:00 2001 From: ayfathim Date: Mon, 15 Jul 2019 11:55:07 +0530 Subject: [PATCH 01/14] removeDisk changes --- .../Accounts/AzureRmAlias/Mappings.json | 2 + .../ScenarioTests/A2A/AsrA2ATests.cs | 14 ++ .../Models/PSEvent.cs | 12 ++ ...ServicesAsrReplicationProtectedItemDisk.cs | 145 ++++++++++++++++++ ...sAsrReplicationProtectedItemHealthError.cs | 145 ++++++++++++++++++ 5 files changed, 318 insertions(+) create mode 100644 src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk.cs create mode 100644 src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs diff --git a/src/Accounts/Accounts/AzureRmAlias/Mappings.json b/src/Accounts/Accounts/AzureRmAlias/Mappings.json index 70289417f95e..ff0d9a7b7a70 100644 --- a/src/Accounts/Accounts/AzureRmAlias/Mappings.json +++ b/src/Accounts/Accounts/AzureRmAlias/Mappings.json @@ -1830,6 +1830,8 @@ "Remove-AzRecoveryServicesAsrProtectionContainerMapping": "Remove-AzureRmRecoveryServicesAsrProtectionContainerMapping", "Remove-AzRecoveryServicesAsrRecoveryPlan": "Remove-AzureRmRecoveryServicesAsrRecoveryPlan", "Remove-AzRecoveryServicesAsrReplicationProtectedItem": "Remove-AzureRmRecoveryServicesAsrReplicationProtectedItem", + "Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk": "Remove-AzureRmRecoveryServicesAsrReplicationProtectedItemDisk", + "Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError": "Remove-AzureRmRecoveryServicesAsrReplicationProtectedItemHealthError", "Remove-AzRecoveryServicesAsrServicesProvider": "Remove-AzureRmRecoveryServicesAsrServicesProvider", "Remove-AzRecoveryServicesAsrStorageClassificationMapping": "Remove-AzureRmRecoveryServicesAsrStorageClassificationMapping", "Remove-AzRecoveryServicesAsrvCenter": "Remove-AzureRmRecoveryServicesAsrvCenter", diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.cs b/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.cs index 6e1bfdf78d40..3cccff3ee05a 100644 --- a/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.cs +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.cs @@ -81,5 +81,19 @@ public void A2ANewAsrReplicationProtectedItemDisk() { this.RunPowerShellTest(_logger, Constants.NewModel, "Test-AddReplicationProtectedItemDisk"); } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void A2ARemoveReplicationProtectedItemDisk() + { + this.RunPowerShellTest(_logger, Constants.NewModel, "Test-RemoveReplicationProtectedItemDisk"); + } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void A2ARemoveReplicationProtectedItemHealthError() + { + this.RunPowerShellTest(_logger, Constants.NewModel, "Test-ResolveHealthError"); + } } } diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery/Models/PSEvent.cs b/src/RecoveryServices/RecoveryServices.SiteRecovery/Models/PSEvent.cs index 64c191ea6a6f..122b58e53f96 100644 --- a/src/RecoveryServices/RecoveryServices.SiteRecovery/Models/PSEvent.cs +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery/Models/PSEvent.cs @@ -213,6 +213,8 @@ public ASRHealthError(HealthError healthError) this.ErrorMessage = healthError.ErrorMessage; this.PossibleCauses = healthError.PossibleCauses; this.RecommendedAction = healthError.RecommendedAction; + this.ErrorId = healthError.ErrorId; + this.CustomerResolvability = healthError.CustomerResolvability; this.RecoveryProviderErrorMessage = healthError.RecoveryProviderErrorMessage; } @@ -255,6 +257,16 @@ public ASRHealthError(HealthError healthError) /// Recovery Provider error message. /// public string RecoveryProviderErrorMessage { get; set; } + + /// + /// Id of error. + /// + public string ErrorId { get; set; } + + /// + /// CustomerResolvability of error. + /// + public string CustomerResolvability { get; set; } } /// diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk.cs b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk.cs new file mode 100644 index 000000000000..a1e81ee38c09 --- /dev/null +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk.cs @@ -0,0 +1,145 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System.Management.Automation; +using System.Collections.Generic; +using Microsoft.Azure.Management.RecoveryServices.SiteRecovery.Models; +using Job = Microsoft.Azure.Management.RecoveryServices.SiteRecovery.Models.Job; + +namespace Microsoft.Azure.Commands.RecoveryServices.SiteRecovery +{ + /// + /// Adds disks to replication protected item. + /// + [Cmdlet("Add", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RecoveryServicesAsrReplicationProtectedItemDisk", + DefaultParameterSetName = ASRParameterSets.EnterpriseToEnterprise, + SupportsShouldProcess = true)] + [Alias("Add-ASRReplicationProtectedItemDisk")] + [OutputType(typeof(ASRJob))] + public class AddAzureRmRecoveryServicesAsrReplicationProtectedItemDisk : SiteRecoveryCmdletBase + { + [Parameter(Mandatory = true, ValueFromPipeline = true)] + [ValidateNotNullOrEmpty] + [Alias("ReplicationProtectedItem")] + public ASRReplicationProtectedItem InputObject { get; set; } + + [ValidateNotNullOrEmpty] + [Parameter(Mandatory = true)] + public ASRAzuretoAzureDiskReplicationConfig[] AzureToAzureDiskReplicationConfiguration { get; set; } + + [Parameter] + public SwitchParameter WaitForCompletion { get; set; } + + /// + /// ProcessRecord of the command. + /// + public override void ExecuteSiteRecoveryCmdlet() + { + base.ExecuteSiteRecoveryCmdlet(); + if (ShouldProcess(this.InputObject.FriendlyName, VerbsCommon.Add)) + { + // check for A2A protected item - if providerSpecificDetails is A2AReplicationDetails. + + var addDisksProviderSpecificInput = new AddDisksProviderSpecificInput(); + var inputProperties = new AddDisksInputProperties + { + ProviderSpecificDetails = addDisksProviderSpecificInput + }; + var input = new AddDisksInput { Properties = inputProperties }; + AzureToAzureReplication(input); + + this.response = this.RecoveryServicesClient.AddDisks( + Utilities.GetValueFromArmId( + this.InputObject.ID, + ARMResourceTypeConstants.ReplicationFabrics), + Utilities.GetValueFromArmId( + this.InputObject.ID, + ARMResourceTypeConstants.ReplicationProtectionContainers), + this.InputObject.Name, + input); + + this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( + PSRecoveryServicesClient.GetJobIdFromReponseLocation(this.response.Location)); + + this.WriteObject(new ASRJob(this.jobResponse)); + + if (this.WaitForCompletion.IsPresent) + { + this.WaitForJobCompletion(this.jobResponse.Name); + + this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( + PSRecoveryServicesClient + .GetJobIdFromReponseLocation(this.response.Location)); + + this.WriteObject(new ASRJob(this.jobResponse)); + } + } + } + + /// + /// Helper method to fill in input details. + /// + private void AzureToAzureReplication(AddDisksInput input) + { + var providerSettings = new A2AAddDisksInput() + { + VmDisks = new List(), + VmManagedDisks = new List() + }; + + foreach (ASRAzuretoAzureDiskReplicationConfig disk in this.AzureToAzureDiskReplicationConfiguration) + { + if (disk.IsManagedDisk) + { + providerSettings.VmManagedDisks.Add(new A2AVmManagedDiskInputDetails + { + DiskId = disk.DiskId, + RecoveryResourceGroupId = disk.RecoveryResourceGroupId, + PrimaryStagingAzureStorageAccountId = disk.LogStorageAccountId, + RecoveryReplicaDiskAccountType = disk.RecoveryReplicaDiskAccountType, + RecoveryTargetDiskAccountType = disk.RecoveryTargetDiskAccountType + }); + } + else + { + providerSettings.VmDisks.Add(new A2AVmDiskInputDetails + { + DiskUri = disk.VhdUri, + RecoveryAzureStorageAccountId = disk.RecoveryAzureStorageAccountId, + PrimaryStagingAzureStorageAccountId = disk.LogStorageAccountId + }); + } + } + + input.Properties.ProviderSpecificDetails = providerSettings; + } + + /// + /// Writes Job. + /// + /// Job object. + private void WriteJob( + Job job) + { + this.WriteObject(new ASRJob(job)); + } + + private Job jobResponse; + + /// + /// Job response. + /// + private PSSiteRecoveryLongRunningOperation response; + } +} \ No newline at end of file diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs new file mode 100644 index 000000000000..a1e81ee38c09 --- /dev/null +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs @@ -0,0 +1,145 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System.Management.Automation; +using System.Collections.Generic; +using Microsoft.Azure.Management.RecoveryServices.SiteRecovery.Models; +using Job = Microsoft.Azure.Management.RecoveryServices.SiteRecovery.Models.Job; + +namespace Microsoft.Azure.Commands.RecoveryServices.SiteRecovery +{ + /// + /// Adds disks to replication protected item. + /// + [Cmdlet("Add", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RecoveryServicesAsrReplicationProtectedItemDisk", + DefaultParameterSetName = ASRParameterSets.EnterpriseToEnterprise, + SupportsShouldProcess = true)] + [Alias("Add-ASRReplicationProtectedItemDisk")] + [OutputType(typeof(ASRJob))] + public class AddAzureRmRecoveryServicesAsrReplicationProtectedItemDisk : SiteRecoveryCmdletBase + { + [Parameter(Mandatory = true, ValueFromPipeline = true)] + [ValidateNotNullOrEmpty] + [Alias("ReplicationProtectedItem")] + public ASRReplicationProtectedItem InputObject { get; set; } + + [ValidateNotNullOrEmpty] + [Parameter(Mandatory = true)] + public ASRAzuretoAzureDiskReplicationConfig[] AzureToAzureDiskReplicationConfiguration { get; set; } + + [Parameter] + public SwitchParameter WaitForCompletion { get; set; } + + /// + /// ProcessRecord of the command. + /// + public override void ExecuteSiteRecoveryCmdlet() + { + base.ExecuteSiteRecoveryCmdlet(); + if (ShouldProcess(this.InputObject.FriendlyName, VerbsCommon.Add)) + { + // check for A2A protected item - if providerSpecificDetails is A2AReplicationDetails. + + var addDisksProviderSpecificInput = new AddDisksProviderSpecificInput(); + var inputProperties = new AddDisksInputProperties + { + ProviderSpecificDetails = addDisksProviderSpecificInput + }; + var input = new AddDisksInput { Properties = inputProperties }; + AzureToAzureReplication(input); + + this.response = this.RecoveryServicesClient.AddDisks( + Utilities.GetValueFromArmId( + this.InputObject.ID, + ARMResourceTypeConstants.ReplicationFabrics), + Utilities.GetValueFromArmId( + this.InputObject.ID, + ARMResourceTypeConstants.ReplicationProtectionContainers), + this.InputObject.Name, + input); + + this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( + PSRecoveryServicesClient.GetJobIdFromReponseLocation(this.response.Location)); + + this.WriteObject(new ASRJob(this.jobResponse)); + + if (this.WaitForCompletion.IsPresent) + { + this.WaitForJobCompletion(this.jobResponse.Name); + + this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( + PSRecoveryServicesClient + .GetJobIdFromReponseLocation(this.response.Location)); + + this.WriteObject(new ASRJob(this.jobResponse)); + } + } + } + + /// + /// Helper method to fill in input details. + /// + private void AzureToAzureReplication(AddDisksInput input) + { + var providerSettings = new A2AAddDisksInput() + { + VmDisks = new List(), + VmManagedDisks = new List() + }; + + foreach (ASRAzuretoAzureDiskReplicationConfig disk in this.AzureToAzureDiskReplicationConfiguration) + { + if (disk.IsManagedDisk) + { + providerSettings.VmManagedDisks.Add(new A2AVmManagedDiskInputDetails + { + DiskId = disk.DiskId, + RecoveryResourceGroupId = disk.RecoveryResourceGroupId, + PrimaryStagingAzureStorageAccountId = disk.LogStorageAccountId, + RecoveryReplicaDiskAccountType = disk.RecoveryReplicaDiskAccountType, + RecoveryTargetDiskAccountType = disk.RecoveryTargetDiskAccountType + }); + } + else + { + providerSettings.VmDisks.Add(new A2AVmDiskInputDetails + { + DiskUri = disk.VhdUri, + RecoveryAzureStorageAccountId = disk.RecoveryAzureStorageAccountId, + PrimaryStagingAzureStorageAccountId = disk.LogStorageAccountId + }); + } + } + + input.Properties.ProviderSpecificDetails = providerSettings; + } + + /// + /// Writes Job. + /// + /// Job object. + private void WriteJob( + Job job) + { + this.WriteObject(new ASRJob(job)); + } + + private Job jobResponse; + + /// + /// Job response. + /// + private PSSiteRecoveryLongRunningOperation response; + } +} \ No newline at end of file From 79f6e5b9c135701e683cc9a1e552155a0003cd32 Mon Sep 17 00:00:00 2001 From: ayfathim Date: Mon, 15 Jul 2019 11:58:36 +0530 Subject: [PATCH 02/14] remove disk 2 --- ...ServicesAsrReplicationProtectedItemDisk.cs | 122 ++++++++---------- ...sAsrReplicationProtectedItemHealthError.cs | 112 ++++++---------- 2 files changed, 96 insertions(+), 138 deletions(-) diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk.cs b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk.cs index a1e81ee38c09..c41e806208a4 100644 --- a/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk.cs +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk.cs @@ -20,23 +20,31 @@ namespace Microsoft.Azure.Commands.RecoveryServices.SiteRecovery { /// - /// Adds disks to replication protected item. + /// Removes disks to replication protected item. /// - [Cmdlet("Add", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RecoveryServicesAsrReplicationProtectedItemDisk", - DefaultParameterSetName = ASRParameterSets.EnterpriseToEnterprise, - SupportsShouldProcess = true)] - [Alias("Add-ASRReplicationProtectedItemDisk")] + [Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RecoveryServicesAsrReplicationProtectedItemDisk", DefaultParameterSetName = ASRParameterSets.AzureToAzure, SupportsShouldProcess = true)] + [Alias("Remove-ASRReplicationProtectedItemDisk")] [OutputType(typeof(ASRJob))] - public class AddAzureRmRecoveryServicesAsrReplicationProtectedItemDisk : SiteRecoveryCmdletBase + public class RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk : SiteRecoveryCmdletBase { [Parameter(Mandatory = true, ValueFromPipeline = true)] [ValidateNotNullOrEmpty] [Alias("ReplicationProtectedItem")] public ASRReplicationProtectedItem InputObject { get; set; } + /// + /// Gets or sets the disk uri. + /// + [Parameter(ParameterSetName = ASRParameterSets.AzureToAzure, Mandatory = true)] + [ValidateNotNullOrEmpty] + public string[] VhdUri { get; set; } + + /// + /// Gets or sets the disk Id. + /// + [Parameter(ParameterSetName = ASRParameterSets.AzureToAzureManagedDisk, Mandatory = true)] [ValidateNotNullOrEmpty] - [Parameter(Mandatory = true)] - public ASRAzuretoAzureDiskReplicationConfig[] AzureToAzureDiskReplicationConfiguration { get; set; } + public string[] DiskId { get; set; } [Parameter] public SwitchParameter WaitForCompletion { get; set; } @@ -47,79 +55,63 @@ public class AddAzureRmRecoveryServicesAsrReplicationProtectedItemDisk : SiteRec public override void ExecuteSiteRecoveryCmdlet() { base.ExecuteSiteRecoveryCmdlet(); - if (ShouldProcess(this.InputObject.FriendlyName, VerbsCommon.Add)) + + // check for A2A protected item - if providerSpecificDetails is A2AReplicationDetails. + + var removeDisksProviderSpecificInput = new RemoveDisksProviderSpecificInput(); + var inputProperties = new RemoveDisksInputProperties { - // check for A2A protected item - if providerSpecificDetails is A2AReplicationDetails. - - var addDisksProviderSpecificInput = new AddDisksProviderSpecificInput(); - var inputProperties = new AddDisksInputProperties - { - ProviderSpecificDetails = addDisksProviderSpecificInput - }; - var input = new AddDisksInput { Properties = inputProperties }; - AzureToAzureReplication(input); - - this.response = this.RecoveryServicesClient.AddDisks( - Utilities.GetValueFromArmId( - this.InputObject.ID, - ARMResourceTypeConstants.ReplicationFabrics), - Utilities.GetValueFromArmId( - this.InputObject.ID, - ARMResourceTypeConstants.ReplicationProtectionContainers), - this.InputObject.Name, - input); + ProviderSpecificDetails = removeDisksProviderSpecificInput + }; + var input = new RemoveDisksInput { Properties = inputProperties }; + FillRemoveDiskInputForAzureToAzureReplication(input); - this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( - PSRecoveryServicesClient.GetJobIdFromReponseLocation(this.response.Location)); + this.response = this.RecoveryServicesClient.RemoveDisks( + Utilities.GetValueFromArmId( + this.InputObject.ID, + ARMResourceTypeConstants.ReplicationFabrics), + Utilities.GetValueFromArmId( + this.InputObject.ID, + ARMResourceTypeConstants.ReplicationProtectionContainers), + this.InputObject.Name, + input); - this.WriteObject(new ASRJob(this.jobResponse)); + this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( + PSRecoveryServicesClient.GetJobIdFromReponseLocation(this.response.Location)); - if (this.WaitForCompletion.IsPresent) - { - this.WaitForJobCompletion(this.jobResponse.Name); + this.WriteObject(new ASRJob(this.jobResponse)); - this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( - PSRecoveryServicesClient - .GetJobIdFromReponseLocation(this.response.Location)); + if (this.WaitForCompletion.IsPresent) + { + this.WaitForJobCompletion(this.jobResponse.Name); - this.WriteObject(new ASRJob(this.jobResponse)); - } + this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( + PSRecoveryServicesClient + .GetJobIdFromReponseLocation(this.response.Location)); + + this.WriteObject(new ASRJob(this.jobResponse)); } } /// /// Helper method to fill in input details. /// - private void AzureToAzureReplication(AddDisksInput input) + private void FillRemoveDiskInputForAzureToAzureReplication(RemoveDisksInput input) { - var providerSettings = new A2AAddDisksInput() + var providerSettings = new A2ARemoveDisksInput() { - VmDisks = new List(), - VmManagedDisks = new List() + VmDisksUris = new List(), + VmManagedDisksIds = new List() }; - foreach (ASRAzuretoAzureDiskReplicationConfig disk in this.AzureToAzureDiskReplicationConfiguration) + switch (this.ParameterSetName) { - if (disk.IsManagedDisk) - { - providerSettings.VmManagedDisks.Add(new A2AVmManagedDiskInputDetails - { - DiskId = disk.DiskId, - RecoveryResourceGroupId = disk.RecoveryResourceGroupId, - PrimaryStagingAzureStorageAccountId = disk.LogStorageAccountId, - RecoveryReplicaDiskAccountType = disk.RecoveryReplicaDiskAccountType, - RecoveryTargetDiskAccountType = disk.RecoveryTargetDiskAccountType - }); - } - else - { - providerSettings.VmDisks.Add(new A2AVmDiskInputDetails - { - DiskUri = disk.VhdUri, - RecoveryAzureStorageAccountId = disk.RecoveryAzureStorageAccountId, - PrimaryStagingAzureStorageAccountId = disk.LogStorageAccountId - }); - } + case ASRParameterSets.AzureToAzure: + providerSettings.VmDisksUris = this.VhdUri; + break; + case ASRParameterSets.AzureToAzureManagedDisk: + providerSettings.VmManagedDisksIds = this.DiskId; + break; } input.Properties.ProviderSpecificDetails = providerSettings; @@ -142,4 +134,4 @@ private void WriteJob( /// private PSSiteRecoveryLongRunningOperation response; } -} \ No newline at end of file +} diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs index a1e81ee38c09..9816c1894964 100644 --- a/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs @@ -20,23 +20,23 @@ namespace Microsoft.Azure.Commands.RecoveryServices.SiteRecovery { /// - /// Adds disks to replication protected item. + /// Removes health error for the replication protected item. /// - [Cmdlet("Add", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RecoveryServicesAsrReplicationProtectedItemDisk", - DefaultParameterSetName = ASRParameterSets.EnterpriseToEnterprise, - SupportsShouldProcess = true)] - [Alias("Add-ASRReplicationProtectedItemDisk")] + [Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RecoveryServicesAsrReplicationProtectedItemHealthError", DefaultParameterSetName = ASRParameterSets.AzureToAzure, SupportsShouldProcess = true)] + [Alias("Remove-ASRReplicationProtectedItemHealthError")] [OutputType(typeof(ASRJob))] - public class AddAzureRmRecoveryServicesAsrReplicationProtectedItemDisk : SiteRecoveryCmdletBase + public class RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError : SiteRecoveryCmdletBase { - [Parameter(Mandatory = true, ValueFromPipeline = true)] [ValidateNotNullOrEmpty] - [Alias("ReplicationProtectedItem")] - public ASRReplicationProtectedItem InputObject { get; set; } + [Parameter(Mandatory = true)] + public ASRReplicationProtectedItem ReplicationProtectedItem { get; set; } - [ValidateNotNullOrEmpty] + /// + /// Gets or sets the errro id. + /// [Parameter(Mandatory = true)] - public ASRAzuretoAzureDiskReplicationConfig[] AzureToAzureDiskReplicationConfiguration { get; set; } + [ValidateNotNullOrEmpty] + public string[] ErrorIds { get; set; } [Parameter] public SwitchParameter WaitForCompletion { get; set; } @@ -47,82 +47,48 @@ public class AddAzureRmRecoveryServicesAsrReplicationProtectedItemDisk : SiteRec public override void ExecuteSiteRecoveryCmdlet() { base.ExecuteSiteRecoveryCmdlet(); - if (ShouldProcess(this.InputObject.FriendlyName, VerbsCommon.Add)) - { - // check for A2A protected item - if providerSpecificDetails is A2AReplicationDetails. - - var addDisksProviderSpecificInput = new AddDisksProviderSpecificInput(); - var inputProperties = new AddDisksInputProperties - { - ProviderSpecificDetails = addDisksProviderSpecificInput - }; - var input = new AddDisksInput { Properties = inputProperties }; - AzureToAzureReplication(input); - - this.response = this.RecoveryServicesClient.AddDisks( - Utilities.GetValueFromArmId( - this.InputObject.ID, - ARMResourceTypeConstants.ReplicationFabrics), - Utilities.GetValueFromArmId( - this.InputObject.ID, - ARMResourceTypeConstants.ReplicationProtectionContainers), - this.InputObject.Name, - input); - this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( - PSRecoveryServicesClient.GetJobIdFromReponseLocation(this.response.Location)); + var input = new ResolveHealthInput { Properties = new ResolveHealthInputProperties() }; + FillResolveHealthErrorInput(input); - this.WriteObject(new ASRJob(this.jobResponse)); + this.response = this.RecoveryServicesClient.ResolveHealthError( + Utilities.GetValueFromArmId( + this.ReplicationProtectedItem.ID, + ARMResourceTypeConstants.ReplicationFabrics), + Utilities.GetValueFromArmId( + this.ReplicationProtectedItem.ID, + ARMResourceTypeConstants.ReplicationProtectionContainers), + this.ReplicationProtectedItem.Name, + input); - if (this.WaitForCompletion.IsPresent) - { - this.WaitForJobCompletion(this.jobResponse.Name); + this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( + PSRecoveryServicesClient.GetJobIdFromReponseLocation(this.response.Location)); - this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( - PSRecoveryServicesClient - .GetJobIdFromReponseLocation(this.response.Location)); + this.WriteObject(new ASRJob(this.jobResponse)); - this.WriteObject(new ASRJob(this.jobResponse)); - } + if (this.WaitForCompletion.IsPresent) + { + this.WaitForJobCompletion(this.jobResponse.Name); + + this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( + PSRecoveryServicesClient + .GetJobIdFromReponseLocation(this.response.Location)); + + this.WriteObject(new ASRJob(this.jobResponse)); } } /// /// Helper method to fill in input details. /// - private void AzureToAzureReplication(AddDisksInput input) + private void FillResolveHealthErrorInput(ResolveHealthInput input) { - var providerSettings = new A2AAddDisksInput() - { - VmDisks = new List(), - VmManagedDisks = new List() - }; + input.Properties.HealthErrors = new List(); - foreach (ASRAzuretoAzureDiskReplicationConfig disk in this.AzureToAzureDiskReplicationConfiguration) + foreach (string errorId in ErrorIds) { - if (disk.IsManagedDisk) - { - providerSettings.VmManagedDisks.Add(new A2AVmManagedDiskInputDetails - { - DiskId = disk.DiskId, - RecoveryResourceGroupId = disk.RecoveryResourceGroupId, - PrimaryStagingAzureStorageAccountId = disk.LogStorageAccountId, - RecoveryReplicaDiskAccountType = disk.RecoveryReplicaDiskAccountType, - RecoveryTargetDiskAccountType = disk.RecoveryTargetDiskAccountType - }); - } - else - { - providerSettings.VmDisks.Add(new A2AVmDiskInputDetails - { - DiskUri = disk.VhdUri, - RecoveryAzureStorageAccountId = disk.RecoveryAzureStorageAccountId, - PrimaryStagingAzureStorageAccountId = disk.LogStorageAccountId - }); - } + input.Properties.HealthErrors.Add(new ResolveHealthError(errorId)); } - - input.Properties.ProviderSpecificDetails = providerSettings; } /// @@ -142,4 +108,4 @@ private void WriteJob( /// private PSSiteRecoveryLongRunningOperation response; } -} \ No newline at end of file +} From cf723453bc82e8755f3f2b58d5bbc2764b2f78bd Mon Sep 17 00:00:00 2001 From: ayfathim Date: Mon, 15 Jul 2019 12:00:22 +0530 Subject: [PATCH 03/14] remove disk 3 --- .../ScenarioTests/A2A/AsrA2ATests.ps1 | 268 ++++++++++++++++++ 1 file changed, 268 insertions(+) diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1 b/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1 index 5a6af300d05e..589ce7c06dad 100644 --- a/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1 +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1 @@ -373,6 +373,274 @@ function Test-AddReplicationProtectedItemDisk{ WaitForJobCompletion -JobId $addDRjob.Name WaitForAddDisksIRCompletion -affectedObjectId $addDRjob.TargetObjectId + $pe = Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $pc -Name $vmName + Assert-NotNull($pe) + +<# +.SYNOPSIS + Test RemoveReplicationProtectedItemDisk new parametersets +#> + +function Test-RemoveReplicationProtectedItemDisk{ + param([string] $seed ='600') + $primaryPolicyName = getPrimaryPolicy + $recoveryPolicyName = getRecoveryPolicy + + $primaryContainerMappingName = getPrimaryContainerMapping + $recoveryContainerMappingName = getRecoveryContainerMapping + + $primaryContainerName = getPrimaryContainer + $recoveryContainerName = getRecoveryContainer + $vaultRgLocation = getVaultRgLocation + $vaultName = getVaultName + $vaultLocation = getVaultLocation + $vaultRg = getVaultRg + $primaryLocation = getPrimaryLocation + $recoveryLocation = getRecoveryLocation + $primaryFabricName = getPrimaryFabric + $recoveryFabricName = getRecoveryFabric + $RecoveryReplicaDiskAccountType = "Premium_LRS" + $RecoveryTargetDiskAccountType = "Premium_LRS" + $policyName = getPrimaryPolicy + $mappingName = getPrimaryContainerMapping + $primaryNetMapping = getPrimaryNetworkMapping + + New-AzResourceGroup -name $vaultRg -location $vaultRgLocation -force + [Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000) + # vault Creation + New-AzRecoveryServicesVault -ResourceGroupName $vaultRg -Name $vaultName -Location $vaultLocation + [Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000) + $Vault = Get-AzRecoveryServicesVault -ResourceGroupName $vaultRg -Name $vaultName + Set-ASRVaultContext -Vault $Vault + # fabric Creation + ### AzureToAzure New paramset + $fabJob= New-AzRecoveryServicesAsrFabric -Azure -Name $primaryFabricName -Location $primaryLocation + WaitForJobCompletion -JobId $fabJob.Name + $fab = Get-AzRecoveryServicesAsrFabric -Name $primaryFabricName + Assert-true { $fab.name -eq $primaryFabricName } + Assert-AreEqual $fab.FabricSpecificDetails.Location $primaryLocation + + $fabJob= New-AzRecoveryServicesAsrFabric -Azure -Name $recoveryFabricName -Location $recoveryLocation + WaitForJobCompletion -JobId $fabJob.Name + $fab = Get-AzRecoveryServicesAsrFabric -Name $recoveryFabricName + Assert-true { $fab.name -eq $recoveryFabricName } + Assert-AreEqual $fab.FabricSpecificDetails.Location $recoveryLocation + $pf = get-asrFabric -Name $primaryFabricName + $rf = get-asrFabric -Name $recoveryFabricName + + ### AzureToAzure (Default) + $job = New-AzRecoveryServicesAsrProtectionContainer -Name $primaryContainerName -Fabric $pf + WaitForJobCompletion -JobId $Job.Name + $pc = Get-asrProtectionContainer -name $primaryContainerName -Fabric $pf + Assert-NotNull($pc) + $job = New-AzRecoveryServicesAsrProtectionContainer -Name $recoveryContainerName -Fabric $rf + WaitForJobCompletion -JobId $Job.Name + $rc = Get-asrProtectionContainer -name $recoveryContainerName -Fabric $rf + Assert-NotNull($rc) + + #create policy and mapping + $job = New-AzRecoveryServicesAsrPolicy -Name $policyName -RecoveryPointRetentionInHours 12 -AzureToAzure + WaitForJobCompletion -JobId $job.Name + $policy = Get-AzRecoveryServicesAsrPolicy -Name $policyName + $job = New-AzRecoveryServicesAsrProtectionContainerMapping -Name $mappingName -Policy $policy -PrimaryProtectionContainer $pc -RecoveryProtectionContainer $rc + WaitForJobCompletion -JobId $job.Name + $mapping = Get-AzRecoveryServicesAsrProtectionContainerMapping -Name $mappingName -ProtectionContainer $pc + + $v2VmIdRec = createRecoveryAzureVm + $recRgName = getRecoveryResourceGroupName + $index =$v2VmIdRec.IndexOf("/providers/") + $recRg =$v2VmIdRec.Substring(0,$index) + $RecoveryAzureNetworkId = $recRg + "/providers/Microsoft.Network/virtualNetworks/" + $recRgName + $v2VmId = createAzureVm + $vmName = getAzureVmName + $logStg = createCacheStorageAccount + $vm = get-azVm -ResourceGroupName $vmName -Name $vmName + $vhdid =$vm.StorageProfile.OSDisk.ManagedDisk.Id + $index =$v2VmId.IndexOf("/providers/") + $Rg =$v2VmId.Substring(0,$index) + $PrimaryAzureNetworkId = $Rg + "/providers/Microsoft.Network/virtualNetworks/" + $vmName + + #network mapping + $job = New-AzRecoveryServicesAsrNetworkMapping -AzureToAzure -Name $primaryNetMapping -PrimaryFabric $pf -PrimaryAzureNetworkId $PrimaryAzureNetworkId -RecoveryFabric $rf -RecoveryAzureNetworkId $RecoveryAzureNetworkId + WaitForJobCompletion -JobId $job.Name + + #enable Replication + $v = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -managed -LogStorageAccountId $logStg ` + -DiskId $vhdid -RecoveryResourceGroupId $recRg -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType ` + -RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType + $enableDRjob = New-AzRecoveryServicesAsrReplicationProtectedItem -AzureToAzure -AzureVmId $v2VmId -Name $vmName -ProtectionContainerMapping $mapping -RecoveryResourceGroupId $recRg -AzureToAzureDiskReplicationConfiguration $v + WaitForJobCompletion -JobId $enableDRjob.Name + WaitForIRCompletion -affectedObjectId $enableDRjob.TargetObjectId + + #add diskId + $pe = Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $pc -Name $vmName + Assert-NotNull($pe) + + #create disk and attach + $diskName = getAzureDataDiskName + $newDiskConfig = New-AzDiskConfig -Location $vm.Location -CreateOption Empty -DiskSizeGB 5 + $newDisk = New-AzDisk -ResourceGroupName $vm.ResourceGroupName -DiskName $diskName -Disk $newDiskConfig + $vm = Add-AzVMDataDisk -VM $vm -Name $diskName -CreateOption Attach -ManagedDiskId $newDisk.Id -Lun 5 + Update-azVm -ResourceGroupName $vmName -VM $vm + + #wait for the add-disk health warning to appear + Write-Host $("Waiting for Add-Disk health warning...") -ForegroundColor Yellow + $HealthQueryWaitTimeInSeconds = 10 + do + { + $pe = Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $pc -Name $vmName + $healthError = $pe.ReplicationHealthErrors | where-object {$_.ErrorCode -eq 153039} + + if($healthError -eq $null) + { + Write-Host $("Waiting for Add-Disk health warning...") -ForegroundColor Yellow + Write-Host $("Waiting for: " + $HealthQueryWaitTimeInSeconds.ToString + " Seconds") -ForegroundColor Yellow + [Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait($HealthQueryWaitTimeInSeconds * 1000) + } + }While($healthError -eq $null) + + #add disks + $disk2= New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -DiskId $newDisk.Id -LogStorageAccountId $pe.ProviderSpecificDetails.A2ADiskDetails[0].PrimaryStagingAzureStorageAccountId -ManagedDisk -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType -RecoveryResourceGroupId $pe.ProviderSpecificDetails.A2ADiskDetails[0].RecoveryResourceGroupId -RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType + $addDRjob = Add-AzRecoveryServicesAsrReplicationProtectedItemDisk -ReplicationProtectedItem $pe -AzureToAzureDiskReplicationConfiguration $disk2 + WaitForJobCompletion -JobId $addDRjob.Name + + #get disk to deattach + | $removeDisk = $pe.ProviderSpecificDetails.A2ADiskDetails | where-object {$_.AllowedDiskLevelOperation.Count -eq 1} + Assert-NotNull($removeDisk) + $vm = get-azVm -ResourceGroupName $vmName -Name $vmName + $removeDiskId = $vm.StorageProfile.DataDisks | Where-Object {$_.ManagedDisk.Name -eq $removeDisk.DiskName} + $removeDRjob = Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk -ReplicationProtectedItem $pe -DiskId $removeDiskId.ManagedDisk.Id + WaitForJobCompletion -JobId $removeDRjob.Name + $pe = Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $pc -Name $vmName Assert-NotNull($pe) } + + +<# +.SYNOPSIS + Test ResolveHealthError new parametersets +#> + +function Test-ResolveHealthError{ + param([string] $seed ='557') + $primaryPolicyName = getPrimaryPolicy + $recoveryPolicyName = getRecoveryPolicy + + $primaryContainerMappingName = getPrimaryContainerMapping + $recoveryContainerMappingName = getRecoveryContainerMapping + + $primaryContainerName = getPrimaryContainer + $recoveryContainerName = getRecoveryContainer + $vaultRgLocation = getVaultRgLocation + $vaultName = getVaultName + $vaultLocation = getVaultLocation + $vaultRg = getVaultRg + $primaryLocation = getPrimaryLocation + $recoveryLocation = getRecoveryLocation + $primaryFabricName = getPrimaryFabric + $recoveryFabricName = getRecoveryFabric + $RecoveryReplicaDiskAccountType = "Premium_LRS" + $RecoveryTargetDiskAccountType = "Premium_LRS" + $policyName = getPrimaryPolicy + $mappingName = getPrimaryContainerMapping + $primaryNetMapping = getPrimaryNetworkMapping + + New-AzResourceGroup -name $vaultRg -location $vaultRgLocation -force + [Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000) + # vault Creation + New-AzRecoveryServicesVault -ResourceGroupName $vaultRg -Name $vaultName -Location $vaultLocation + [Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000) + $Vault = Get-AzRecoveryServicesVault -ResourceGroupName $vaultRg -Name $vaultName + Set-ASRVaultContext -Vault $Vault + # fabric Creation + ### AzureToAzure New paramset + $fabJob= New-AzRecoveryServicesAsrFabric -Azure -Name $primaryFabricName -Location $primaryLocation + WaitForJobCompletion -JobId $fabJob.Name + $fab = Get-AzRecoveryServicesAsrFabric -Name $primaryFabricName + Assert-true { $fab.name -eq $primaryFabricName } + Assert-AreEqual $fab.FabricSpecificDetails.Location $primaryLocation + + $fabJob= New-AzRecoveryServicesAsrFabric -Azure -Name $recoveryFabricName -Location $recoveryLocation + WaitForJobCompletion -JobId $fabJob.Name + $fab = Get-AzRecoveryServicesAsrFabric -Name $recoveryFabricName + Assert-true { $fab.name -eq $recoveryFabricName } + Assert-AreEqual $fab.FabricSpecificDetails.Location $recoveryLocation + $pf = get-asrFabric -Name $primaryFabricName + $rf = get-asrFabric -Name $recoveryFabricName + + ### AzureToAzure (Default) + $job = New-AzRecoveryServicesAsrProtectionContainer -Name $primaryContainerName -Fabric $pf + WaitForJobCompletion -JobId $Job.Name + $pc = Get-asrProtectionContainer -name $primaryContainerName -Fabric $pf + Assert-NotNull($pc) + $job = New-AzRecoveryServicesAsrProtectionContainer -Name $recoveryContainerName -Fabric $rf + WaitForJobCompletion -JobId $Job.Name + $rc = Get-asrProtectionContainer -name $recoveryContainerName -Fabric $rf + Assert-NotNull($rc) + + #create policy and mapping + $job = New-AzRecoveryServicesAsrPolicy -Name $policyName -RecoveryPointRetentionInHours 12 -AzureToAzure + WaitForJobCompletion -JobId $job.Name + $policy = Get-AzRecoveryServicesAsrPolicy -Name $policyName + $job = New-AzRecoveryServicesAsrProtectionContainerMapping -Name $mappingName -Policy $policy -PrimaryProtectionContainer $pc -RecoveryProtectionContainer $rc + WaitForJobCompletion -JobId $job.Name + $mapping = Get-AzRecoveryServicesAsrProtectionContainerMapping -Name $mappingName -ProtectionContainer $pc + + $v2VmIdRec = createRecoveryAzureVm + $recRgName = getRecoveryResourceGroupName + $index =$v2VmIdRec.IndexOf("/providers/") + $recRg =$v2VmIdRec.Substring(0,$index) + $RecoveryAzureNetworkId = $recRg + "/providers/Microsoft.Network/virtualNetworks/" + $recRgName + $v2VmId = createAzureVm + $vmName = getAzureVmName + $logStg = createCacheStorageAccount + $vm = get-azVm -ResourceGroupName $vmName -Name $vmName + $vhdid =$vm.StorageProfile.OSDisk.ManagedDisk.Id + $index =$v2VmId.IndexOf("/providers/") + $Rg =$v2VmId.Substring(0,$index) + $PrimaryAzureNetworkId = $Rg + "/providers/Microsoft.Network/virtualNetworks/" + $vmName + + #network mapping + $job = New-AzRecoveryServicesAsrNetworkMapping -AzureToAzure -Name $primaryNetMapping -PrimaryFabric $pf -PrimaryAzureNetworkId $PrimaryAzureNetworkId -RecoveryFabric $rf -RecoveryAzureNetworkId $RecoveryAzureNetworkId + WaitForJobCompletion -JobId $job.Name + + #enable Replication + $v = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -managed -LogStorageAccountId $logStg ` + -DiskId $vhdid -RecoveryResourceGroupId $recRg -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType ` + -RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType + $enableDRjob = New-AzRecoveryServicesAsrReplicationProtectedItem -AzureToAzure -AzureVmId $v2VmId -Name $vmName -ProtectionContainerMapping $mapping -RecoveryResourceGroupId $recRg -AzureToAzureDiskReplicationConfiguration $v + WaitForJobCompletion -JobId $enableDRjob.Name + WaitForIRCompletion -affectedObjectId $enableDRjob.TargetObjectId + + #add diskId + $pe = Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $pc -Name $vmName + Assert-NotNull($pe) + + #create disk and attach + $diskName = getAzureDataDiskName + $newDiskConfig = New-AzDiskConfig -Location $vm.Location -CreateOption Empty -DiskSizeGB 5 + $newDisk = New-AzDisk -ResourceGroupName $vm.ResourceGroupName -DiskName $diskName -Disk $newDiskConfig + $vm = Add-AzVMDataDisk -VM $vm -Name $diskName -CreateOption Attach -ManagedDiskId $newDisk.Id -Lun 5 + Update-azVm -ResourceGroupName $vmName -VM $vm + + #wait for the add-disk health warning to appear + Write-Host $("Waiting for Add-Disk health warning...") -ForegroundColor Yellow + $HealthQueryWaitTimeInSeconds = 10 + do + { + $pe = Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $pc -Name $vmName + $healthError = $pe.ReplicationHealthErrors | where-object {$_.ErrorCode -eq 153039} + + if($healthError -eq $null) + { + Write-Host $("Waiting for Add-Disk health warning...") -ForegroundColor Yellow + Write-Host $("Waiting for: " + $HealthQueryWaitTimeInSeconds.ToString + " Seconds") -ForegroundColor Yellow + [Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait($HealthQueryWaitTimeInSeconds * 1000) + } + }While($healthError -eq $null) + + #resolve health error + $addDRjob = Remove-AzureRmRecoveryServicesAsrReplicationProtectedItemHealthError -ReplicationProtectedItem $pe -ErrorIds $healthError.ErrorId + WaitForJobCompletion -JobId $addDRjob.Name +} \ No newline at end of file From 0862b87ecbbbb07740c5f1133d309353feea5f06 Mon Sep 17 00:00:00 2001 From: ayfathim Date: Mon, 15 Jul 2019 12:03:44 +0530 Subject: [PATCH 04/14] remove disk 4 --- .../PSAsrReplicationProtectedItemsClient.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery/Common/PSAsrReplicationProtectedItemsClient.cs b/src/RecoveryServices/RecoveryServices.SiteRecovery/Common/PSAsrReplicationProtectedItemsClient.cs index b01847fe9494..a638b06b2f33 100644 --- a/src/RecoveryServices/RecoveryServices.SiteRecovery/Common/PSAsrReplicationProtectedItemsClient.cs +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery/Common/PSAsrReplicationProtectedItemsClient.cs @@ -162,6 +162,62 @@ public PSSiteRecoveryLongRunningOperation AddDisks( return result; } + /// + /// Remove disks from replication protected item. + /// + /// Fabric Name + /// Protection Container Name + /// Replication Protected Item Name + /// Remove disks input. + /// Job response + public PSSiteRecoveryLongRunningOperation RemoveDisks( + string fabricName, + string protectionContainerName, + string replicationProtectedItemName, + RemoveDisksInput input) + { + var op = this.GetSiteRecoveryClient() + .ReplicationProtectedItems.BeginRemoveDisksWithHttpMessagesAsync( + fabricName, + protectionContainerName, + replicationProtectedItemName, + input, + this.GetRequestHeaders(true)) + .GetAwaiter() + .GetResult(); + + var result = SiteRecoveryAutoMapperProfile.Mapper.Map(op); + return result; + } + + /// + /// Removes the Health error from replication protected item. + /// + /// Fabric Name + /// Protection Container Name + /// Replication Protected Item Name + /// Remove disks input. + /// Job response + public PSSiteRecoveryLongRunningOperation ResolveHealthError( + string fabricName, + string protectionContainerName, + string replicationProtectedItemName, + ResolveHealthInput input) + { + var op = this.GetSiteRecoveryClient() + .ReplicationProtectedItems.BeginResolveHealthErrorsWithHttpMessagesAsync( + fabricName, + protectionContainerName, + replicationProtectedItemName, + input, + this.GetRequestHeaders(true)) + .GetAwaiter() + .GetResult(); + + var result = SiteRecoveryAutoMapperProfile.Mapper.Map(op); + return result; + } + /// /// Retrieves Protected Items. /// From a82f93c14fce2159decbcb1dd0ff85e58dd44a58 Mon Sep 17 00:00:00 2001 From: ayfathim Date: Mon, 15 Jul 2019 12:05:40 +0530 Subject: [PATCH 05/14] remove disk 5 --- .../RecoveryServices/Az.RecoveryServices.psd1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/RecoveryServices/RecoveryServices/Az.RecoveryServices.psd1 b/src/RecoveryServices/RecoveryServices/Az.RecoveryServices.psd1 index abfcb4d04273..441e25dab57c 100644 --- a/src/RecoveryServices/RecoveryServices/Az.RecoveryServices.psd1 +++ b/src/RecoveryServices/RecoveryServices/Az.RecoveryServices.psd1 @@ -132,7 +132,9 @@ CmdletsToExport = 'Remove-AzRecoveryServicesAsrProtectionContainer', 'Remove-AzRecoveryServicesAsrProtectionContainerMapping', 'Remove-AzRecoveryServicesAsrRecoveryPlan', - 'Remove-AzRecoveryServicesAsrReplicationProtectedItem', + 'Remove-AzRecoveryServicesAsrReplicationProtectedItem', + 'Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk', + 'Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError', 'Remove-AzRecoveryServicesAsrServicesProvider', 'Remove-AzRecoveryServicesAsrStorageClassificationMapping', 'Remove-AzRecoveryServicesAsrvCenter', @@ -217,7 +219,9 @@ AliasesToExport = 'Get-AzRecoveryServicesBackupProperties', 'New-ASRStorageClassificationMapping', 'New-ASRvCenter', 'Remove-ASRFabric', 'Remove-ASRNetworkMapping', 'Remove-ASRPolicy', 'Remove-ASRProtectionContainerMapping', 'Remove-ASRRP', - 'Remove-ASRRecoveryPlan', 'Remove-ASRReplicationProtectedItem', + 'Remove-ASRRecoveryPlan', 'Remove-ASRReplicationProtectedItem', + 'Remove-ASRReplicationProtectedItemDisk', + 'Remove-ASRReplicationProtectedItemHealthError', 'Remove-ASRServicesProvider', 'Remove-ASRStorageClassificationMapping', 'Remove-ASRvCenter', 'Restart-ASRJob', 'Resume-ASRJob', 'Set-ASRAlertSetting', From ce5b201462ddb7016246cd6f2f0f1a8a694bf8ec Mon Sep 17 00:00:00 2001 From: ayfathim Date: Mon, 15 Jul 2019 13:19:07 +0530 Subject: [PATCH 06/14] remove disk7 --- ...ServicesAsrReplicationProtectedItemDisk.md | 162 ++++++++++++++++++ ...sAsrReplicationProtectedItemHealthError.md | 139 +++++++++++++++ 2 files changed, 301 insertions(+) create mode 100644 src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md create mode 100644 src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md diff --git a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md new file mode 100644 index 000000000000..2403e7405570 --- /dev/null +++ b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md @@ -0,0 +1,162 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.SiteRecovery.dll-Help.xml +Module Name: Az.RecoveryServices +online version: +schema: 2.0.0 +--- + +# Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +### AzureToAzure (Default) +``` +Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk -InputObject + -VhdUri [-WaitForCompletion] [-DefaultProfile ] [-WhatIf] [-Confirm] + [] +``` + +### AzureToAzureManagedDisk +``` +Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk -InputObject + -DiskId [-WaitForCompletion] [-DefaultProfile ] [-WhatIf] [-Confirm] + [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DiskId +{{ Fill DiskId Description }} + +```yaml +Type: System.String[] +Parameter Sets: AzureToAzureManagedDisk +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +{{ Fill InputObject Description }} + +```yaml +Type: Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRReplicationProtectedItem +Parameter Sets: (All) +Aliases: ReplicationProtectedItem + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -VhdUri +{{ Fill VhdUri Description }} + +```yaml +Type: System.String[] +Parameter Sets: AzureToAzure +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WaitForCompletion +{{ Fill WaitForCompletion Description }} + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRReplicationProtectedItem + +## OUTPUTS + +### Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRJob + +## NOTES + +## RELATED LINKS diff --git a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md new file mode 100644 index 000000000000..1a65fdaaa181 --- /dev/null +++ b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md @@ -0,0 +1,139 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.SiteRecovery.dll-Help.xml +Module Name: Az.RecoveryServices +online version: +schema: 2.0.0 +--- + +# Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError + +## SYNOPSIS +{{ Fill in the Synopsis }} + +## SYNTAX + +``` +Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError + -ReplicationProtectedItem -ErrorIds [-WaitForCompletion] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +{{ Fill in the Description }} + +## EXAMPLES + +### Example 1 +```powershell +PS C:\> {{ Add example code here }} +``` + +{{ Add example description here }} + +## PARAMETERS + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ErrorIds +{{ Fill ErrorIds Description }} + +```yaml +Type: System.String[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ReplicationProtectedItem +{{ Fill ReplicationProtectedItem Description }} + +```yaml +Type: Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRReplicationProtectedItem +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WaitForCompletion +{{ Fill WaitForCompletion Description }} + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +### Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRJob + +## NOTES + +## RELATED LINKS From 0cae6596ebc07cd078d398bc4a861eb098493e94 Mon Sep 17 00:00:00 2001 From: ayfathim Date: Mon, 15 Jul 2019 13:21:25 +0530 Subject: [PATCH 07/14] rd 9 --- ...ServicesAsrReplicationProtectedItemDisk.md | 66 +++++++++++-------- ...sAsrReplicationProtectedItemHealthError.md | 50 +++++++------- 2 files changed, 62 insertions(+), 54 deletions(-) diff --git a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md index 2403e7405570..1b5c07b8c202 100644 --- a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md +++ b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md @@ -8,7 +8,7 @@ schema: 2.0.0 # Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk ## SYNOPSIS -{{ Fill in the Synopsis }} +Removes disks to replication protected item. ## SYNTAX @@ -27,24 +27,47 @@ Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk -InputObject {{ Add example code here }} +PS C:\> Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk -ReplicationProtectedItem $rpi -VhdUri $vhdUri ``` -{{ Add example description here }} +Start the operation to remove specified disk from protection VM for unManaged disk. + + +### Example 2 +```powershell +PS C:\> Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk -ReplicationProtectedItem $rpi -DiskId $diskId +``` + +Start the operation to remove specified disk from protection VM for Managed disk. ## PARAMETERS +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -DefaultProfile The credentials, account, tenant, and subscription used for communication with Azure. ```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer +Type: IAzureContextContainer Parameter Sets: (All) Aliases: AzContext, AzureRmContext, AzureCredential @@ -56,10 +79,10 @@ Accept wildcard characters: False ``` ### -DiskId -{{ Fill DiskId Description }} +Specifies the list of managed disk Ids. ```yaml -Type: System.String[] +Type: String[] Parameter Sets: AzureToAzureManagedDisk Aliases: @@ -71,10 +94,10 @@ Accept wildcard characters: False ``` ### -InputObject -{{ Fill InputObject Description }} +The input object to the cmdlet: The ASR replication protected item object corresponding to which disk is to be removed. ```yaml -Type: Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRReplicationProtectedItem +Type: ASRReplicationProtectedItem Parameter Sets: (All) Aliases: ReplicationProtectedItem @@ -86,10 +109,10 @@ Accept wildcard characters: False ``` ### -VhdUri -{{ Fill VhdUri Description }} +Specifies the list of vhd Uri's. ```yaml -Type: System.String[] +Type: String[] Parameter Sets: AzureToAzure Aliases: @@ -101,10 +124,10 @@ Accept wildcard characters: False ``` ### -WaitForCompletion -{{ Fill WaitForCompletion Description }} +Wait For Completion ```yaml -Type: System.Management.Automation.SwitchParameter +Type: SwitchParameter Parameter Sets: (All) Aliases: @@ -115,27 +138,12 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: cf - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -WhatIf Shows what would happen if the cmdlet runs. The cmdlet is not run. ```yaml -Type: System.Management.Automation.SwitchParameter +Type: SwitchParameter Parameter Sets: (All) Aliases: wi diff --git a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md index 1a65fdaaa181..ace6562c9036 100644 --- a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md +++ b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md @@ -8,7 +8,7 @@ schema: 2.0.0 # Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError ## SYNOPSIS -{{ Fill in the Synopsis }} +Removes the health error from the ASR replication protected item. ## SYNTAX @@ -19,26 +19,26 @@ Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError ``` ## DESCRIPTION -{{ Fill in the Description }} +The **Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError** cmdlet removes the health from the already protected azure virtual machine. ## EXAMPLES ### Example 1 ```powershell -PS C:\> {{ Add example code here }} +PS C:\> Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError -ReplicationProtectedItem $rpi -ErrorIds $errorId ``` -{{ Add example description here }} +Start the operation to remove the health errors from the ASR Replication protected item. ## PARAMETERS -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with Azure. +### -Confirm +Prompts you for confirmation before running the cmdlet. ```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer +Type: SwitchParameter Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential +Aliases: cf Required: False Position: Named @@ -47,26 +47,26 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ErrorIds -{{ Fill ErrorIds Description }} +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. ```yaml -Type: System.String[] +Type: IAzureContextContainer Parameter Sets: (All) -Aliases: +Aliases: AzContext, AzureRmContext, AzureCredential -Required: True +Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -ReplicationProtectedItem -{{ Fill ReplicationProtectedItem Description }} +### -ErrorIds +Health Error Ids. ```yaml -Type: Microsoft.Azure.Commands.RecoveryServices.SiteRecovery.ASRReplicationProtectedItem +Type: String[] Parameter Sets: (All) Aliases: @@ -77,28 +77,28 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -WaitForCompletion -{{ Fill WaitForCompletion Description }} +### -ReplicationProtectedItem +The input object to the cmdlet: The ASR replication protected item object corresponding to which the helath error is to be removed. ```yaml -Type: System.Management.Automation.SwitchParameter +Type: ASRReplicationProtectedItem Parameter Sets: (All) Aliases: -Required: False +Required: True Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ``` -### -Confirm -Prompts you for confirmation before running the cmdlet. +### -WaitForCompletion +Wait For Completion ```yaml -Type: System.Management.Automation.SwitchParameter +Type: SwitchParameter Parameter Sets: (All) -Aliases: cf +Aliases: Required: False Position: Named @@ -112,7 +112,7 @@ Shows what would happen if the cmdlet runs. The cmdlet is not run. ```yaml -Type: System.Management.Automation.SwitchParameter +Type: SwitchParameter Parameter Sets: (All) Aliases: wi From 5517ad11fa8b9e7dc5535346522c7bf687283e39 Mon Sep 17 00:00:00 2001 From: ayfathim Date: Mon, 15 Jul 2019 13:27:48 +0530 Subject: [PATCH 08/14] rd 10 --- .../Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md index 1b5c07b8c202..b350f74ad1af 100644 --- a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md +++ b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md @@ -38,7 +38,6 @@ PS C:\> Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk -ReplicationPro Start the operation to remove specified disk from protection VM for unManaged disk. - ### Example 2 ```powershell PS C:\> Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk -ReplicationProtectedItem $rpi -DiskId $diskId From a56616b93a42c0141d20636ff50576c3ac54c0b5 Mon Sep 17 00:00:00 2001 From: ayfathim Date: Mon, 15 Jul 2019 13:32:21 +0530 Subject: [PATCH 09/14] rd 11 --- .../RecoveryServices/help/Az.RecoveryServices.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/RecoveryServices/RecoveryServices/help/Az.RecoveryServices.md b/src/RecoveryServices/RecoveryServices/help/Az.RecoveryServices.md index eee44c2c1c23..a89bbc552c81 100644 --- a/src/RecoveryServices/RecoveryServices/help/Az.RecoveryServices.md +++ b/src/RecoveryServices/RecoveryServices/help/Az.RecoveryServices.md @@ -1,4 +1,4 @@ ---- +--- Module Name: Az.RecoveryServices Module Guid: 4aa53b7e-fcfe-4e22-979c-9a4e6380de58 Download Help Link: https://docs.microsoft.com/en-us/powershell/module/az.recoveryservices @@ -212,6 +212,12 @@ Deletes the specified ASR recovery plan from Recovery Services vault. ### [Remove-AzRecoveryServicesAsrReplicationProtectedItem](Remove-AzRecoveryServicesAsrReplicationProtectedItem.md) Stops/Disables replication for an Azure Site Recovery replication protected item. +### [Remove-AzRecoveryServicesAsrReplicationProtectedItem](Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md) +Removes a protected disk from replication protected item. + +### [Remove-AzRecoveryServicesAsrReplicationProtectedItem](Remove-AzRecoveryServicesAsrReplicationProtectedItemHealth.md) +Removes the health error from replication protected item. + ### [Remove-AzRecoveryServicesAsrServicesProvider](Remove-AzRecoveryServicesAsrServicesProvider.md) Deletes/unregister the specified Azure Site Recovery recovery services provider from the recovery services vault. From 8a29122865454c75ac8f7ce10d006bac5ae92af7 Mon Sep 17 00:00:00 2001 From: ayfathim Date: Mon, 15 Jul 2019 14:10:18 +0530 Subject: [PATCH 10/14] rd 12 --- .../Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md | 2 +- ...-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md index b350f74ad1af..f6481961c411 100644 --- a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md +++ b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk.md @@ -1,7 +1,7 @@ --- external help file: Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.SiteRecovery.dll-Help.xml Module Name: Az.RecoveryServices -online version: +online version: https://docs.microsoft.com/en-us/powershell/module/az.recoveryservices/remove-azrecoveryservicesasrreplicationprotecteditemDisk schema: 2.0.0 --- diff --git a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md index ace6562c9036..5fc13a84e61a 100644 --- a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md +++ b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md @@ -1,7 +1,7 @@ --- external help file: Microsoft.Azure.PowerShell.Cmdlets.RecoveryServices.SiteRecovery.dll-Help.xml Module Name: Az.RecoveryServices -online version: +online version: https://docs.microsoft.com/en-us/powershell/module/az.recoveryservices/remove-azrecoveryservicesasrreplicationprotecteditemHealthError schema: 2.0.0 --- From 38f890090f660e4e28c3c2a8acf2555415882243 Mon Sep 17 00:00:00 2001 From: ayfathim Date: Tue, 16 Jul 2019 13:07:02 +0530 Subject: [PATCH 11/14] fixing static analysis results --- .../ScenarioTests/A2A/AsrA2ATests.ps1 | 2 +- ...mRecoveryServicesAsrReplicationProtectedItemHealthError.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1 b/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1 index 589ce7c06dad..bd60d1244e7a 100644 --- a/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1 +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1 @@ -641,6 +641,6 @@ function Test-ResolveHealthError{ }While($healthError -eq $null) #resolve health error - $addDRjob = Remove-AzureRmRecoveryServicesAsrReplicationProtectedItemHealthError -ReplicationProtectedItem $pe -ErrorIds $healthError.ErrorId + $addDRjob = Remove-AzureRmRecoveryServicesAsrReplicationProtectedItemHealthError -ReplicationProtectedItem $pe -ErrorId $healthError.ErrorId WaitForJobCompletion -JobId $addDRjob.Name } \ No newline at end of file diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs index 9816c1894964..cdfe66de10a5 100644 --- a/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs @@ -36,7 +36,7 @@ public class RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError /// [Parameter(Mandatory = true)] [ValidateNotNullOrEmpty] - public string[] ErrorIds { get; set; } + public string[] ErrorId { get; set; } [Parameter] public SwitchParameter WaitForCompletion { get; set; } @@ -85,7 +85,7 @@ private void FillResolveHealthErrorInput(ResolveHealthInput input) { input.Properties.HealthErrors = new List(); - foreach (string errorId in ErrorIds) + foreach (string errorId in ErrorId) { input.Properties.HealthErrors.Add(new ResolveHealthError(errorId)); } From 028fb1cd9e7f7e0487d4119d955dc3c77a2d29d4 Mon Sep 17 00:00:00 2001 From: ayfathim Date: Tue, 16 Jul 2019 13:09:41 +0530 Subject: [PATCH 12/14] fixing static analysis results --- ...zRecoveryServicesAsrReplicationProtectedItemHealthError.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md index 5fc13a84e61a..576f7dab45fd 100644 --- a/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md +++ b/src/RecoveryServices/RecoveryServices/help/Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError.md @@ -14,7 +14,7 @@ Removes the health error from the ASR replication protected item. ``` Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError - -ReplicationProtectedItem -ErrorIds [-WaitForCompletion] + -ReplicationProtectedItem -ErrorId [-WaitForCompletion] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` @@ -62,7 +62,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -ErrorIds +### -ErrorId Health Error Ids. ```yaml From 29ed3b76b98366d8c8c9f266abc448bdcc8e70af Mon Sep 17 00:00:00 2001 From: ayfathim Date: Wed, 4 Sep 2019 15:04:03 +0530 Subject: [PATCH 13/14] updated as per comments --- .../Accounts/AzureRmAlias/Mappings.json | 2 - ...ServicesAsrReplicationProtectedItemDisk.cs | 41 +++++++------------ ...sAsrReplicationProtectedItemHealthError.cs | 41 +++++++------------ .../RecoveryServices/Az.RecoveryServices.psd1 | 8 ++-- 4 files changed, 32 insertions(+), 60 deletions(-) diff --git a/src/Accounts/Accounts/AzureRmAlias/Mappings.json b/src/Accounts/Accounts/AzureRmAlias/Mappings.json index ff0d9a7b7a70..70289417f95e 100644 --- a/src/Accounts/Accounts/AzureRmAlias/Mappings.json +++ b/src/Accounts/Accounts/AzureRmAlias/Mappings.json @@ -1830,8 +1830,6 @@ "Remove-AzRecoveryServicesAsrProtectionContainerMapping": "Remove-AzureRmRecoveryServicesAsrProtectionContainerMapping", "Remove-AzRecoveryServicesAsrRecoveryPlan": "Remove-AzureRmRecoveryServicesAsrRecoveryPlan", "Remove-AzRecoveryServicesAsrReplicationProtectedItem": "Remove-AzureRmRecoveryServicesAsrReplicationProtectedItem", - "Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk": "Remove-AzureRmRecoveryServicesAsrReplicationProtectedItemDisk", - "Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError": "Remove-AzureRmRecoveryServicesAsrReplicationProtectedItemHealthError", "Remove-AzRecoveryServicesAsrServicesProvider": "Remove-AzureRmRecoveryServicesAsrServicesProvider", "Remove-AzRecoveryServicesAsrStorageClassificationMapping": "Remove-AzureRmRecoveryServicesAsrStorageClassificationMapping", "Remove-AzRecoveryServicesAsrvCenter": "Remove-AzureRmRecoveryServicesAsrvCenter", diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk.cs b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk.cs index c41e806208a4..ddb6893e3db3 100644 --- a/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk.cs +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk.cs @@ -46,9 +46,6 @@ public class RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemDisk : Site [ValidateNotNullOrEmpty] public string[] DiskId { get; set; } - [Parameter] - public SwitchParameter WaitForCompletion { get; set; } - /// /// ProcessRecord of the command. /// @@ -66,28 +63,23 @@ public override void ExecuteSiteRecoveryCmdlet() var input = new RemoveDisksInput { Properties = inputProperties }; FillRemoveDiskInputForAzureToAzureReplication(input); - this.response = this.RecoveryServicesClient.RemoveDisks( - Utilities.GetValueFromArmId( - this.InputObject.ID, - ARMResourceTypeConstants.ReplicationFabrics), - Utilities.GetValueFromArmId( - this.InputObject.ID, - ARMResourceTypeConstants.ReplicationProtectionContainers), - this.InputObject.Name, - input); - - this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( - PSRecoveryServicesClient.GetJobIdFromReponseLocation(this.response.Location)); - - this.WriteObject(new ASRJob(this.jobResponse)); - - if (this.WaitForCompletion.IsPresent) + if (this.ShouldProcess( + this.InputObject.FriendlyName, + "Removes the protected disk")) { - this.WaitForJobCompletion(this.jobResponse.Name); + PSSiteRecoveryLongRunningOperation response = + this.RecoveryServicesClient.RemoveDisks( + Utilities.GetValueFromArmId( + this.InputObject.ID, + ARMResourceTypeConstants.ReplicationFabrics), + Utilities.GetValueFromArmId( + this.InputObject.ID, + ARMResourceTypeConstants.ReplicationProtectionContainers), + this.InputObject.Name, + input); this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( - PSRecoveryServicesClient - .GetJobIdFromReponseLocation(this.response.Location)); + PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(this.jobResponse)); } @@ -128,10 +120,5 @@ private void WriteJob( } private Job jobResponse; - - /// - /// Job response. - /// - private PSSiteRecoveryLongRunningOperation response; } } diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs index cdfe66de10a5..3fe09b192d68 100644 --- a/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError.cs @@ -38,9 +38,6 @@ public class RemoveAzureRmRecoveryServicesAsrReplicationProtectedItemHealthError [ValidateNotNullOrEmpty] public string[] ErrorId { get; set; } - [Parameter] - public SwitchParameter WaitForCompletion { get; set; } - /// /// ProcessRecord of the command. /// @@ -51,28 +48,23 @@ public override void ExecuteSiteRecoveryCmdlet() var input = new ResolveHealthInput { Properties = new ResolveHealthInputProperties() }; FillResolveHealthErrorInput(input); - this.response = this.RecoveryServicesClient.ResolveHealthError( - Utilities.GetValueFromArmId( - this.ReplicationProtectedItem.ID, - ARMResourceTypeConstants.ReplicationFabrics), - Utilities.GetValueFromArmId( - this.ReplicationProtectedItem.ID, - ARMResourceTypeConstants.ReplicationProtectionContainers), - this.ReplicationProtectedItem.Name, - input); - - this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( - PSRecoveryServicesClient.GetJobIdFromReponseLocation(this.response.Location)); - - this.WriteObject(new ASRJob(this.jobResponse)); - - if (this.WaitForCompletion.IsPresent) + if (this.ShouldProcess( + this.ReplicationProtectedItem.FriendlyName, + "Removes the protected item's health error")) { - this.WaitForJobCompletion(this.jobResponse.Name); + PSSiteRecoveryLongRunningOperation response = + this.RecoveryServicesClient.ResolveHealthError( + Utilities.GetValueFromArmId( + this.ReplicationProtectedItem.ID, + ARMResourceTypeConstants.ReplicationFabrics), + Utilities.GetValueFromArmId( + this.ReplicationProtectedItem.ID, + ARMResourceTypeConstants.ReplicationProtectionContainers), + this.ReplicationProtectedItem.Name, + input); this.jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( - PSRecoveryServicesClient - .GetJobIdFromReponseLocation(this.response.Location)); + PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(this.jobResponse)); } @@ -102,10 +94,5 @@ private void WriteJob( } private Job jobResponse; - - /// - /// Job response. - /// - private PSSiteRecoveryLongRunningOperation response; } } diff --git a/src/RecoveryServices/RecoveryServices/Az.RecoveryServices.psd1 b/src/RecoveryServices/RecoveryServices/Az.RecoveryServices.psd1 index 441e25dab57c..75436eb91280 100644 --- a/src/RecoveryServices/RecoveryServices/Az.RecoveryServices.psd1 +++ b/src/RecoveryServices/RecoveryServices/Az.RecoveryServices.psd1 @@ -133,8 +133,8 @@ CmdletsToExport = 'Remove-AzRecoveryServicesAsrProtectionContainerMapping', 'Remove-AzRecoveryServicesAsrRecoveryPlan', 'Remove-AzRecoveryServicesAsrReplicationProtectedItem', - 'Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk', - 'Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError', + 'Remove-AzRecoveryServicesAsrReplicationProtectedItemDisk', + 'Remove-AzRecoveryServicesAsrReplicationProtectedItemHealthError', 'Remove-AzRecoveryServicesAsrServicesProvider', 'Remove-AzRecoveryServicesAsrStorageClassificationMapping', 'Remove-AzRecoveryServicesAsrvCenter', @@ -220,8 +220,8 @@ AliasesToExport = 'Get-AzRecoveryServicesBackupProperties', 'Remove-ASRFabric', 'Remove-ASRNetworkMapping', 'Remove-ASRPolicy', 'Remove-ASRProtectionContainerMapping', 'Remove-ASRRP', 'Remove-ASRRecoveryPlan', 'Remove-ASRReplicationProtectedItem', - 'Remove-ASRReplicationProtectedItemDisk', - 'Remove-ASRReplicationProtectedItemHealthError', + 'Remove-ASRReplicationProtectedItemDisk', + 'Remove-ASRReplicationProtectedItemHealthError', 'Remove-ASRServicesProvider', 'Remove-ASRStorageClassificationMapping', 'Remove-ASRvCenter', 'Restart-ASRJob', 'Resume-ASRJob', 'Set-ASRAlertSetting', From bd40bb26c4fc1710f941884cf36e4188d9aa71c7 Mon Sep 17 00:00:00 2001 From: viverm Date: Wed, 6 Nov 2019 13:50:40 +0530 Subject: [PATCH 14/14] test fixes --- .../ScenarioTests/A2A/AsrA2ATests.cs | 6 +++--- .../ScenarioTests/A2A/AsrA2ATests.ps1 | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.cs b/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.cs index 3cccff3ee05a..b1067921e3b8 100644 --- a/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.cs +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.cs @@ -32,11 +32,11 @@ public AsrA2ATests( this.PowershellHelperFile = System.IO.Path.Combine( System.AppDomain.CurrentDomain.BaseDirectory, - "ScenarioTests\\A2A\\A2ATestsHelper.ps1"); + "ScenarioTests", "A2A", "A2ATestsHelper.ps1"); - this.PowershellFile = System.IO.Path.Combine( + this.PowershellFile = System.IO.Path.Combine( System.AppDomain.CurrentDomain.BaseDirectory, - "ScenarioTests\\A2A\\AsrA2ATests.ps1"); + "ScenarioTests", "A2A", "AsrA2ATests.ps1"); this.Initialize(); } diff --git a/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1 b/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1 index bd60d1244e7a..6fea9cbd9313 100644 --- a/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1 +++ b/src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1 @@ -375,6 +375,7 @@ function Test-AddReplicationProtectedItemDisk{ $pe = Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $pc -Name $vmName Assert-NotNull($pe) +} <# .SYNOPSIS @@ -505,7 +506,7 @@ function Test-RemoveReplicationProtectedItemDisk{ WaitForJobCompletion -JobId $addDRjob.Name #get disk to deattach - | $removeDisk = $pe.ProviderSpecificDetails.A2ADiskDetails | where-object {$_.AllowedDiskLevelOperation.Count -eq 1} + $removeDisk = $pe.ProviderSpecificDetails.A2ADiskDetails | where-object {$_.AllowedDiskLevelOperation.Count -eq 1} Assert-NotNull($removeDisk) $vm = get-azVm -ResourceGroupName $vmName -Name $vmName $removeDiskId = $vm.StorageProfile.DataDisks | Where-Object {$_.ManagedDisk.Name -eq $removeDisk.DiskName} @@ -643,4 +644,4 @@ function Test-ResolveHealthError{ #resolve health error $addDRjob = Remove-AzureRmRecoveryServicesAsrReplicationProtectedItemHealthError -ReplicationProtectedItem $pe -ErrorId $healthError.ErrorId WaitForJobCompletion -JobId $addDRjob.Name -} \ No newline at end of file +}