/// <summary> /// Syncs the collections on a bound PSCloudPool with its wrapped OM object /// </summary> internal static void BoundPoolSyncCollections(PSCloudPool pool) { if (pool != null) { pool.omObject.ApplicationPackageReferences = CreateSyncedList(pool.ApplicationPackageReferences, (apr) => { return(ConvertApplicationPackageReference(apr)); }); pool.omObject.CertificateReferences = CreateSyncedList(pool.CertificateReferences, (c) => { return(ConvertCertificateReference(c)); }); pool.omObject.Metadata = CreateSyncedList(pool.Metadata, (m) => { MetadataItem metadata = new MetadataItem(m.Name, m.Value); return(metadata); }); if (pool.StartTask != null) { StartTaskSyncCollections(pool.StartTask); } } }
public static void WaitForSteadyPoolAllocation(BatchController controller, BatchAccountContext context, string poolId) { RequestInterceptor interceptor = CreateHttpRecordingInterceptor(); BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor }; BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); ListPoolOptions options = new ListPoolOptions(context, behaviors) { PoolId = poolId }; DateTime timeout = DateTime.Now.AddMinutes(2); PSCloudPool pool = client.ListPools(options).First(); while (pool.AllocationState != AllocationState.Steady) { if (DateTime.Now > timeout) { throw new TimeoutException("Timed out waiting for steady allocation state"); } Sleep(5000); pool = client.ListPools(options).First(); } }
public static string WaitForOSVersionChange(BatchController controller, BatchAccountContext context, string poolId) { RequestInterceptor interceptor = CreateHttpRecordingInterceptor(); BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor }; BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); ListPoolOptions options = new ListPoolOptions(context, behaviors) { PoolId = poolId }; DateTime timeout = DateTime.Now.AddMinutes(2); PSCloudPool pool = client.ListPools(options).First(); while (pool.CurrentOSVersion != pool.TargetOSVersion) { if (DateTime.Now > timeout) { throw new TimeoutException("Timed out waiting for active state pool"); } Sleep(5000); pool = client.ListPools(options).First(); } return(pool.TargetOSVersion); }
public void WhenGetBatchPoolNodeCountsCommandIsCalledWithCloudPoolOption_ShouldHonorPoolFilter() { // Setup cmdlet to list pools using an OData filter BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys(); PSCloudPool fakeCloudPool = new PSCloudPool(BatchTestHelpers.CreateFakeBoundPool(context)); cmdlet.BatchContext = context; cmdlet.Pool = fakeCloudPool; string requestFilter = null; AzureOperationResponse <IPage <ProxyModels.PoolNodeCounts>, ProxyModels.AccountListPoolNodeCountsHeaders> fakeResponse = BatchTestHelpers.CreateGenericAzureOperationListResponse <ProxyModels.PoolNodeCounts, ProxyModels.AccountListPoolNodeCountsHeaders>(); Action <BatchRequest <ProxyModels.AccountListPoolNodeCountsOptions, AzureOperationResponse <IPage <ProxyModels.PoolNodeCounts>, ProxyModels.AccountListPoolNodeCountsHeaders> > > requestAction = (request) => { ProxyModels.AccountListPoolNodeCountsOptions options = request.Options; requestFilter = options.Filter; }; RequestInterceptor requestInterceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor( responseToUse: fakeResponse, requestAction: requestAction); cmdlet.AdditionalBehaviors = new List <BatchClientBehavior>() { requestInterceptor }; cmdlet.ExecuteCmdlet(); Assert.Equal(requestFilter, $"(poolId eq '{fakeCloudPool.Id}')"); }
/// <summary> /// Gets the CurrentDedicated count from a pool /// </summary> public static int GetPoolCurrentDedicated(BatchController controller, BatchAccountContext context, string poolId) { BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); ListPoolOptions options = new ListPoolOptions(context) { PoolId = poolId }; PSCloudPool pool = client.ListPools(options).First(); return(pool.CurrentDedicated.Value); }
/// <summary> /// Gets the CurrentDedicated count from a pool /// </summary> public static int GetPoolCurrentDedicated(BatchController controller, BatchAccountContext context, string poolId) { RequestInterceptor interceptor = CreateHttpRecordingInterceptor(); BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor }; BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); ListPoolOptions options = new ListPoolOptions(context, behaviors) { PoolId = poolId }; PSCloudPool pool = client.ListPools(options).First(); return(pool.CurrentDedicated.Value); }
public static void WaitForSteadyPoolAllocation(BatchController controller, BatchAccountContext context, string poolId) { BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); ListPoolOptions options = new ListPoolOptions(context) { PoolId = poolId }; DateTime timeout = DateTime.Now.Add(GetTimeout(TimeSpan.FromMinutes(5))); PSCloudPool pool = client.ListPools(options).First(); while (pool.AllocationState != AllocationState.Steady) { if (DateTime.Now > timeout) { throw new TimeoutException("Timed out waiting for steady allocation state"); } Sleep(5000); pool = client.ListPools(options).First(); } }
public static string WaitForOSVersionChange(BatchController controller, BatchAccountContext context, string poolId) { BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); ListPoolOptions options = new ListPoolOptions(context) { PoolId = poolId }; DateTime timeout = DateTime.Now.AddMinutes(5); PSCloudPool pool = client.ListPools(options).First(); while (pool.CloudServiceConfiguration.CurrentOSVersion != pool.CloudServiceConfiguration.TargetOSVersion) { if (DateTime.Now > timeout) { throw new TimeoutException("Timed out waiting for active state pool"); } Sleep(5000); pool = client.ListPools(options).First(); } return(pool.CloudServiceConfiguration.TargetOSVersion); }