Validate/Validate.psm1
Import-Module -Name $PSScriptRoot\..\Util\Util function Start-RMVSphereValidateOSBasedMigrationProfile { param( [System.Object] $Entitlement, [System.Object] $Source, [System.Object] $CloudAccount, [string] $TargetVMName, [string] $TransferType, [string] $CoresPerSocket, [string] $MemorySize, [string] $OverrideMemory, [string] $OverrideMemorySize, [string] $DatacenterName, [string] $Cluster, [string] $ResourcePool, [string] $FolderName, [string] $HardwareVersion, [string[]] $DatastoreLocations, [string[]] $DisksProvisioningType, [string] $DataTransferPort, [string] $IpType, [string] $MigrationNetworkName, [string] $IpAddress, [string] $Netmask, [string] $DefaultGateway, [string] $PrimaryDNS, [string] $SecondaryDNS, [string] $EnableDestinationNetworkIsolation, [string] $IsolatedIpType, [string] $IsolatedNetworkName, [string] $IsolatedIpAddress, [string] $IsolatedNetmask, [string] $IsolatedDefaultGateway, [string] $IsolatedPrimaryDNS, [string] $IsolatedSecondaryDNS, [string] $DisableAuthomaticDNSRegistrationOnTheTarget, [string] $ShutdownSource, [string] $ShutdownTarget, [string] $RemoveRMSAgent, [hashtable] $MigrationInstructions, [System.Object[]] $SelectedMounts ) $Cpu = $Source.attributes.cpu.processors.Count $Partitions = Get-RMPartition -SelectedMounts $SelectedMounts $MigrationInstructionsList = Get-RMMigrationInstruction -MigrationInstructions $MigrationInstructions $ValidateData = @{ "source_ip" = $Source.host "migration_method" = "OS-based" "source_hostname" = $Source.hostname "os_type" = $Source.os_type "migration_type" = "full" "scheduled_at" = "" "target_vm_name" = "$TargetVMName" "transfer_method" = "$TransferType" "cpus" = "$Cpu" "cores_per_socket" = "$CoresPerSocket" "memory" = "$MemorySize" "override_memory" = "$OverrideMemory" "override_memory_size" = "$OverrideMemorySize" "override_cpus" = "$false" "datacenter" = "$DatacenterName" "cluster" = "$Cluster" "resource_pool" = "$ResourcePool" "vm_folder" = "$FolderName" "vm_hardware_version" = "$HardwareVersion" "disk_datastores" = $DatastoreLocations "disks_provisioning_type" = $DisksProvisioningType "data_transfer_port" = "$DataTransferPort" "ip_type" = "$IpType" "destination_network_name"= "$MigrationNetworkName" "ip_address" = "$IpAddress" "netmask" = "$Netmask" "default_gateway" = "$DefaultGateway" "primary_dns" = "$PrimaryDNS" "secondary_dns" = "$SecondaryDNS" "enable_destination_network_isolation" = "$EnableDestinationNetworkIsolation" "network_isolation_ip_type" = "$IsolatedIpType" "network_isolation_network_name" = "$IsolatedNetworkName" "network_isolation_ip_address" = "$IsolatedIpAddress" "network_isolation_netmask" = "$IsolatedNetmask" "network_isolation_default_gateway" = "$IsolatedDefaultGateway" "network_isolation_primary_dns" = "$IsolatedPrimaryDNS" "network_isolation_secondary_dns" = "$IsolatedSecondaryDNS" "disable_automatic_dns_registration_on_target" = "$DisableAuthomaticDNSRegistrationOnTheTarget" "source_shutdown" = "$ShutdownSource" "target_shutdown" = "$ShutdownTarget" "remove_rms_agent_post_migration" = "$RemoveRMSAgent" "override_source_migration" = "$false" "migration_instructions" = @($MigrationInstructionsList) "ignore_validation_errors" = "$true" "cloud_account_name" = $CloudAccount.name "source_id" = $Source.id "create_resource_pool" = "$false" "create_vm_folder" = "$false" "partitions" = @($Partitions) } $RMLoginResult = Get-Variable -Name "RMContext-UserLogin" $Uri = Get-Variable -Name "RMContext-ReactorURI" $Headers = @{ Accept = "application/rm+json" "X-Auth-Token" = $RMLoginResult.Value.token } $Body = @{ "entitlement_id" = $Entitlement.id "timezone" = "test" "csv_migration_data" = @($ValidateData) "migration_method" = "OS-based" } | ConvertTo-Json -Depth 100 $Params = @{ Method = "Post" Uri = $Uri.Value + "/csvmigrations/validate" Headers = $Headers ContentType = "application/json" Body =$Body } Invoke-RMRestMethod -Params $Params } |