Merge pull request #4 from vmware/master

Updating the fork v2
This commit is contained in:
Kyle Ruddy
2019-09-15 06:34:51 -04:00
committed by GitHub
5 changed files with 176 additions and 20 deletions

View File

@@ -0,0 +1,97 @@
{
"Type": "AUTOMATED",
"Data": {
"Name": "LCFarmJson",
"DisplayName": "FarmJsonTest",
"AccessGroup": "Root",
"Description": "created LC Farm from PS via JSON with NVIDIA GRID VGPU",
"Enabled": null,
"Deleting": false,
"Settings": {
"DisconnectedSessionTimeoutPolicy": "NEVER",
"DisconnectedSessionTimeoutMinutes": 1,
"EmptySessionTimeoutPolicy": "AFTER",
"EmptySessionTimeoutMinutes": 1,
"LogoffAfterTimeout": false
},
"Desktop": null,
"DisplayProtocolSettings": {
"DefaultDisplayProtocol": "PCOIP",
"AllowDisplayProtocolOverride": false,
"EnableHTMLAccess": false,
"EnableCollaboration": false,
"EnableGRIDvGPUs": true,
"VGPUGridProfile": "grid_m10-8a"
},
"ServerErrorThreshold": null,
"MirageConfigurationOverrides": {
"OverrideGlobalSetting": false,
"Enabled": false,
"Url": null
}
},
"AutomatedFarmSpec": {
"ProvisioningType": "VIEW_COMPOSER",
"VirtualCenter": null,
"RdsServerNamingSpec": {
"NamingMethod": "PATTERN",
"PatternNamingSettings": {
"NamingPattern": "LCFarmVMPS",
"MaxNumberOfRDSServers": 1
}
},
"VirtualCenterProvisioningSettings": {
"EnableProvisioning": true,
"StopProvisioningOnError": true,
"MinReadyVMsOnVComposerMaintenance": 0,
"VirtualCenterProvisioningData": {
"ParentVm": "RDSServer",
"Snapshot": "RDS_SNAP1",
"Datacenter": null,
"VmFolder": "Praveen",
"HostOrCluster": "CS-1",
"ResourcePool": "CS-1"
},
"VirtualCenterStorageSettings": {
"Datastores": [
{
"Datastore": "Datastore1",
"StorageOvercommit": "UNBOUNDED"
}
],
"UseVSan": false,
"ViewComposerStorageSettings": {
"UseSeparateDatastoresReplicaAndOSDisks": false,
"ReplicaDiskDatastore": null,
"UseNativeSnapshots": false,
"SpaceReclamationSettings": {
"ReclaimVmDiskSpace": false,
"ReclamationThresholdGB": null,
"BlackoutTimes": null
}
}
},
"VirtualCenterNetworkingSettings": {
"Nics": null
}
},
"VirtualCenterManagedCommonSettings": {
"TransparentPageSharingScope": "VM"
},
"CustomizationSettings": {
"CustomizationType": "SYS_PREP",
"DomainAdministrator": null,
"AdContainer": "CN=Computers",
"ReusePreExistingAccounts": false,
"SysprepCustomizationSettings": {
"CustomizationSpec": "PraveenCust"
}
},
"RdsServerMaxSessionsData": {
"MaxSessionsType": "UNLIMITED",
"MaxSessions": null
}
},
"ManualFarmSpec": null,
"NetBiosName": "adviewdev"
}

View File

