Skip to content

Commit 2032a22

Browse files
author
jasper-schneider
committed
Batch update cmdlets
1 parent 29f8f3a commit 2032a22

15 files changed

+478
-7
lines changed

src/ResourceManager/AzureBatch/Commands.Batch/Commands.Batch.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,19 @@
156156
<Compile Include="Accounts\SetBatchAccountCommand.cs" />
157157
<Compile Include="ComputeNodes\ResetBatchComputeNodeCommand.cs" />
158158
<Compile Include="ComputeNodes\RestartBatchComputeNodeCommand.cs" />
159+
<Compile Include="ComputeNodeUsers\SetBatchComputeNodeUserCommand.cs" />
159160
<Compile Include="Files\GetBatchNodeFileCommand.cs" />
160161
<Compile Include="Files\GetBatchNodeFileContentCommand.cs" />
161162
<Compile Include="Files\GetBatchRemoteDesktopProtocolFileCommand.cs" />
162163
<Compile Include="JobSchedules\DisableBatchJobScheduleCommand.cs" />
163164
<Compile Include="JobSchedules\EnableBatchJobScheduleCommand.cs" />
165+
<Compile Include="JobSchedules\SetBatchJobScheduleCommand.cs" />
164166
<Compile Include="JobSchedules\StopBatchJobScheduleCommand.cs" />
165167
<Compile Include="Jobs\DisableBatchJobCommand.cs" />
166168
<Compile Include="Jobs\EnableBatchJobCommand.cs" />
167169
<Compile Include="Jobs\NewBatchJobCommand.cs" />
168170
<Compile Include="Jobs\RemoveBatchJobCommand.cs" />
171+
<Compile Include="Jobs\SetBatchJobCommand.cs" />
169172
<Compile Include="Jobs\StopBatchJobCommand.cs" />
170173
<Compile Include="Models.Generated\PSAutoScaleEvaluation.cs" />
171174
<Compile Include="Models.Generated\PSCloudJobSchedule.cs" />
@@ -257,11 +260,13 @@
257260
<Compile Include="Models\ComputeNodeOperationParameters.cs" />
258261
<Compile Include="Models\JobScheduleOperationParameters.cs" />
259262
<Compile Include="Models\TerminateJobParameters.cs" />
263+
<Compile Include="Models\UpdateComputeNodeUserParameters.cs" />
260264
<Compile Include="Pools\DisableBatchAutoScaleCommand.cs" />
261265
<Compile Include="Pools\EnableBatchAutoScaleCommand.cs" />
262266
<Compile Include="Pools\GetBatchPoolCommand.cs" />
263267
<Compile Include="Pools\NewBatchPoolCommand.cs" />
264268
<Compile Include="Pools\RemoveBatchPoolCommand.cs" />
269+
<Compile Include="Pools\SetBatchPoolCommand.cs" />
265270
<Compile Include="Pools\SetBatchPoolOSVersionCommand.cs" />
266271
<Compile Include="Pools\StartBatchPoolResizeCommand.cs" />
267272
<Compile Include="Pools\StopBatchPoolResizeCommand.cs" />
@@ -277,6 +282,7 @@
277282
<Compile Include="Tasks\RemoveBatchTaskCommand.cs" />
278283
<Compile Include="ComputeNodeUsers\NewBatchComputeNodeUserCommand.cs" />
279284
<Compile Include="ComputeNodeUsers\RemoveBatchComputeNodeUserCommand.cs" />
285+
<Compile Include="Tasks\SetBatchTaskCommand.cs" />
280286
<Compile Include="Tasks\StopBatchTaskCommand.cs" />
281287
<Compile Include="Utils\Constants.cs" />
282288
<Compile Include="Utils\Utils.cs" />
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
using System;
16+
using Microsoft.Azure.Commands.Batch.Models;
17+
using System.Management.Automation;
18+
using Constants = Microsoft.Azure.Commands.Batch.Utils.Constants;
19+
20+
namespace Microsoft.Azure.Commands.Batch
21+
{
22+
[Cmdlet(VerbsCommon.Set, Constants.AzureBatchComputeNodeUser)]
23+
public class SetBatchComputeNodeUserCommand : BatchObjectModelCmdletBase
24+
{
25+
[Parameter(Position = 0, Mandatory = true,
26+
HelpMessage = "The id of the pool containing the compute node.")]
27+
[ValidateNotNullOrEmpty]
28+
public string PoolId { get; set; }
29+
30+
[Parameter(Position = 1, Mandatory = true,
31+
HelpMessage = "The id of the compute node containing the user account to update.")]
32+
[ValidateNotNullOrEmpty]
33+
public string ComputeNodeId { get; set; }
34+
35+
[Parameter(Position = 2, Mandatory = true,
36+
HelpMessage = "The name of the user account to update.")]
37+
[ValidateNotNullOrEmpty]
38+
public string Name { get; set; }
39+
40+
[Parameter(Position = 3, Mandatory = true, HelpMessage = "The account password.")]
41+
[ValidateNotNullOrEmpty]
42+
public string Password { get; set; }
43+
44+
[Parameter]
45+
[ValidateNotNullOrEmpty]
46+
public DateTime ExpiryTime { get; set; }
47+
48+
public override void ExecuteCmdlet()
49+
{
50+
UpdateComputeNodeUserParameters parameters = new UpdateComputeNodeUserParameters(this.BatchContext,
51+
this.PoolId, this.ComputeNodeId, this.Name, this.AdditionalBehaviors)
52+
{
53+
Password = this.Password,
54+
ExpiryTime = this.ExpiryTime
55+
};
56+
this.BatchClient.UpdateComputeNodeUser(parameters);
57+
}
58+
}
59+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
using Microsoft.Azure.Commands.Batch.Models;
16+
using System.Management.Automation;
17+
using Constants = Microsoft.Azure.Commands.Batch.Utils.Constants;
18+
19+
namespace Microsoft.Azure.Commands.Batch
20+
{
21+
[Cmdlet(VerbsCommon.Set, Constants.AzureBatchJobSchedule)]
22+
public class SetBatchJobScheduleCommand : BatchObjectModelCmdletBase
23+
{
24+
[Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true,
25+
HelpMessage = "The PSCloudJobSchedule object representing the job schedule to update.")]
26+
[ValidateNotNullOrEmpty]
27+
public PSCloudJobSchedule JobSchedule { get; set; }
28+
29+
public override void ExecuteCmdlet()
30+
{
31+
this.BatchClient.UpdateJobSchedule(this.BatchContext, this.JobSchedule, this.AdditionalBehaviors);
32+
}
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
using Microsoft.Azure.Commands.Batch.Models;
16+
using System.Management.Automation;
17+
using Constants = Microsoft.Azure.Commands.Batch.Utils.Constants;
18+
19+
namespace Microsoft.Azure.Commands.Batch
20+
{
21+
[Cmdlet(VerbsCommon.Set, Constants.AzureBatchJob)]
22+
public class SetBatchJobCommand : BatchObjectModelCmdletBase
23+
{
24+
[Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true,
25+
HelpMessage = "The PSCloudJob object representing the job to update.")]
26+
[ValidateNotNullOrEmpty]
27+
public PSCloudJob Job { get; set; }
28+
29+
public override void ExecuteCmdlet()
30+
{
31+
this.BatchClient.UpdateJob(this.BatchContext, this.Job, this.AdditionalBehaviors);
32+
}
33+
}
34+
}

src/ResourceManager/AzureBatch/Commands.Batch/Models/BatchClient.ComputeNodeUsers.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,26 @@ public void CreateComputeNodeUser(NewComputeNodeUserParameters options)
5858
user.Commit(ComputeNodeUserCommitSemantics.AddUser, options.AdditionalBehaviors);
5959
}
6060

