Skip to content

Commit 172db75

Browse files
committed
Update Batch Powershell to target new SDKs
- Target Microsoft.Azure.Batch 12.0. - Target Microsoft.Azure.Management.Batch 9.0. - Update tests.
1 parent a4b5080 commit 172db75

26 files changed

+812
-196
lines changed

src/Batch/Batch.Test/Batch.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Microsoft.Azure.Batch" Version="10.1.0" />
18-
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="7.0.0" />
17+
<PackageReference Include="Microsoft.Azure.Batch" Version="12.0.0" />
18+
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="9.0.0" />
1919
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
2020
</ItemGroup>
2121

src/Batch/Batch.Test/BatchAccounts/GetBatchNodeAgentSkusCommandTests.cs renamed to src/Batch/Batch.Test/BatchAccounts/GetBatchSupportedImagesCommandTests.cs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@
2828

2929
namespace Microsoft.Azure.Commands.Batch.Test.Accounts
3030
{
31-
public class GetBatchNodeAgentSkusCommandTests : WindowsAzure.Commands.Test.Utilities.Common.RMTestBase
31+
public class GetBatchSupportedImagesCommandTests : WindowsAzure.Commands.Test.Utilities.Common.RMTestBase
3232
{
33-
private GetBatchAccountNodeAgentSkuCommand cmdlet;
33+
private GetBatchAccountSupportedImagesCommand cmdlet;
3434
private Mock<BatchClient> batchClientMock;
3535
private Mock<ICommandRuntime> commandRuntimeMock;
3636

37-
public GetBatchNodeAgentSkusCommandTests(Xunit.Abstractions.ITestOutputHelper output)
37+
public GetBatchSupportedImagesCommandTests(Xunit.Abstractions.ITestOutputHelper output)
3838
{
3939
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagement.Common.Models.XunitTracingInterceptor(output));
4040
batchClientMock = new Mock<BatchClient>();
4141
commandRuntimeMock = new Mock<ICommandRuntime>();
42-
cmdlet = new GetBatchAccountNodeAgentSkuCommand()
42+
cmdlet = new GetBatchAccountSupportedImagesCommand()
4343
{
4444
CommandRuntime = commandRuntimeMock.Object,
4545
BatchClient = batchClientMock.Object,
@@ -48,45 +48,45 @@ public GetBatchNodeAgentSkusCommandTests(Xunit.Abstractions.ITestOutputHelper ou
4848

4949
[Fact]
5050
[Trait(Category.AcceptanceType, Category.CheckIn)]
51-
public void ListBatchNodeAgentSkusParametersTest()
51+
public void ListBatchSupportedImagesParametersTest()
5252
{
5353
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
5454
cmdlet.BatchContext = context;
5555

5656
string[] idsOfNodeAgentSkus = new[] { "batch.node.centos 7", "batch.node.debian 8", "batch.node.opensuse 13.2" };
5757

5858
// Don't go to the service on an Get NodeAgentSkus call
59-
AzureOperationResponse<IPage<ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders> response =
60-
BatchTestHelpers.CreateNodeAgentSkuResponse(idsOfNodeAgentSkus);
59+
AzureOperationResponse<IPage<ProxyModels.ImageInformation>, ProxyModels.AccountListSupportedImagesHeaders> response =
60+
BatchTestHelpers.CreateSupportedImagesResponse(idsOfNodeAgentSkus);
6161

6262
RequestInterceptor interceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
63-
ProxyModels.AccountListNodeAgentSkusOptions,
64-
AzureOperationResponse<IPage<ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders>>(responseToUse: response);
63+
ProxyModels.AccountListSupportedImagesOptions,
64+
AzureOperationResponse<IPage<ProxyModels.ImageInformation>, ProxyModels.AccountListSupportedImagesHeaders>>(responseToUse: response);
6565

6666
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { interceptor };
6767

6868
// Setup the cmdlet to write pipeline output to a list that can be examined later
69-
List<PSNodeAgentSku> pipeline = new List<PSNodeAgentSku>();
69+
var pipeline = new List<PSImageInformation>();
7070
commandRuntimeMock.Setup(r =>
71-
r.WriteObject(It.IsAny<PSNodeAgentSku>()))
72-
.Callback<object>(p => pipeline.Add((PSNodeAgentSku)p));
71+
r.WriteObject(It.IsAny<PSImageInformation>()))
72+
.Callback<object>(p => pipeline.Add((PSImageInformation)p));
7373

7474
// Verify no exceptions when required parameter is set
7575
cmdlet.ExecuteCmdlet();
7676

7777
Assert.Equal(3, pipeline.Count);
7878
int nodeAgentCount = 0;
79-
foreach (PSNodeAgentSku p in pipeline)
79+
foreach (PSImageInformation imageInfo in pipeline)
8080
{
81-
Assert.Contains(p.Id, idsOfNodeAgentSkus);
81+
Assert.Contains(imageInfo.NodeAgentSkuId, idsOfNodeAgentSkus);
8282
nodeAgentCount++;
8383
}
8484
Assert.Equal(idsOfNodeAgentSkus.Length, nodeAgentCount);
8585
}
8686

8787
[Fact]
8888
[Trait(Category.AcceptanceType, Category.CheckIn)]
89-
public void ListBatchNodeAgentSkusWithFilterTest()
89+
public void ListBatchSupportedImagesWithFilterTest()
9090
{
9191
BatchAccountContext context = BatchTestHelpers.CreateBatchContextWithKeys();
9292
cmdlet.BatchContext = context;
@@ -95,11 +95,14 @@ public void ListBatchNodeAgentSkusWithFilterTest()
9595
string requestFilter = null;
9696

9797
// Don't go to the service on an Get NodeAgentSkus call
98-
AzureOperationResponse<IPage<ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders> getResponse = BatchTestHelpers.CreateGenericAzureOperationListResponse<ProxyModels.NodeAgentSku, ProxyModels.AccountListNodeAgentSkusHeaders>();
99-
RequestInterceptor requestInterceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<ProxyModels.AccountListNodeAgentSkusOptions, AzureOperationResponse<IPage<ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders>>(responseToUse: getResponse);
98+
var getResponse = BatchTestHelpers.CreateGenericAzureOperationListResponse<ProxyModels.ImageInformation, ProxyModels.AccountListSupportedImagesHeaders>();
99+
RequestInterceptor requestInterceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor<
100+
ProxyModels.AccountListSupportedImagesOptions,
101+
AzureOperationResponse<IPage<ProxyModels.ImageInformation>,
102+
ProxyModels.AccountListSupportedImagesHeaders>>(responseToUse: getResponse);
100103
ResponseInterceptor responseInterceptor = new ResponseInterceptor((response, request) =>
101104
{
102-
ProxyModels.AccountListNodeAgentSkusOptions listNodeAgentSkusOptions = (ProxyModels.AccountListNodeAgentSkusOptions)request.Options;
105+
var listNodeAgentSkusOptions = (ProxyModels.AccountListSupportedImagesOptions)request.Options;
103106
requestFilter = listNodeAgentSkusOptions.Filter;
104107

105108
return Task.FromResult(response);

src/Batch/Batch.Test/BatchTestHelpers.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ public static class BatchTestHelpers
4848
/// <summary>
4949
/// Builds an AccountResource object using the specified parameters
5050
/// </summary>
51-
public static BatchAccount CreateAccountResource(string accountName, string resourceGroupName, string location = "location",
52-
Hashtable tags = null, string storageId = null)
51+
public static BatchAccount CreateAccountResource(
52+
string accountName,
53+
string resourceGroupName,
54+
string location = "location",
55+
Hashtable tags = null,
56+
string storageId = null,
57+
bool dedicatedCoreQuotaPerVMFamilyEnforced = false,
58+
IList<VirtualMachineFamilyCoreQuota> machineFamilyQuotas = null)
5359
{
5460
string tenantUrlEnding = "batch-test.windows-int.net";
5561
string endpoint = string.Format("{0}.{1}", accountName, tenantUrlEnding);
@@ -58,6 +64,8 @@ public static BatchAccount CreateAccountResource(string accountName, string reso
5864

5965
string id = string.Format("id/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Batch/batchAccounts/abc", subscription, resourceGroup);
6066

67+
machineFamilyQuotas = machineFamilyQuotas ?? new List<VirtualMachineFamilyCoreQuota> { new VirtualMachineFamilyCoreQuota("foo", 55 ) };
68+
6169
BatchAccount resource = new BatchAccount(
6270
dedicatedCoreQuota: DefaultQuotaCount,
6371
lowPriorityCoreQuota: DefaultQuotaCount,
@@ -69,7 +77,9 @@ public static BatchAccount CreateAccountResource(string accountName, string reso
6977
location: location,
7078
provisioningState: ProvisioningState.Succeeded,
7179
autoStorage: new AutoStorageProperties() { StorageAccountId = storageId },
72-
tags: tags == null ? null : TagsConversionHelper.CreateTagDictionary(tags, true));
80+
tags: tags == null ? null : TagsConversionHelper.CreateTagDictionary(tags, true),
81+
dedicatedCoreQuotaPerVMFamilyEnforced: dedicatedCoreQuotaPerVMFamilyEnforced,
82+
dedicatedCoreQuotaPerVMFamily: machineFamilyQuotas);
7383

7484
return resource;
7585
}
@@ -796,15 +806,15 @@ public static AzureOperationResponse<
796806
/// <summary>
797807
/// Builds a NodeAgentSKUResponse object
798808
/// </summary>
799-
public static AzureOperationResponse<IPage<ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders> CreateNodeAgentSkuResponse(IEnumerable<string> skuIds)
809+
public static AzureOperationResponse<IPage<ProxyModels.ImageInformation>, ProxyModels.AccountListSupportedImagesHeaders> CreateSupportedImagesResponse(IEnumerable<string> skuIds)
800810
{
801-
IEnumerable<ProxyModels.NodeAgentSku> nodeAgents =
802-
skuIds.Select(id => new ProxyModels.NodeAgentSku() { Id = id });
811+
IEnumerable<ProxyModels.ImageInformation> imageInfo =
812+
skuIds.Select(id => new ProxyModels.ImageInformation() { NodeAgentSKUId = id });
803813

804-
var response = new AzureOperationResponse<IPage<ProxyModels.NodeAgentSku>, ProxyModels.AccountListNodeAgentSkusHeaders>()
814+
var response = new AzureOperationResponse<IPage<ProxyModels.ImageInformation>, ProxyModels.AccountListSupportedImagesHeaders>()
805815
{
806816
Response = new HttpResponseMessage(HttpStatusCode.OK),
807-
Body = new MockPagedEnumerable<ProxyModels.NodeAgentSku>(nodeAgents)
817+
Body = new MockPagedEnumerable<ProxyModels.ImageInformation>(imageInfo)
808818
};
809819

810820
return response;

src/Batch/Batch.Test/Pools/NewBatchPoolCommandTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public void NewBatchPoolParametersGetPassedToRequestTest()
103103
cmdlet.TaskSchedulingPolicy = new PSTaskSchedulingPolicy(Azure.Batch.Common.ComputeNodeFillType.Spread);
104104
cmdlet.VirtualMachineConfiguration = new PSVirtualMachineConfiguration(new PSImageReference("offer", "publisher", "sku"), "node agent");
105105
cmdlet.VirtualMachineSize = "small";
106+
cmdlet.MountConfiguration = new[] { new PSMountConfiguration(new PSAzureBlobFileSystemConfiguration("foo", "bar", "baz", AzureStorageAuthenticationKey.FromAccountKey("abc"))) };
106107

107108
PoolAddParameter requestParameters = null;
108109

@@ -142,6 +143,10 @@ public void NewBatchPoolParametersGetPassedToRequestTest()
142143
Assert.Equal(cmdlet.VirtualMachineConfiguration.ImageReference.Offer, requestParameters.VirtualMachineConfiguration.ImageReference.Offer);
143144
Assert.Equal(cmdlet.VirtualMachineConfiguration.ImageReference.Sku, requestParameters.VirtualMachineConfiguration.ImageReference.Sku);
144145
Assert.Equal(cmdlet.VirtualMachineSize, requestParameters.VmSize);
146+
Assert.Equal(cmdlet.MountConfiguration[0].AzureBlobFileSystemConfiguration.AccountName, requestParameters.MountConfiguration[0].AzureBlobFileSystemConfiguration.AccountName);
147+
Assert.Equal(cmdlet.MountConfiguration[0].AzureBlobFileSystemConfiguration.AccountKey, requestParameters.MountConfiguration[0].AzureBlobFileSystemConfiguration.AccountKey);
148+
Assert.Equal(cmdlet.MountConfiguration[0].AzureBlobFileSystemConfiguration.ContainerName, requestParameters.MountConfiguration[0].AzureBlobFileSystemConfiguration.ContainerName);
149+
Assert.Equal(cmdlet.MountConfiguration[0].AzureBlobFileSystemConfiguration.RelativeMountPath, requestParameters.MountConfiguration[0].AzureBlobFileSystemConfiguration.RelativeMountPath);
145150
}
146151

147152
[Fact]

src/Batch/Batch/Az.Batch.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ CmdletsToExport = 'Remove-AzBatchAccount',
127127
'Get-AzBatchPoolStatistic',
128128
'Get-AzBatchPoolUsageMetric',
129129
'Get-AzBatchPool',
130-
'Get-AzBatchNodeAgentSku',
130+
'Get-AzBatchSupportedImages',
131131
'New-AzBatchPool',
132132
'Remove-AzBatchPool',
133133
'Set-AzBatchPool',

src/Batch/Batch/Batch.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.Azure.Batch" Version="10.1.0" />
16-
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="7.0.0" />
15+
<PackageReference Include="Microsoft.Azure.Batch" Version="12.0.0" />
16+
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="9.0.0" />
1717
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
1818
</ItemGroup>
1919

src/Batch/Batch/BatchAccounts/GetBatchAccountNodeAgentSkuCommand.cs renamed to src/Batch/Batch/BatchAccounts/GetBatchAccountSupportedImagesCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
namespace Microsoft.Azure.Commands.Batch
2121
{
22-
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzurePrefix + "BatchNodeAgentSku"),OutputType(typeof(PSNodeAgentSku))]
23-
public class GetBatchAccountNodeAgentSkuCommand : BatchObjectModelCmdletBase
22+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzurePrefix + "BatchSupportedImages"),OutputType(typeof(PSImageInformation))]
23+
public class GetBatchAccountSupportedImagesCommand : BatchObjectModelCmdletBase
2424
{
2525
private int maxCount = Constants.DefaultMaxCount;
2626

@@ -38,7 +38,7 @@ public int MaxCount
3838

3939
protected override void ExecuteCmdletImpl()
4040
{
41-
foreach (PSNodeAgentSku nodeAgentSku in BatchClient.ListNodeAgentSkus(this.BatchContext, this.Filter, this.MaxCount, this.AdditionalBehaviors))
41+
foreach (PSImageInformation nodeAgentSku in BatchClient.ListSupportedImages(this.BatchContext, this.Filter, this.MaxCount, this.AdditionalBehaviors))
4242
{
4343
WriteObject(nodeAgentSku);
4444
}

src/Batch/Batch/ChangeLog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@
3939
* Renamed `CurrentOSVersion` to `OSVersion` on `PSCloudServiceConfiguration`.
4040
* Removed `DataEgressGiB` and `DataIngressGiB` from `PSPoolUsageMetrics`.
4141

42+
* Removed **Get-AzBatchNodeAgentSku** and replaced it with **Get-AzBatchSupportedImages**.
43+
- **Get-AzBatchSupportedImages** returns the same data as **Get-AzBatchNodeAgentSku** but in a more friendly format.
44+
- New non-verified images are also now returned. Additional information about `Capabilities` and `BatchSupportEndOfLife` for each image is also included.
45+
* Added ability to mount remote file-systems on each node of a pool via the new `MountConfiguration` parameter of **New-AzBatchPool**.
46+
* Now support network security rules blocking network access to a pool based on the source port of the traffic. This is done via the `SourcePortRanges` property on `PSNetworkSecurityGroupRule`.
47+
* When running a container, Batch now supports executing the task in the container working directory or in the Batch task working directory. This is controlled by the `WorkingDirectory` property on `PSTaskContainerSettings`.
48+
* Added ability to specify a collection of public IPs on `PSNetworkConfiguration` via the new `PublicIPs` property. This guarantees nodes in the Pool will have an IP from the list user provided IPs.
49+
* When not specified, the default value of `WaitForSuccess` on `PSSTartTask` is now `$True` (was `$False`).
50+
* When not specified, the default value of `Scope` on `PSAutoUserSpecification` is now `Pool` (was `Task` on Windows and `Pool` on Linux).
51+
52+
53+
4254
## Version 1.1.1
4355
* Fixed typo in help message and documentation to capitalize Windows
4456
* Fixed miscellaneous typos across module
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// -----------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// -----------------------------------------------------------------------------
14+
//------------------------------------------------------------------------------
15+
// <auto-generated>
16+
// This code was generated by a tool.
17+
// Runtime Version:4.0.30319.42000
18+
//
19+
// Changes to this file may cause incorrect behavior and will be lost if
20+
// the code is regenerated.
21+
// </auto-generated>
22+
//------------------------------------------------------------------------------
23+
24+
namespace Microsoft.Azure.Commands.Batch.Models
25+
{
26+
using System;
27+
using System.Collections;
28+
using System.Collections.Generic;
29+
using Microsoft.Azure.Batch;
30+
31+
32+
public partial class PSAzureBlobFileSystemConfiguration
33+
{
34+
35+
internal Microsoft.Azure.Batch.AzureBlobFileSystemConfiguration omObject;
36+
37+
public PSAzureBlobFileSystemConfiguration(string accountName, string containerName, string relativeMountPath, Microsoft.Azure.Batch.AzureStorageAuthenticationKey key, string blobfuseOptions = null)
38+
{
39+
this.omObject = new Microsoft.Azure.Batch.AzureBlobFileSystemConfiguration(accountName, containerName, relativeMountPath, key, blobfuseOptions);
40+
}
41+
42+
internal PSAzureBlobFileSystemConfiguration(Microsoft.Azure.Batch.AzureBlobFileSystemConfiguration omObject)
43+
{
44+
if ((omObject == null))
45+
{
46+
throw new System.ArgumentNullException("omObject");
47+
}
48+
this.omObject = omObject;
49+
}
50+
51+
public string AccountKey
52+
{
53+
get
54+
{
55+
return this.omObject.AccountKey;
56+
}
57+
}
58+
59+
public string AccountName
60+
{
61+
get
62+
{
63+
return this.omObject.AccountName;
64+
}
65+
}
66+
67+
public string BlobfuseOptions
68+
{
69+
get
70+
{
71+
return this.omObject.BlobfuseOptions;
72+
}
73+
}
74+
75+
public string ContainerName
76+
{
77+
get
78+
{
79+
return this.omObject.ContainerName;
80+
}
81+
}
82+
83+
public string RelativeMountPath
84+
{
85+
get
86+
{
87+
return this.omObject.RelativeMountPath;
88+
}
89+
}
90+
91+
public string SasKey
92+
{
93+
get
94+
{
95+
return this.omObject.SasKey;
96+
}
97+
}
98+
}
99+
}

0 commit comments

Comments
 (0)