示例#1
0
        /// <summary>
        /// Update Replication Plan: Utility call
        /// </summary>
        private void UpdateRecoveryPlan(string recoveryPlanName, UpdateRecoveryPlanInput updateRecoveryPlanInput)
        {
            LongRunningOperationResponse response =
                RecoveryServicesClient.UpdateAzureSiteRecoveryRecoveryPlan(recoveryPlanName, updateRecoveryPlanInput);

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

            WriteObject(new ASRJob(jobResponse.Job));
        }
        /// <summary>
        ///     Update Replication Plan: Utility call
        /// </summary>
        private void UpdateRecoveryPlan(
            string recoveryPlanName,
            UpdateRecoveryPlanInput updateRecoveryPlanInput)
        {
            var response = this.RecoveryServicesClient.UpdateAzureSiteRecoveryRecoveryPlan(
                recoveryPlanName,
                updateRecoveryPlanInput);

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

            this.WriteObject(new ASRJob(jobResponse));
        }
示例#3
0
        /// <summary>
        /// Update Recovery Plan: By Service object
        /// </summary>
        private void UpdateRecoveryPlan(RecoveryPlan recoveryPlan)
        {
            UpdateRecoveryPlanInputProperties updateRecoveryPlanInputProperties = new UpdateRecoveryPlanInputProperties()
            {
                Groups = recoveryPlan.Properties.Groups,
            };

            UpdateRecoveryPlanInput updateRecoveryPlanInput = new UpdateRecoveryPlanInput()
            {
                Properties = updateRecoveryPlanInputProperties
            };

            UpdateRecoveryPlan(recoveryPlan.Name, updateRecoveryPlanInput);
        }
示例#4
0
        /// <summary>
        /// Update Recovery Plan: By powerShell Recovery Plan object
        /// </summary>
        private void UpdateRecoveryPlan(ASRRecoveryPlan asrRecoveryPlan)
        {
            UpdateRecoveryPlanInputProperties updateRecoveryPlanInputProperties = new UpdateRecoveryPlanInputProperties()
            {
                Groups = new List <RecoveryPlanGroup>(),
            };

            foreach (ASRRecoveryPlanGroup asrRecoveryPlanGroup in asrRecoveryPlan.Groups)
            {
                RecoveryPlanGroup recoveryPlanGroup = new RecoveryPlanGroup()
                {
                    GroupType = asrRecoveryPlanGroup.GroupType,

                    // Initialize ReplicationProtectedItems with empty List if asrRecoveryPlanGroup.ReplicationProtectedItems is null
                    // otherwise assign respective values
                    ReplicationProtectedItems = asrRecoveryPlanGroup.ReplicationProtectedItems == null ? new List <RecoveryPlanProtectedItem>() :
                                                asrRecoveryPlanGroup.ReplicationProtectedItems.Select(item =>
                    {
                        var newItem = new RecoveryPlanProtectedItem(item.Id);

                        string VmId = null;

                        if (item.Properties.ProviderSpecificDetails.GetType() == typeof(HyperVReplicaAzureReplicationDetails))
                        {
                            VmId = ((HyperVReplicaAzureReplicationDetails)item.Properties.ProviderSpecificDetails).VmId;
                        }
                        else if (item.Properties.ProviderSpecificDetails.GetType() == typeof(HyperVReplica2012ReplicationDetails))
                        {
                            VmId = ((HyperVReplica2012ReplicationDetails)item.Properties.ProviderSpecificDetails).VmId;
                        }

                        newItem.VirtualMachineId = VmId;

                        return(newItem);
                    }).ToList(),
                    StartGroupActions = asrRecoveryPlanGroup.StartGroupActions,
                    EndGroupActions   = asrRecoveryPlanGroup.EndGroupActions
                };

                updateRecoveryPlanInputProperties.Groups.Add(recoveryPlanGroup);
            }

            UpdateRecoveryPlanInput updateRecoveryPlanInput = new UpdateRecoveryPlanInput()
            {
                Properties = updateRecoveryPlanInputProperties
            };

            UpdateRecoveryPlan(asrRecoveryPlan.Name, updateRecoveryPlanInput);
        }