61+
/// <summary>
62+
/// Updates a compute node user account
63+
/// </summary>
64+
/// <param name="parameters">The parameters specifying the compute node user to update and the changes to make</param>
65+
public void UpdateComputeNodeUser(UpdateComputeNodeUserParameters parameters)
66+
{
67+
if (parameters == null)
68+
{
69+
throw new ArgumentNullException("parameters");
70+
}
71+
72+
WriteVerbose(string.Format(Resources.UpdatingComputeNodeUser, parameters.ComputeNodeUserName));
73+
74+
ComputeNodeUser computeNodeUser = new ComputeNodeUser(parameters.Context.BatchOMClient.PoolOperations, parameters.PoolId, parameters.ComputeNodeId);
75+
computeNodeUser.Name = parameters.ComputeNodeUserName;
76+
computeNodeUser.Password = parameters.Password;
77+
computeNodeUser.ExpiryTime = parameters.ExpiryTime;
78+
computeNodeUser.Commit(ComputeNodeUserCommitSemantics.UpdateUser, parameters.AdditionalBehaviors);
79+
}
80+
6181
/// <summary>
6282
/// Deletes the specified compute node user.
6383
/// </summary>

src/ResourceManager/AzureBatch/Commands.Batch/Models/BatchClient.JobSchedules.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,25 @@ public void CreateJobSchedule(NewJobScheduleParameters parameters)
111111
jobSchedule.Commit(parameters.AdditionalBehaviors);
112112
}
113113

