コード例 #1
0
        public void CreateAndAssociateE2E()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client         = GetSiteRecoveryClient(CustomHttpHandler);
                var requestHeaders = RequestHeaders;
                requestHeaders.AgentAuthenticationHeader = GenerateAgentAuthenticationHeader(requestHeaders.ClientRequestId);

                string serializedHyperVReplicaAzureProfileManagementInput = null;

                var settings = new HyperVReplicaProtectionProfileInput();
                settings.AllowedAuthenticationType = 1;
                settings.AllowReplicaDeletion      = false;
                settings.ApplicationConsistentSnapshotFrequencyInHours = 0;
                settings.CompressionEnabled           = true;
                settings.OfflineReplicationExportPath = null;
                settings.OfflineReplicationImportPath = null;
                settings.OnlineReplicationMethod      = true;
                settings.OnlineReplicationStartTime   = null;
                settings.RecoveryPoints = 1;
                settings.ReplicationFrequencyInSeconds = 300;
                settings.ReplicationPort = 8083;

                serializedHyperVReplicaAzureProfileManagementInput =
                    DataContractUtils <HyperVReplicaProtectionProfileInput> .Serialize(settings);

                var responsePC = client.ProtectionContainer.List(RequestHeaders);

                string primaryPCId  = null;
                string recoveryPCId = null;
                foreach (var pc in responsePC.ProtectionContainers)
                {
                    if (string.IsNullOrWhiteSpace(pc.Role))
                    {
                        if (primaryPCId == null)
                        {
                            primaryPCId = pc.ID;
                            continue;
                        }

                        if (recoveryPCId == null)
                        {
                            recoveryPCId = pc.ID;
                            break;
                        }
                    }
                }

                var input = new CreateAndAssociateProtectionProfileInput();

                input.ProtectionProfileInput      = new CreateProtectionProfileInput();
                input.ProtectionProfileInput.Name = "E2E_Profile";
                input.ProtectionProfileInput.ReplicationProvider         = "HyperVReplica";
                input.ProtectionProfileInput.ReplicationProviderSettings =
                    serializedHyperVReplicaAzureProfileManagementInput;

                input.AssociationInput = new ProtectionProfileAssociationInput();
                input.AssociationInput.PrimaryProtectionContainerId  = primaryPCId;
                input.AssociationInput.RecoveryProtectionContainerId = recoveryPCId;

                JobResponse response = client.ProtectionProfile.CreateAndAssociate(input, requestHeaders);

                Assert.NotNull(response.Job);
                Assert.NotNull(response.Job.ID);
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }
コード例 #2
0
        public void CreateAndAssociateE2E()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                var client = GetSiteRecoveryClient(CustomHttpHandler);
                var requestHeaders = RequestHeaders;
                requestHeaders.AgentAuthenticationHeader = GenerateAgentAuthenticationHeader(requestHeaders.ClientRequestId);

                string serializedHyperVReplicaAzureProfileManagementInput = null;
               
                var settings = new HyperVReplicaProtectionProfileInput();
                settings.AllowedAuthenticationType = 1;
                settings.AllowReplicaDeletion = false;
                settings.ApplicationConsistentSnapshotFrequencyInHours = 0;
                settings.CompressionEnabled = true;
                settings.OfflineReplicationExportPath = null;
                settings.OfflineReplicationImportPath = null;
                settings.OnlineReplicationMethod = true;
                settings.OnlineReplicationStartTime = null;
                settings.RecoveryPoints = 1;
                settings.ReplicationFrequencyInSeconds = 300;
                settings.ReplicationPort = 8083;

                serializedHyperVReplicaAzureProfileManagementInput =
                    DataContractUtils<HyperVReplicaProtectionProfileInput>.Serialize(settings);

                var responsePC = client.ProtectionContainer.List(RequestHeaders);

                string primaryPCId = null;
                string recoveryPCId = null;
                foreach (var pc in responsePC.ProtectionContainers)
                {
                    if (string.IsNullOrWhiteSpace(pc.Role))
                    {
                        if (primaryPCId == null)
                        {
                            primaryPCId = pc.ID;
                            continue;
                        }

                        if (recoveryPCId == null)
                        {
                            recoveryPCId = pc.ID;
                            break;
                        }
                    }
                }

                var input = new CreateAndAssociateProtectionProfileInput();

                input.ProtectionProfileInput = new CreateProtectionProfileInput();
                input.ProtectionProfileInput.Name = "E2E_Profile";
                input.ProtectionProfileInput.ReplicationProvider = "HyperVReplica";
                input.ProtectionProfileInput.ReplicationProviderSettings =
                    serializedHyperVReplicaAzureProfileManagementInput;

                input.AssociationInput = new ProtectionProfileAssociationInput();
                input.AssociationInput.PrimaryProtectionContainerId = primaryPCId;
                input.AssociationInput.RecoveryProtectionContainerId = recoveryPCId;

                JobResponse response = client.ProtectionProfile.CreateAndAssociate(input, requestHeaders);

                Assert.NotNull(response.Job);
                Assert.NotNull(response.Job.ID);
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            }
        }