本文整理汇总了C#中Microsoft.Azure.Commands.Batch.Models.BatchClient.ListPools方法的典型用法代码示例。如果您正苦于以下问题:C# BatchClient.ListPools方法的具体用法?C# BatchClient.ListPools怎么用?C# BatchClient.ListPools使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Azure.Commands.Batch.Models.BatchClient
的用法示例。
在下文中一共展示了BatchClient.ListPools方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPoolCurrentDedicated
/// <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;
}
示例2: GetPoolCount
/// <summary>
/// Gets the number of pools under the specified account
/// </summary>
public static int GetPoolCount(BatchController controller, BatchAccountContext context)
{
RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
ListPoolOptions options = new ListPoolOptions(context, behaviors);
return client.ListPools(options).Count();
}
示例3: WaitForOSVersionChange
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;
}
示例4: WaitForSteadyPoolAllocation
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();
}
}
示例5: GetPoolCount
/// <summary>
/// Gets the number of pools under the specified account
/// </summary>
public static int GetPoolCount(BatchController controller, BatchAccountContext context)
{
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
ListPoolOptions options = new ListPoolOptions(context);
return client.ListPools(options).Count();
}
示例6: GetPoolCurrentDedicated
/// <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;
}
示例7: CreateMpiPoolIfNotExists
/// <summary>
/// Creates an MPI pool.
/// </summary>
public static void CreateMpiPoolIfNotExists(BatchController controller, BatchAccountContext context, int targetDedicated = 3)
{
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
ListPoolOptions listOptions = new ListPoolOptions(context)
{
PoolId = MpiPoolId
};
try
{
client.ListPools(listOptions);
return; // The call returned without throwing an exception, so the pool exists
}
catch (AggregateException aex)
{
BatchException innerException = aex.InnerException as BatchException;
if (innerException == null || innerException.RequestInformation == null || innerException.RequestInformation.AzureError == null ||
innerException.RequestInformation.AzureError.Code != BatchErrorCodeStrings.PoolNotFound)
{
throw;
}
// We got the pool not found error, so continue and create the pool
}
string blobUrl = UploadBlobAndGetUrl(MpiSetupFileContainer, MpiSetupFileName, MpiSetupFileLocalPath);
StartTask startTask = new StartTask();
startTask.CommandLine = string.Format("cmd /c set & {0} -unattend -force", MpiSetupFileName);
startTask.ResourceFiles = new List<ResourceFile>();
startTask.ResourceFiles.Add(new ResourceFile(blobUrl, MpiSetupFileName));
startTask.RunElevated = true;
startTask.WaitForSuccess = true;
CreateTestPool(controller, context, MpiPoolId, targetDedicated, startTask: startTask);
}
示例8: WaitForOSVersionChange
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;
}
示例9: CreateMpiPoolIfNotExists
/// <summary>
/// Creates an MPI pool.
/// </summary>
public static void CreateMpiPoolIfNotExists(BatchController controller, BatchAccountContext context, int targetDedicated = 3)
{
BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
ListPoolOptions listOptions = new ListPoolOptions(context)
{
PoolId = MpiPoolId
};
try
{
client.ListPools(listOptions);
return; // The call returned without throwing an exception, so the pool exists
}
catch (BatchException ex)
{
if (ex.RequestInformation == null || ex.RequestInformation.BatchError == null ||
ex.RequestInformation.BatchError.Code != BatchErrorCodeStrings.PoolNotFound)
{
throw;
}
// We got the pool not found error, so continue and create the pool
}
CreateTestPool(controller, context, MpiPoolId, targetDedicated);
}