Skip to content

Commit

Permalink
Merge pull request #17 from AzCiS/onesdk-avirupch
Browse files Browse the repository at this point in the history
Updates in Start-AzureStorSimpleDeviceFailoverJob
  • Loading branch information
parvezah committed Mar 12, 2015
2 parents 8c38ae8 + 36f63e4 commit ebb4935
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
{
[Cmdlet(VerbsLifecycle.Start, "AzureStorSimpleDeviceFailoverJob", DefaultParameterSetName = StorSimpleCmdletParameterSet.Empty),
OutputType(typeof(TaskResponse), typeof(TaskStatusInfo))]
OutputType(typeof(string))]
public class StartAzureStorSimpleDeviceFailoverJob : StorSimpleCmdletBase
{
[Parameter(Position = 0, Mandatory = true, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyById, HelpMessage = StorSimpleCmdletHelpMessage.DeviceId)]
Expand All @@ -32,7 +32,7 @@ public class StartAzureStorSimpleDeviceFailoverJob : StorSimpleCmdletBase
[ValidateNotNullOrEmpty]
public string DeviceName { get; set; }

[Parameter(Position = 1, Mandatory = true, HelpMessage = StorSimpleCmdletHelpMessage.VolumeContainerGroups)]
[Parameter(Position = 1, Mandatory = true, ValueFromPipeline = true, HelpMessage = StorSimpleCmdletHelpMessage.VolumeContainerGroups)]
[ValidateNotNull]
public List<DataContainerGroup> VolumecontainerGroups { get; set; }

Expand Down Expand Up @@ -93,9 +93,8 @@ public override void ExecuteCmdlet()
return;
}

if(deviceId.Equals(targetDeviceId, StringComparison.InvariantCultureIgnoreCase))
if (!ValidTargetDeviceForFailover(deviceId, targetDeviceId))
{
WriteVerbose(Resources.DeviceFailoverSourceAndTargetDeviceSameError);
WriteObject(null);
return;
}
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 @@ -487,7 +487,7 @@
<value>Are you sure you want to failover the selected volume containers from device {0} to device {1}?</value>
</data>
<data name="VolumeContainerGroupNotEligibleForFailoverError" xml:space="preserve">
<value>Volume Container Group \"{0}\" is not eligible for failover due to the reason: {1}</value>
<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 -InstanceId {1} for tracking the job's status</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,16 @@ internal virtual void HandleException(Exception exception)
}
else if (exType == typeof(ArgumentNullException))
{
var argEx = ex as ArgumentNullException;
var argNullEx = ex as ArgumentNullException;
if (argNullEx == null)
break;
WriteVerbose(string.Format(Resources.InvalidInputMessage, ex.Message));
errorRecord = new ErrorRecord(argNullEx, string.Empty, ErrorCategory.InvalidData, null);
break;
}
else if (exType == typeof(ArgumentException))
{
var argEx = ex as ArgumentException;
if (argEx == null)
break;
WriteVerbose(string.Format(Resources.InvalidInputMessage, ex.Message));
Expand Down Expand Up @@ -479,5 +488,21 @@ internal bool ValidParamsForFirstDeviceConfiguration(NetworkConfig[] netConfigs,
}
return true;
}

/// <summary>
/// Validate that the target device is eligible for failover
/// </summary>
/// <param name="sourceDeviceName">The source device identifier</param>
/// <param name="targetDeviceName">The target device identifier</param>
/// <returns></returns>
internal bool ValidTargetDeviceForFailover(string sourceDeviceId, string targetDeviceId)
{
if (sourceDeviceId.Equals(targetDeviceId, StringComparison.InvariantCultureIgnoreCase))
{
throw new ArgumentException(Resources.DeviceFailoverSourceAndTargetDeviceSameError);
}

return true;
}
}
}

0 comments on commit ebb4935

Please sign in to comment.