/// <summary>
 /// Starts Azure Site Recovery test failover.
 /// </summary>
 /// <param name="recoveryPlanId">Recovery Plan ID</param>
 /// <param name="recoveryPlanTestFailoverRequest">Recovery Plan test failover request</param>
 /// <returns>Job response</returns>
 public JobResponse StartAzureSiteRecoveryTestFailover(
     string recoveryPlanId,
     RpTestFailoverRequest recoveryPlanTestFailoverRequest)
 {
     return this.GetSiteRecoveryClient().RecoveryPlan.RecoveryPlanTestFailover(
         recoveryPlanId,
         recoveryPlanTestFailoverRequest, 
         this.GetRequestHeaders());
 }
        /// <summary>
        /// Starts RP test failover.
        /// </summary>
        private void StartRpTestFailover()
        {
            RpTestFailoverRequest recoveryPlanTestFailoverRequest = new RpTestFailoverRequest();
            recoveryPlanTestFailoverRequest.FailoverDirection = this.Direction;
            this.jobResponse = RecoveryServicesClient.StartAzureSiteRecoveryTestFailover(
                this.RpId, 
                recoveryPlanTestFailoverRequest);

            this.WriteJob(this.jobResponse.Job);

            if (this.WaitForCompletion.IsPresent)
            {
                this.WaitForJobCompletion(this.jobResponse.Job.ID);
            }
        }
        /// <summary>
        /// Starts RP test failover.
        /// </summary>
        private void StartRpTestFailover()
        {
            RpTestFailoverRequest request = new RpTestFailoverRequest();

            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)
            {
                if (this.Direction == Constants.PrimaryToRecovery)
                {
                    var blob = new AzureFailoverInput();
                    blob.VaultLocation = this.GetCurrentValutLocation();
                    request.ReplicationProviderSettings = DataContractUtils.Serialize<AzureFailoverInput>(blob);
                }
            }

            request.NetworkID = this.networkId;
            request.NetworkType = this.networkType;

            request.ReplicationProvider = this.RecoveryPlan.ReplicationProvider;
            request.FailoverDirection = this.Direction;

            this.jobResponse = RecoveryServicesClient.StartAzureSiteRecoveryTestFailover(
                this.RpId, 
                request);

            this.WriteJob(this.jobResponse.Job);

            if (this.WaitForCompletion.IsPresent)
            {
                this.WaitForJobCompletion(this.jobResponse.Job.ID);
            }
        }
Exemplo n.º 4
0
        public void RP_TFO_E2A_Test()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = GetSiteRecoveryClient(CustomHttpHandler);

                var requestHeaders = RequestHeaders;
                requestHeaders.AgentAuthenticationHeader = GenerateAgentAuthenticationHeader(requestHeaders.ClientRequestId);

                var responseRP = client.RecoveryPlan.List(RequestHeaders);

                JobResponse response = new JobResponse();
                foreach (var rp in responseRP.RecoveryPlans)
                {
                    RpTestFailoverRequest request = new RpTestFailoverRequest();
                    request.NetworkID = "ID";
                    request.NetworkType = "Type";
                    request.FailoverDirection = "PrimaryToRecovery";
                    request.ReplicationProvider = "HyperVReplicaAzure";
                    AzureFailoverInput foInput = new AzureFailoverInput();
                    foInput.VaultLocation = VaultLocation;
                    request.ReplicationProviderSettings = DataContractUtils.Serialize<AzureFailoverInput>
                        (foInput);
                    response = client.RecoveryPlan.RecoveryPlanTestFailover(
                        rp.ID,
                        request,
                        requestHeaders);
                }

                Assert.NotNull(response.Job);
                Assert.NotNull(response.Job.ID);
                Assert.True(response.Job.Errors.Count < 1, "Errors found while doing unplanned failover operation");
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
 /// <summary>
 /// TestFailover for the recovery plan.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.SiteRecovery.IRecoveryPlanOperations.
 /// </param>
 /// <param name='recoveryPlanId'>
 /// Required. RecoveryPlan ID.
 /// </param>
 /// <param name='parameters'>
 /// Optional.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// The response model for the Job details object.
 /// </returns>
 public static Task<JobResponse> RecoveryPlanTestFailoverAsync(this IRecoveryPlanOperations operations, string recoveryPlanId, RpTestFailoverRequest parameters, CustomRequestHeaders customRequestHeaders)
 {
     return operations.RecoveryPlanTestFailoverAsync(recoveryPlanId, parameters, customRequestHeaders, CancellationToken.None);
 }
 /// <summary>
 /// TestFailover for the recovery plan.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.SiteRecovery.IRecoveryPlanOperations.
 /// </param>
 /// <param name='recoveryPlanId'>
 /// Required. RecoveryPlan ID.
 /// </param>
 /// <param name='parameters'>
 /// Optional.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// The response model for the Job details object.
 /// </returns>
 public static JobResponse RecoveryPlanTestFailover(this IRecoveryPlanOperations operations, string recoveryPlanId, RpTestFailoverRequest parameters, CustomRequestHeaders customRequestHeaders)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IRecoveryPlanOperations)s).RecoveryPlanTestFailoverAsync(recoveryPlanId, parameters, customRequestHeaders);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }