Skip to content

Commit 443b2b3

Browse files
committed
Merge pull request #13 from AzCiS/device-config
Device config
2 parents cc9f537 + 6c053fb commit 443b2b3

File tree

5 files changed

+43
-21
lines changed

5 files changed

+43
-21
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DeviceDetails/SetAzureStorSimpleDevice.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class SetAzureStorSimpleDevice : StorSimpleCmdletBase
7171
/// <summary>
7272
/// A collection of network configs for interfaces on the device.
7373
/// </summary>
74-
[Parameter(Mandatory = false, Position = 4, HelpMessage = StorSimpleCmdletHelpMessage.StorSimpleNetworkConfig)]
74+
[Parameter(Mandatory = false, Position = 4, HelpMessage = StorSimpleCmdletHelpMessage.StorSimpleNetworkConfig, ValueFromPipeline=true)]
7575
[ValidateNotNullOrEmpty]
7676
public NetworkConfig[] StorSimpleNetworkConfig { get; set; }
7777

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DeviceJobs/GetAzureStorSimpleJob.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class GetAzureStorSimpleJob : StorSimpleCmdletBase
3838
/// </summary>
3939
[Parameter(Mandatory = true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByDeviceName,
4040
HelpMessage=StorSimpleCmdletHelpMessage.DeviceName)]
41+
[ValidateNotNullOrEmpty]
4142
public string DeviceName { get; set; }
4243

4344

@@ -46,7 +47,8 @@ public class GetAzureStorSimpleJob : StorSimpleCmdletBase
4647
/// </summary>
4748
[Parameter(Mandatory=true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyById,
4849
HelpMessage = StorSimpleCmdletHelpMessage.DeviceJobId)]
49-
public string JobId { get; set; }
50+
[ValidateNotNullOrEmpty]
51+
public string InstanceId { get; set; }
5052

5153
/// <summary>
5254
/// Filter jobs by their status.
@@ -107,13 +109,13 @@ public override void ExecuteCmdlet()
107109
}
108110

109111
// Make call to get device jobs.
110-
var response = StorSimpleClient.GetDeviceJobs(deviceId, Type, Status, JobId, fromDateTimeIsoString, toDateTimeIsoString, (int)Skip, (int)First);
112+
var response = StorSimpleClient.GetDeviceJobs(deviceId, Type, Status, InstanceId, fromDateTimeIsoString, toDateTimeIsoString, (int)Skip, (int)First);
111113