114+
/// <summary>
115+
/// Commits changes to a PSCloudJobSchedule object to the Batch Service.
116+
/// </summary>
117+
/// <param name="context">The account to use.</param>
118+
/// <param name="jobSchedule">The PSCloudJobSchedule object representing the job schedule to update.</param>
119+
/// <param name="additionBehaviors">Additional client behaviors to perform.</param>
120+
public void UpdateJobSchedule(BatchAccountContext context, PSCloudJobSchedule jobSchedule, IEnumerable<BatchClientBehavior> additionBehaviors = null)
121+
{
122+
if (jobSchedule == null)
123+
{
124+
throw new ArgumentNullException("jobSchedule");
125+
}
126+
127+
WriteVerbose(string.Format(Resources.UpdatingJobSchedule, jobSchedule.Id));
128+
129+
Utils.Utils.BoundJobScheduleSyncCollections(jobSchedule);
130+
jobSchedule.omObject.Commit(additionBehaviors);
131+
}
132+
114133
/// <summary>
115134
/// Deletes the specified job schedule.
116135
/// </summary>

src/ResourceManager/AzureBatch/Commands.Batch/Models/BatchClient.Jobs.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,25 @@ public void CreateJob(NewJobParameters parameters)
153153
job.Commit(parameters.AdditionalBehaviors);
154154
}
155155

156+
/// <summary>
157+
/// Commits changes to a PSCloudJob object to the Batch Service.
158+
/// </summary>
159+
/// <param name="context">The account to use.</param>
160+
/// <param name="job">The PSCloudJob object representing the job to update.</param>
161+
/// <param name="additionBehaviors">Additional client behaviors to perform.</param>
162+
public void UpdateJob(BatchAccountContext context, PSCloudJob job, IEnumerable<BatchClientBehavior> additionBehaviors = null)
163+
{
164+
if (job == null)
165+
{
166+
throw new ArgumentNullException("job");
167+
}
168+
169+
WriteVerbose(string.Format(Resources.UpdatingJob, job.Id));
170+
171+
Utils.Utils.BoundJobSyncCollections(job);
172+
job.omObject.Commit(additionBehaviors);
173+
}
174+
156175
/// <summary>
157176
/// Deletes the specified job.
158177
/// </summary>

