/// <summary>
        /// Associates protection profile with enterprise based protection containers
        /// </summary>
        private void EnterpriseToEnterpriseAssociation()
        {
            if (string.Compare(
                    this.ProtectionProfile.ReplicationProvider,
                    Constants.HyperVReplica,
                    StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new InvalidOperationException(
                          string.Format(
                              Properties.Resources.IncorrectReplicationProvider,
                              this.ProtectionProfile.ReplicationProvider));
            }

            HyperVReplicaProtectionProfileInput hyperVReplicaProtectionProfileInput
                = new HyperVReplicaProtectionProfileInput()
                {
                ApplicationConsistentSnapshotFrequencyInHours = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ApplicationConsistentSnapshotFrequencyInHours,
                ReplicationFrequencyInSeconds = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationFrequencyInSeconds,
                OnlineReplicationStartTime    = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationStartTime,
                CompressionEnabled            = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.CompressionEnabled,
                OnlineReplicationMethod       = (string.Compare(this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationMethod, Constants.OnlineReplicationMethod, StringComparison.OrdinalIgnoreCase) == 0) ? true : false,
                RecoveryPoints            = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.RecoveryPoints,
                ReplicationPort           = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.ReplicationPort,
                AllowReplicaDeletion      = this.ProtectionProfile.HyperVReplicaProviderSettingsObject.AllowReplicaDeletion,
                AllowedAuthenticationType = (ushort)((string.Compare(this.ProtectionProfile.HyperVReplicaProviderSettingsObject.Authentication, Constants.AuthenticationTypeKerberos, StringComparison.OrdinalIgnoreCase) == 0) ? 1 : 2),
                };

            CreateProtectionProfileInput createProtectionProfileInput =
                new CreateProtectionProfileInput(
                    //// Name of the protection profile as the name of the protection container if not given
                    string.IsNullOrEmpty(this.ProtectionProfile.Name) ? this.PrimaryProtectionContainer.Name : this.ProtectionProfile.Name,
                    this.ProtectionProfile.ReplicationProvider,
                    DataContractUtils <HyperVReplicaProtectionProfileInput> .Serialize(hyperVReplicaProtectionProfileInput));

            ProtectionProfileAssociationInput protectionProfileAssociationInput =
                new ProtectionProfileAssociationInput(
                    this.PrimaryProtectionContainer.ID,
                    this.RecoveryProtectionContainer.ID);

            CreateAndAssociateProtectionProfileInput createAndAssociateProtectionProfileInput =
                new CreateAndAssociateProtectionProfileInput(
                    createProtectionProfileInput,
                    protectionProfileAssociationInput);

            this.jobResponse = RecoveryServicesClient.StartCreateAndAssociateAzureSiteRecoveryProtectionProfileJob(
                createAndAssociateProtectionProfileInput);

            this.WriteJob(this.jobResponse.Job);
        }
示例#2
0
        /// <summary>
        /// Creates an E2E Protection Profile object
        /// </summary>
        private void EnterpriseToEnterpriseProtectionProfileObject()
        {
            if (string.Compare(this.ReplicationProvider, Constants.HyperVReplica, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new InvalidOperationException(
                          string.Format(
                              Properties.Resources.IncorrectReplicationProvider,
                              this.ReplicationProvider));
            }

            PSRecoveryServicesClient.ValidateReplicationStartTime(this.ReplicationStartTime);

            ushort replicationFrequencyInSeconds =
                PSRecoveryServicesClient.ConvertReplicationFrequencyToUshort(this.ReplicationFrequencyInSeconds);

            HyperVReplicaProtectionProfileInput hyperVReplicaProtectionProfileInput
                = new HyperVReplicaProtectionProfileInput()
                {
                ApplicationConsistentSnapshotFrequencyInHours = this.ApplicationConsistentSnapshotFrequencyInHours,
                ReplicationFrequencyInSeconds = replicationFrequencyInSeconds,
                OnlineReplicationStartTime    = this.ReplicationStartTime,
                Compression = this.CompressionEnabled == true ? "Enable" : "Disable",
                InitialReplicationMethod =
                    (string.Compare(this.ReplicationMethod, Constants.OnlineReplicationMethod, StringComparison.OrdinalIgnoreCase) == 0) ? "OverNetwork" : "Offline",
                RecoveryPoints            = this.RecoveryPoints,
                ReplicationPort           = this.ReplicationPort,
                ReplicaDeletion           = this.AllowReplicaDeletion == true ? "Required" : "NotRequired",
                AllowedAuthenticationType =
                    (ushort)((string.Compare(this.Authentication, Constants.AuthenticationTypeKerberos, StringComparison.OrdinalIgnoreCase) == 0) ? 1 : 2)
                };

            CreateProtectionProfileInput createProtectionProfileInput = new CreateProtectionProfileInput();

            createProtectionProfileInput.Name = this.Name;
            createProtectionProfileInput.ReplicationProvider         = this.ReplicationProvider;
            createProtectionProfileInput.ReplicationProviderSettings =
                hyperVReplicaProtectionProfileInput;

            LongRunningOperationResponse response =
                RecoveryServicesClient.CreateProtectionProfile(createProtectionProfileInput);

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

            WriteObject(new ASRJob(jobResponse.Job));
        }
        /// <summary>
        /// Creates an E2E Protection Profile object
        /// </summary>
        private void EnterpriseToEnterpriseProtectionProfileObject()
        {
            if (string.Compare(this.ReplicationProvider, Constants.HyperVReplica, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new InvalidOperationException(
                    string.Format(
                    Properties.Resources.IncorrectReplicationProvider,
                    this.ReplicationProvider));
            }

            PSRecoveryServicesClient.ValidateReplicationStartTime(this.ReplicationStartTime);

            ushort replicationFrequencyInSeconds =
                PSRecoveryServicesClient.ConvertReplicationFrequencyToUshort(this.ReplicationFrequencyInSeconds);

            HyperVReplicaProtectionProfileInput hyperVReplicaProtectionProfileInput
                    = new HyperVReplicaProtectionProfileInput()
                    {
                        ApplicationConsistentSnapshotFrequencyInHours = this.ApplicationConsistentSnapshotFrequencyInHours,
                        ReplicationFrequencyInSeconds = replicationFrequencyInSeconds,
                        OnlineReplicationStartTime = this.ReplicationStartTime,
                        Compression = this.CompressionEnabled == true ? "Enable" : "Disable",
                        InitialReplicationMethod =
                            (string.Compare(this.ReplicationMethod, Constants.OnlineReplicationMethod, StringComparison.OrdinalIgnoreCase) == 0) ? "OverNetwork" : "Offline",
                        RecoveryPoints = this.RecoveryPoints,
                        ReplicationPort = this.ReplicationPort,
                        ReplicaDeletion = this.AllowReplicaDeletion == true ? "Required" : "NotRequired",
                        AllowedAuthenticationType =
                            (ushort)((string.Compare(this.Authentication, Constants.AuthenticationTypeKerberos, StringComparison.OrdinalIgnoreCase) == 0) ? 1 : 2)
                    };

            CreateProtectionProfileInput createProtectionProfileInput = new CreateProtectionProfileInput();
            createProtectionProfileInput.Name = this.Name;
            createProtectionProfileInput.ReplicationProvider = this.ReplicationProvider;
            createProtectionProfileInput.ReplicationProviderSettings =
                hyperVReplicaProtectionProfileInput;

            LongRunningOperationResponse response =
                RecoveryServicesClient.CreateProtectionProfile(createProtectionProfileInput);

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

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