Advertisement
Guest User

Untitled

a guest
Mar 10th, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. <#
  2. Author: Daniel Linsley, @danlinsley, dlinsley@vmware.com
  3. Description: Sample add VC to View with all available options
  4. #>
  5.  
  6. Import-Module VMware.VimAutomation.HorizonView
  7.  
  8. Connect-HVServer -Server "view.corp.local" -User "administrator@vsphere.local" -Pass "VMware1!"
  9. $vc_service = New-Object VMware.Hv.VirtualCenter
  10.  
  11. #Create a vc_spec for each VirtualCenter you want to add
  12. $vc_spec = New-Object VMware.Hv.VirtualCenterSpec
  13.  
  14. $vc_spec.DisplayName = "Your vCenter Host"
  15. $vc_spec.Description = "Your vCenter Host for XYZ"
  16. $vc_password = ConvertTo-SecureString "VMware1!" -AsPlainText -Force
  17. $vc_spec.ServerSpec = createVcServerSpec("vcenter.corp.local", "administrator@vsphere.local",$vc_password)
  18. $vc_spec.Limits = createVcLimits(20, 50, 30, 30, 20)
  19.  
  20. # Does not need to be specified
  21. #$vc_spec.CertificateOverride
  22.  
  23. $vc_spec.StorageAcceleratorData = createVcStorageAcceleratorData($True, 1024)
  24. $vc_spec.SeSparseReclamationEnabled = $True
  25. $vc_spec.ViewComposerData = createViewComposerData("STANDALONE", "viewcomp.corp.local", "admin@vsphere.local", $vc_password)
  26.  
  27. # Add the vCenter to View:
  28. $vC_Id = $vc_service.VirtualCenter_Create($vc_spec)
  29.  
  30. ###############################################################
  31.  
  32. function createVcServerSpec($hostName, $username, $password) {
  33. $spec = New-Object VMware.Hv.ServerSpec
  34. $spec.ServerName = $hostName
  35. $spec.Port = 443
  36. $spec.UseSSL = $true
  37. $spec.UserName = $username
  38. $spec.Password = $password
  39. $spec.ServerType = "VIRTUAL_CENTER"
  40. return $spec
  41. }
  42.  
  43. function createViewComposerServerSpec($hostName, $username, $password) {
  44. $spec = New-Object VMware.Hv.ServerSpec
  45. $spec.ServerName = $hostName
  46. $spec.Port = 18443
  47. $spec.UseSSL = $true
  48. $spec.UserName = $username
  49. $spec.Password = $password
  50. $spec.ServerType = "VIEW_COMPOSER"
  51. return $spec
  52. }
  53. function createVcLimits($vcProvLimit, $vcPowerOpsLimit, $viewProvLimit, $viewMaintLimit, $instaCloneLimit) {
  54. $limits = New-Object VMware.Hv.VirtualCenterConcurrentOperationLimits
  55. $limits.VcProvisioningLimit = $vcProvLimit
  56. $limits.VcPowerOperationsLimit = $vcPowerOpsLimit
  57. $limits.ViewComposerProvisioningLimit = $viewProvLimit
  58. $limits.ViewComposerMaintenanceLimit = $viewMaintLimit
  59. $limits.InstantCloneEngineProvisioningLimit = $instaCloneLimit
  60. return $limits
  61. }
  62.  
  63. function createVcStorageAcceleratorData($enable, $defaultCacheSizeMB) {
  64. $data = New-Object VMware.Hv.VirtualCenterStorageAcceleratorData
  65. $data.Enabled = $enable
  66. $data.DefaultCacheSizeMB = $defaultCacheSizeMB
  67. return $data
  68. }
  69.  
  70. function createViewComposerData($type, $hostname, $username, $password) {
  71. $data = New-Object VMware.Hv.VirtualCenterViewComposerData
  72. $data.ViewComposerType = $type #Possible Values: DISABLED, LOCAL_TO_VC, STANDALONE
  73. if ($type -ne "DISABLED") {
  74. $data.ServerSpec = createViewComposerServerSpec($hostname,$username,$password)
  75. }
  76. return $data
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement