Skip to content

Azure Migrate new cmdlets to support VMwareCbt Migration #13024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 122 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
0916b89
Generate Migrate & OffAzur
msJinLei Apr 24, 2020
8dd84c0
custom
prsadhu-ms-idc Aug 16, 2020
5652fd1
using directives to customise properties
prsadhu-ms-idc Aug 17, 2020
99b83e0
made hash code
prsadhu-ms-idc Aug 19, 2020
f950080
complete branch
prsadhu-ms-idc Aug 19, 2020
707c010
adding interal files
prsadhu-ms-idc Aug 19, 2020
4ad4f83
fixed internal cmdlet
prsadhu-ms-idc Aug 20, 2020
584ae68
hid expanded
prsadhu-ms-idc Aug 20, 2020
9447bb3
fixed directive'
prsadhu-ms-idc Aug 20, 2020
64bac2e
cleanup
prsadhu-ms-idc Aug 21, 2020
f333887
cleanup
prsadhu-ms-idc Aug 21, 2020
1baf934
m
prsadhu-ms-idc Aug 21, 2020
63c716b
m
prsadhu-ms-idc Aug 24, 2020
235172e
revision
prsadhu-ms-idc Aug 25, 2020
401b720
fix
prsadhu-ms-idc Aug 26, 2020
c558624
added a variant
prsadhu-ms-idc Aug 26, 2020
872e8d4
fixed mistake
prsadhu-ms-idc Aug 26, 2020
3f806dc
added getremi and restartjobs
prsadhu-ms-idc Aug 26, 2020
9b8151b
added disable
prsadhu-ms-idc Aug 26, 2020
c6349ae
fixed bug
prsadhu-ms-idc Aug 26, 2020
7023034
fixed restart to resync
prsadhu-ms-idc Aug 27, 2020
521a6cb
added new enable
prsadhu-ms-idc Aug 27, 2020
4546dfd
mock
prsadhu-ms-idc Sep 2, 2020
daf5dca
good night
prsadhu-ms-idc Sep 2, 2020
47a14d4
m
prsadhu-ms-idc Sep 3, 2020
fdde2d6
as
prsadhu-ms-idc Sep 3, 2020
5f83dff
s
prsadhu-ms-idc Sep 3, 2020
d405c85
added changes
prsadhu-ms-idc Sep 3, 2020
eb2fcce
Merge branch 'srs' of https://github.com/prsadhu-ms-idc/azure-powersh…
prsadhu-ms-idc Sep 3, 2020
7fbd3b8
designreview
prsadhu-ms-idc Sep 4, 2020
a0755ac
last commit before AMH (#1)
prsadhu-ms-idc Sep 16, 2020
3ca46e5
merging 2 readmes in 1 (#2)
prsadhu-ms-idc Sep 16, 2020
a251bca
Srsamh (#4)
prsadhu-ms-idc Sep 21, 2020
ad94f5f
bug fix
prsadhu-ms-idc Sep 21, 2020
5be7bd2
Az migrate staging219 (#7)
prsadhu-ms-idc Sep 22, 2020
7242228
Az migrate staging219 (#8)
prsadhu-ms-idc Sep 22, 2020
78151e8
Az migrate staging219 (#9)
prsadhu-ms-idc Sep 22, 2020
59311ba
merged AMH and SDS swagger generated cmdlets with SRS cmdlets.
kuchatur-ms Sep 22, 2020
21c16d7
Merge branch 'AzMigrateStaging' into migrateTestKuchatur2
prsadhu-ms-idc Sep 23, 2020
5d7cf85
Merge pull request #10 from prsadhu-ms-idc/migrateTestKuchatur2
prsadhu-ms-idc Sep 23, 2020
0e25474
Delete Get-AzmigrateJob.md
prsadhu-ms-idc Sep 23, 2020
e4a36da
Delete Get-AzmigrateJob.md
prsadhu-ms-idc Sep 23, 2020
e3d5afd
updated and added some tests. New/remove cmdlet tests remain
kuchatur-ms Sep 23, 2020
beaffce
Merge pull request #11 from prsadhu-ms-idc/migrateTestKuchatur2
kuchatur-ms Sep 23, 2020
9635a57
Delete Get-AzmigrateJob.Tests.ps1
prsadhu-ms-idc Sep 23, 2020
714a134
fixed some syntax issues, exposed some cmdlets
prsadhu-ms-idc Sep 23, 2020
cbbd085
fixed some syntax issues, exposed some cmdlets
prsadhu-ms-idc Sep 23, 2020
34446f9
Merge pull request #12 from prsadhu-ms-idc/Cleanup
prsadhu-ms-idc Sep 23, 2020
4435550
test,rec,ex for job
prsadhu-ms-idc Sep 23, 2020
f80ac9a
test,rec,ex for job
prsadhu-ms-idc Sep 23, 2020
fa01770
fixed bug
prsadhu-ms-idc Sep 23, 2020
4aab54f
Merge pull request #13 from prsadhu-ms-idc/A1
prsadhu-ms-idc Sep 23, 2020
74b0707
added fabric
prsadhu-ms-idc Sep 23, 2020
2a312b9
Merge pull request #14 from prsadhu-ms-idc/A1
prsadhu-ms-idc Sep 23, 2020
ae1ce20
policy
prsadhu-ms-idc Sep 23, 2020
77eb87e
Merge pull request #15 from prsadhu-ms-idc/A1
prsadhu-ms-idc Sep 23, 2020
1b07663
Update Get-AzMigrateReplicationPolicy.Tests.ps1
prsadhu-ms-idc Sep 23, 2020
dbebfd2
container
prsadhu-ms-idc Sep 23, 2020
dd863f8
mapping
prsadhu-ms-idc Sep 23, 2020
7775365
provider,server,disk
prsadhu-ms-idc Sep 23, 2020
bf61bfb
fix
prsadhu-ms-idc Sep 23, 2020
202d111
Merge pull request #16 from prsadhu-ms-idc/A1
prsadhu-ms-idc Sep 23, 2020
68554fa
server
prsadhu-ms-idc Sep 23, 2020
16c4e69
disk
prsadhu-ms-idc Sep 23, 2020
a6c0956
disk
prsadhu-ms-idc Sep 23, 2020
4a76022
policy
prsadhu-ms-idc Sep 23, 2020
f735523
Merge pull request #17 from prsadhu-ms-idc/A1
prsadhu-ms-idc Sep 23, 2020
028f694
maping
prsadhu-ms-idc Sep 24, 2020
368a4ce
enable
prsadhu-ms-idc Sep 24, 2020
a94e568
Merge pull request #18 from prsadhu-ms-idc/A1
prsadhu-ms-idc Sep 24, 2020
ef76db4
added changes files
prsadhu-ms-idc Sep 24, 2020
c503ec5
set
prsadhu-ms-idc Sep 24, 2020
7ed1ff9
Merge pull request #19 from prsadhu-ms-idc/A1
prsadhu-ms-idc Sep 24, 2020
8ac1d27
test
prsadhu-ms-idc Sep 24, 2020
33e858b
New and Remove cmdlet tests added.
kuchatur-ms Sep 24, 2020
a3e7da3
fix syntax
prsadhu-ms-idc Sep 24, 2020
40875c9
Merge pull request #20 from prsadhu-ms-idc/A1
prsadhu-ms-idc Sep 24, 2020
248ed55
Merge pull request #21 from prsadhu-ms-idc/migrateTestKuchatur2
kuchatur-ms Sep 24, 2020
b8e1bce
added remove
prsadhu-ms-idc Sep 24, 2020
f0b9dfe
added changes
prsadhu-ms-idc Sep 24, 2020
8f79237
added register tool commandlet and its tests.
kuchatur-ms Sep 24, 2020
f2e3f2f
leftovers
prsadhu-ms-idc Sep 24, 2020
498992d
Merge pull request #23 from prsadhu-ms-idc/migrateTestKuchatur2
kuchatur-ms Sep 24, 2020
617a80b
Merge pull request #22 from prsadhu-ms-idc/A1
prsadhu-ms-idc Sep 24, 2020
a400e40
Added examples.
kuchatur-ms Sep 24, 2020
16124eb
fixed machine get doc
kuchatur-ms Sep 24, 2020
66629a4
Merge pull request #24 from prsadhu-ms-idc/migrateTestKuchatur2
kuchatur-ms Sep 24, 2020
6afc966
removed get by identity and updated docs
kuchatur-ms Sep 25, 2020
3bdbbe3
Merge pull request #25 from prsadhu-ms-idc/migrateTestKuchatur2
kuchatur-ms Sep 25, 2020
29e9202
adding env files
prsadhu-ms-idc Sep 25, 2020
dbed560
Merge pull request #26 from prsadhu-ms-idc/A1
prsadhu-ms-idc Sep 25, 2020
5600eef
added get sds machines by migrate project
kuchatur-ms Sep 25, 2020
b3355d2
Merge pull request #27 from prsadhu-ms-idc/migrateTestKuchatur2
kuchatur-ms Sep 25, 2020
f53f9ae
added recordings
kuchatur-ms Sep 25, 2020
8332c2f
Merge pull request #28 from prsadhu-ms-idc/migrateTestKuchatur2
kuchatur-ms Sep 25, 2020
9913c0d
added code changes
prsadhu-ms-idc Sep 25, 2020
237863d
added set
prsadhu-ms-idc Sep 25, 2020
0d30a23
Merge pull request #29 from prsadhu-ms-idc/A1
prsadhu-ms-idc Sep 25, 2020
bf7c52c
get server
prsadhu-ms-idc Sep 25, 2020
e8a4307
docs
prsadhu-ms-idc Sep 25, 2020
fe6e452
adding back file
prsadhu-ms-idc Sep 25, 2020
7ccc424
Merge pull request #30 from prsadhu-ms-idc/A2
prsadhu-ms-idc Sep 25, 2020
808f31b
new
prsadhu-ms-idc Sep 25, 2020
694c837
remove
prsadhu-ms-idc Sep 25, 2020
770eab5
restart
prsadhu-ms-idc Sep 25, 2020
761200f
Merge pull request #31 from prsadhu-ms-idc/A2
prsadhu-ms-idc Sep 25, 2020
1c34052
set
prsadhu-ms-idc Sep 25, 2020
b127885
mig
prsadhu-ms-idc Sep 25, 2020
8aa98e4
test
prsadhu-ms-idc Sep 25, 2020
2481903
vars
prsadhu-ms-idc Sep 25, 2020
829e11e
leftovers
prsadhu-ms-idc Sep 25, 2020
ce6f8dc
Merge pull request #32 from prsadhu-ms-idc/A2
prsadhu-ms-idc Sep 25, 2020
b77dc33
removed whatif
prsadhu-ms-idc Sep 26, 2020
4ef02a8
Merge pull request #33 from prsadhu-ms-idc/A3
prsadhu-ms-idc Sep 26, 2020
c7c2bb7
output
prsadhu-ms-idc Sep 26, 2020
68dd63b
Merge pull request #34 from prsadhu-ms-idc/A3
prsadhu-ms-idc Sep 26, 2020
7755b15
removed asjob
prsadhu-ms-idc Sep 26, 2020
e9b0bab
Merge pull request #35 from prsadhu-ms-idc/A4
prsadhu-ms-idc Sep 26, 2020
bfe62b3
added if else
prsadhu-ms-idc Sep 26, 2020
237caed
Merge pull request #36 from prsadhu-ms-idc/A4
prsadhu-ms-idc Sep 26, 2020
5ebbdb2
docs
prsadhu-ms-idc Sep 27, 2020
12ca7fb
Merge pull request #37 from prsadhu-ms-idc/A5
prsadhu-ms-idc Sep 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
192 changes: 192 additions & 0 deletions src/Migrate/custom/Get-AzMigrateJob.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@

# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.Synopsis
Retrieves the status of an Azure Migrate job.
.Description
The Get-AzMigrateJob cmdlet retrives the status of an Azure Migrate job.
.Link
https://docs.microsoft.com/en-us/powershell/module/az.migrate/get-azmigratejob
#>
function Get-AzMigrateJob {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob])]
[CmdletBinding(DefaultParameterSetName='ListByName', PositionalBinding=$false)]
param(
[Parameter(ParameterSetName='GetById', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[System.String]
# Specifies the job id for which the details needs to be retrieved.
${JobID},

[Parameter(ParameterSetName='GetByName', Mandatory)]
[Parameter(ParameterSetName='ListByName', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[System.String]
# The name of the resource group where the recovery services vault is present.
${ResourceGroupName},

[Parameter(ParameterSetName='GetByName', Mandatory)]
[Parameter(ParameterSetName='ListByName', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[System.String]
# The name of the migrate project.
${ProjectName},

[Parameter(ParameterSetName='GetByName', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[System.String]
# Job identifier
${JobName},

[Parameter(ParameterSetName='GetByInputObject', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api20180110.IJob]
# Specifies the job object of the replicating server.
${InputObject},

[Parameter(ParameterSetName='ListById', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[System.String]
# Specifies the Resource Group of the Azure Migrate Project in the current subscription.
${ResourceGroupID},

[Parameter(ParameterSetName='ListById', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[System.String]
# Specifies the Azure Migrate Project in which servers are replicating.
${ProjectID},

[Parameter(ParameterSetName='ListByName')]
[Parameter(ParameterSetName='ListById')]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Query')]
[System.String]
# OData filter options.
${Filter},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
[System.String]
# Azure Subscription ID.
${SubscriptionId},

[Parameter()]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Azure')]
[System.Management.Automation.PSObject]
# The credentials, account, tenant, and subscription used for communication with Azure.
${DefaultProfile},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Wait for .NET debugger to attach
${Break},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be appended to the front of the pipeline
${HttpPipelineAppend},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
${HttpPipelinePrepend},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')]
[System.Uri]
# The URI for the proxy server to use
${Proxy},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')]
[System.Management.Automation.PSCredential]
# Credentials for a proxy server to use for the remote call
${ProxyCredential},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Use the default credentials for the proxy
${ProxyUseDefaultCredentials}
)

process {
$parameterSet = $PSCmdlet.ParameterSetName
$null = $PSBoundParameters.Remove('JobID')
$null = $PSBoundParameters.Remove('ResourceGroupName')
$null = $PSBoundParameters.Remove('ProjectName')
$null = $PSBoundParameters.Remove('JobName')
$null = $PSBoundParameters.Remove('InputObject')
$null = $PSBoundParameters.Remove('InputServerObject')
$null = $PSBoundParameters.Remove('ResourceGroupID')
$null = $PSBoundParameters.Remove('ProjectID')
$HasFilter = $PSBoundParameters.ContainsKey('Filter')
$null = $PSBoundParameters.Remove('Filter')


if(($parameterSet -match 'Name') -or ($parameterSet -eq 'ListById')){
if($parameterSet -eq 'ListById'){
$ProjectName = $ProjectID.Split("/")[8]
$ResourceGroupName = $ResourceGroupID.Split("/")[4]
}
$null = $PSBoundParameters.Add("ResourceGroupName", $ResourceGroupName)
$null = $PSBoundParameters.Add("Name", "Servers-Migration-ServerMigration")
$null = $PSBoundParameters.Add("MigrateProjectName", $ProjectName)

$solution = Az.Migrate\Get-AzMigrateSolution @PSBoundParameters
if($solution -and ($solution.Count -ge 1)){
$ResourceName = $solution.DetailExtendedDetail.AdditionalProperties.vaultId.Split("/")[8]
}else{
throw "Solution not found."
}
$null = $PSBoundParameters.Remove("Name")
$null = $PSBoundParameters.Remove("MigrateProjectName")
$null = $PSBoundParameters.Remove("ResourceGroupName")
}else{
if($parameterSet -eq 'GetByInputObject'){
$JobID = $InputObject.Id
}
$JobIdArray = $JobID.split('/')
$JobName = $JobIdArray[10]
$ResourceName = $JobIdArray[8]
$ResourceGroupName = $JobIdArray[4]
}

if($parameterSet -match 'Get'){
$null = $PSBoundParameters.Add('JobName', $JobName)
$null = $PSBoundParameters.Add('ResourceName', $ResourceName)
$null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName)

return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters
}else{
$null = $PSBoundParameters.Add('ResourceName', $ResourceName)
$null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName)
if($HasFilter){$null = $PSBoundParameters.Add('Filter', $Filter)}

return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters
}


}
}
73 changes: 73 additions & 0 deletions src/Migrate/custom/Get-AzMigrateServer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@

# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.Synopsis
Get All servers in a migrate project.
.Description
Get Azure migrate server commandlet fetches all servers in a migrate project.
.Link
https://docs.microsoft.com/en-us/powershell/module/az.migrate/get-azmigrateserver
#>

function Get-AzMigrateServer {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Migrate.Models.Api202001.IVMwareMachine])]
param (
[Parameter(Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[System.String]
# Specifies the migrate project name.
${MigrateProjectName},

[Parameter(Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[System.String]
# Specifies the resource group name.
${ResourceGroupName},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
[System.String[]]
# Specifies the subscription id.
${SubscriptionId}
)

process {
$discoverySolutionName = "Servers-Discovery-ServerDiscovery"
$discoverySolution = Get-AzMigrateSolution -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -MigrateProjectName $MigrateProjectName -Name $discoverySolutionName
if ($discoverySolution.Name -ne $discoverySolutionName) {
throw "Server Discovery Solution not found."
}

$extendedDetails = $discoverySolution.DetailExtendedDetail["applianceNameToSiteIdMapV2"] | ConvertFrom-Json

$projectSdsMachines = [System.Collections.ArrayList]::new()
foreach ($det in $extendedDetails) {
$siteArmId = $det.SiteId
$r = '(?<=/Microsoft.OffAzure/VMwareSites/).*$'

if ($siteArmId -match $r) {
$siteName = $Matches[0]
$siteMachines = Get-AzMigrateMachine -ResourceGroupName $ResourceGroupName -SiteName $siteName -SubscriptionId $SubscriptionId
if ($null -ne $siteMachines) {
$projectSdsMachines.AddRange($siteMachines)
}
}
}

return $projectSdsMachines
}
}
Loading