Skip to content

Commit 473e99b

Browse files
committed
Merge pull request #59 from AzCiS/LAMigration
Adding support for -All for Import DC, Start Migration Plan and Confirm Migration cmdlets
2 parents eb5a412 + 160e124 commit 473e99b

File tree

7 files changed

+96
-13
lines changed

7 files changed

+96
-13
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/Migration/ConfirmAzureStorSimpleLegacyVolumeContainerStatus.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,43 @@ public class ConfirmAzureStorSimpleLegacyVolumeContainerStatus : StorSimpleCmdle
3434
[ValidateSet("Commit", "Rollback", IgnoreCase = true)]
3535
public string MigrationOperation { get; set; }
3636

37-
[Parameter(Mandatory = false, Position = 2,
37+
[Parameter(Mandatory = true, Position = 2, ParameterSetName = StorSimpleCmdletParameterSet.MigrateSpecificContainer,
3838
HelpMessage = StorSimpleCmdletHelpMessage.MigrationLegacyDataContainers)]
3939
public string[] LegacyContainerNames { get; set; }
4040

41+
[Parameter(Mandatory = true, Position = 2, ParameterSetName = StorSimpleCmdletParameterSet.MigrateAllContainer,
42+
HelpMessage = StorSimpleCmdletHelpMessage.MigrationAllContainers)]
43+
public SwitchParameter All { get; set; }
44+
4145
public override void ExecuteCmdlet()
4246
{
4347
try
4448
{
4549
var confirmMigrationRequest = new MigrationConfirmStatusRequest();
4650
confirmMigrationRequest.Operation =
4751
(MigrationOperation) Enum.Parse(typeof (MigrationOperation), MigrationOperation, true);
48-
confirmMigrationRequest.DataContainerNameList = (null != LegacyContainerNames)
49-
? new List<string>(LegacyContainerNames.ToList().Distinct(StringComparer.InvariantCultureIgnoreCase))
50-
: new List<string>();
52+
switch (ParameterSetName)
53+
{
54+
case StorSimpleCmdletParameterSet.MigrateAllContainer:
55+
{
56+
confirmMigrationRequest.DataContainerNameList = new List<string>();
57+
break;
58+
}
59+
case StorSimpleCmdletParameterSet.MigrateSpecificContainer:
60+
{
61+
confirmMigrationRequest.DataContainerNameList =
62+
new List<string>(LegacyContainerNames.ToList().Distinct(
63+
StringComparer.InvariantCultureIgnoreCase));
64+
break;
65+
}
66+
default:
67+
{
68+
// unexpected code path hit.
69+
throw new ParameterBindingException(
70+
string.Format(Resources.MigrationParameterSetNotFound, ParameterSetName));
71+
}
72+
}
73+
5174
var status = StorSimpleClient.ConfirmLegacyVolumeContainerStatus(LegacyConfigId, confirmMigrationRequest);
5275
MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter();
5376
WriteObject(opFormatter.GetResultMessage(Resources.ConfirmMigrationSuccessMessage, status));

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/Migration/ImportAzureStorSimpleLegacyVolumeContainer.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ public class ImportAzureStorSimpleLegacyVolumeContainer : StorSimpleCmdletBase
2929
[ValidateNotNullOrEmpty]
3030
public string LegacyConfigId { get; set; }
3131

32-
[Parameter(Mandatory = false, Position = 1,
32+
[Parameter(Mandatory = true, Position = 1, ParameterSetName = StorSimpleCmdletParameterSet.MigrateSpecificContainer,
3333
HelpMessage = StorSimpleCmdletHelpMessage.MigrationLegacyDataContainers)]
3434
public string[] LegacyContainerNames { get; set; }
3535

36+
[Parameter(Mandatory = true, Position = 1, ParameterSetName = StorSimpleCmdletParameterSet.MigrateAllContainer,
37+
HelpMessage = StorSimpleCmdletHelpMessage.MigrationAllContainers)]
38+
public SwitchParameter All { get; set; }
39+
3640
[Parameter(Mandatory = false, Position = 2,
3741
HelpMessage = StorSimpleCmdletHelpMessage.MigrationImportDCWithSkipACRs)]
3842
public SwitchParameter SkipACRs { get; set; }
@@ -45,9 +49,28 @@ public override void ExecuteCmdlet()
4549
try
4650
{
4751
var importDataContainerRequest = new MigrationImportDataContainerRequest();
48-
importDataContainerRequest.DataContainerNames = (null != LegacyContainerNames)
49-
? new List<string>(LegacyContainerNames.ToList().Distinct(StringComparer.InvariantCultureIgnoreCase))
50-
: new List<string>();
52+
switch (ParameterSetName)
53+
{
54+
case StorSimpleCmdletParameterSet.MigrateAllContainer:
55+
{
56+
importDataContainerRequest.DataContainerNames = new List<string>();
57+
break;
58+
}
59+
case StorSimpleCmdletParameterSet.MigrateSpecificContainer:
60+
{
61+
importDataContainerRequest.DataContainerNames =
62+
new List<string>(LegacyContainerNames.ToList().Distinct(
63+
StringComparer.InvariantCultureIgnoreCase));
64+
break;
65+
}
66+
default:
67+
{
68+
// unexpected code path.
69+
throw new ParameterBindingException(
70+
string.Format(Resources.MigrationParameterSetNotFound, ParameterSetName));
71+
}
72+
}
73+
5174
importDataContainerRequest.ForceOnOtherDevice = Force.IsPresent;
5275
importDataContainerRequest.SkipACRs = SkipACRs.IsPresent;
5376

src/ServiceManagement/StorSimple/Commands.StorSimple/Cmdlets/Migration/StartAzureStorSimpleLegacyVolumeContainerMigrationPlan.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,41 @@ public class StartAzureStorSimpleLegacyVolumeContainerMigrationPlan : StorSimple
2929
[ValidateNotNullOrEmpty]
3030
public string LegacyConfigId { get; set; }
3131

32-
[Parameter(Mandatory = false, Position = 1,
32+
[Parameter(Mandatory = true, Position = 1, ParameterSetName = StorSimpleCmdletParameterSet.MigrateSpecificContainer,
3333
HelpMessage = StorSimpleCmdletHelpMessage.MigrationLegacyDataContainers)]
3434
public string[] LegacyContainerNames { get; set; }
3535

36+
[Parameter(Mandatory = true, Position = 1, ParameterSetName = StorSimpleCmdletParameterSet.MigrateAllContainer,
37+
HelpMessage = StorSimpleCmdletHelpMessage.MigrationAllContainers)]
38+
public SwitchParameter All { get; set; }
39+
3640
public override void ExecuteCmdlet()
3741
{
3842
try
3943
{
4044
var startMigrationPlanRequest = new MigrationPlanStartRequest();
4145
startMigrationPlanRequest.ConfigId = LegacyConfigId;
42-
startMigrationPlanRequest.DataContainerNameList = (null != LegacyContainerNames)
43-
? new List<string>(LegacyContainerNames.ToList().Distinct(StringComparer.InvariantCultureIgnoreCase))
44-
: new List<string>();
46+
switch (ParameterSetName)
47+
{
48+
case StorSimpleCmdletParameterSet.MigrateAllContainer:
49+
{
50+
startMigrationPlanRequest.DataContainerNameList = new List<string>();
51+
break;
52+
}
53+
case StorSimpleCmdletParameterSet.MigrateSpecificContainer:
54+
{
55+
startMigrationPlanRequest.DataContainerNameList =
56+
new List<string>(LegacyContainerNames.ToList().Distinct(
57+
StringComparer.InvariantCultureIgnoreCase));
58+
break;
59+
}
60+
default:
61+
{
62+
// unexpected code path hit.
63+
throw new ParameterBindingException(
64+
string.Format(Resources.MigrationParameterSetNotFound, ParameterSetName));
65+
}
66+
}
4567

4668
var status = StorSimpleClient.StartLegacyVolumeContainerMigrationPlan(startMigrationPlanRequest);
4769
MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter();

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

Lines changed: 10 additions & 1 deletion
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,4 +571,7 @@ a special character</value>
571571
<data name="MigrationPlanNotFound" xml:space="preserve">
572572
<value>No migration plan found corresponding to the LegacyConfigId.</value>
573573
</data>
574+
<data name="MigrationParameterSetNotFound" xml:space="preserve">
575+
<value>Parameter set cannot be resolved using the specified named parameters {0}</value>
576+
</data>
574577
</root>

src/ServiceManagement/StorSimple/Commands.StorSimple/StorSimpleCmdletHelpMessage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ internal static class StorSimpleCmdletHelpMessage
127127
public const string MigrationTargetDevice = "The target appliance to which migration needs to be performed";
128128
public const string MigrationConfigDecryptionKey = "The key to decrypt the legacy appliance config file";
129129
public const string MigrationLegacyDataContainers = "Names of data containers to be migrated seperated by ','";
130+
public const string MigrationAllContainers = "All data containers will be considered for migration";
130131
public const string MigrationConfigId = "Legacy config id";
131132
public const string MigrationOperation = "Commit or Rollback";
132133
public const string MigrationImportDCByForce = "Force import data container on a different device even if data container has been imported on a different device";

src/ServiceManagement/StorSimple/Commands.StorSimple/StorSimpleCmdletParameterSet.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ internal static class StorSimpleCmdletParameterSet
2828
public const string IdentifyByStatus = "IdentifyByStatus";
2929
public const string UseExistingStorageAccount = "UseExistingStorageAccount";
3030
public const string CreateNewStorageAccount = "CreateNewStorageAccount";
31+
public const string MigrateAllContainer = "MigrateAllContainer";
32+
public const string MigrateSpecificContainer = "MigrateSpecificContainer";
3133
}
3234
}

0 commit comments

Comments
 (0)