src/ResourceManager/AzureBatch/Commands.Batch/Models/BatchClient.Pools.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,25 @@ public void CreatePool(NewPoolParameters parameters)
130130
pool.Commit(parameters.AdditionalBehaviors);
131131
}
132132

133+
/// <summary>
134+
/// Commits changes to a PSCloudPool object to the Batch Service.
135+
/// </summary>
136+
/// <param name="context">The account to use.</param>
137+
/// <param name="pool">The PSCloudPool object representing the pool to update.</param>
138+
/// <param name="additionBehaviors">Additional client behaviors to perform.</param>
139+
public void UpdatePool(BatchAccountContext context, PSCloudPool pool, IEnumerable<BatchClientBehavior> additionBehaviors = null)
140+
{
141+
if (pool == null)
142+
{
143+
throw new ArgumentNullException("pool");
144+
}
145+
146+
WriteVerbose(string.Format(Resources.UpdatingPool, pool.Id));
147+
148+
Utils.Utils.BoundPoolSyncCollections(pool);
149+
pool.omObject.Commit(additionBehaviors);
150+
}
151+
133152
/// <summary>
134153
/// Deletes the specified pool.
135154
/// </summary>

src/ResourceManager/AzureBatch/Commands.Batch/Models/BatchClient.Tasks.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,24 @@ public void CreateTask(NewTaskParameters parameters)
135135
}
136136
}
137137

138+
/// <summary>
139+
/// Commits changes to a PSCloudTask object to the Batch Service.
140+
/// </summary>
141+
/// <param name="context">The account to use.</param>
142+
/// <param name="task">The PSCloudTask object representing the task to update.</param>
143+
/// <param name="additionBehaviors">Additional client behaviors to perform.</param>
144+
public void UpdateTask(BatchAccountContext context, PSCloudTask task, IEnumerable<BatchClientBehavior> additionBehaviors = null)
145+
{
146+
if (task == null)
147+
{
148+
throw new ArgumentNullException("task");
149+
}
150+
151+
WriteVerbose(string.Format(Resources.UpdatingTask, task.Id));
152+
153+
task.omObject.Commit(additionBehaviors);
154+
}
155+
138156
/// <summary>
139157
/// Deletes the specified task.
140158
/// </summary>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
using System;
16+
using Microsoft.Azure.Batch;
17+
using System.Collections.Generic;
18+
19+
namespace Microsoft.Azure.Commands.Batch.Models
20+
{
21+
public class UpdateComputeNodeUserParameters : ComputeNodeUserOperationParameters
22+
{
23+
public UpdateComputeNodeUserParameters(BatchAccountContext context, string poolId, string computeNodeId, string computeNodeUserName,
24+
IEnumerable<BatchClientBehavior> additionalBehaviors = null)
25+
: base(context, poolId, computeNodeId, computeNodeUserName, additionalBehaviors)
26+
{ }
27+
28+
/// <summary>
29+
/// The account password.
30+
/// </summary>
31+
public string Password { get; set; }
32+
33+
/// <summary>
34+
/// The expiry time.
35+
/// </summary>
36+
public DateTime ExpiryTime { get; set; }
37+
}
38+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
using Microsoft.Azure.Commands.Batch.Models;
16+
using System.Management.Automation;
17+
using Constants = Microsoft.Azure.Commands.Batch.Utils.Constants;
18+
19+
namespace Microsoft.Azure.Commands.Batch
20+
{
21+
[Cmdlet(VerbsCommon.Set, Constants.AzureBatchPool)]
22+
public class SetBatchPoolCommand : BatchObjectModelCmdletBase
23+
{
24+
[Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true,
25+
HelpMessage = "The PSCloudPool object representing the pool to update.")]
26+
[ValidateNotNullOrEmpty]
27+
public PSCloudPool Pool { get; set; }
28+
29+
public override void ExecuteCmdlet()
30+
{
31+
this.BatchClient.UpdatePool(this.BatchContext, this.Pool, this.AdditionalBehaviors);
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)