예제 #1
0
        /// <summary>
        ///     ProcessRecord of the command.
        /// </summary>
        public override void ExecuteSiteRecoveryCmdlet()
        {
            base.ExecuteSiteRecoveryCmdlet();

            if (this.ShouldProcess(
                    TargetProcessServer.FriendlyName,
                    "Switch the process server"))
            {
                // Set the Fabric Name and Protection Container Name.
                this.fabricName = this.Fabric.Name;
                var protectionContainerList = this.RecoveryServicesClient
                                              .GetAzureSiteRecoveryProtectionContainer(this.fabricName);
                this.protectionContainerName = protectionContainerList[0].Name;

                var failoverPSRequestProperties = new FailoverProcessServerRequestProperties();
                failoverPSRequestProperties.SourceProcessServerId = this.SourceProcessServer.Id;
                failoverPSRequestProperties.TargetProcessServerId = this.TargetProcessServer.Id;
                failoverPSRequestProperties.ContainerName         = this.protectionContainerName;

                if (this.ReplicationProtectedItem != null)
                {
                    this.protectedItemsIdsForRpi = new List <string>();
                    foreach (var replicationProtectedItem in this.ReplicationProtectedItem)
                    {
                        this.protectedItemsIdsForRpi.Add(
                            Utilities.GetValueFromArmId(
                                replicationProtectedItem.ProtectableItemId,
                                ARMResourceTypeConstants.ProtectableItems));
                    }

                    failoverPSRequestProperties.VmsToMigrate = this.protectedItemsIdsForRpi;
                    failoverPSRequestProperties.UpdateType   =
                        ProcessServerFailoverType.ServerLevel.ToString();
                }
                else
                {
                    failoverPSRequestProperties.UpdateType =
                        ProcessServerFailoverType.SystemLevel.ToString();
                }

                var failoverPSRequest = new FailoverProcessServerRequest
                {
                    Properties = failoverPSRequestProperties
                };

                // Switch the process server.
                var response = this.RecoveryServicesClient.ReassociateProcessServer(
                    this.fabricName,
                    failoverPSRequest);

                var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails(
                    PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

                this.WriteObject(new ASRJob(jobResponse));
            }
        }
        /// <summary>
        ///     Reassociate replicated items with another Process Server.
        /// </summary>
        /// <param name="fabricName">Fabric Name</param>
        /// <param name="input">Input object for switching process server.</param>
        /// <returns>Job Response</returns>
        public PSSiteRecoveryLongRunningOperation ReassociateProcessServer(
            string fabricName,
            FailoverProcessServerRequest input)
        {
            var op = this.GetSiteRecoveryClient()
                     .ReplicationFabrics.BeginReassociateGatewayWithHttpMessagesAsync(
                fabricName,
                input,
                this.GetRequestHeaders(true))
                     .GetAwaiter()
                     .GetResult();

            var result = SiteRecoveryAutoMapperProfile.Mapper.Map <PSSiteRecoveryLongRunningOperation>(op);

            return(result);
        }
예제 #3
0
 /// <summary>
 /// Performs reassociate gateway operation on a fabric.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.IFabricOperations.
 /// </param>
 /// <param name='fabricName'>
 /// Required. Fabric Name.
 /// </param>
 /// <param name='input'>
 /// Required. Input to reassociate a gateway.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static Task <LongRunningOperationResponse> ReassociateGatewayAsync(this IFabricOperations operations, string fabricName, FailoverProcessServerRequest input, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.ReassociateGatewayAsync(fabricName, input, customRequestHeaders, CancellationToken.None));
 }
예제 #4
0
 /// <summary>
 /// Performs reassociate gateway operation on a fabric.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.IFabricOperations.
 /// </param>
 /// <param name='fabricName'>
 /// Required. Fabric Name.
 /// </param>
 /// <param name='input'>
 /// Required. Input to reassociate a gateway.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static LongRunningOperationResponse ReassociateGateway(this IFabricOperations operations, string fabricName, FailoverProcessServerRequest input, CustomRequestHeaders customRequestHeaders)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IFabricOperations)s).ReassociateGatewayAsync(fabricName, input, customRequestHeaders);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Perform failover of the process server.
 /// </summary>
 /// <remarks>
 /// The operation to move replications from a process server to another process
 /// server.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='fabricName'>
 /// The name of the fabric containing the process server.
 /// </param>
 /// <param name='failoverProcessServerRequest'>
 /// The input to the failover process server operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Fabric> BeginReassociateGatewayAsync(this IReplicationFabricsOperations operations, string fabricName, FailoverProcessServerRequest failoverProcessServerRequest, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginReassociateGatewayWithHttpMessagesAsync(fabricName, failoverProcessServerRequest, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Perform failover of the process server.
 /// </summary>
 /// <remarks>
 /// The operation to move replications from a process server to another process
 /// server.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='fabricName'>
 /// The name of the fabric containing the process server.
 /// </param>
 /// <param name='failoverProcessServerRequest'>
 /// The input to the failover process server operation.
 /// </param>
 public static Fabric BeginReassociateGateway(this IReplicationFabricsOperations operations, string fabricName, FailoverProcessServerRequest failoverProcessServerRequest)
 {
     return(operations.BeginReassociateGatewayAsync(fabricName, failoverProcessServerRequest).GetAwaiter().GetResult());
 }