Esempio n. 1
0
        /// <summary>
        ///     Starts PE Apply Recovery Point.
        /// </summary>
        private void StartPEApplyRecoveryPoint()
        {
            var applyRecoveryPointInputProperties = new ApplyRecoveryPointInputProperties
            {
                RecoveryPointId         = this.RecoveryPoint.ID,
                ProviderSpecificDetails = new ApplyRecoveryPointProviderSpecificInput()
            };

            var input =
                new ApplyRecoveryPointInput {
                Properties = applyRecoveryPointInputProperties
            };

            if (0 ==
                string.Compare(
                    this.ReplicationProtectedItem.ReplicationProvider,
                    Constants.HyperVReplicaAzure,
                    StringComparison.OrdinalIgnoreCase))
            {
                var hyperVReplicaAzureApplyRecoveryPointInput =
                    new HyperVReplicaAzureApplyRecoveryPointInput
                {
                    PrimaryKekCertificatePfx   = this.primaryKekCertpfx,
                    SecondaryKekCertificatePfx = this.secondaryKekCertpfx,
                    VaultLocation = "dummy"
                };
                input.Properties.ProviderSpecificDetails =
                    hyperVReplicaAzureApplyRecoveryPointInput;
            }

            var response = this.RecoveryServicesClient.StartAzureSiteRecoveryApplyRecoveryPoint(
                this.fabricName,
                this.protectionContainerName,
                this.ReplicationProtectedItem.Name,
                input);

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

            this.WriteObject(new ASRJob(jobResponse));
        }
        /// <summary>
        ///     Starts PE Apply Recovery Point.
        /// </summary>
        private void StartPEApplyRecoveryPoint()
        {
            var applyRecoveryPointInputProperties = new ApplyRecoveryPointInputProperties
            {
                RecoveryPointId         = this.RecoveryPoint.ID,
                ProviderSpecificDetails = new ApplyRecoveryPointProviderSpecificInput()
            };

            var input =
                new ApplyRecoveryPointInput {
                Properties = applyRecoveryPointInputProperties
            };

            if (0 ==
                string.Compare(
                    this.ReplicationProtectedItem.ReplicationProvider,
                    Constants.HyperVReplicaAzure,
                    StringComparison.OrdinalIgnoreCase))
            {
                var hyperVReplicaAzureApplyRecoveryPointInput =
                    new HyperVReplicaAzureApplyRecoveryPointInput
                {
                    PrimaryKekCertificatePfx   = this.primaryKekCertpfx,
                    SecondaryKekCertificatePfx = this.secondaryKekCertpfx,
                    VaultLocation = "dummy"
                };
                input.Properties.ProviderSpecificDetails =
                    hyperVReplicaAzureApplyRecoveryPointInput;
            }
            else if (string.Compare(
                         this.ReplicationProtectedItem.ReplicationProvider,
                         Constants.InMageAzureV2,
                         StringComparison.OrdinalIgnoreCase) ==
                     0)
            {
                // Create the InMageAzureV2 specific Apply Recovery Point Input.
                var inMageAzureV2ApplyRecoveryPointInput =
                    new InMageAzureV2ApplyRecoveryPointInput();
                input.Properties.ProviderSpecificDetails = inMageAzureV2ApplyRecoveryPointInput;
            }
            else if (string.Compare(
                         this.ReplicationProtectedItem.ReplicationProvider,
                         Constants.InMage,
                         StringComparison.OrdinalIgnoreCase) ==
                     0)
            {
                throw new InvalidOperationException(
                          string.Format(
                              Resources.UnsupportedReplicationProviderForApplyRecoveryPoint,
                              this.ReplicationProtectedItem.ReplicationProvider));
            }
            else if (Constants.A2A.Equals(this.ReplicationProtectedItem.ReplicationProvider, StringComparison.OrdinalIgnoreCase))
            {
                input.Properties.ProviderSpecificDetails = new A2AApplyRecoveryPointInput();
            }

            var response = this.RecoveryServicesClient.StartAzureSiteRecoveryApplyRecoveryPoint(
                this.fabricName,
                this.protectionContainerName,
                this.ReplicationProtectedItem.Name,
                input);

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

            this.WriteObject(new ASRJob(jobResponse));
        }