/// <summary> /// Starts RP Planned failover. /// </summary> private void StartRpPlannedFailover() { RpPlannedFailoverRequest request = new RpPlannedFailoverRequest(); if (this.RecoveryPlan == null) { var rp = RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan( this.RPId); this.RecoveryPlan = new ASRRecoveryPlan(rp.RecoveryPlan); this.ValidateUsageById( this.RecoveryPlan.ReplicationProvider, Constants.RPId); } if (this.RecoveryPlan.ReplicationProvider == Constants.HyperVReplicaAzure) { if (this.Direction == Constants.PrimaryToRecovery) { var blob = new AzureFailoverInput(); blob.VaultLocation = this.GetCurrentValutLocation(); request.ReplicationProviderSettings = DataContractUtils.Serialize<AzureFailoverInput>(blob); } else { var blob = new AzureFailbackInput(); blob.CreateRecoveryVmIfDoesntExist = false; blob.SkipDataSync = this.Optimize == Constants.ForDowntime ? true : false; request.ReplicationProviderSettings = DataContractUtils.Serialize<AzureFailbackInput>(blob); } } request.ReplicationProvider = this.RecoveryPlan.ReplicationProvider; request.FailoverDirection = this.Direction; this.jobResponse = RecoveryServicesClient.StartAzureSiteRecoveryPlannedFailover( this.RPId, request); this.WriteJob(this.jobResponse.Job); if (this.WaitForCompletion.IsPresent) { this.WaitForJobCompletion(this.jobResponse.Job.ID); } }
/// <summary> /// Starts PE Test failover. /// </summary> private void StartPETestFailover() { var request = new TestFailoverRequest(); if (this.ProtectionEntity == null) { var pe = RecoveryServicesClient.GetAzureSiteRecoveryProtectionEntity( this.ProtectionContainerId, this.ProtectionEntityId); this.ProtectionEntity = new ASRProtectionEntity(pe.ProtectionEntity); this.ValidateUsageById( this.ProtectionEntity.ReplicationProvider, Constants.ProtectionEntityId); } request.ReplicationProviderSettings = string.Empty; if (this.ProtectionEntity.ReplicationProvider == Constants.HyperVReplicaAzure) { if (this.Direction == Constants.PrimaryToRecovery) { var blob = new AzureFailoverInput(); blob.VaultLocation = this.GetCurrentValutLocation(); request.ReplicationProviderSettings = DataContractUtils.Serialize<AzureFailoverInput>(blob); } } request.ReplicationProvider = this.ProtectionEntity.ReplicationProvider; request.FailoverDirection = this.Direction; request.NetworkID = this.networkId; request.NetworkType = this.networkType; this.jobResponse = RecoveryServicesClient.StartAzureSiteRecoveryTestFailover( this.ProtectionContainerId, this.ProtectionEntityId, request); this.WriteJob(this.jobResponse.Job); if (this.WaitForCompletion.IsPresent) { this.WaitForJobCompletion(this.jobResponse.Job.ID); } }
/// <summary> /// Starts RP Planned failover. /// </summary> private void StartRpUnPlannedFailover() { RpUnplannedFailoverRequest request = new RpUnplannedFailoverRequest(); if (this.RecoveryPlan == null) { var rp = RecoveryServicesClient.GetAzureSiteRecoveryRecoveryPlan( this.RPId); this.RecoveryPlan = new ASRRecoveryPlan(rp.RecoveryPlan); this.ValidateUsageById( this.RecoveryPlan.ReplicationProvider, Constants.RPId); } request.ReplicationProviderSettings = string.Empty; if (this.RecoveryPlan.ReplicationProvider == Constants.HyperVReplicaAzure) { request.ReplicationProvider = this.RecoveryPlan.ReplicationProvider; if (this.Direction == Constants.PrimaryToRecovery) { var blob = new AzureFailoverInput(); blob.VaultLocation = this.GetCurrentValutLocation(); request.ReplicationProviderSettings = DataContractUtils.Serialize<AzureFailoverInput>(blob); } } request.ReplicationProvider = this.RecoveryPlan.ReplicationProvider; request.FailoverDirection = this.Direction; request.PrimaryAction = this.PerformSourceSideActions; this.jobResponse = RecoveryServicesClient.StartAzureSiteRecoveryUnplannedFailover( this.RPId, request); this.WriteJob(this.jobResponse.Job); if (this.WaitForCompletion.IsPresent) { this.WaitForJobCompletion(this.jobResponse.Job.ID); } }