/// <summary> /// Starts RP Planned failover. /// </summary> private void StartRpPlannedFailover() { // Refresh RP Object var rp = RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan(this.RecoveryPlan.Name); var recoveryPlanPlannedFailoverInputProperties = new RecoveryPlanPlannedFailoverInputProperties() { FailoverDirection = this.Direction, ProviderSpecificDetails = new List <RecoveryPlanProviderSpecificFailoverInput>() }; foreach (string replicationProvider in rp.RecoveryPlan.Properties.ReplicationProviders) { if (0 == string.Compare( replicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase)) { if (this.Direction == Constants.PrimaryToRecovery) { var recoveryPlanHyperVReplicaAzureFailoverInput = new RecoveryPlanHyperVReplicaAzureFailoverInput() { InstanceType = replicationProvider, PrimaryKekCertificatePfx = primaryKekCertpfx, SecondaryKekCertificatePfx = secondaryKekCertpfx, VaultLocation = this.GetCurrentVaultLocation() }; recoveryPlanPlannedFailoverInputProperties.ProviderSpecificDetails.Add(recoveryPlanHyperVReplicaAzureFailoverInput); } else { var recoveryPlanHyperVReplicaAzureFailbackInput = new RecoveryPlanHyperVReplicaAzureFailbackInput() { InstanceType = replicationProvider + "Failback", DataSyncOption = this.Optimize == Constants.ForDownTime ? Constants.ForDownTime : Constants.ForSynchronization, RecoveryVmCreationOption = String.Compare(this.CreateVmIfNotFound, Constants.Yes, StringComparison.OrdinalIgnoreCase) == 0 ? Constants.CreateVmIfNotFound : Constants.NoAction }; recoveryPlanPlannedFailoverInputProperties.ProviderSpecificDetails.Add(recoveryPlanHyperVReplicaAzureFailbackInput); } } } var recoveryPlanPlannedFailoverInput = new RecoveryPlanPlannedFailoverInput() { Properties = recoveryPlanPlannedFailoverInputProperties }; LongRunningOperationResponse response = RecoveryServicesClient.StartAzureSiteRecoveryPlannedFailover( this.RecoveryPlan.Name, recoveryPlanPlannedFailoverInput); JobResponse jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); WriteObject(new ASRJob(jobResponse.Job)); }
/// <summary> /// Starts RP Unplanned failover. /// </summary> private void StartRpUnplannedFailover() { // Refresh RP Object var rp = this.RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan( this.RecoveryPlan.Name); var recoveryPlanUnplannedFailoverInputProperties = new RecoveryPlanUnplannedFailoverInputProperties { FailoverDirection = this.Direction == PossibleOperationsDirections.PrimaryToRecovery.ToString() ? PossibleOperationsDirections.PrimaryToRecovery : PossibleOperationsDirections.RecoveryToPrimary, SourceSiteOperations = this.PerformSourceSideAction ? SourceSiteOperations.Required : SourceSiteOperations.NotRequired, //Required|NotRequired ProviderSpecificDetails = new List <RecoveryPlanProviderSpecificFailoverInput>() }; foreach (var replicationProvider in rp.Properties.ReplicationProviders) { if (0 == string.Compare( replicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase)) { if (this.Direction == Constants.PrimaryToRecovery) { var recoveryPlanHyperVReplicaAzureFailoverInput = new RecoveryPlanHyperVReplicaAzureFailoverInput { PrimaryKekCertificatePfx = this.primaryKekCertpfx, SecondaryKekCertificatePfx = this.secondaryKekCertpfx, VaultLocation = "dummy" }; recoveryPlanUnplannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanHyperVReplicaAzureFailoverInput); } } } var recoveryPlanUnplannedFailoverInput = new RecoveryPlanUnplannedFailoverInput { Properties = recoveryPlanUnplannedFailoverInputProperties }; var response = this.RecoveryServicesClient.StartAzureSiteRecoveryUnplannedFailover( this.RecoveryPlan.Name, recoveryPlanUnplannedFailoverInput); var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(jobResponse)); }
/// <summary> /// Starts RP Test failover. /// </summary> private void StartRpTestFailover() { // Refresh RP Object var rp = RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan(this.RecoveryPlan.Name); var recoveryPlanTestFailoverInputProperties = new RecoveryPlanTestFailoverInputProperties() { FailoverDirection = this.Direction, NetworkId = this.networkId, NetworkType = this.networkType, ProviderSpecificDetails = new List <RecoveryPlanProviderSpecificFailoverInput>() }; foreach (string replicationProvider in rp.RecoveryPlan.Properties.ReplicationProviders) { if (0 == string.Compare( replicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase)) { if (this.Direction == Constants.PrimaryToRecovery) { var recoveryPlanHyperVReplicaAzureFailoverInput = new RecoveryPlanHyperVReplicaAzureFailoverInput() { InstanceType = replicationProvider, PrimaryKekCertificatePfx = primaryKekCertpfx, SecondaryKekCertificatePfx = secondaryKekCertpfx, VaultLocation = this.GetCurrentVaultLocation() }; recoveryPlanTestFailoverInputProperties.ProviderSpecificDetails.Add(recoveryPlanHyperVReplicaAzureFailoverInput); } else { new ArgumentException(Properties.Resources.UnsupportedDirectionForTFO);// Throw Unsupported Direction Exception } } } var recoveryPlanTestFailoverInput = new RecoveryPlanTestFailoverInput() { Properties = recoveryPlanTestFailoverInputProperties }; LongRunningOperationResponse response = RecoveryServicesClient.StartAzureSiteRecoveryTestFailover( this.RecoveryPlan.Name, recoveryPlanTestFailoverInput); JobResponse jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); WriteObject(new ASRJob(jobResponse.Job)); }
/// <summary> /// Starts RP Unplanned failover. /// </summary> private void StartRpUnplannedFailover() { // Refresh RP Object var rp = RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan(this.RecoveryPlan.Name); var recoveryPlanUnplannedFailoverInputProperties = new RecoveryPlanUnplannedFailoverInputProperties() { FailoverDirection = this.Direction, SourceSiteOperations = this.PerformSourceSideActions ? "Required" : "NotRequired", //Required|NotRequired ProviderSpecificDetails = new List <RecoveryPlanProviderSpecificFailoverInput>() }; foreach (string replicationProvider in rp.RecoveryPlan.Properties.ReplicationProviders) { if (0 == string.Compare( replicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase)) { if (this.Direction == Constants.PrimaryToRecovery) { var recoveryPlanHyperVReplicaAzureFailoverInput = new RecoveryPlanHyperVReplicaAzureFailoverInput() { InstanceType = replicationProvider, PrimaryKekCertificatePfx = primaryKekCertpfx, SecondaryKekCertificatePfx = secondaryKekCertpfx, VaultLocation = this.GetCurrentVaultLocation() }; recoveryPlanUnplannedFailoverInputProperties.ProviderSpecificDetails.Add(recoveryPlanHyperVReplicaAzureFailoverInput); } } } var recoveryPlanUnplannedFailoverInput = new RecoveryPlanUnplannedFailoverInput() { Properties = recoveryPlanUnplannedFailoverInputProperties }; LongRunningOperationResponse response = RecoveryServicesClient.StartAzureSiteRecoveryUnplannedFailover( this.RecoveryPlan.Name, recoveryPlanUnplannedFailoverInput); JobResponse jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); WriteObject(new ASRJob(jobResponse.Job)); }
/// <summary> /// Starts RP Planned failover. /// </summary> private void StartRpPlannedFailover() { // Refresh RP Object var rp = this.RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan( this.RecoveryPlan.Name); var recoveryPlanPlannedFailoverInputProperties = new RecoveryPlanPlannedFailoverInputProperties { FailoverDirection = this.Direction == PossibleOperationsDirections.PrimaryToRecovery.ToString() ? PossibleOperationsDirections.PrimaryToRecovery : PossibleOperationsDirections.RecoveryToPrimary, ProviderSpecificDetails = new List <RecoveryPlanProviderSpecificFailoverInput>() }; foreach (var replicationProvider in rp.Properties.ReplicationProviders) { if (0 == string.Compare( replicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase)) { if (this.Direction == Constants.PrimaryToRecovery) { var recoveryPlanHyperVReplicaAzureFailoverInput = new RecoveryPlanHyperVReplicaAzureFailoverInput { PrimaryKekCertificatePfx = this.primaryKekCertpfx, SecondaryKekCertificatePfx = this.secondaryKekCertpfx, VaultLocation = "dummy" }; recoveryPlanPlannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanHyperVReplicaAzureFailoverInput); } else { var recoveryPlanHyperVReplicaAzureFailbackInput = new RecoveryPlanHyperVReplicaAzureFailbackInput { DataSyncOption = this.Optimize == Constants.ForDownTime ? DataSyncStatus.ForDownTime : DataSyncStatus.ForSynchronization, RecoveryVmCreationOption = string.Compare( this.CreateVmIfNotFound, Constants.Yes, StringComparison .OrdinalIgnoreCase) == 0 ? AlternateLocationRecoveryOption .CreateVmIfNotFound : AlternateLocationRecoveryOption.NoAction }; recoveryPlanPlannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanHyperVReplicaAzureFailbackInput); } } } var recoveryPlanPlannedFailoverInput = new RecoveryPlanPlannedFailoverInput { Properties = recoveryPlanPlannedFailoverInputProperties }; var response = this.RecoveryServicesClient.StartAzureSiteRecoveryPlannedFailover( this.RecoveryPlan.Name, recoveryPlanPlannedFailoverInput); var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(jobResponse)); }
/// <summary> /// Starts recovery plan unplanned failover. /// </summary> private void StartRpUnplannedFailover() { // Refresh RP Object var rp = this.RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan( this.RecoveryPlan.Name); var recoveryPlanUnplannedFailoverInputProperties = new RecoveryPlanUnplannedFailoverInputProperties { FailoverDirection = this.Direction == PossibleOperationsDirections.PrimaryToRecovery.ToString() ? PossibleOperationsDirections.PrimaryToRecovery : PossibleOperationsDirections.RecoveryToPrimary, SourceSiteOperations = this.PerformSourceSideAction ? SourceSiteOperations.Required : SourceSiteOperations.NotRequired, //Required|NotRequired ProviderSpecificDetails = new List <RecoveryPlanProviderSpecificFailoverInput>() }; foreach (var replicationProvider in rp.Properties.ReplicationProviders) { if (0 == string.Compare( replicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase)) { if (this.Direction == Constants.PrimaryToRecovery) { var recoveryPlanHyperVReplicaAzureFailoverInput = new RecoveryPlanHyperVReplicaAzureFailoverInput { PrimaryKekCertificatePfx = this.primaryKekCertpfx, SecondaryKekCertificatePfx = this.secondaryKekCertpfx, VaultLocation = "dummy" }; if (this.RecoveryTag != null) { var recoveryPointType = this.RecoveryTag == Constants.RecoveryTagLatestAvailableApplicationConsistent ? HyperVReplicaAzureRpRecoveryPointType.LatestApplicationConsistent : this.RecoveryTag == Constants.RecoveryTagLatestAvailable ? HyperVReplicaAzureRpRecoveryPointType.LatestProcessed : HyperVReplicaAzureRpRecoveryPointType.Latest; recoveryPlanHyperVReplicaAzureFailoverInput.RecoveryPointType = recoveryPointType; } recoveryPlanUnplannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanHyperVReplicaAzureFailoverInput); } } else if (string.Compare( replicationProvider, Constants.InMageAzureV2, StringComparison.OrdinalIgnoreCase) == 0) { // Check if the Direction is PrimaryToRecovery. if (this.Direction == Constants.PrimaryToRecovery) { // Set the Recovery Point Types for InMage. var recoveryPointType = this.RecoveryTag == Constants.RecoveryTagLatestAvailableApplicationConsistent ? InMageV2RpRecoveryPointType.LatestApplicationConsistent : this.RecoveryTag == Constants.RecoveryTagLatestAvailable ? InMageV2RpRecoveryPointType.LatestProcessed : this.RecoveryTag == Constants.RecoveryTagLatestAvailableCrashConsistent ? InMageV2RpRecoveryPointType.LatestCrashConsistent : InMageV2RpRecoveryPointType.Latest; // Create the InMageAzureV2 Provider specific input. var recoveryPlanInMageAzureV2FailoverInput = new RecoveryPlanInMageAzureV2FailoverInput { RecoveryPointType = recoveryPointType, VaultLocation = "dummy" }; // Add the InMageAzureV2 Provider specific input in the Planned Failover Input. recoveryPlanUnplannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanInMageAzureV2FailoverInput); } } else if (string.Compare( replicationProvider, Constants.InMage, StringComparison.OrdinalIgnoreCase) == 0) { // Check if the Direction is RecoveryToPrimary. if (this.Direction == Constants.RecoveryToPrimary) { // Set the Recovery Point Types for InMage. var recoveryPointType = this.RecoveryTag == Constants.RecoveryTagLatestAvailableApplicationConsistent ? RpInMageRecoveryPointType.LatestTag : RpInMageRecoveryPointType.LatestTime; // Create the InMage Provider specific input. var recoveryPlanInMageFailoverInput = new RecoveryPlanInMageFailoverInput { RecoveryPointType = recoveryPointType }; // Add the InMage Provider specific input in the Planned Failover Input. recoveryPlanUnplannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanInMageFailoverInput); } } else if (0 == string.Compare( replicationProvider, Constants.A2A, StringComparison.OrdinalIgnoreCase)) { A2ARpRecoveryPointType recoveryPointType = A2ARpRecoveryPointType.Latest; switch (this.RecoveryTag) { case Constants.RecoveryTagLatestAvailableCrashConsistent: recoveryPointType = A2ARpRecoveryPointType.LatestCrashConsistent; break; case Constants.RecoveryTagLatestAvailableApplicationConsistent: recoveryPointType = A2ARpRecoveryPointType.LatestApplicationConsistent; break; case Constants.RecoveryTagLatestAvailable: recoveryPointType = A2ARpRecoveryPointType.LatestProcessed; break; case Constants.RecoveryTagLatest: recoveryPointType = A2ARpRecoveryPointType.Latest; break; } var recoveryPlanA2AFailoverInput = new RecoveryPlanA2AFailoverInput() { RecoveryPointType = recoveryPointType }; recoveryPlanUnplannedFailoverInputProperties.ProviderSpecificDetails.Add(recoveryPlanA2AFailoverInput); } } var recoveryPlanUnplannedFailoverInput = new RecoveryPlanUnplannedFailoverInput { Properties = recoveryPlanUnplannedFailoverInputProperties }; var response = this.RecoveryServicesClient.StartAzureSiteRecoveryUnplannedFailover( this.RecoveryPlan.Name, recoveryPlanUnplannedFailoverInput); var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(jobResponse)); }
/// <summary> /// Starts RP Planned failover. /// </summary> private void StartRpPlannedFailover() { // Refresh RP Object var rp = this.RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan( this.RecoveryPlan.Name); var recoveryPlanPlannedFailoverInputProperties = new RecoveryPlanPlannedFailoverInputProperties { FailoverDirection = this.Direction == PossibleOperationsDirections.PrimaryToRecovery.ToString() ? PossibleOperationsDirections.PrimaryToRecovery : PossibleOperationsDirections.RecoveryToPrimary, ProviderSpecificDetails = new List <RecoveryPlanProviderSpecificFailoverInput>() }; foreach (var replicationProvider in rp.Properties.ReplicationProviders) { if (0 == string.Compare( replicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase)) { if (this.Direction == Constants.PrimaryToRecovery) { var recoveryPlanHyperVReplicaAzureFailoverInput = new RecoveryPlanHyperVReplicaAzureFailoverInput { PrimaryKekCertificatePfx = this.primaryKekCertpfx, SecondaryKekCertificatePfx = this.secondaryKekCertpfx }; recoveryPlanPlannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanHyperVReplicaAzureFailoverInput); } else { var recoveryPlanHyperVReplicaAzureFailbackInput = new RecoveryPlanHyperVReplicaAzureFailbackInput { DataSyncOption = this.Optimize == Constants.ForDownTime ? DataSyncStatus.ForDownTime : DataSyncStatus.ForSynchronization, RecoveryVmCreationOption = string.Compare( this.CreateVmIfNotFound, Constants.Yes, StringComparison .OrdinalIgnoreCase) == 0 ? AlternateLocationRecoveryOption .CreateVmIfNotFound : AlternateLocationRecoveryOption.NoAction }; recoveryPlanPlannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanHyperVReplicaAzureFailbackInput); } } else if (0 == string.Compare( replicationProvider, Constants.InMageRcmFailback, StringComparison.OrdinalIgnoreCase)) { this.MultiVmSyncPoint = this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.MultiVmSyncPoint)) ? this.MultiVmSyncPoint : Constants.Enable; var recoveryPointType = this.RecoveryTag == Constants.RecoveryTagApplicationConsistent ? InMageRcmFailbackRecoveryPointType.ApplicationConsistent : InMageRcmFailbackRecoveryPointType.CrashConsistent; // Validate the direction as RecoveryToPrimary. if (this.Direction == Constants.RecoveryToPrimary) { var recoveryPlanFailoverInput = new RecoveryPlanInMageRcmFailbackFailoverInput { RecoveryPointType = recoveryPointType, UseMultiVmSyncPoint = this.MultiVmSyncPoint == Constants.Enable ? Constants.True : Constants.False }; recoveryPlanPlannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanFailoverInput); } else { // PrimaryToRecovery direction is invalid for InMageRcmFailback. new ArgumentException(Resources.InvalidDirectionForAzureToVMWare); } } else if (string.Compare( replicationProvider, Constants.InMageAzureV2, StringComparison.OrdinalIgnoreCase) == 0 || string.Compare( replicationProvider, Constants.InMage, StringComparison.OrdinalIgnoreCase) == 0 || string.Compare( replicationProvider, Constants.InMageRcm, StringComparison.OrdinalIgnoreCase) == 0) { throw new InvalidOperationException( string.Format( Resources.UnsupportedReplicationProviderForPlannedFailover, replicationProvider)); } } var recoveryPlanPlannedFailoverInput = new RecoveryPlanPlannedFailoverInput { Properties = recoveryPlanPlannedFailoverInputProperties }; var response = this.RecoveryServicesClient.StartAzureSiteRecoveryPlannedFailover( this.RecoveryPlan.Name, recoveryPlanPlannedFailoverInput); var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(jobResponse)); }
/// <summary> /// Starts recovery plan unplanned failover. /// </summary> private void StartRpUnplannedFailover() { // Refresh RP Object var rp = this.RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan( this.RecoveryPlan.Name); var recoveryPlanUnplannedFailoverInputProperties = new RecoveryPlanUnplannedFailoverInputProperties { FailoverDirection = this.Direction == PossibleOperationsDirections.PrimaryToRecovery.ToString() ? PossibleOperationsDirections.PrimaryToRecovery : PossibleOperationsDirections.RecoveryToPrimary, SourceSiteOperations = this.PerformSourceSideAction ? SourceSiteOperations.Required : SourceSiteOperations.NotRequired, //Required|NotRequired ProviderSpecificDetails = new List <RecoveryPlanProviderSpecificFailoverInput>() }; foreach (var replicationProvider in rp.Properties.ReplicationProviders) { if (0 == string.Compare( replicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase)) { if (this.Direction == Constants.PrimaryToRecovery) { var recoveryPlanHyperVReplicaAzureFailoverInput = new RecoveryPlanHyperVReplicaAzureFailoverInput { PrimaryKekCertificatePfx = this.primaryKekCertpfx, SecondaryKekCertificatePfx = this.secondaryKekCertpfx }; if (this.RecoveryTag != null) { var recoveryPointType = this.RecoveryTag == Constants.RecoveryTagLatestAvailableApplicationConsistent ? HyperVReplicaAzureRpRecoveryPointType.LatestApplicationConsistent : this.RecoveryTag == Constants.RecoveryTagLatestAvailable ? HyperVReplicaAzureRpRecoveryPointType.LatestProcessed : HyperVReplicaAzureRpRecoveryPointType.Latest; recoveryPlanHyperVReplicaAzureFailoverInput.RecoveryPointType = recoveryPointType; } recoveryPlanUnplannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanHyperVReplicaAzureFailoverInput); } } else if (string.Compare( replicationProvider, Constants.InMageAzureV2, StringComparison.OrdinalIgnoreCase) == 0) { // Check if the Direction is PrimaryToRecovery. if (this.Direction == Constants.PrimaryToRecovery) { // Set the Recovery Point Types for InMage. var recoveryPointType = this.RecoveryTag == Constants.RecoveryTagLatestAvailableApplicationConsistent ? InMageV2RpRecoveryPointType.LatestApplicationConsistent : this.RecoveryTag == Constants.RecoveryTagLatestAvailable ? InMageV2RpRecoveryPointType.LatestProcessed : this.RecoveryTag == Constants.RecoveryTagLatestAvailableCrashConsistent ? InMageV2RpRecoveryPointType.LatestCrashConsistent : InMageV2RpRecoveryPointType.Latest; // Create the InMageAzureV2 Provider specific input. var recoveryPlanInMageAzureV2FailoverInput = new RecoveryPlanInMageAzureV2FailoverInput { RecoveryPointType = recoveryPointType }; // Add the InMageAzureV2 Provider specific input in the Planned Failover Input. recoveryPlanUnplannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanInMageAzureV2FailoverInput); } } else if (string.Compare( replicationProvider, Constants.InMage, StringComparison.OrdinalIgnoreCase) == 0) { // Check if the Direction is RecoveryToPrimary. if (this.Direction == Constants.RecoveryToPrimary) { // Set the Recovery Point Types for InMage. var recoveryPointType = this.RecoveryTag == Constants.RecoveryTagLatestAvailableApplicationConsistent ? RpInMageRecoveryPointType.LatestTag : RpInMageRecoveryPointType.LatestTime; // Create the InMage Provider specific input. var recoveryPlanInMageFailoverInput = new RecoveryPlanInMageFailoverInput { RecoveryPointType = recoveryPointType }; // Add the InMage Provider specific input in the Planned Failover Input. recoveryPlanUnplannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanInMageFailoverInput); } } else if (0 == string.Compare( replicationProvider, Constants.A2A, StringComparison.OrdinalIgnoreCase)) { string recoveryPointType = A2ARpRecoveryPointType.Latest; switch (this.RecoveryTag) { case Constants.RecoveryTagLatestAvailableCrashConsistent: recoveryPointType = A2ARpRecoveryPointType.LatestCrashConsistent; break; case Constants.RecoveryTagLatestAvailableApplicationConsistent: recoveryPointType = A2ARpRecoveryPointType.LatestApplicationConsistent; break; case Constants.RecoveryTagLatestAvailable: recoveryPointType = A2ARpRecoveryPointType.LatestProcessed; break; case Constants.RecoveryTagLatest: recoveryPointType = A2ARpRecoveryPointType.Latest; break; } var recoveryPlanA2AFailoverInput = new RecoveryPlanA2AFailoverInput() { RecoveryPointType = recoveryPointType }; recoveryPlanUnplannedFailoverInputProperties.ProviderSpecificDetails.Add(recoveryPlanA2AFailoverInput); } else if (string.Compare( replicationProvider, Constants.InMageRcm, StringComparison.OrdinalIgnoreCase) == 0) { var recoveryPointType = this.RecoveryTag == Constants.RecoveryTagLatestAvailableApplicationConsistent ? RecoveryPlanPointType.LatestApplicationConsistent : this.RecoveryTag == Constants.RecoveryTagLatest ? RecoveryPlanPointType.Latest : this.RecoveryTag == Constants.RecoveryTagLatestAvailableCrashConsistent ? RecoveryPlanPointType.LatestCrashConsistent : RecoveryPlanPointType.LatestProcessed; this.MultiVmSyncPoint = this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.MultiVmSyncPoint)) ? this.MultiVmSyncPoint : Constants.Disable; // Check if the direction is PrimaryToRecovery. if (this.Direction == Constants.PrimaryToRecovery) { // Create the InMageRcm provider specific input. var recoveryPlanInMageRcmFailoverInput = new RecoveryPlanInMageRcmFailoverInput { RecoveryPointType = recoveryPointType, UseMultiVmSyncPoint = this.MultiVmSyncPoint == Constants.Enable ? Constants.True : Constants.False }; // Add the InMagRcm provider specific input in the unplanned failover input. recoveryPlanUnplannedFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanInMageRcmFailoverInput); } } else if (string.Compare( this.ReplicationProtectedItem.ReplicationProvider, Constants.InMageRcmFailback, StringComparison.OrdinalIgnoreCase) == 0) { throw new InvalidOperationException( string.Format( Resources.UnsupportedReplicationProviderForUnplannedFailover, this.ReplicationProtectedItem.ReplicationProvider)); } } var recoveryPlanUnplannedFailoverInput = new RecoveryPlanUnplannedFailoverInput { Properties = recoveryPlanUnplannedFailoverInputProperties }; var response = this.RecoveryServicesClient.StartAzureSiteRecoveryUnplannedFailover( this.RecoveryPlan.Name, recoveryPlanUnplannedFailoverInput); var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(jobResponse)); }
/// <summary> /// Starts RP Test failover. /// </summary> private void StartRpTestFailover() { // Refresh RP Object var rp = this.RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan( this.RecoveryPlan.Name); var recoveryPlanTestFailoverInputProperties = new RecoveryPlanTestFailoverInputProperties { FailoverDirection = this.Direction == PossibleOperationsDirections.PrimaryToRecovery.ToString() ? PossibleOperationsDirections.PrimaryToRecovery : PossibleOperationsDirections.RecoveryToPrimary, NetworkId = this.networkId, NetworkType = this.networkType, ProviderSpecificDetails = new List <RecoveryPlanProviderSpecificFailoverInput>(), SkipTestFailoverCleanup = bool.TrueString }; foreach (var replicationProvider in rp.Properties.ReplicationProviders) { if (0 == string.Compare( replicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase)) { if (this.Direction == Constants.PrimaryToRecovery) { var recoveryPlanHyperVReplicaAzureFailoverInput = new RecoveryPlanHyperVReplicaAzureFailoverInput { PrimaryKekCertificatePfx = this.primaryKekCertpfx, SecondaryKekCertificatePfx = this.secondaryKekCertpfx, VaultLocation = "dummy" }; recoveryPlanTestFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanHyperVReplicaAzureFailoverInput); } else { throw new ArgumentException( Resources .UnsupportedDirectionForTFO); // Throw Unsupported Direction Exception } } else if (string.Compare( replicationProvider, Constants.InMageAzureV2, StringComparison.OrdinalIgnoreCase) == 0) { // Check if the Direction is PrimaryToRecovery. if (this.Direction == Constants.PrimaryToRecovery) { // Set the Recovery Point Types for InMage. var recoveryPointType = this.RecoveryTag == Constants.RecoveryTagLatestAvailableApplicationConsistent ? InMageV2RpRecoveryPointType.LatestApplicationConsistent : this.RecoveryTag == Constants.RecoveryTagLatest ? InMageV2RpRecoveryPointType.Latest : InMageV2RpRecoveryPointType.LatestProcessed; // Create the InMageAzureV2 Provider specific input. var recoveryPlanInMageAzureV2FailoverInput = new RecoveryPlanInMageAzureV2FailoverInput { RecoveryPointType = recoveryPointType, VaultLocation = "dummy" }; // Add the InMageAzureV2 Provider specific input in the Test Failover Input. recoveryPlanTestFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanInMageAzureV2FailoverInput); } } else if (string.Compare( replicationProvider, Constants.InMage, StringComparison.OrdinalIgnoreCase) == 0) { throw new InvalidOperationException( string.Format( Resources.UnsupportedReplicationProviderForTestFailover, this.ReplicationProtectedItem.ReplicationProvider)); } else if (string.Compare( replicationProvider, Constants.A2A, StringComparison.OrdinalIgnoreCase) == 0) { // Set the Recovery Point Types for InMage. var recoveryPointType = this.RecoveryTag == Constants.RecoveryTagLatestAvailableApplicationConsistent ? A2ARpRecoveryPointType.LatestApplicationConsistent : this.RecoveryTag == Constants.RecoveryTagLatest ? A2ARpRecoveryPointType.Latest : this.RecoveryTag == Constants.RecoveryTagLatestAvailableCrashConsistent ? A2ARpRecoveryPointType.LatestCrashConsistent : A2ARpRecoveryPointType.LatestProcessed; // Create the InMageAzureV2 Provider specific input. var recoveryPlanInMageAzureV2FailoverInput = new RecoveryPlanA2AFailoverInput { RecoveryPointType = recoveryPointType, CloudServiceCreationOption = this.CloudServiceCreationOption }; // Add the InMageAzureV2 Provider specific input in the Test Failover Input. recoveryPlanTestFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanInMageAzureV2FailoverInput); } } var recoveryPlanTestFailoverInput = new RecoveryPlanTestFailoverInput { Properties = recoveryPlanTestFailoverInputProperties }; var response = this.RecoveryServicesClient.StartAzureSiteRecoveryTestFailover( this.RecoveryPlan.Name, recoveryPlanTestFailoverInput); var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(jobResponse)); }
/// <summary> /// Starts RP Test failover. /// </summary> private void StartRpTestFailover() { // Refresh RP Object var rp = this.RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan( this.RecoveryPlan.Name); var recoveryPlanTestFailoverInputProperties = new RecoveryPlanTestFailoverInputProperties { FailoverDirection = this.Direction == PossibleOperationsDirections.PrimaryToRecovery.ToString() ? PossibleOperationsDirections.PrimaryToRecovery : PossibleOperationsDirections.RecoveryToPrimary, NetworkId = this.networkId, NetworkType = this.networkType, ProviderSpecificDetails = new List <RecoveryPlanProviderSpecificFailoverInput>() }; foreach (var replicationProvider in rp.Properties.ReplicationProviders) { if (0 == string.Compare( replicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase)) { if (this.Direction == Constants.PrimaryToRecovery) { var recoveryPlanHyperVReplicaAzureFailoverInput = new RecoveryPlanHyperVReplicaAzureFailoverInput { PrimaryKekCertificatePfx = this.primaryKekCertpfx, SecondaryKekCertificatePfx = this.secondaryKekCertpfx, VaultLocation = "dummy" }; recoveryPlanTestFailoverInputProperties.ProviderSpecificDetails.Add( recoveryPlanHyperVReplicaAzureFailoverInput); } else { throw new ArgumentException( Resources .UnsupportedDirectionForTFO); // Throw Unsupported Direction Exception } } } var recoveryPlanTestFailoverInput = new RecoveryPlanTestFailoverInput { Properties = recoveryPlanTestFailoverInputProperties }; var response = this.RecoveryServicesClient.StartAzureSiteRecoveryTestFailover( this.RecoveryPlan.Name, recoveryPlanTestFailoverInput); var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails( PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); this.WriteObject(new ASRJob(jobResponse)); }