VMware vSphere

 View Only
Expand all | Collapse all

vApp Scripting

  • 1.  vApp Scripting

    Posted Feb 09, 2018 02:43 PM

    I note that PowerCLI only has the following commandlets to manage vApps:

    • Export-VApp
    • Get-VApp
    • Set-VApp
    • Import-VApp
    • New-VApp
    • Remove-VApp
    • Start-VApp
    • Stop-VApp

    What none of these commandlets seem to offer is a way of manipulating the vApp "Start Order".

    Is the vSphere Web Client the only way to set a vApp Start Order?

    Or are there any APIs that can allow us to set the start order through scripts?



  • 2.  RE: vApp Scripting

    Posted Feb 09, 2018 02:54 PM

    According to an old response from LucD​, it wasn't possible to change this with PowerCLI. I don't think much has changed there.



  • 3.  RE: vApp Scripting

    Posted Feb 09, 2018 03:12 PM

    Is PowerCLI representative of all APIs then?

    In other words is it true to say, "If you can't do it in PowerCLI, then don't bother looking elsewhere like vCenter API"?

    Seems a bit odd, it makes automated/scripted deployments difficult.



  • 4.  RE: vApp Scripting
    Best Answer

    Posted Feb 09, 2018 03:39 PM

    Seems I was wrong with that, you can change the start order of VMs in a vApp.

    Quick example: simple vApp with 3 VMs in there. The default Start Order

    With the following snippet I cam change that to 2 start groups

    $vAppName = 'vApp1'

    $vapp = Get-VApp -Name $vAppName

    $vmOrder = @(

        @{

            Group = 1

            VM = @('VM2','VM3')

        },

        @{

            Group = 2

            VM = @('VM1')

        }

    )

    $spec = New-Object VMware.Vim.VAppConfigSpec

    $spec.EntityConfig = $vapp.ExtensionData.VAppConfig.EntityConfig

    foreach($group in $vmOrder){

        $spec.EntityConfig | where{$group.VM -contains $_.Tag} | %{

            $_.StartOrder = $group.Group

        }

    }

    $vapp.ExtensionData.UpdateVAppConfig($spec)

    And the start order is now exactly as we specified in $vmOrder



  • 5.  RE: vApp Scripting

    Posted Feb 09, 2018 03:41 PM

    Cool!



  • 6.  RE: vApp Scripting

    Posted Feb 09, 2018 03:54 PM

    Ah! I had just returned with something I had found, which I believe amounts to the same thing...

    https://vwiki.co.uk/vApp_Script_Extracts_and_Examples

    This is good, I shall pass this to my developers and get them going with this.

    Cheers all!



  • 7.  RE: vApp Scripting

    Posted Feb 09, 2018 04:03 PM

    Should I be able to do this via other APIs?

    vSphere API?

    I understand some of the management code is developed in C#.



  • 8.  RE: vApp Scripting

    Posted Feb 09, 2018 05:06 PM

    The API methods stay the same, you just need to call them from the C# framework.
    They can use the PowerShell script as a prototype :smileygrin:



  • 9.  RE: vApp Scripting

    Posted Feb 12, 2018 09:47 AM

    If I have more than one VM in a start order group, and I have "waitingForGuest" set to True, will vCenter wait until all VMs in the group are detected as started via VMTools before moving onto the next group or just the first one?



  • 10.  RE: vApp Scripting

    Posted Feb 12, 2018 12:02 PM

    I have been told that VMs using PCoIP or Blast cannot have their desktop connections brokered when they are part of a vApp, is this true?

    Google is simply coming with too many hits for me to quickly find anything that confirms or denies this.



  • 11.  RE: vApp Scripting

    Posted Feb 12, 2018 12:20 PM

    Yes, I assume that WaitingForGuest will mean that all VMs in that group have to be detected, before the next group will be started.

    I don't know if VMs in a vApp, that use PCOIP, can not be brokered.

    You could ask in the Horizon community?



  • 12.  RE: vApp Scripting

    Posted Feb 12, 2018 03:43 PM

    Yup! I think I will.