Skip to content

Commit f1e654d

Browse files
prsadhu-ms-idcmsJinLeikuchatur-ms
authored
Azure Migrate new cmdlets to support VMwareCbt Migration (#13024)
* Generate Migrate & OffAzur * custom * using directives to customise properties * made hash code * complete branch * adding interal files * fixed internal cmdlet * hid expanded * fixed directive' * cleanup * cleanup * m * m * revision * fix * added a variant * fixed mistake * added getremi and restartjobs * added disable * fixed bug * fixed restart to resync * added new enable * mock * good night * m * as * s * added changes * designreview * last commit before AMH (#1) * merging 2 readmes in 1 (#2) * merging 2 readmes * merging 2 readmes * Srsamh (#4) * merging 2 readmes * merging 2 readmes * added changes after DR * fix * bug fix * Az migrate staging219 (#7) * added changes to fix bug * fix bug * Az migrate staging219 (#8) * added changes to fix bug * fix bug * Az migrate staging219 (#9) * added changes to fix bug * fix bug * fix bug * merged AMH and SDS swagger generated cmdlets with SRS cmdlets. * Delete Get-AzmigrateJob.md * Delete Get-AzmigrateJob.md * updated and added some tests. New/remove cmdlet tests remain * Delete Get-AzmigrateJob.Tests.ps1 * fixed some syntax issues, exposed some cmdlets * fixed some syntax issues, exposed some cmdlets * test,rec,ex for job * test,rec,ex for job * fixed bug * added fabric * policy * Update Get-AzMigrateReplicationPolicy.Tests.ps1 * container * mapping * provider,server,disk * fix * server * disk * disk * policy * maping * enable * added changes files * set * test * New and Remove cmdlet tests added. * fix syntax * added remove * added changes * added register tool commandlet and its tests. * leftovers * Added examples. * fixed machine get doc * removed get by identity and updated docs * adding env files * added get sds machines by migrate project * added recordings * added code changes * added set * get server * docs * adding back file * new * remove * restart * set * mig * test * vars * leftovers * removed whatif * output * removed asjob * added if else * docs Co-authored-by: msJinLei <lei.jin@microsoft.com> Co-authored-by: Kunal Chaturvedi <kuchatur@microsoft.com> Co-authored-by: kuchatur-ms <69152307+kuchatur-ms@users.noreply.github.com>
1 parent 53a535e commit f1e654d

File tree

122 files changed

+14778
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+14778
-0
lines changed
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
#
4+
# Copyright Microsoft Corporation
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ----------------------------------------------------------------------------------
15+
16+
<#
17+
.Synopsis
18+
Retrieves the status of an Azure Migrate job.
19+
.Description
20+
The Get-AzMigrateJob cmdlet retrives the status of an Azure Migrate job.
21+
.Link
22+
https://docs.microsoft.com/en-us/powershell/module/az.migrate/get-azmigratejob
23+
#>
24+
function Get-AzMigrateJob {
25+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob])]
26+
[CmdletBinding(DefaultParameterSetName='ListByName', PositionalBinding=$false)]
27+
param(
28+
[Parameter(ParameterSetName='GetById', Mandatory)]
29+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
30+
[System.String]
31+
# Specifies the job id for which the details needs to be retrieved.
32+
${JobID},
33+
34+
[Parameter(ParameterSetName='GetByName', Mandatory)]
35+
[Parameter(ParameterSetName='ListByName', Mandatory)]
36+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
37+
[System.String]
38+
# The name of the resource group where the recovery services vault is present.
39+
${ResourceGroupName},
40+
41+
[Parameter(ParameterSetName='GetByName', Mandatory)]
42+
[Parameter(ParameterSetName='ListByName', Mandatory)]
43+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
44+
[System.String]
45+
# The name of the migrate project.
46+
${ProjectName},
47+
48+
[Parameter(ParameterSetName='GetByName', Mandatory)]
49+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
50+
[System.String]
51+
# Job identifier
52+
${JobName},
53+
54+
[Parameter(ParameterSetName='GetByInputObject', Mandatory)]
55+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
56+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob]
57+
# Specifies the job object of the replicating server.
58+
${InputObject},
59+
60+
[Parameter(ParameterSetName='ListById', Mandatory)]
61+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
62+
[System.String]
63+
# Specifies the Resource Group of the Azure Migrate Project in the current subscription.
64+
${ResourceGroupID},
65+
66+
[Parameter(ParameterSetName='ListById', Mandatory)]
67+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
68+
[System.String]
69+
# Specifies the Azure Migrate Project in which servers are replicating.
70+
${ProjectID},
71+
72+
[Parameter(ParameterSetName='ListByName')]
73+
[Parameter(ParameterSetName='ListById')]
74+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Query')]
75+
[System.String]
76+
# OData filter options.
77+
${Filter},
78+
79+
[Parameter()]
80+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
81+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
82+
[System.String]
83+
# Azure Subscription ID.
84+
${SubscriptionId},
85+
86+
[Parameter()]
87+
[Alias('AzureRMContext', 'AzureCredential')]
88+
[ValidateNotNull()]
89+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Azure')]
90+
[System.Management.Automation.PSObject]
91+
# The credentials, account, tenant, and subscription used for communication with Azure.
92+
${DefaultProfile},
93+
94+
[Parameter(DontShow)]
95+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')]
96+
[System.Management.Automation.SwitchParameter]
97+
# Wait for .NET debugger to attach
98+
${Break},
99+
100+
[Parameter(DontShow)]
101+
[ValidateNotNull()]
102+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')]
103+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]]
104+
# SendAsync Pipeline Steps to be appended to the front of the pipeline
105+
${HttpPipelineAppend},
106+
107+
[Parameter(DontShow)]
108+
[ValidateNotNull()]
109+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')]
110+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]]
111+
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
112+
${HttpPipelinePrepend},
113+
114+
[Parameter(DontShow)]
115+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')]
116+
[System.Uri]
117+
# The URI for the proxy server to use
118+
${Proxy},
119+
120+
[Parameter(DontShow)]
121+
[ValidateNotNull()]
122+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')]
123+
[System.Management.Automation.PSCredential]
124+
# Credentials for a proxy server to use for the remote call
125+
${ProxyCredential},
126+
127+
[Parameter(DontShow)]
128+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')]
129+
[System.Management.Automation.SwitchParameter]
130+
# Use the default credentials for the proxy
131+
${ProxyUseDefaultCredentials}
132+
)
133+
134+
process {
135+
$parameterSet = $PSCmdlet.ParameterSetName
136+
$null = $PSBoundParameters.Remove('JobID')
137+
$null = $PSBoundParameters.Remove('ResourceGroupName')
138+
$null = $PSBoundParameters.Remove('ProjectName')
139+
$null = $PSBoundParameters.Remove('JobName')
140+
$null = $PSBoundParameters.Remove('InputObject')
141+
$null = $PSBoundParameters.Remove('InputServerObject')
142+
$null = $PSBoundParameters.Remove('ResourceGroupID')
143+
$null = $PSBoundParameters.Remove('ProjectID')
144+
$HasFilter = $PSBoundParameters.ContainsKey('Filter')
145+
$null = $PSBoundParameters.Remove('Filter')
146+
147+
148+
if(($parameterSet -match 'Name') -or ($parameterSet -eq 'ListById')){
149+
if($parameterSet -eq 'ListById'){
150+
$ProjectName = $ProjectID.Split("/")[8]
151+
$ResourceGroupName = $ResourceGroupID.Split("/")[4]
152+
}
153+
$null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName)
154+
$null = $PSBoundParameters.Add("Name", "Servers-Migration-ServerMigration")
155+
$null = $PSBoundParameters.Add("MigrateProjectName", $ProjectName)
156+
157+
$solution = Az.Migrate\Get-AzMigrateSolution @PSBoundParameters
158+
if($solution -and ($solution.Count -ge 1)){
159+
$ResourceName = $solution.DetailExtendedDetail.AdditionalProperties.vaultId.Split("/")[8]
160+
}else{
161+
throw "Solution not found."
162+
}
163+
$null = $PSBoundParameters.Remove("Name")
164+
$null = $PSBoundParameters.Remove("MigrateProjectName")
165+
$null = $PSBoundParameters.Remove("ResourceGroupName")
166+
}else{
167+
if($parameterSet -eq 'GetByInputObject'){
168+
$JobID = $InputObject.Id
169+
}
170+
$JobIdArray = $JobID.split('/')
171+
$JobName = $JobIdArray[10]
172+
$ResourceName = $JobIdArray[8]
173+
$ResourceGroupName = $JobIdArray[4]
174+
}
175+
176+
if($parameterSet -match 'Get'){
177+
$null = $PSBoundParameters.Add('JobName', $JobName)
178+
$null = $PSBoundParameters.Add('ResourceName', $ResourceName)
179+
$null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName)
180+
181+
return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters
182+
}else{
183+
$null = $PSBoundParameters.Add('ResourceName', $ResourceName)
184+
$null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName)
185+
if($HasFilter){$null = $PSBoundParameters.Add('Filter', $Filter)}
186+
187+
return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters
188+
}
189+
190+
191+
}
192+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
#
4+
# Copyright Microsoft Corporation
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ----------------------------------------------------------------------------------
15+
16+
<#
17+
.Synopsis
18+
Get All servers in a migrate project.
19+
.Description
20+
Get Azure migrate server commandlet fetches all servers in a migrate project.
21+
.Link
22+
https://docs.microsoft.com/en-us/powershell/module/az.migrate/get-azmigrateserver
23+
#>
24+
25+
function Get-AzMigrateServer {
26+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api202001.IVMwareMachine])]
27+
param (
28+
[Parameter(Mandatory)]
29+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
30+
[System.String]
31+
# Specifies the migrate project name.
32+
${MigrateProjectName},
33+
34+
[Parameter(Mandatory)]
35+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
36+
[System.String]
37+
# Specifies the resource group name.
38+
${ResourceGroupName},
39+
40+
[Parameter()]
41+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
42+
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
43+
[System.String[]]
44+
# Specifies the subscription id.
45+
${SubscriptionId}
46+
)
47+
48+
process {
49+
$discoverySolutionName = "Servers-Discovery-ServerDiscovery"
50+
$discoverySolution = Get-AzMigrateSolution -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -MigrateProjectName $MigrateProjectName -Name $discoverySolutionName
51+
if ($discoverySolution.Name -ne $discoverySolutionName) {
52+
throw "Server Discovery Solution not found."
53+
}
54+
55+
$extendedDetails = $discoverySolution.DetailExtendedDetail["applianceNameToSiteIdMapV2"] | ConvertFrom-Json
56+
57+
$projectSdsMachines = [System.Collections.ArrayList]::new()
58+
foreach ($det in $extendedDetails) {
59+
$siteArmId = $det.SiteId
60+
$r = '(?<=/Microsoft.OffAzure/VMwareSites/).*$'
61+
62+
if ($siteArmId -match $r) {
63+
$siteName = $Matches[0]
64+
$siteMachines = Get-AzMigrateMachine -ResourceGroupName $ResourceGroupName -SiteName $siteName -SubscriptionId $SubscriptionId
65+
if ($null -ne $siteMachines) {
66+
$projectSdsMachines.AddRange($siteMachines)
67+
}
68+
}
69+
}
70+
71+
return $projectSdsMachines
72+
}
73+
}

0 commit comments

Comments
 (0)