/// <summary>
 /// Create storage mapping.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.SiteRecovery.IStoragePoolMappingOperations.
 /// </param>
 /// <param name='parameters'>
 /// Required. Storage pool mapping input.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// The response model for the Job details object.
 /// </returns>
 public static JobResponse Create(this IStoragePoolMappingOperations operations, StoragePoolMappingInput parameters, CustomRequestHeaders customRequestHeaders)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IStoragePoolMappingOperations)s).CreateAsync(parameters, customRequestHeaders);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// Create storage mapping.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.SiteRecovery.IStoragePoolMappingOperations.
 /// </param>
 /// <param name='parameters'>
 /// Required. Storage pool mapping input.
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Optional. Request header parameters.
 /// </param>
 /// <returns>
 /// The response model for the Job details object.
 /// </returns>
 public static Task<JobResponse> CreateAsync(this IStoragePoolMappingOperations operations, StoragePoolMappingInput parameters, CustomRequestHeaders customRequestHeaders)
 {
     return operations.CreateAsync(parameters, customRequestHeaders, CancellationToken.None);
 }
예제 #3
0
        public void SanE2ETest()
        {
            using (UndoContext context = UndoContext.Current)
            {
                try
                {
                    context.Start();
                    var client = GetSiteRecoveryClient(CustomHttpHandler);

                    var requestHeaders = RequestHeaders;
                    requestHeaders.AgentAuthenticationHeader = GenerateAgentAuthenticationHeader(requestHeaders.ClientRequestId);

                    string containerId = "fc1e58ee-b96a-46fe-8afe-330f7ea545a1_d6a83495-5a6a-4ceb-9dc3-2829f6719032";
                    string entityId = "a7b4f73c-7a02-4fa2-b895-ddfcfceb0d7d";
                    string primaryServerId = "fc1e58ee-b96a-46fe-8afe-330f7ea545a1";
                    string recoveryServerId = "e19be056-3a6b-4239-8d01-b0820bc1aeaf";

                    //var responseServer = client.Servers.List(requestHeaders);

                    //var responsePE = client.ProtectionEntity.Get(containerId, entityId, RequestHeaders);

                    var responseStoragePoolPaired = client.StoragePoolMappings.List(primaryServerId, recoveryServerId, requestHeaders);

                    var responseStoragePrimary = client.Storages.List(primaryServerId, requestHeaders);
                    AsrStorage storagePoolPrimary = null;
                    foreach (var storage in responseStoragePrimary.Storages)
                    {
                        if (storage.Type == "Pool")
                        {
                            if (storage.StoragePools.Count > 0)
                            {
                                storagePoolPrimary = storage;
                            }
                        }
                    }

                    var responseStorageRecovery = client.Storages.List(recoveryServerId, requestHeaders);
                    AsrStorage storagePoolRecovery = null;
                    foreach (var storage in responseStorageRecovery.Storages)
                    {
                        if (storage.Type == "Pool")
                        {
                            if (storage.StoragePools.Count > 0)
                            {
                                storagePoolRecovery = storage;
                            }
                        }
                    }

                    StoragePoolMappingInput storagePoolMappingInput = new StoragePoolMappingInput();
                    storagePoolMappingInput.PrimaryServerId = primaryServerId;
                    storagePoolMappingInput.RecoveryServerId = recoveryServerId;
                    storagePoolMappingInput.PrimaryArrayId = storagePoolPrimary.ID;
                    storagePoolMappingInput.RecoveryArrayId = storagePoolRecovery.ID;
                    storagePoolMappingInput.PrimaryStoragePoolId = storagePoolPrimary.StoragePools[0].ID;
                    storagePoolMappingInput.RecoveryStoragePoolId = storagePoolRecovery.StoragePools[0].ID;
                    var responseStoragePoolPair = client.StoragePoolMappings.Create(storagePoolMappingInput, requestHeaders);
                    var responseStoragePoolUnpair = client.StoragePoolMappings.Delete(storagePoolMappingInput, requestHeaders);

                    FailoverRequest request = new FailoverRequest();

                    // Planned Failover RG
                    request = new PlannedFailoverRequest();
                    request.ReplicationProvider = "San";
                    request.FailoverDirection = "PrimaryToRecovery";
                    var response = client.ProtectionEntity.PlannedFailover(containerId, entityId, (PlannedFailoverRequest)request, requestHeaders);
                    ValidateResponse(response);
                    WaitForJobToComplete(client, response.Job.ID);

                    // Reverse protect RG
                    request = new ReprotectRequest();
                    request.ReplicationProvider = "San";
                    request.FailoverDirection = "RecoveryToPrimary";
                    response = client.ProtectionEntity.Reprotect(containerId, entityId, (ReprotectRequest)request, requestHeaders);
                    ValidateResponse(response);
                    WaitForJobToComplete(client, response.Job.ID);

                    // UnPlanned Failover RG
                    request = new UnplannedFailoverRequest();
                    request.ReplicationProvider = "San";
                    request.FailoverDirection = "RecoveryToPrimary";
                    response = client.ProtectionEntity.UnplannedFailover(containerId, entityId, (UnplannedFailoverRequest)request, requestHeaders);
                    ValidateResponse(response);
                    WaitForJobToComplete(client, response.Job.ID);

                    // Reverse protect RG
                    request = new ReprotectRequest();
                    request.ReplicationProvider = "San";
                    request.FailoverDirection = "PrimaryToRecovery";
                    response = client.ProtectionEntity.Reprotect(containerId, entityId, (ReprotectRequest)request, requestHeaders);
                    ValidateResponse(response);
                    WaitForJobToComplete(client, response.Job.ID);

                    // Test Failover RG
                    request = new TestFailoverRequest();
                    request.ReplicationProvider = "San";
                    request.FailoverDirection = "PrimaryToRecovery";
                    ((TestFailoverRequest)request).NetworkType = "NoNetworkAttachAsInput";
                    ((TestFailoverRequest)request).NetworkID = "xxx";
                    response = client.ProtectionEntity.TestFailover(containerId, entityId, (TestFailoverRequest)request, requestHeaders);
                    ValidateResponse(response);
                }
                catch
                {
                    //skip
                }
            }
        }