/// <summary> /// Creates an E2A Policy Object /// </summary> private void EnterpriseToAzurePolicyObject() { if (string.Compare(this.ReplicationProvider, Constants.HyperVReplicaAzure, StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException( string.Format( Properties.Resources.IncorrectReplicationProvider, this.ReplicationProvider)); } PSRecoveryServicesClient.ValidateReplicationStartTime(this.ReplicationStartTime); ushort replicationFrequencyInSeconds = PSRecoveryServicesClient.ConvertReplicationFrequencyToUshort(this.ReplicationFrequencyInSeconds); var hyperVReplicaAzurePolicyInput = new HyperVReplicaAzurePolicyInput() { ApplicationConsistentSnapshotFrequencyInHours = this.ApplicationConsistentSnapshotFrequencyInHours, Encryption = this.MyInvocation.BoundParameters.ContainsKey(Utilities.GetMemberName(() => this.Encryption)) ? this.Encryption : Constants.Disable, OnlineIrStartTime = this.ReplicationStartTime, RecoveryPointHistoryDuration = this.RecoveryPoints, ReplicationInterval = replicationFrequencyInSeconds }; hyperVReplicaAzurePolicyInput.StorageAccounts = new System.Collections.Generic.List <string>(); if (RecoveryAzureStorageAccountId != null) { string storageAccount = this.RecoveryAzureStorageAccountId; hyperVReplicaAzurePolicyInput.StorageAccounts.Add(storageAccount); } var createPolicyInputProperties = new CreatePolicyInputProperties() { ProviderSpecificInput = hyperVReplicaAzurePolicyInput }; var createPolicyInput = new CreatePolicyInput() { Properties = createPolicyInputProperties }; LongRunningOperationResponse response = RecoveryServicesClient.CreatePolicy(this.Name, createPolicyInput); JobResponse jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location)); WriteObject(new ASRJob(jobResponse.Job)); }
/// <summary> /// Creates an InMageRcm policy. /// </summary> private void CreateInMageRcmPolicy() { if (string.Compare( this.ReplicationProvider, Constants.InMageRcm, StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException( string.Format( Resources.IncorrectReplicationProvider, this.ReplicationProvider)); } this.MultiVmSyncStatus = this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.MultiVmSyncStatus)) ? this.MultiVmSyncStatus : Constants.Enable; var crashConsistentFrequencyInMinutes = 5; var createPolicyInput = new CreatePolicyInput() { Properties = new CreatePolicyInputProperties() { ProviderSpecificInput = new InMageRcmPolicyCreationInput() { RecoveryPointHistoryInMinutes = this.RecoveryPointRetentionInHours * 60, CrashConsistentFrequencyInMinutes = crashConsistentFrequencyInMinutes, AppConsistentFrequencyInMinutes = this.ApplicationConsistentSnapshotFrequencyInHours * 60, EnableMultiVmSync = this.MultiVmSyncStatus.Equals(Constants.Enable) ? Constants.True : Constants.False } } }; var response = RecoveryServicesClient.CreatePolicy(this.Name, createPolicyInput); string jobId = PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location); var jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(jobId); WriteObject(new ASRJob(jobResponse)); }
/// <summary> /// Creates an A2A Policy. /// </summary> private void CreateA2APolicy() { this.MultiVmSyncStatus = this.MyInvocation.BoundParameters.ContainsKey( Utilities.GetMemberName(() => this.MultiVmSyncStatus)) ? this.MultiVmSyncStatus : Constants.Enable; var crashConsistentFrequencyInMinutes = 5; var a2aPolicyCreationInput = new A2APolicyCreationInput() { AppConsistentFrequencyInMinutes = this.ApplicationConsistentSnapshotFrequencyInHours * 60, CrashConsistentFrequencyInMinutes = crashConsistentFrequencyInMinutes, MultiVmSyncStatus = (SetMultiVmSyncStatus)Enum.Parse( typeof(SetMultiVmSyncStatus), this.MultiVmSyncStatus), RecoveryPointHistory = this.RecoveryPointRetentionInHours * 60 }; var createPolicyInputProperties = new CreatePolicyInputProperties() { ProviderSpecificInput = a2aPolicyCreationInput }; var createPolicyInput = new CreatePolicyInput() { Properties = createPolicyInputProperties }; var response = RecoveryServicesClient.CreatePolicy(this.Name, createPolicyInput); string jobId = PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location); var jobResponse = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(jobId); WriteObject(new ASRJob(jobResponse)); }
/// <summary> /// Creates an E2E Policy object /// </summary> private void EnterpriseToEnterprisePolicyObject() { if (string.Compare(this.ReplicationProvider, Constants.HyperVReplica2012, StringComparison.OrdinalIgnoreCase) != 0 && string.Compare(this.ReplicationProvider, Constants.HyperVReplica2012R2, StringComparison.OrdinalIgnoreCase) != 0) { throw new InvalidOperationException( string.Format( Properties.Resources.IncorrectReplicationProvider, this.ReplicationProvider)); } PSRecoveryServicesClient.ValidateReplicationStartTime(this.ReplicationStartTime); ushort replicationFrequencyInSeconds = PSRecoveryServicesClient.ConvertReplicationFrequencyToUshort(this.ReplicationFrequencyInSeconds); var createPolicyInputProperties = new CreatePolicyInputProperties(); if (string.Compare(this.ReplicationProvider, Constants.HyperVReplica2012, StringComparison.OrdinalIgnoreCase) == 0) { createPolicyInputProperties.ProviderSpecificInput = new HyperVReplica2012PolicyInput() { AllowedAuthenticationType = (ushort)((string.Compare(this.Authentication, Constants.AuthenticationTypeKerberos, StringComparison.OrdinalIgnoreCase) == 0) ? 1 : 2), ApplicationConsistentSnapshotFrequencyInHours = this.ApplicationConsistentSnapshotFrequencyInHours, Compression = this.CompressionEnabled == true ? "Enable" : "Disable", InitialReplicationMethod = (string.Compare(this.ReplicationMethod, Constants.OnlineReplicationMethod, StringComparison.OrdinalIgnoreCase) == 0) ? "OverNetwork" : "Offline", OnlineReplicationStartTime = this.ReplicationStartTime, RecoveryPoints = this.RecoveryPoints, ReplicaDeletion = this.AllowReplicaDeletion == true ? "Required" : "NotRequired", ReplicationPort = this.ReplicationPort }; } else { createPolicyInputProperties.ProviderSpecificInput = new HyperVReplica2012R2PolicyInput() { AllowedAuthenticationType = (ushort)((string.Compare(this.Authentication, Constants.AuthenticationTypeKerberos, StringComparison.OrdinalIgnoreCase) == 0) ? 1 : 2), ApplicationConsistentSnapshotFrequencyInHours = this.ApplicationConsistentSnapshotFrequencyInHours, Compression = this.CompressionEnabled == true ? "Enable" : "Disable", InitialReplicationMethod = (string.Compare(this.ReplicationMethod, Constants.OnlineReplicationMethod, StringComparison.OrdinalIgnoreCase) == 0) ? "OverNetwork" : "Offline", OnlineReplicationStartTime = this.ReplicationStartTime, RecoveryPoints = this.RecoveryPoints, ReplicaDeletion = this.AllowReplicaDeletion == true ? "Required" : "NotRequired", ReplicationFrequencyInSeconds = replicationFrequencyInSeconds, ReplicationPort = this.ReplicationPort }; } var createPolicyInput = new CreatePolicyInput() { Properties = createPolicyInputProperties }; LongRunningOperationResponse responseBlue = RecoveryServicesClient.CreatePolicy(this.Name, createPolicyInput); JobResponse jobResponseBlue = RecoveryServicesClient .GetAzureSiteRecoveryJobDetails(PSRecoveryServicesClient.GetJobIdFromReponseLocation(responseBlue.Location)); WriteObject(new ASRJob(jobResponseBlue.Job)); }