Skip to content

Commit

Permalink
Merge pull request #13 from AzCiS/device-config
Browse files Browse the repository at this point in the history
Device config
  • Loading branch information
avirupch committed Mar 2, 2015
2 parents cc9f537 + 6c053fb commit 443b2b3
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class SetAzureStorSimpleDevice : StorSimpleCmdletBase
/// <summary>
/// A collection of network configs for interfaces on the device.
/// </summary>
[Parameter(Mandatory = false, Position = 4, HelpMessage = StorSimpleCmdletHelpMessage.StorSimpleNetworkConfig)]
[Parameter(Mandatory = false, Position = 4, HelpMessage = StorSimpleCmdletHelpMessage.StorSimpleNetworkConfig, ValueFromPipeline=true)]
[ValidateNotNullOrEmpty]
public NetworkConfig[] StorSimpleNetworkConfig { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class GetAzureStorSimpleJob : StorSimpleCmdletBase
/// </summary>
[Parameter(Mandatory = true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByDeviceName,
HelpMessage=StorSimpleCmdletHelpMessage.DeviceName)]
[ValidateNotNullOrEmpty]
public string DeviceName { get; set; }


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

/// <summary>
/// Filter jobs by their status.
Expand Down Expand Up @@ -107,13 +109,13 @@ public override void ExecuteCmdlet()
}

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

if (ParameterSetName == StorSimpleCmdletParameterSet.IdentifyById)
{
if (response == null || response.DeviceJobList.Count < 1)
{
WriteVerbose(string.Format(Resources.NoDeviceJobFoundWithGivenIdMessage, JobId));
WriteVerbose(string.Format(Resources.NoDeviceJobFoundWithGivenIdMessage, InstanceId));
WriteObject(null);
return;
}
Expand All @@ -122,7 +124,7 @@ public override void ExecuteCmdlet()
}
else
{
WriteObject(response.DeviceJobList);
WriteObject(response.DeviceJobList, true);
WriteVerbose(string.Format(Resources.DeviceJobsReturnedCount, response.DeviceJobList.Count,
response.DeviceJobList.Count > 1 ? "s" : string.Empty));
if (response.NextPageUri != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public class StopAzureStorSimpleJob : StorSimpleCmdletBase
/// <summary>
/// Device job id of the job to stop.
/// </summary>
[Parameter(Mandatory = true, Position = 0, HelpMessage = StorSimpleCmdletHelpMessage.DeviceJobId)]
[ValidateNotNullOrEmptyAttribute]
public string JobId { get; set; }
[Parameter(Mandatory = true, Position = 0, HelpMessage = StorSimpleCmdletHelpMessage.DeviceJobId, ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string InstanceId { get; set; }

/// <summary>
/// Wheter to prompt for permission or not.
Expand All @@ -48,23 +48,31 @@ public override void ExecuteCmdlet()
{
ConfirmAction(
Force.IsPresent,
string.Format(Resources.StopAzureStorSimpleJobWarningMessage, JobId),
string.Format(Resources.StopAzureStorSimpleJobMessage, JobId),
JobId,
string.Format(Resources.StopAzureStorSimpleJobWarningMessage, InstanceId),
string.Format(Resources.StopAzureStorSimpleJobMessage, InstanceId),
InstanceId,
() =>
{
// Get details of the job being cancelled.
var deviceJobDetails = StorSimpleClient.GetDeviceJobById(JobId);
var deviceJobDetails = StorSimpleClient.GetDeviceJobById(InstanceId);
if (deviceJobDetails == null)
{
WriteVerbose(string.Format(Resources.NoDeviceJobFoundWithGivenIdMessage, JobId));
WriteVerbose(string.Format(Resources.NoDeviceJobFoundWithGivenIdMessage, InstanceId));
WriteObject(null);
return;
}

// Make sure the job is running and cancellable, else fail.
if (!(deviceJobDetails.IsJobCancellable && deviceJobDetails.Status == "Running"))
{
WriteVerbose(string.Format(Resources.JobNotRunningOrCancellable, InstanceId));
WriteObject(null);
return;
}

// issue call to cancel the job.
WriteVerbose(string.Format(Resources.StoppingDeviceJob,JobId));
var taskStatusInfo = StorSimpleClient.StopDeviceJob(deviceJobDetails.Device.InstanceId, JobId);
WriteVerbose(string.Format(Resources.StoppingDeviceJob,InstanceId));
var taskStatusInfo = StorSimpleClient.StopDeviceJob(deviceJobDetails.Device.InstanceId, InstanceId);
HandleSyncTaskResponse(taskStatusInfo, "stop");
if (taskStatusInfo.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,10 @@
<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>
</data>
<data name="DeviceJobsNextPageFormatMessage" xml:space="preserve">
<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>
<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>
</data>
<data name="DeviceJobsNextPagewithNoFirstMessage" xml:space="preserve">
<value>More jobs are available in the subsequent pages for your query. To access the next page use \"-Skip {0}\" in your commandlet</value>
<value>More jobs are available in the subsequent pages for your query. To access the next page use -Skip {0} in your commandlet</value>
</data>
<data name="DeviceJobsNoMorePagesMessage" xml:space="preserve">
<value>No more jobs are present for your query!</value>
Expand Down Expand Up @@ -490,7 +490,7 @@
<value>Volume Container Group \"{0}\" is not eligible for failover due to the reason: {1}</value>
</data>
<data name="SuccessMessageSubmitDeviceJob" xml:space="preserve">
<value>The {0} job is triggered successfully. Please use the command Get-AzureStorSimpleJob -JobId {1} for tracking the job's status</value>
<value>The {0} job is triggered successfully. Please use the command Get-AzureStorSimpleJob -InstanceId {1} for tracking the job's status</value>
</data>
<data name="StartAzureStorSimpleBackupCloneJobMessage" xml:space="preserve">
<value>Cloning backup with backupId {0}...</value>
Expand All @@ -504,4 +504,7 @@
<data name="DeviceFailoverSourceAndTargetDeviceSameError" xml:space="preserve">
<value>Source and Target device in a failover operation can not be the same.</value>
</data>
<data name="JobNotRunningOrCancellable" xml:space="preserve">
<value>Cannot stop job with id {0}. It is not a running cancellable job.</value>
</data>
</root>

0 comments on commit 443b2b3

Please sign in to comment.