2 Replies Latest reply on Feb 28, 2020 10:15 AM by jnivoit

    REST API - Struggling to customise a VM at point of deployment

    MarkHanford Lurker

      Hi folks. I'm trying to build some automation around deploying new VMs and vApps etc. I have an existing vApp, and would like to deploy a new VM into it from a Catalog Item. So far, that seems to work if I only specify the bare minimum <source> element, and I end up with a clone of the template VM with the same name.

       

      If I want to specify a new name however, I get a 400 BAD_REQUEST response with the error "The parameter is not supported in the current context: VmGeneralParamsType".

       

      For example, this works and deploys a vanilla VM from the Catalog:

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

      <RecomposeVAppParams

      xmlns="http://www.vmware.com/vcloud/v1.5"

      xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"

          xmlns:environment_1="http://schemas.dmtf.org/ovf/environment/1">

          <SourcedItem>

              <Source href="https://api.vcd.local/api/vAppTemplate/vappTemplate-b1490f4a-86e0-4095-b258-2e7062ee0335" />

          </SourcedItem>

      </RecomposeVAppParams>

       

      But this one fails with the error:

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>

      <RecomposeVAppParams

      xmlns="http://www.vmware.com/vcloud/v1.5"

      xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"

          xmlns:environment_1="http://schemas.dmtf.org/ovf/environment/1">

          <SourcedItem>

          <Source href="https://api.vcd.local/api/vAppTemplate/vappTemplate-b1490f4a-86e0-4095-b258-2e7062ee0335" />

              <VmGeneralParams>

                  <Name>new-vm-name</Name>

                  <Description>New VM Description</Description>

                  <NeedsCustomization>true</NeedsCustomization>

              </VmGeneralParams>

          </SourcedItem>

      </RecomposeVAppParams>

       

      As far as I can determine from the docs, the elements are correct and even in the correct order.

       

      As it may be relevant, I get my Source href by:

       

      1. Call /api/catalogs/query to find the CatalogRecord for the desired catalog, and getting the href
      2. Call the href from #1 to find the CatalogItem for the version I need.
      3. Call the href from #2 to find the template Entity