1 Reply Latest reply on May 16, 2017 3:23 AM by pauldstoneuk

    Deploy OVF from Content Library to inventory

    nirvy Master

      Hi All


      Been trying to work out how to deploy an OVF from a content library through PowerCLI.  I've got as far as this:

      Connect-ViServer <vcenterfqdn>
      Connect-CisService <vcenterfqdn>
      $rp = Get-Cluster | New-ResourcePool -Name Test
      $ovfLibItem = Get-CisService -Name com.vmware.vcenter.ovf.library_item
      $deployment_target = $ovfLibItem.Help.deploy.target.CreateExample()
      $deployment_target.resource_pool_id = $rp.Id
      $deploymentSpec = $ovfLibItem.help.deploy.deployment_spec.CreateExample()
      $deploymentSpec.accept_all_EULA = $true
      $deploymentSpec.default_datastore_id = (Get-Datastore -name Shared).Id
      $UniqueID = [guid]::NewGuid().tostring()


      $ovfLibItem has a deploy() function which requires four arguments - Client token ($UniqueID), OVF ID, Deployment Target, Deployment Spec.  I'm good for the client token, deployment target and deployment spec as above, but I can't figure out how to get the OVF ID.


      I can get *an* ID from a content library item using the following code:

      $svcContentLibrary = Get-CISService com.vmware.content.local_library
      $CLID = $svcContentLibrary.list() | Select-Object -First 1
      $ContentLibrary = $svcContentLibrary.get($CLID.Value)
      $svcLibraryItems   = Get-CisService com.vmware.content.library.item
      $LibraryItems = $svcLibraryItems.list($CLID.Value)
      $LibraryItem = $svcLibraryItems.get(($LibraryItems | ?{ ($svcLibraryItems.get($_.Value) | ?{$_.Name -eq "CentOS-Gold-Master"}) }).Value)


      But if I plug the ID from $LibraryItem into the the deploy function it just comes back with an error saying the OVF item could not be found.