PlatformMethods.ps1
# # Citrix IPS platform job support # function Format-AzureData([hashtable]$Parameters, [psobject]$ConfigData=$Null, [bool]$Verbose=$False) { $azureData = @{ subscriptionId = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'AzureSubscriptionId' -Verbose $Verbose azureRegion = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'AzureLocation' -Verbose $Verbose targetDiskResourceGroupName = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'TargetResourceGroup' -Verbose $Verbose VirtualNetworkResourceGroupName = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'AzureVirtualNetworkResourceGroupName' -Verbose $Verbose VirtualNetworkName = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'AzureVirtualNetworkName' -Verbose $Verbose VirtualNetworkSubnetName = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'AzureVirtualNetworkSubnetName' -Verbose $Verbose UsePublicIP = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'UsePublicIP' -Verbose $Verbose resourceGroup = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'AzureVmResourceGroup' -Verbose $Verbose } Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName "NetworkIsolation" -JobData $azureData -Verbose $Verbose $TargetDiskName = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'TargetDiskName' -ConfigParameterName "CloudDiskName" -Verbose $Verbose $TargetSnapshotName = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName "TargetSnapshotName" -ConfigParameterName "CloudSnapshotName" -Verbose $Verbose if ($TargetDiskName) { $azureData['targetDiskName'] = $TargetDiskName } elseif ($TargetSnapshotName) { $azureData['targetSnapshotName'] = $TargetSnapshotName } else { throw "One of the parameters TargetDiskName or TargetSnapshotName are required." } return $azureData } function Format-GcpData([hashtable]$Parameters, [psobject]$ConfigData=$Null, [bool]$Verbose=$False, [switch]$Prepare) { $gcpData = @{ zone = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'GcpZone' -Verbose $Verbose VpcNetworkName = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'VpcNetworkName' -Verbose $Verbose UsePublicIP = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'UsePublicIP' -Verbose $Verbose } $target = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'CloudDiskName' -Verbose $Verbose if ($Prepare) { $gcpData['targetImageName'] = $target } else { $gcpData['targetDiskName'] = $target } Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName "VpcNetworkSubnetName" -JobData $gcpData -Verbose $Verbose Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName "NetworkTags" -JobData $gcpData -Verbose $Verbose return $gcpData } function Format-AhvData([hashtable]$Parameters, [psobject]$ConfigData=$Null, [bool]$Verbose=$False) { $ahvData = @{ host = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'PrismHost' -Verbose $Verbose port = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'PrismPort' -Verbose $Verbose clusterUuid = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'ClusterUuid' -Verbose $Verbose subnetUuid = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'SubnetUuid' -Verbose $Verbose } $PrismSslCaCertificateFilePath = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters "PrismSslCaCertificateFilePath" -Verbose $Verbose $prismSslCaCertificate = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters "prismSslCaCertificate" -Verbose $Verbose if ($PrismSslCaCertificateFilePath -And (Test-Path -Path $PrismSslCaCertificateFilePath -PathType "Leaf")) { $ahvData['sslCaCertificate'] = ((Get-Content $PrismSslCaCertificateFilePath) -join "`n") + "`n" } elseif ($prismSslCaCertificate) { # Replace raw string \n -> PowerShell-readable `n $PrismSslCaCertificate = $PrismSslCaCertificate.replace("\n", "`n") $ahvData['sslCaCertificate'] = $PrismSslCaCertificate } Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName "PrismSslFingerprint" -OutputName 'sslFingerprint' -JobData $ahvData -Verbose $Verbose Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName "PrismSslNoCheckHostname" -OutputName 'sslNoCheckHostname' -JobData $ahvData -Verbose $Verbose $SourceImageName = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters "SourceImageName" -Verbose $Verbose $SourceImageUuid = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters "SourceImageUuid" -Verbose $Verbose $SourceVmUuid = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters "SourceVmUuid" -Verbose $Verbose if ($SourceImageName) { $ahvData['sourceImageName'] = $SourceImageName } elseif ($SourceImageUuid) { $ahvData['sourceImageUuid'] = $SourceImageUuid } elseif ($SourceVmUuid) { $ahvData['sourceVmUuid'] = $SourceVmUuid } else { throw "One of the parameters SourceImageName, SourceImageUuid, or SourceVmUuid are required." } return $ahvData } function Format-AwsData([hashtable]$Parameters, [psobject]$ConfigData=$Null, [bool]$Verbose=$False) { $awsData = @{ region = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'AwsRegion' -Verbose $Verbose subnetId = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'AwsSubnetId' -Verbose $Verbose securityGroupIds = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'AwsSecurityGroupIds' -Verbose $Verbose usePublicIP = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'UsePublicIP' -Verbose $Verbose } Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName "AwsTargetSnapshotId" -OutputName 'targetSnapshotId' -JobData $awsData -Verbose $Verbose Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'AwsVolumeId' -OutputName 'volumeId' -JobData $awsData -Verbose $Verbose Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'CreateAMI' -OutputName 'createAMI' -JobData $awsData -Verbose $Verbose Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'LicenseType' -OutputName 'licenseType' -JobData $awsData -Verbose $Verbose Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'RoleName' -OutputName 'roleName' -JobData $awsData -Verbose $Verbose return $awsData } function Format-VSphereData([hashtable]$Parameters, [psobject]$ConfigData=$Null, [bool]$Verbose=$False) { $vsphereData = @{ vCenterHost = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'VsphereHost' -Verbose $Verbose vCenterPort = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'VspherePort' -Verbose $Verbose datacenter = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'VsphereDataCenter' -Verbose $Verbose datastore = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'VsphereDataStore' -Verbose $Verbose network = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName 'VsphereNetwork' -Verbose $Verbose } Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName "VsphereHostSystem" -OutputName 'hostSystem' -JobData $vsphereData -Verbose $Verbose Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName "VsphereCluster" -OutputName 'cluster' -JobData $vsphereData -Verbose $Verbose Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName "VsphereResourcePool" -OutputName 'resourcePoolName' -JobData $vsphereData -Verbose $Verbose $VsphereSslCaCertificateFilePath = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters "VsphereSslCaCertificateFilePath" -Verbose $Verbose $VsphereSslCaCertificate = Get-JobParameter -ConfigData $ConfigData -Parameters $Parameters "VsphereSslCaCertificate" -Verbose $Verbose if ($VsphereSslCaCertificateFilePath -And (Test-Path -Path $VsphereSslCaCertificateFilePath -PathType "Leaf")) { $vsphereData['vCenterSslCaCertificate'] = ((Get-Content $VsphereSslCaCertificateFilePath) -join "`n") + "`n" } elseif ($VsphereSslCaCertificate) { # Replace raw string \n -> PowerShell-readable `n $VsphereSslCaCertificate = $VsphereSslCaCertificate.replace("\n", "`n") $vsphereData['vCenterSslCaCertificate'] = $VsphereSslCaCertificate } Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName "VsphereSslFingerprint" -OutputName 'vCenterSslFingerprint' -JobData $vsphereData -Verbose $Verbose Set-JobParameter -ConfigData $ConfigData -Parameters $Parameters -ParameterName "vCenterSslNoCheckHostname" -OutputName 'VsphereSslNoCheckHostname' -JobData $vsphereData -Verbose $Verbose return $vsphereData } function Format-XenData([hashtable]$Parameters, [bool]$Verbose) { $xenData = @{ host = Get-JobParameter -Parameters $Parameters -ParameterName 'XenHost' -Verbose $Verbose port = Get-JobParameter -Parameters $Parameters -ParameterName 'XenPort' -Verbose $Verbose storageRepositoryUuid = Get-JobParameter -Parameters $Parameters -ParameterName 'StorageRepositoryUuid' -Verbose $Verbose network = Get-JobParameter -Parameters $Parameters -ParameterName 'Network' -Verbose $Verbose } Set-JobParameter -Parameters $Parameters -ParameterName "TargetDiskUuid" -JobData $xenData -Verbose $Verbose Set-JobParameter -Parameters $Parameters -ParameterName "sourceDiskUuid" -JobData $xenData -Verbose $Verbose Set-JobParameter -Parameters $Parameters -ParameterName "XenSslFingerprint" -OutputName 'sslFingerprint' -JobData $xenData -Verbose $Verbose return $xenData } |