-
Notifications
You must be signed in to change notification settings - Fork 2
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
Powershell Changes for Security Type #37
base: generation
Are you sure you want to change the base?
Changes from 3 commits
0e0f1cb
a948c23
7d5f2e0
ffe0b4c
a49adc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,6 +185,20 @@ function New-AzMigrateServerReplication { | |
# Specifies the Operating System disk for the source server to be migrated. | ||
${OSDiskID}, | ||
|
||
[ValidateSet("Standard" , "TrustedLaunch")] | ||
[ArgumentCompleter( { "Standard" , "TrustedLaunch" })] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] | ||
[System.String] | ||
# Specifies the security type for the Azure VM. | ||
${TargetSecurityType}, | ||
|
||
[ValidateSet("true" , "false")] | ||
[ArgumentCompleter( { "true" , "false" })] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] | ||
[System.String] | ||
# Specifies if secure boot needs to be enabled on target VM. | ||
${TargetVMSecureBootEnabled}, | ||
|
||
[Parameter(ParameterSetName = 'ByIdDefaultUser')] | ||
[Parameter(ParameterSetName = 'ByInputObjectDefaultUser')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Migrate.Category('Path')] | ||
|
@@ -261,6 +275,8 @@ function New-AzMigrateServerReplication { | |
$HasResync = $PSBoundParameters.ContainsKey('PerformAutoResync') | ||
$HasDiskEncryptionSetID = $PSBoundParameters.ContainsKey('DiskEncryptionSetID') | ||
$HasTargetVMSize = $PSBoundParameters.ContainsKey('TargetVMSize') | ||
$HasTargetSecurityType = $PSBoundParameters.ContainsKey('TargetSecurityType') | ||
$HasTargetVMSecureBootEnabled = $PSBoundParameters.ContainsKey('TargetVMSecureBootEnabled') | ||
|
||
$null = $PSBoundParameters.Remove('ReplicationContainerMapping') | ||
$null = $PSBoundParameters.Remove('VMWarerunasaccountID') | ||
|
@@ -286,6 +302,8 @@ function New-AzMigrateServerReplication { | |
$null = $PSBoundParameters.Remove('SqlServerLicenseType') | ||
$null = $PSBoundParameters.Remove('LicenseType') | ||
$null = $PSBoundParameters.Remove('DiskEncryptionSetID') | ||
$null = $PSBoundParameters.Remove('TargetSecurityType') | ||
$null = $PSBoundParameters.Remove('TargetVMSecureBootEnabled') | ||
|
||
$null = $PSBoundParameters.Remove('MachineId') | ||
$null = $PSBoundParameters.Remove('InputObject') | ||
|
@@ -426,7 +444,7 @@ function New-AzMigrateServerReplication { | |
if ($FabricName -eq "") { | ||
throw "Fabric not found for given resource group." | ||
} | ||
|
||
$null = $PSBoundParameters.Add('FabricName', $FabricName) | ||
$peContainers = Az.Migrate\Get-AzMigrateReplicationProtectionContainer @PSBoundParameters | ||
$ProtectionContainerName = "" | ||
|
@@ -539,6 +557,17 @@ public static int hashForArtifact(String artifact) | |
$ProviderSpecificDetails.InstanceType = 'VMwareCbt' | ||
$ProviderSpecificDetails.LicenseType = $LicenseType | ||
$ProviderSpecificDetails.PerformAutoResync = $PerformAutoResync | ||
if ($HasTargetVMSecureBootEnabled) { | ||
$ProviderSpecificDetails.TargetVMSecurityProfileIsTargetVmsecureBootEnabled = $TargetVMSecureBootEnabled | ||
} | ||
|
||
if ($HasTargetSecurityType -and $TargetSecurityType -ne "Standard") { | ||
$ProviderSpecificDetails.TargetVMSecurityProfileTargetVmsecurityType = $TargetSecurityType | ||
$ProviderSpecificDetails.TargetVMSecurityProfileIsTargetVmtpmEnabled = $true | ||
} elseif($HasTargetVMSecureBootEnabled) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Space after elseif. |
||
throw "SecureBoot when security type is trusted launch virtual machine." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get the error message reviewed from PM. |
||
} | ||
|
||
if ($HasTargetAVSet) { | ||
$ProviderSpecificDetails.TargetAvailabilitySetId = $TargetAvailabilitySet | ||
} | ||
|
@@ -639,6 +668,7 @@ public static int hashForArtifact(String artifact) | |
} | ||
|
||
Import-Module Az.Resources | ||
Import-Module Az.Compute | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove if not required. |
||
$vmId = $ProviderSpecificDetails.TargetResourceGroupId + "/providers/Microsoft.Compute/virtualMachines/" + $TargetVMName | ||
$VMNamePresentinRg = Get-AzResource -ResourceId $vmId -ErrorVariable notPresent -ErrorAction SilentlyContinue | ||
if ($VMNamePresentinRg) { | ||
|
@@ -664,9 +694,6 @@ public static int hashForArtifact(String artifact) | |
$DiskObject.IsOSDisk = "false" | ||
$DiskObject.LogStorageAccountSasSecretName = $LogStorageAccountSas | ||
$DiskObject.LogStorageAccountId = $LogStorageAccountID | ||
if ($HasDiskEncryptionSetID) { | ||
$DiskObject.DiskEncryptionSetId = $DiskEncryptionSetID | ||
} | ||
$DiskToInclude += $DiskObject | ||
} | ||
} | ||
|
@@ -719,7 +746,5 @@ public static int hashForArtifact(String artifact) | |
$null = $PSBoundParameters.Add('ResourceGroupName', $ResourceGroupName) | ||
|
||
return Az.Migrate.internal\Get-AzMigrateReplicationJob @PSBoundParameters | ||
|
||
} | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if SecureBoot is not passed and SecurityType is TrustedLaunch?
Do we need to keep default value of SecureBoot as True or throw error asking user to provide SecureBoot input? Check with PM.