Skip to content

Commit 1ac43e4

Browse files
committed
Migration Related changes
1 parent 3f1d1ea commit 1ac43e4

18 files changed

+1302
-659
lines changed

src/ServiceManagement/StorSimple/Commands.StorSimple.Test/Commands.StorSimple.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Scheduler.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Scheduler.dll</HintPath>
8080
</Reference>
8181
<Reference Include="Microsoft.WindowsAzure.Management.StorSimple">
82-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.StorSimple.1.0.3-preview\lib\net40\Microsoft.WindowsAzure.Management.StorSimple.dll</HintPath>
82+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.StorSimple.1.0.4-preview\lib\net40\Microsoft.WindowsAzure.Management.StorSimple.dll</HintPath>
8383
</Reference>
8484
<Reference Include="Newtonsoft.Json">
8585
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>

src/ServiceManagement/StorSimple/Commands.StorSimple.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
1313
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
1414
<package id="Microsoft.WindowsAzure.Management.Scheduler" version="6.0.0" targetFramework="net45" />
15-
<package id="Microsoft.WindowsAzure.Management.StorSimple" version="1.0.3-preview" targetFramework="net45" />
15+
<package id="Microsoft.WindowsAzure.Management.StorSimple" version="1.0.4-preview" targetFramework="net45" />
1616
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
1717
<package id="xunit" version="1.9.2" targetFramework="net45" />
1818
</packages>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
16+
using Microsoft.WindowsAzure.Management.StorSimple;
17+
using Microsoft.WindowsAzure.Management.StorSimple.Models;
18+
using System;
19+
using System.Collections.Generic;
20+
using System.Linq;
21+
using System.Management.Automation;
22+
using System.Text;
23+
24+
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
25+
{
26+
[Cmdlet(VerbsLifecycle.Confirm, "AzureStorSimpleLegacyVolumeContainerStatus")]
27+
public class ConfirmAzureStorSimpleLegacyVolumeContainerStatus : StorSimpleCmdletBase
28+
{
29+
[Parameter(Mandatory = true, Position = 0, HelpMessage = StorSimpleCmdletHelpMessage.MigrationConfigId)]
30+
[ValidateNotNullOrEmpty]
31+
public string LegacyConfigId { get; set; }
32+
33+
[Parameter(Mandatory = true, Position = 1, HelpMessage = StorSimpleCmdletHelpMessage.MigrationOperation)]
34+
[ValidateSet("Commit", "Rollback", IgnoreCase = true)]
35+
public string MigrationOperation { get; set; }
36+
37+
[Parameter(Mandatory = false, Position = 2,
38+
HelpMessage = StorSimpleCmdletHelpMessage.MigrationLegacyDataContainers)]
39+
public string[] LegacyContainerNames { get; set; }
40+
41+
public override void ExecuteCmdlet()
42+
{
43+
try
44+
{
45+
var confirmMigrationRequest = new MigrationConfirmStatusRequest();
46+
confirmMigrationRequest.Operation =
47+
(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>();
51+
var status = StorSimpleClient.ConfirmLegacyVolumeContainerStatus(LegacyConfigId, confirmMigrationRequest);
52+
MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter();
53+
WriteObject(opFormatter.GetResultMessage(Resources.ConfirmMigrationSuccessMessage, status));
54+
}
55+
catch (Exception except)
56+
{
57+
this.HandleException(except);
58+
}
59+
}
60+
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Management.StorSimple;
16+
using System;
17+
using System.Linq;
18+
using System.Management.Automation;
19+
20+
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
21+
{
22+
[Cmdlet(VerbsCommon.Get, "AzureStorSimpleLegacyVolumeContainerConfirmStatus")]
23+
public class GetAzureStorSimpleLegacyVolumeContainerConfirmStatus : StorSimpleCmdletBase
24+
{
25+
[Parameter(Mandatory = true, Position = 0, HelpMessage = StorSimpleCmdletHelpMessage.MigrationConfigId)]
26+
[ValidateNotNullOrEmpty]
27+
public string LegacyConfigId { get; set; }
28+
29+
[Parameter(Mandatory = false, Position = 1,
30+
HelpMessage = StorSimpleCmdletHelpMessage.MigrationLegacyDataContainers)]
31+
public string[] LegacyContainerNames { get; set; }
32+
33+
public override void ExecuteCmdlet()
34+
{
35+
try
36+
{
37+
StorSimpleClient.UpdateMigrationConfirmStatusSync(LegacyConfigId);
38+
var confirmStatus = StorSimpleClient.GetMigrationConfirmStatus(LegacyConfigId);
39+
if (0 < confirmStatus.ContainerConfirmStatus.Count)
40+
{
41+
if (null != LegacyContainerNames)
42+
{
43+
var legacyContainerNameList = LegacyContainerNames.ToList();
44+
confirmStatus.ContainerConfirmStatus = confirmStatus.ContainerConfirmStatus.ToList().FindAll(
45+
status =>
46+
legacyContainerNameList.Contains(status.CloudConfigurationName,
47+
StringComparer.InvariantCultureIgnoreCase));
48+
}
49+
}
50+
51+
var confirmStatusMsg = new ConfirmMigrationStatusMsg(LegacyConfigId, confirmStatus);
52+
WriteObject(confirmStatusMsg);
53+
}
54+
catch (Exception except)
55+
{
56+
this.HandleException(except);
57+
}
58+
}
59+
}
60+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.StorSimple.Properties;
16+
using Microsoft.WindowsAzure.Management.StorSimple;
17+
using Microsoft.WindowsAzure.Management.StorSimple.Models;
18+
using System;
19+
using System.Linq;
20+
using System.Management.Automation;
21+
22+
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
23+
{
24+
[Cmdlet(VerbsCommon.Get, "AzureStorSimpleLegacyVolumeContainerMigrationPlan")]
25+
public class GetAzureStorSimpleLegacyVolumeContainerMigrationPlan : StorSimpleCmdletBase
26+
{
27+
[Parameter(Mandatory = false, Position = 0, HelpMessage = StorSimpleCmdletHelpMessage.MigrationConfigId)]
28+
[ValidateNotNullOrEmpty]
29+
public string LegacyConfigId { get; set; }
30+
31+
[Parameter(Mandatory = false, Position = 1,
32+
HelpMessage = StorSimpleCmdletHelpMessage.MigrationLegacyDataContainers)]
33+
public string[] LegacyContainerNames { get; set; }
34+
35+
public override void ExecuteCmdlet()
36+
{
37+
try
38+
{
39+
if (string.IsNullOrEmpty(LegacyConfigId))
40+
{
41+
var migrationPlanList = StorSimpleClient.GetAllMigrationPlan();
42+
if (migrationPlanList.MigrationPlans.Count == 0)
43+
{
44+
WriteWarning(Resources.MigrationPlanNoConfigs);
45+
}
46+
else
47+
{
48+
foreach (var migrationPlan in migrationPlanList.MigrationPlans)
49+
{
50+
var migrationPlanConfig = new MigrationConfig(migrationPlan);
51+
WriteObject(migrationPlanConfig);
52+
}
53+
}
54+
}
55+
else
56+
{
57+
StorSimpleClient.UpdateMigrationPlanSync(LegacyConfigId);
58+
var migrationPlanList = StorSimpleClient.GetMigrationPlan(LegacyConfigId);
59+
if (0 >= migrationPlanList.MigrationPlans.Count)
60+
{
61+
throw new ArgumentException(Resources.MigrationPlanNotFound);
62+
}
63+
else
64+
{
65+
MigrationPlan migrationPlan = migrationPlanList.MigrationPlans.First();
66+
if (null != LegacyContainerNames)
67+
{
68+
var legacyContainerNamesList = LegacyContainerNames.ToList();
69+
migrationPlan.MigrationPlanInfo =
70+
migrationPlan.MigrationPlanInfo.ToList().FindAll(
71+
plan =>
72+
legacyContainerNamesList.Contains(plan.DataContainerName,
73+
StringComparer.InvariantCultureIgnoreCase));
74+
}
75+
76+
var migrationPlanMsg = new MigrationPlanMsg(migrationPlan);
77+
WriteObject(migrationPlanMsg);
78+
}
79+
}
80+
}
81+
catch (Exception except)
82+
{
83+
this.HandleException(except);
84+
}
85+
}
86+
}
87+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Management.StorSimple;
16+
using System;
17+
using System.Collections.Generic;
18+
using System.Linq;
19+
using System.Management.Automation;
20+
21+
namespace Microsoft.WindowsAzure.Commands.StorSimple.Cmdlets
22+
{
23+
[Cmdlet(VerbsCommon.Get, "AzureStorSimpleLegacyVolumeContainerStatus")]
24+
public class GetAzureStorSimpleLegacyVolumeContainerStatus : StorSimpleCmdletBase
25+
{
26+
[Parameter(Mandatory = true, Position = 0, HelpMessage = StorSimpleCmdletHelpMessage.MigrationConfigId)]
27+
[ValidateNotNullOrEmpty]
28+
public string LegacyConfigId { get; set; }
29+
30+
[Parameter(Mandatory = false, Position = 1,
31+
HelpMessage = StorSimpleCmdletHelpMessage.MigrationLegacyDataContainers)]
32+
public string[] LegacyContainerNames { get; set; }
33+
34+
public override void ExecuteCmdlet()
35+
{
36+
try
37+
{
38+
StorSimpleClient.UpdateDataContainerMigrationStatusSync(LegacyConfigId);
39+
var overallMigrationStatusList = StorSimpleClient.GetDataContainerMigrationStatus(LegacyConfigId);
40+
var migrationDataContainerStatusList =
41+
overallMigrationStatusList.MigrationDataContainerStatuses.ToList();
42+
if (null != LegacyContainerNames && 0 < LegacyContainerNames.Length)
43+
{
44+
45+
var containerNameList = LegacyContainerNames.ToList();
46+
migrationDataContainerStatusList = migrationDataContainerStatusList.ToList().FindAll(
47+
status =>
48+
containerNameList.Contains(status.CloudConfigurationName,
49+
StringComparer.InvariantCultureIgnoreCase));
50+
}
51+
52+
var migrationStatus = new DataContainerMigrationStatus(
53+
LegacyConfigId, migrationDataContainerStatusList);
54+
55+
WriteObject(migrationStatus);
56+
}
57+
catch (Exception except)
58+
{
59+
this.HandleException(except);
60+
}
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)