@@ -2243,6 +2243,21 @@ function New-HVFarm {
[boolean] [boolean]
$EnableHTMLAccess = $false, $EnableHTMLAccess = $false,
#farmSpec.data.displayProtocolSettings.EnableCollaboration
[Parameter(Mandatory = $false)]
[boolean]
$EnableCollaboration = $false,
#farmSpec.data.displayProtocolSettings.EnableGRIDvGPUs
[Parameter(Mandatory = $false)]
[boolean]
$EnableGRIDvGPUs = $false,
#farmSpec.data.displayProtocolSettings.VGPUGridProfile
[Parameter(Mandatory = $false)]
[string]
$VGPUGridProfile,
#farmSpec.data.serverErrorThreshold #farmSpec.data.serverErrorThreshold
[Parameter(Mandatory = $false)] [Parameter(Mandatory = $false)]
[ValidateRange(0,[Int]::MaxValue)] [ValidateRange(0,[Int]::MaxValue)]
@@ -2659,6 +2674,12 @@ function New-HVFarm {
$defaultDisplayProtocol = $jsonObject.Data.DisplayProtocolSettings.DefaultDisplayProtocol $defaultDisplayProtocol = $jsonObject.Data.DisplayProtocolSettings.DefaultDisplayProtocol
$allowDisplayProtocolOverride = $jsonObject.Data.DisplayProtocolSettings.AllowDisplayProtocolOverride $allowDisplayProtocolOverride = $jsonObject.Data.DisplayProtocolSettings.AllowDisplayProtocolOverride
$enableHTMLAccess = $jsonObject.Data.DisplayProtocolSettings.EnableHTMLAccess $enableHTMLAccess = $jsonObject.Data.DisplayProtocolSettings.EnableHTMLAccess
$EnableCollaboration = $jsonObject.Data.DisplayProtocolSettings.EnableCollaboration
if ($null -ne $jsonObject.Data.DisplayProtocolSettings.VGPUGridProfile) {
$EnableGRIDvGPUs = $jsonObject.Data.DisplayProtocolSettings.EnableGRIDvGPUs
$VGPUGridProfile = $jsonObject.Data.DisplayProtocolSettings.VGPUGridProfile
}
} }
if ($null -ne $jsonObject.Data.serverErrorThreshold) { if ($null -ne $jsonObject.Data.serverErrorThreshold) {
$serverErrorThreshold = $jsonObject.Data.serverErrorThreshold $serverErrorThreshold = $jsonObject.Data.serverErrorThreshold
@@ -2802,6 +2823,11 @@ function New-HVFarm {
$farmData.DisplayProtocolSettings.DefaultDisplayProtocol = $defaultDisplayProtocol $farmData.DisplayProtocolSettings.DefaultDisplayProtocol = $defaultDisplayProtocol
$farmData.DisplayProtocolSettings.AllowDisplayProtocolOverride = $AllowDisplayProtocolOverride $farmData.DisplayProtocolSettings.AllowDisplayProtocolOverride = $AllowDisplayProtocolOverride
$farmData.DisplayProtocolSettings.EnableHTMLAccess = $enableHTMLAccess $farmData.DisplayProtocolSettings.EnableHTMLAccess = $enableHTMLAccess
$farmData.DisplayProtocolSettings.EnableCollaboration = $EnableCollaboration
if($VGPUGridProfile -ne $false){
$farmData.DisplayProtocolSettings.EnableGRIDvGPUs = $EnableGRIDvGPUs
$farmData.DisplayProtocolSettings.VGPUGridProfile = $VGPUGridProfile
}
} }
if ($farmData.MirageConfigurationOverrides){ if ($farmData.MirageConfigurationOverrides){
$farmData.MirageConfigurationOverrides.OverrideGlobalSetting = $overrideGlobalSetting $farmData.MirageConfigurationOverrides.OverrideGlobalSetting = $overrideGlobalSetting

View File

@@ -33,8 +33,8 @@ Function Connect-VMCVIServer {
Organization: VMware Organization: VMware
Blog: http://vmware.com/go/powercli Blog: http://vmware.com/go/powercli
Twitter: @powercli Twitter: @powercli
=========================================================================== ===========================================================================
.SYNOPSIS .SYNOPSIS
Cmdlet to connect to your VMC vCenter Server Cmdlet to connect to your VMC vCenter Server
.DESCRIPTION .DESCRIPTION
@@ -47,17 +47,25 @@ Function Connect-VMCVIServer {
Param ( Param (
[Parameter(Mandatory=$true)]$Org, [Parameter(Mandatory=$true)]$Org,
[Parameter(Mandatory=$true)]$Sddc, [Parameter(Mandatory=$true)]$Sddc,
[switch]$Autologin [switch]$Autologin,
[switch]$UseManagementIP
) )
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else { If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
$creds = Get-VMCSDDCDefaultCredential -Org $Org -Sddc $Sddc $creds = Get-VMCSDDCDefaultCredential -Org $Org -Sddc $Sddc
Write-Host "Connecting to VMC vCenter Server" $creds.vc_public_ip If($UseManagementIP){
Connect-VIServer -Server $creds.vc_public_ip -User $creds.cloud_username -Password $creds.cloud_password | Add-Member -MemberType Noteproperty -Name Location -Value "VMC" $Server = $creds.vc_management_ip
Write-Host "Connecting to VMC CIS Endpoint" $creds.vc_public_ip }Else{
Connect-CisServer -Server $creds.vc_public_ip -User $creds.cloud_username -Password $creds.cloud_password | Add-Member -MemberType Noteproperty -Name Location -Value "VMC" $Server = $creds.vc_public_ip
}
Write-Host "Connecting to VMC vCenter Server" $Server
Connect-VIServer -Server $Server -User $creds.cloud_username -Password $creds.cloud_password | Add-Member -MemberType Noteproperty -Name Location -Value "VMC"
Write-Host "Connecting to VMC CIS Endpoint" $Server
Connect-CisServer -Server $Server -User $creds.cloud_username -Password $creds.cloud_password | Add-Member -MemberType Noteproperty -Name Location -Value "VMC"
} }
} }
Function Get-VMCOrg { Function Get-VMCOrg {
<# <#
.NOTES .NOTES

View File

@@ -8,7 +8,6 @@
# Added PowerShell-Core compatibility # Added PowerShell-Core compatibility
# #
# 1) PS prompt # 1) PS prompt
# - detect pwsh-core
# - current (local) time # - current (local) time
# - execution time of the previous command # - execution time of the previous command
# - shortened PWD # - shortened PWD
@@ -21,10 +20,6 @@
function prompt function prompt
{ {
# Detect PS-Core
If ($PSVersionTable.PSEdition -eq 'Core') {
Write-Host '(Core) ' -NoNewLine
}
# Current time # Current time
$date = (Get-Date).ToString('HH:mm:ss') $date = (Get-Date).ToString('HH:mm:ss')
Write-Host -Object '[' -NoNewLine Write-Host -Object '[' -NoNewLine
@@ -60,7 +55,7 @@ function prompt
function Set-Title function Set-Title
{ {
# Running as Administrator or a regular user # Running as Administrator or a regular user
If (($PSVersionTable.PSEdition -eq 'Core') -and ($IsWindows -eq 'True') -or ($PSVersionTable.PSEdition -ine 'Core')) If (($PSEdition -eq 'Core') -and ($IsWindows -eq 'True') -or ($PSEdition -ine 'Core'))
{ {
$userInfo = [Security.Principal.WindowsIdentity]::GetCurrent() $userInfo = [Security.Principal.WindowsIdentity]::GetCurrent()
if ((New-Object Security.Principal.WindowsPrincipal $userInfo).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)) if ((New-Object Security.Principal.WindowsPrincipal $userInfo).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator))
@@ -74,7 +69,7 @@ function Set-Title
} }
# Usertype user@hostname # Usertype user@hostname
If (($PSVersionTable.PSEdition -eq 'Core') -and ($IsWindows -ine 'True')) { If (($PSEdition -eq 'Core') -and ($IsWindows -ine 'True')) {
$env:computername = hostname $env:computername = hostname
$user = "$($env:user)@$($env:computername)" $user = "$($env:user)@$($env:computername)"
} }

View File

@@ -5,15 +5,23 @@ function Export-Tag {
[VMware.VimAutomation.ViCore.Types.V1.VIServer]$Server, [VMware.VimAutomation.ViCore.Types.V1.VIServer]$Server,
[Parameter(Mandatory = $True, Position = 2)] [Parameter(Mandatory = $True, Position = 2)]
[string]$Destination [string]$Destination,
[Parameter(Mandatory = $False, Position = 3)]
[boolean]$ExportAssignments
) )
# Retrieve all categories # Retrieve all categories
$categoryList = Get-TagCategory -Server $server $categoryList = Get-TagCategory -Server $server
# Retrieve all tags # Retrieve all tags
$tagList = Get-Tag -Server $server $tagList = Get-Tag -Server $server
# Store the tags and categories in a list to export them at once # Store the tags, categories and assignments (if selected) in a list to export them at once
$export = @($categoryList, $tagList) If ($ExportAssignments) {
$tagAssignments = Get-TagAssignment -Server $server
$export = @($categoryList, $tagList, $tagAssignments)
} else {
$export = @($categoryList, $tagList)
}
# Export the tags and categories to the specified destination # Export the tags and categories to the specified destination
Export-Clixml -InputObject $export -Path $destination Export-Clixml -InputObject $export -Path $destination
} }
@@ -25,7 +33,10 @@ function Import-Tag {
[VMware.VimAutomation.ViCore.Types.V1.VIServer]$Server, [VMware.VimAutomation.ViCore.Types.V1.VIServer]$Server,
[Parameter(Mandatory = $True, Position = 2)] [Parameter(Mandatory = $True, Position = 2)]
[string]$Source [string]$Source,
[Parameter(Mandatory = $False, Position = 3)]
[boolean]$ImportAssignments
) )
# Import the tags and categories from the specified source # Import the tags and categories from the specified source
@@ -62,4 +73,23 @@ function Import-Tag {
-Server $server ` -Server $server `
| Out-Null | Out-Null
} }
}
# Restore the assignments if selected
If ($ImportAssignments) {
# Check for assignments in the file
If ($import[2]) {
# If tags were found, assign them
$tagAssignments = $import[2]
ForEach ($assignment in $tagAssignments) {
New-TagAssignment `
-Tag (Get-Tag -Server $server -Name $assignment.Tag.Name -Category $assignment.Tag.Category) `
-Entity (Get-VIObjectByVIView -MORef $assignment.Entity.id) `
-Server $server `
| Out-Null
}
} else {
# If no assignments were found, output warning
Write-Warning "Source file does not contain tag assignments."
}
}
}