Merge pull request #10641 from matthchr/feature/fix-batch-vmconfig-collections
Fix 10602: Fix bug with New-AzBatchPool collections
This commit is contained in:
Коммит
04be7e4dfc
|
@ -33,13 +33,16 @@ function Test-PoolCRUD
|
|||
$paasConfiguration = New-Object Microsoft.Azure.Commands.Batch.Models.PSCloudServiceConfiguration -ArgumentList @($osFamily, $targetOSVersion)
|
||||
New-AzBatchPool $poolId1 -CloudServiceConfiguration $paasConfiguration -TargetDedicated $targetDedicated -VirtualMachineSize $vmSize -BatchContext $context
|
||||
|
||||
$vmSize = "standard_a1"
|
||||
$publisher = "Canonical"
|
||||
$offer = "UbuntuServer"
|
||||
$osSKU = "16.04.0-LTS"
|
||||
$vmSize = "standard_d1_v2"
|
||||
$publisher = "microsoft-azure-batch"
|
||||
$offer = "ubuntu-server-container"
|
||||
$osSKU = "16-04-lts"
|
||||
$nodeAgent = "batch.node.ubuntu 16.04"
|
||||
$imageRef = New-Object Microsoft.Azure.Commands.Batch.Models.PSImageReference -ArgumentList @($offer, $publisher, $osSKU)
|
||||
$iaasConfiguration = New-Object Microsoft.Azure.Commands.Batch.Models.PSVirtualMachineConfiguration -ArgumentList @($imageRef, $nodeAgent)
|
||||
$iaasConfiguration.ContainerConfiguration = New-Object Microsoft.Azure.Commands.Batch.Models.PSContainerConfiguration
|
||||
$iaasConfiguration.ContainerConfiguration.ContainerImageNames = New-Object System.Collections.Generic.List[string]
|
||||
$iaasConfiguration.ContainerConfiguration.ContainerImageNames.Add("test")
|
||||
New-AzBatchPool $poolId2 -VirtualMachineConfiguration $iaasConfiguration -TargetDedicated $targetDedicated -VirtualMachineSize $vmSize -BatchContext $context
|
||||
|
||||
# List the pools to ensure they were created
|
||||
|
@ -49,6 +52,11 @@ function Test-PoolCRUD
|
|||
Assert-NotNull $pool1
|
||||
Assert-NotNull $pool2
|
||||
|
||||
# Ensure that some of the properties were set correctly
|
||||
Assert-NotNull $pool2.VirtualMachineConfiguration.ContainerConfiguration
|
||||
Assert-NotNull $pool2.VirtualMachineConfiguration.ContainerConfiguration.ContainerImageNames
|
||||
Assert-AreEqual "test" $pool2.VirtualMachineConfiguration.ContainerConfiguration.ContainerImageNames[0]
|
||||
|
||||
# Update a pool
|
||||
$startTaskCmd = "/bin/bash -c 'echo start task'"
|
||||
$startTask = New-Object Microsoft.Azure.Commands.Batch.Models.PSStartTask -ArgumentList @($startTaskCmd)
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -18,6 +18,7 @@
|
|||
- Additional information about change #1
|
||||
-->
|
||||
## Upcoming Release
|
||||
* Fix issue #10602, where **New-AzBatchPool** did not properly send `VirtualMachineConfiguration.ContainerConfiguration` or `VirtualMachineConfiguration.DataDisks` to the server.
|
||||
|
||||
## Version 2.0.1
|
||||
* Renamed `CoreQuota` on `BatchAccountContext` to `DedicatedCoreQuota`. There is also a new `LowPriorityCoreQuota`.
|
||||
|
|
|
@ -159,6 +159,7 @@ namespace Microsoft.Azure.Commands.Batch.Models
|
|||
|
||||
if (parameters.VirtualMachineConfiguration != null)
|
||||
{
|
||||
Utils.Utils.VirtualMachineConfigurationSyncCollections(parameters.VirtualMachineConfiguration);
|
||||
pool.VirtualMachineConfiguration = parameters.VirtualMachineConfiguration.omObject;
|
||||
}
|
||||
|
||||
|
|
|
@ -243,6 +243,8 @@ namespace Microsoft.Azure.Commands.Batch.Utils
|
|||
{
|
||||
StartTaskSyncCollections(spec.StartTask);
|
||||
}
|
||||
|
||||
VirtualMachineConfigurationSyncCollections(spec.VirtualMachineConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -281,6 +283,26 @@ namespace Microsoft.Azure.Commands.Batch.Utils
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Syncs the collections on a PSVirtualMachineConfiguration with its wrapped OM object
|
||||
/// </summary>
|
||||
internal static void VirtualMachineConfigurationSyncCollections(PSVirtualMachineConfiguration virtualMachineConfiguration)
|
||||
{
|
||||
if (virtualMachineConfiguration != null)
|
||||
{
|
||||
if (virtualMachineConfiguration.omObject.ContainerConfiguration != null)
|
||||
{
|
||||
virtualMachineConfiguration.omObject.ContainerConfiguration.ContainerImageNames =
|
||||
CreateSyncedList(virtualMachineConfiguration.ContainerConfiguration.ContainerImageNames, s => s);
|
||||
|
||||
virtualMachineConfiguration.omObject.ContainerConfiguration.ContainerRegistries =
|
||||
CreateSyncedList(virtualMachineConfiguration.ContainerConfiguration.ContainerRegistries, ps => ps.omObject);
|
||||
}
|
||||
|
||||
virtualMachineConfiguration.omObject.DataDisks = CreateSyncedList(virtualMachineConfiguration.DataDisks, ps => ps.omObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Syncs the collections on a PSMultiInstanceSettings with its wrapped OM object
|
||||
/// </summary>
|
||||
|
|
Загрузка…
Ссылка в новой задаче