Fix 10602: Fix bug with New-AzBatchPool collections

- New-AzBatchPool was not correctly propagating some
    collections to the server.
This commit is contained in:
Matthew Christopher 2019-12-02 11:04:09 -08:00
Родитель dd10ff93e5
Коммит 3f8d9fcf6a
5 изменённых файлов: 97 добавлений и 65 удалений

Просмотреть файл

@ -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>