Skip to content

Commit

Permalink
Merge pull request #12 from AzCiS/parvezah
Browse files Browse the repository at this point in the history
Adding Device Id inputs to the Clone cmdlets.
  • Loading branch information
avirupch committed Feb 27, 2015
2 parents 766658a + 9a243c6 commit 57d5daa
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,39 @@ namespace Microsoft.AzureStorSimpleDeviceCmdlets.Commands
/// Given a backupId, snapshot and a targetDeviceName , this commandlet will
/// clone it on the given target device.
/// </summary>
[Cmdlet(VerbsLifecycle.Start, "AzureStorSimpleBackupCloneJob")]
[Cmdlet(VerbsLifecycle.Start, "AzureStorSimpleBackupCloneJob", DefaultParameterSetName = StorSimpleCmdletParameterSet.Empty)]
public class StartAzureStorSimpleBackupCloneJob : StorSimpleCmdletBase
{
[Parameter(Mandatory = true, Position = 0, HelpMessage = StorSimpleCmdletHelpMessage.SourceDeviceName)]
[Parameter(Mandatory = true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByName, HelpMessage = StorSimpleCmdletHelpMessage.SourceDeviceName)]
[ValidateNotNullOrEmpty]
public string SourceDeviceName { get; set; }

[Parameter(Mandatory = true, Position = 1, HelpMessage = StorSimpleCmdletHelpMessage.TargetDeviceName)]
[Parameter(Mandatory = true, Position = 0, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyById, HelpMessage = StorSimpleCmdletHelpMessage.SourceDeviceId)]
[ValidateNotNullOrEmpty]
public string SourceDeviceId { get; set; }

[Parameter(Mandatory = true, Position = 1, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyByName, HelpMessage = StorSimpleCmdletHelpMessage.TargetDeviceName)]
[ValidateNotNullOrEmpty]
public string TargetDeviceName { get; set; }

[Parameter(Mandatory = true, Position = 1, ParameterSetName = StorSimpleCmdletParameterSet.IdentifyById, HelpMessage = StorSimpleCmdletHelpMessage.TargetDeviceId)]
[ValidateNotNullOrEmpty]
public string TargetDeviceId { get; set; }

[Parameter(Mandatory = true, Position = 2, HelpMessage = StorSimpleCmdletHelpMessage.BackupIdToClone)]
[ValidateNotNullOrEmpty]
public string BackupId { get; set; }

[Parameter(Mandatory = true, Position = 3, ValueFromPipeline = true, HelpMessage = StorSimpleCmdletHelpMessage.SnapshotToClone)]
[ValidateNotNull]
public Snapshot Snapshot { get; set; }

[Parameter(Mandatory = false, Position = 4, ValueFromPipeline = true, HelpMessage = StorSimpleCmdletHelpMessage.VolumeAcrList)]
[ValidateNotNull]
public List<AccessControlRecord> TargetAccessControlRecords { get; set; }

[Parameter(Mandatory = false, Position = 5, HelpMessage = StorSimpleCmdletHelpMessage.CloneVolumeName)]
[ValidateNotNullOrEmpty]
public string CloneVolumeName { get; set; }

[Parameter(Mandatory = false, Position = 6, HelpMessage = StorSimpleCmdletHelpMessage.Force)]
Expand Down Expand Up @@ -83,22 +97,31 @@ public override void ExecuteCmdlet()

private bool ProcessParameters()
{
this.sourceDeviceId = StorSimpleClient.GetDeviceId(SourceDeviceName);

if (this.sourceDeviceId == null)
switch (ParameterSetName)
{
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
return false;
}
case StorSimpleCmdletParameterSet.IdentifyById:
this.sourceDeviceId = SourceDeviceId;
this.targetDeviceId = TargetDeviceId;
break;
case StorSimpleCmdletParameterSet.IdentifyByName:
this.sourceDeviceId = StorSimpleClient.GetDeviceId(SourceDeviceName);

if (this.sourceDeviceId == null)
{
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
return false;
}

this.targetDeviceId = StorSimpleClient.GetDeviceId(TargetDeviceName);
this.targetDeviceId = StorSimpleClient.GetDeviceId(TargetDeviceName);

if (this.targetDeviceId == null)
{
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
return false;
if (this.targetDeviceId == null)
{
WriteVerbose(Resources.NoDeviceFoundWithGivenNameInResourceMessage);
return false;
}
break;
}

return true;
}

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 @@ -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 -InstanceId {1} for tracking the job's status</value>
<value>The {0} job is triggered successfully. Please use the command Get-AzureStorSimpleJob -JobId {1} for tracking the job's status</value>
</data>
<data name="StartASSBackupCloneJobMessage" xml:space="preserve">
<value>Cloning backup with backupId {0}...</value>
Expand Down

0 comments on commit 57d5daa

Please sign in to comment.