Skip to content

Commit f519e7d

Browse files
committed
Add migration cmdlets to Preview module
1 parent 1f0bd25 commit f519e7d

File tree

6 files changed

+325
-5
lines changed

6 files changed

+325
-5
lines changed

src/ServiceManagement/Common/Commands.ServiceManagement.Common/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
[assembly: ComVisible(false)]
2626
[assembly: CLSCompliant(false)]
2727
[assembly: Guid("4f3ab2e4-cc7a-43ac-bb15-f481fcf94d58")]
28-
[assembly: AssemblyVersion("1.3.2")]
29-
[assembly: AssemblyFileVersion("1.3.2")]
28+
[assembly: AssemblyVersion("1.3.3")]
29+
[assembly: AssemblyFileVersion("1.3.3")]
3030
#if SIGN
3131
[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
3232
[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.CloudService, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]

src/ServiceManagement/Compute/Commands.ServiceManagement.Preview/Commands.ServiceManagement.Preview.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@
278278
<Compile Include="Generated\VirtualMachine\VirtualMachineStartRolesMethod.cs" />
279279
<Compile Include="Generated\VirtualMachine\VirtualMachineUpdateLoadBalancedEndpointSetMethod.cs" />
280280
<Compile Include="Generated\VirtualMachine\VirtualMachineUpdateMethod.cs" />
281+
<Compile Include="Migration\MoveAzureService.cs" />
282+
<Compile Include="Migration\MoveAzureVirtualNetwork.cs" />
281283
<Compile Include="Properties\AssemblyInfo.cs" />
282284
<Compile Include="Properties\Resources.Designer.cs">
283285
<AutoGen>True</AutoGen>
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
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 System;
16+
using System.Management.Automation;
17+
using Microsoft.Azure;
18+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
19+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
20+
using Microsoft.WindowsAzure.Management.Compute;
21+
using Microsoft.WindowsAzure.Management.Compute.Models;
22+
23+
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices
24+
{
25+
/// <summary>
26+
/// Migrate ASM deployment to ARM
27+
/// </summary>
28+
[Cmdlet(VerbsCommon.Move, "AzureService"), OutputType(typeof(OperationStatusResponse))]
29+
public class MoveAzureServiceCommand : ServiceManagementBaseCmdlet
30+
{
31+
private const string AbortParameterSetName = "AbortMigrationParameterSet";
32+
private const string CommitParameterSetName = "CommitMigrationParameterSet";
33+
private const string PrepareDefaultParameterSetName = "PrepareDefaultMigrationParameterSet";
34+
private const string PrepareNewParameterSetName = "PrepareNewMigrationParameterSet";
35+
private const string PrepareExistingParameterSetName = "PrepareExistingMigrationParameterSet";
36+
37+
private string DestinationVNetType;
38+
39+
[Parameter(
40+
Position =0,
41+
Mandatory = true,
42+
ParameterSetName = AbortParameterSetName,
43+
HelpMessage = "Abort migration")]
44+
public SwitchParameter Abort
45+
{
46+
get;
47+
set;
48+
}
49+
50+
[Parameter(
51+
Position = 0,
52+
Mandatory = true,
53+
ParameterSetName = CommitParameterSetName,
54+
HelpMessage = "Commit migration")]
55+
public SwitchParameter Commit
56+
{
57+
get;
58+
set;
59+
}
60+
61+
[Parameter(
62+
Position = 0,
63+
Mandatory = true,
64+
ParameterSetName = PrepareDefaultParameterSetName,
65+
HelpMessage = "Prepare migration")]
66+
public SwitchParameter PrepareDefault
67+
{
68+
get;
69+
set;
70+
}
71+
72+
[Parameter(
73+
Position = 0,
74+
Mandatory = true,
75+
ParameterSetName = PrepareNewParameterSetName,
76+
HelpMessage = "Prepare migration")]
77+
public SwitchParameter PrepareNew
78+
{
79+
get;
80+
set;
81+
}
82+
83+
[Parameter(
84+
Position = 0,
85+
Mandatory = true,
86+
ParameterSetName = PrepareExistingParameterSetName,
87+
HelpMessage = "Prepare migration")]
88+
public SwitchParameter PrepareExistingDestinationVNet
89+
{
90+
get;
91+
set;
92+
}
93+
94+
[Parameter(
95+
Position = 1,
96+
Mandatory = true,
97+
ValueFromPipelineByPropertyName = true,
98+
HelpMessage = "Service name to be migrated")]
99+
[ValidateNotNullOrEmpty]
100+
public string ServiceName
101+
{
102+
get;
103+
set;
104+
}
105+
106+
[Parameter(
107+
Position = 2,
108+
Mandatory = true,
109+
HelpMessage = "Deployment name to be migrated")]
110+
[ValidateNotNullOrEmpty]
111+
public string DeploymentName
112+
{
113+
get;
114+
set;
115+
}
116+
117+
[Parameter(
118+
Position = 3,
119+
Mandatory = true,
120+
ParameterSetName = PrepareExistingParameterSetName,
121+
HelpMessage = "Resource group name for migration")]
122+
[ValidateNotNullOrEmpty]
123+
public string ResourceGroupName
124+
{
125+
get;
126+
set;
127+
}
128+
129+
[Parameter(
130+
Position = 4,
131+
Mandatory = true,
132+
ParameterSetName = PrepareExistingParameterSetName,
133+
HelpMessage = "Virtual network name for migration")]
134+
[ValidateNotNullOrEmpty]
135+
public string VirtualNetworkName
136+
{
137+
get;
138+
set;
139+
}
140+
141+
[Parameter(
142+
Position = 5,
143+
Mandatory = true,
144+
ParameterSetName = PrepareExistingParameterSetName,
145+
HelpMessage = "Subnet Name for migration")]
146+
[ValidateNotNullOrEmpty]
147+
public string SubnetName
148+
{
149+
get;
150+
set;
151+
}
152+
153+
protected override void OnProcessRecord()
154+
{
155+
ServiceManagementProfile.Initialize();
156+
157+
if (this.Abort.IsPresent)
158+
{
159+
ExecuteClientActionNewSM(
160+
null,
161+
CommandRuntime.ToString(),
162+
() => this.ComputeClient.Deployments.AbortMigration(this.ServiceName, DeploymentName));
163+
}
164+
else if (this.Commit.IsPresent)
165+
{
166+
ExecuteClientActionNewSM(
167+
null,
168+
CommandRuntime.ToString(),
169+
() => this.ComputeClient.Deployments.CommitMigration(this.ServiceName, DeploymentName));
170+
}
171+
else
172+
{
173+
if (this.PrepareDefault.IsPresent)
174+
{
175+
DestinationVNetType = DestinationVirtualNetwork.Default;
176+
}
177+
else if (this.PrepareNew.IsPresent)
178+
{
179+
DestinationVNetType = DestinationVirtualNetwork.New;
180+
}
181+
else
182+
{
183+
DestinationVNetType = DestinationVirtualNetwork.Existing;
184+
}
185+
186+
var parameter = (this.ParameterSetName == PrepareExistingParameterSetName)
187+
? new PrepareDeploymentMigrationParameters
188+
{
189+
DestinationVirtualNetwork = this.DestinationVNetType,
190+
ResourceGroupName = this.ResourceGroupName,
191+
SubNetName = this.SubnetName,
192+
VirtualNetworkName = this.VirtualNetworkName
193+
}
194+
: new PrepareDeploymentMigrationParameters
195+
{
196+
DestinationVirtualNetwork = this.DestinationVNetType,
197+
ResourceGroupName = string.Empty,
198+
SubNetName = string.Empty,
199+
VirtualNetworkName = string.Empty
200+
};
201+
202+
ExecuteClientActionNewSM(
203+
null,
204+
CommandRuntime.ToString(),
205+
() => this.ComputeClient.Deployments.PrepareMigration(this.ServiceName, DeploymentName, parameter));
206+
}
207+
}
208+
}
209+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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 System;
16+
using System.Management.Automation;
17+
using Microsoft.Azure;
18+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
19+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
20+
using Microsoft.WindowsAzure.Management.Compute;
21+
using Microsoft.WindowsAzure.Management.Compute.Models;
22+
using Microsoft.WindowsAzure.Management.Network;
23+
24+
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices
25+
{
26+
/// <summary>
27+
/// Migrate ASM virtual network to ARM
28+
/// </summary>
29+
[Cmdlet(VerbsCommon.Move, "AzureVirtualNetwork"), OutputType(typeof(OperationStatusResponse))]
30+
public class MoveVirtualNetworkCommand : ServiceManagementBaseCmdlet
31+
{
32+
private const string AbortParameterSetName = "AbortMigrationParameterSet";
33+
private const string CommitParameterSetName = "CommitMigrationParameterSet";
34+
private const string PrepareParameterSetName = "PrepareMigrationParameterSet";
35+
36+
[Parameter(
37+
Position = 0,
38+
Mandatory = true,
39+
ParameterSetName = AbortParameterSetName,
40+
HelpMessage = "Abort migration")]
41+
public SwitchParameter Abort
42+
{
43+
get;
44+
set;
45+
}
46+
47+
[Parameter(Position = 0,
48+
Mandatory = true,
49+
ParameterSetName = CommitParameterSetName,
50+
HelpMessage = "Commit migration")]
51+
public SwitchParameter Commit
52+
{
53+
get;
54+
set;
55+
}
56+
57+
[Parameter(
58+
Position = 0,
59+
Mandatory = true,
60+
ParameterSetName = PrepareParameterSetName,
61+
HelpMessage = "Prepare migration")]
62+
public SwitchParameter Prepare
63+
{
64+
get;
65+
set;
66+
}
67+
68+
[Parameter(
69+
Position = 1,
70+
Mandatory = true,
71+
ValueFromPipelineByPropertyName = true,
72+
HelpMessage = "Service name.")]
73+
[ValidateNotNullOrEmpty]
74+
public string VirtualNetworkName
75+
{
76+
get;
77+
set;
78+
}
79+
80+
protected override void OnProcessRecord()
81+
{
82+
ServiceManagementProfile.Initialize();
83+
84+
if (this.Abort.IsPresent)
85+
{
86+
87+
ExecuteClientActionNewSM(
88+
null,
89+
CommandRuntime.ToString(),
90+
() => this.NetworkClient.Networks.AbortMigration(this.VirtualNetworkName));
91+
}
92+
else if (this.Commit.IsPresent)
93+
{
94+
ExecuteClientActionNewSM(
95+
null,
96+
CommandRuntime.ToString(),
97+
() => this.NetworkClient.Networks.CommitMigration(this.VirtualNetworkName));
98+
}
99+
else
100+
{
101+
ExecuteClientActionNewSM(
102+
null,
103+
CommandRuntime.ToString(),
104+
() => this.NetworkClient.Networks.PrepareMigration(this.VirtualNetworkName));
105+
}
106+
107+
}
108+
}
109+
}

src/ServiceManagement/Services/Commands.Utilities/Azure.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@{
1010

1111
# Version number of this module.
12-
ModuleVersion = '1.3.2'
12+
ModuleVersion = '1.3.3'
1313

1414
# ID used to uniquely identify this module
1515
GUID = 'D48CF693-4125-4D2D-8790-1514F44CE325'

src/ServiceManagement/Services/Commands.Utilities/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
// You can specify all the values or you can default the Build and Revision Numbers
3030
// by using the '*' as shown below:
3131
// [assembly: AssemblyVersion("1.0.*")]
32-
[assembly: AssemblyVersion("1.3.2")]
33-
[assembly: AssemblyFileVersion("1.3.2")]
32+
[assembly: AssemblyVersion("1.3.3")]
33+
[assembly: AssemblyFileVersion("1.3.3")]
3434
#if SIGN
3535
[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
3636
[assembly: InternalsVisibleTo("Microsoft.WindowsAzure.Commands.Profile, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]

0 commit comments

Comments
 (0)