112114
if (ParameterSetName == StorSimpleCmdletParameterSet.IdentifyById)
113115
{
114116
if (response == null || response.DeviceJobList.Count < 1)
115117
{
116-
WriteVerbose(string.Format(Resources.NoDeviceJobFoundWithGivenIdMessage, JobId));
118+
WriteVerbose(string.Format(Resources.NoDeviceJobFoundWithGivenIdMessage, InstanceId));
117119
WriteObject(null);
118120
return;
119121
}
@@ -122,7 +124,7 @@ public override void ExecuteCmdlet()
122124
}
123125
else
124126
{
125-
WriteObject(response.DeviceJobList);
127+
WriteObject(response.DeviceJobList, true);
126128
WriteVerbose(string.Format(Resources.DeviceJobsReturnedCount, response.DeviceJobList.Count,
127129
response.DeviceJobList.Count > 1 ? "s" : string.Empty));
128130
if (response.NextPageUri != null

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/DeviceJobs/StopAzureStorSimpleJob.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public class StopAzureStorSimpleJob : StorSimpleCmdletBase
3232
/// <summary>
3333
/// Device job id of the job to stop.
3434
/// </summary>
35-
[Parameter(Mandatory = true, Position = 0, HelpMessage = StorSimpleCmdletHelpMessage.DeviceJobId)]
36-
[ValidateNotNullOrEmptyAttribute]
37-
public string JobId { get; set; }
35+
[Parameter(Mandatory = true, Position = 0, HelpMessage = StorSimpleCmdletHelpMessage.DeviceJobId, ValueFromPipelineByPropertyName = true)]
36+
[ValidateNotNullOrEmpty]
37+
public string InstanceId { get; set; }
3838

3939
/// <summary>
4040
/// Wheter to prompt for permission or not.
@@ -48,23 +48,31 @@ public override void ExecuteCmdlet()
4848
{
4949
ConfirmAction(
5050
Force.IsPresent,
51-
string.Format(Resources.StopAzureStorSimpleJobWarningMessage, JobId),
52-
string.Format(Resources.StopAzureStorSimpleJobMessage, JobId),
53-
JobId,
51+
string.Format(Resources.StopAzureStorSimpleJobWarningMessage, InstanceId),
52+
string.Format(Resources.StopAzureStorSimpleJobMessage, InstanceId),
53+
InstanceId,
5454
() =>
5555
{
5656
// Get details of the job being cancelled.
57-
var deviceJobDetails = StorSimpleClient.GetDeviceJobById(JobId);
57+
var deviceJobDetails = StorSimpleClient.GetDeviceJobById(InstanceId);
5858
if (deviceJobDetails == null)
5959
{
60-
WriteVerbose(string.Format(Resources.NoDeviceJobFoundWithGivenIdMessage, JobId));
60+
WriteVerbose(string.Format(Resources.NoDeviceJobFoundWithGivenIdMessage, InstanceId));
61+
WriteObject(null);
62+
return;
63+
}
64+
65+
// Make sure the job is running and cancellable, else fail.
66+
if (!(deviceJobDetails.IsJobCancellable && deviceJobDetails.Status == "Running"))
67+
{
68+
WriteVerbose(string.Format(Resources.JobNotRunningOrCancellable, InstanceId));
6169
WriteObject(null);
6270
return;
6371
}
6472

6573
// issue call to cancel the job.
66-
WriteVerbose(string.Format(Resources.StoppingDeviceJob,JobId));
67-
var taskStatusInfo = StorSimpleClient.StopDeviceJob(deviceJobDetails.Device.InstanceId, JobId);
74+
WriteVerbose(string.Format(Resources.StoppingDeviceJob,InstanceId));
75+
var taskStatusInfo = StorSimpleClient.StopDeviceJob(deviceJobDetails.Device.InstanceId, InstanceId);
6876
HandleSyncTaskResponse(taskStatusInfo, "stop");
6977
if (taskStatusInfo.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded)
7078
{

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.Designer.cs

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ServiceManagement/StorSimple/Commands.StorSimple/Properties/Resources.resx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,10 @@
430430
<value>Data0 configuration with Controller0 and Controller1 IP Addresses along with TimeZone and Primary DNS Server information is mandatory when configuring the device for the first time</value>
431431
</data>
432432
<data name="DeviceJobsNextPageFormatMessage" xml:space="preserve">
433-
<value>More jobs are available for your query. To access the next page of your result use \"-First {0} -Skip {1}\" in your commandlet</value>
433+
<value>More jobs are available for your query. To access the next page of your result use -First {0} -Skip {1} in your commandlet</value>
434434
</data>
435435
<data name="DeviceJobsNextPagewithNoFirstMessage" xml:space="preserve">
436-
<value>More jobs are available in the subsequent pages for your query. To access the next page use \"-Skip {0}\" in your commandlet</value>
436+
<value>More jobs are available in the subsequent pages for your query. To access the next page use -Skip {0} in your commandlet</value>
437437
</data>
438438
<data name="DeviceJobsNoMorePagesMessage" xml:space="preserve">
439439
<value>No more jobs are present for your query!</value>
@@ -490,7 +490,7 @@
490490
<value>Volume Container Group \"{0}\" is not eligible for failover due to the reason: {1}</value>
491491
</data>
492492
<data name="SuccessMessageSubmitDeviceJob" xml:space="preserve">
493-
<value>The {0} job is triggered successfully. Please use the command Get-AzureStorSimpleJob -JobId {1} for tracking the job's status</value>
493+
<value>The {0} job is triggered successfully. Please use the command Get-AzureStorSimpleJob -InstanceId {1} for tracking the job's status</value>
494494
</data>
495495
<data name="StartAzureStorSimpleBackupCloneJobMessage" xml:space="preserve">
496496
<value>Cloning backup with backupId {0}...</value>
@@ -504,4 +504,7 @@
504504
<data name="DeviceFailoverSourceAndTargetDeviceSameError" xml:space="preserve">
505505
<value>Source and Target device in a failover operation can not be the same.</value>
506506
</data>
507+
<data name="JobNotRunningOrCancellable" xml:space="preserve">
508+
<value>Cannot stop job with id {0}. It is not a running cancellable job.</value>
509+
</data>
507510
</root>

0 commit comments

Comments
 (0)