示例#5
0
        /// <summary>
        ///     Update Azure Site Recovery Recovery Plan.
        /// </summary>
        /// <param name="recoveryPlanName">Recovery Plan Name</param>
        /// <param name="input">Update Recovery Plan Input</param>
        /// <returns>Job response</returns>
        public PSSiteRecoveryLongRunningOperation UpdateAzureSiteRecoveryRecoveryPlan(
            string recoveryPlanName,
            UpdateRecoveryPlanInput input)
        {
            var op = this.GetSiteRecoveryClient()
                     .ReplicationRecoveryPlans.BeginUpdateWithHttpMessagesAsync(
                recoveryPlanName,
                input,
                this.GetRequestHeaders(true))
                     .GetAwaiter()
                     .GetResult();
            var result = Mapper.Map <PSSiteRecoveryLongRunningOperation>(op);

            return(result);
        }
        /// <summary>
        ///     Update Recovery Plan: By Service object
        /// </summary>
        private void UpdateRecoveryPlan(
            RecoveryPlan recoveryPlan)
        {
            var updateRecoveryPlanInputProperties =
                new UpdateRecoveryPlanInputProperties {
                Groups = recoveryPlan.Properties.Groups
            };

            var updateRecoveryPlanInput =
                new UpdateRecoveryPlanInput {
                Properties = updateRecoveryPlanInputProperties
            };

            this.UpdateRecoveryPlan(
                recoveryPlan.Name,
                updateRecoveryPlanInput);
        }
        /// <summary>
        ///     Update Recovery Plan: By powerShell Recovery Plan object
        /// </summary>
        private void UpdateRecoveryPlan(
            ASRRecoveryPlan asrRecoveryPlan)
        {
            var updateRecoveryPlanInputProperties =
                new UpdateRecoveryPlanInputProperties {
                Groups = new List <RecoveryPlanGroup>()
            };

            foreach (var asrRecoveryPlanGroup in asrRecoveryPlan.Groups)
            {
                var recoveryPlanGroup = new RecoveryPlanGroup
                {
                    GroupType = asrRecoveryPlanGroup.GroupType,

                    // Initialize ReplicationProtectedItems with empty List if asrRecoveryPlanGroup.ReplicationProtectedItems is null
                    // otherwise assign respective values
                    ReplicationProtectedItems =
                        asrRecoveryPlanGroup.ReplicationProtectedItems == null
                            ? new List <RecoveryPlanProtectedItem>() : asrRecoveryPlanGroup
                        .ReplicationProtectedItems.Select(
                            item =>
                    {
                        var newItem = new RecoveryPlanProtectedItem(item.ID);

                        string VmId = null;

                        if (item.ProviderSpecificDetails.GetType() ==
                            typeof(ASRHyperVReplicaAzureSpecificRPIDetails))
                        {
                            VmId = ((ASRHyperVReplicaAzureSpecificRPIDetails)item.ProviderSpecificDetails).VmId;
                        }
                        else if (item.ProviderSpecificDetails.GetType() == typeof(ASRHyperVReplicaRPIDetails))
                        {
                            VmId = ((ASRHyperVReplicaRPIDetails)item.ProviderSpecificDetails).VmId;
                        }
                        else if (item.ProviderSpecificDetails.GetType() == typeof(ASRHyperVReplicaBlueRPIDetails))
                        {
                            VmId = ((ASRHyperVReplicaBlueRPIDetails)item.ProviderSpecificDetails).VmId;
                        }
                        else if (item.ProviderSpecificDetails.GetType() == typeof(ASRInMageSpecificRPIDetails))
                        {
                            VmId = ((ASRInMageSpecificRPIDetails)item.ProviderSpecificDetails).VmId;
                        }
                        else if (item.ProviderSpecificDetails.GetType() == typeof(ASRInMageSpecificRPIDetails))
                        {
                            VmId = ((ASRInMageSpecificRPIDetails)item.ProviderSpecificDetails).VmId;
                        }

                        newItem.VirtualMachineId = VmId;

                        return(newItem);
                    })
                        .ToList(),
                    StartGroupActions = asrRecoveryPlanGroup.StartGroupActions == null ?
                                        null : asrRecoveryPlanGroup.StartGroupActions.ToList().ConvertAll(
                        action => ASRRecoveryPlanAction.GetSrsRecoveryPlanAction(action)),
                    EndGroupActions = asrRecoveryPlanGroup.EndGroupActions == null ?
                                      null : asrRecoveryPlanGroup.EndGroupActions.ToList().ConvertAll(
                        action => ASRRecoveryPlanAction.GetSrsRecoveryPlanAction(action)),
                };

                updateRecoveryPlanInputProperties.Groups.Add(recoveryPlanGroup);
            }

            var updateRecoveryPlanInput =
                new UpdateRecoveryPlanInput {
                Properties = updateRecoveryPlanInputProperties
            };

            this.UpdateRecoveryPlan(
                asrRecoveryPlan.Name,
                updateRecoveryPlanInput);
        }
 /// <summary>
 /// Updates the given recovery plan.
 /// </summary>
 /// <remarks>
 /// The operation to update a recovery plan.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='recoveryPlanName'>
 /// Recovery plan name.
 /// </param>
 /// <param name='input'>
 /// Update recovery plan input.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <RecoveryPlan> BeginUpdateAsync(this IReplicationRecoveryPlansOperations operations, string recoveryPlanName, UpdateRecoveryPlanInput input, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(recoveryPlanName, input, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Updates the given recovery plan.
 /// </summary>
 /// <remarks>
 /// The operation to update a recovery plan.
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='recoveryPlanName'>
 /// Recovery plan name.
 /// </param>
 /// <param name='input'>
 /// Update recovery plan input.
 /// </param>
 public static RecoveryPlan BeginUpdate(this IReplicationRecoveryPlansOperations operations, string recoveryPlanName, UpdateRecoveryPlanInput input)
 {
     return(operations.BeginUpdateAsync(recoveryPlanName, input).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Update Azure Site Recovery Recovery Plan.
 /// </summary>
 /// <param name="recoveryPlanName">Recovery Plan Name</param>
 /// <param name="input">Update Recovery Plan Input</param>
 /// <returns>Job response</returns>
 public LongRunningOperationResponse UpdateAzureSiteRecoveryRecoveryPlan(string recoveryPlanName, UpdateRecoveryPlanInput input)
 {
     return(this.GetSiteRecoveryClient().RecoveryPlan.BeginUpdating(recoveryPlanName,
                                                                    input,
                                                                    this.GetRequestHeaders()));
 }
 /// <summary>
 /// Updates the given recovery plan.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.IRecoveryPlanOperations.
 /// </param>
 /// <param name='recoveryPlanName'>
 /// Required. Recovery plan name.
 /// </param>
 /// <param name='input'>
 /// Required. Update recovery plan input.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static Task <LongRunningOperationResponse> UpdateAsync(this IRecoveryPlanOperations operations, string recoveryPlanName, UpdateRecoveryPlanInput input, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.UpdateAsync(recoveryPlanName, input, customRequestHeaders, CancellationToken.None));
 }
 /// <summary>
 /// Updates the given recovery plan.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.SiteRecovery.IRecoveryPlanOperations.
 /// </param>
 /// <param name='recoveryPlanName'>
 /// Required. Recovery plan name.
 /// </param>
 /// <param name='input'>
 /// Required. Update recovery plan input.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// A standard service response for long running operations.
 /// </returns>
 public static LongRunningOperationResponse Update(this IRecoveryPlanOperations operations, string recoveryPlanName, UpdateRecoveryPlanInput input, CustomRequestHeaders customRequestHeaders)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IRecoveryPlanOperations)s).UpdateAsync(recoveryPlanName, input, customRequestHeaders);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }