VMware {code} Community
Windspirit
Hot Shot
Hot Shot
Jump to solution

vCloud 5.1 api SourcedVmInstantiationParams

hi,

as 5.1 now supports the ability to choose the storage profile when provisioning I'm trying to rework my instantiateVAppTemplate php sctipt. The REST API shows:

<InstantiateVAppTemplateParams xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" name="xs:string" deploy="xs:boolean" powerOn="xs:boolean" linkedClone="xs:boolean">
     <Description> xs:string </Description>
     <VAppParent href="xs:anyURI" id="xs:string" name="xs:string" type="xs:string"/>
     <InstantiationParams>
         <ovf:Section> ovf:Section_Type </ovf:Section>
     </InstantiationParams>
     <Source href="xs:anyURI" id="xs:string" name="xs:string" type="xs:string"/>
     <IsSourceDelete> xs:boolean </IsSourceDelete>
     <SourcedVmInstantiationParams>
         <Source href="xs:anyURI" id="xs:string" name="xs:string" type="xs:string"/>
         <StorageProfile href="xs:anyURI" id="xs:string" name="xs:string" type="xs:string"/>
         <LocalityParams>
             <ResourceEntity href="xs:anyURI" id="xs:string" name="xs:string" type="xs:string"/>
         </LocalityParams>
     </SourcedVmInstantiationParams>
     <AllEULAsAccepted> xs:boolean </AllEULAsAccepted>
</InstantiateVAppTemplateParams>

meaning that I can eitehr use the old 1.5 api to instanciate (source) or use SourcedVmInstantiationParams to chose a storage profile.

in PHP SDK I found: setSourcedVmInstantiationParams ( $SourcedVmInstantiationParams)

and I came up with

$SourcedVmInstantiationParams= new VMware_VCloud_API_SourcedVmInstantiationParamsType();
$SourcedVmInstantiationParams->setsource($vAppTemplateRef);
$SourcedVmInstantiationParams->setStorageProfile($StorProRef);

$params = new VMware_VCloud_API_InstantiateVAppTemplateParamsType();
$params->set_name($vAppName);
$params->setDescription("Nada");
$params->setInstantiationParams($iparams);
#$params->setSource($vAppTemplateRef);
$params->setSourcedVmInstantiationParams(array($SourcedVmInstantiationParams));

however in the PHP SDK there is no further info about the internal workings of  $SourcedVmInstantiationParams so....any ideas?

BTW: when enabling the  #$params->setSource($vAppTemplateRef); line, the whole thing works, however it put the VApp onto the default Storage Profile -> seems to ignore the  SourcedVmInstantiation section\

However this is NOT a PHP problem. looks like its the same in the REST API....seee below

0 Kudos
1 Solution

Accepted Solutions
rkamal
VMware Employee
VMware Employee
Jump to solution

<SourcedVmInstantiationParams>
       <Source href="VM inside vApp Template" name="something" />
      <StorageProfile href="Storage profile" name="np-gold"/>
    </SourcedVmInstantiationParams>

You are missing the name property that is why the null pointer exception.

Regards,

Rajesh Kamal.

View solution in original post

0 Kudos
9 Replies
IamTHEvilONE
Immortal
Immortal
Jump to solution

I'd try posing in the SDK Forum ... this is the PHP Specific one:

http://communities.vmware.com/community/vmtn/developer/forums/vcloudsdkphp

There is a more general one as well.

Best Regards,

Jon Hemming

0 Kudos
Windspirit
Hot Shot
Hot Shot
Jump to solution

Moved it back and forth......

I figured out some of the SourcedVmInstantiationParam stuff out. The call below works just fine....

<InstantiateVAppTemplateParams
   xmlns="http://www.vmware.com/vcloud/v1.5"
   name="App Test"
   deploy="true"
   powerOn="false"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
   <Description>Some VM</Description>
   <InstantiationParams> 
   <NetworkConfigSection>
         <ovf:Info>Configuration parameters for logical networks</ovf:Info>
         <NetworkConfig
            networkName="VApp Network">
            <Configuration>
               <ParentNetwork
                  href="OvDC Network" />
               <FenceMode>bridged</FenceMode>
            </Configuration>
         </NetworkConfig>
      </NetworkConfigSection>
   </InstantiationParams>
<Source href="vApp Template" />
    <SourcedVmInstantiationParams>
       <Source href="VM inside vApp Template" />
    </SourcedVmInstantiationParams>
   <AllEULAsAccepted>true</AllEULAsAccepted>
</InstantiateVAppTemplateParams>

however if I use

<SourcedVmInstantiationParams>
       <Source href="VM inside vApp Template" />
      <StorageProfile href="Storage profile" name="np-gold"/>
    </SourcedVmInstantiationParams>

I get the following error (same error with or without the name in it)

minorErrorCode="INTERNAL_SERVER_ERROR" message="class java.lang.NullPointerException" majorErrorCode="500"

xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://10.75.119.142/api/v1.5/schema/master.xsd"/>

anyone?

0 Kudos
rkamal
VMware Employee
VMware Employee
Jump to solution

<SourcedVmInstantiationParams>
       <Source href="VM inside vApp Template" name="something" />
      <StorageProfile href="Storage profile" name="np-gold"/>
    </SourcedVmInstantiationParams>

You are missing the name property that is why the null pointer exception.

Regards,

Rajesh Kamal.

0 Kudos
Windspirit
Hot Shot
Hot Shot
Jump to solution

WORKS. TA

UNBELIVIBLE....you dont need the name (in VM) if you leave out the Storage Profile...

TESTING:

ALSO...the Name attribute can be filled with ANYTHING. It dosnt Name the VM or anything....so THIS is a BUG.

MORE TESTING:

<SourcedVmInstantiationParams>
       <Source href="/api/vAppTemplate/" name=""/>
<StorageProfile href="/api/vdcStorageProfile/" />
    </SourcedVmInstantiationParams>


This works also....so def a BUG in the XMLNS

0 Kudos
clabman
Contributor
Contributor
Jump to solution

Yes and even you configured the Storage Profile, it is not considered.

The vm will always be associated with the default storage profile...

Seems to be another bug !!

0 Kudos
kaoru0001
Contributor
Contributor
Jump to solution

Hi Windspirit,

When I run your client sclipt which you posted no.2 but got below schema error. any thoughts ?

----

400 Bad Request

$VAR1 = bless( {

                 '_protocol' => 'HTTP/1.1',

                 '_content' => '<?xml version="1.0" encoding="UTF-8"?>

<Error xmlns="http://www.vmware.com/vcloud/v1.5" minorErrorCode="BAD_REQUEST" message="Bad request

- Unexpected JAXB Exception

- cvc-complex-type.2.4.a: Invalid content was found starting with element \'NetworkConfig\'. One of \'{&quot;http://schemas.dmtf.org/ovf/envelope/1":Info}\' is expected." majorErrorCode="400" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://*******/api/v1.5/schema/master.xsd"></Error>

---

0 Kudos
Windspirit
Hot Shot
Hot Shot
Jump to solution

Please attach your complete xml

Sent from mobile phone

0 Kudos
kaoru0001
Contributor
Contributor
Jump to solution

Hi,

below is my actual xml request. Am I missing name space settings ?

-----

<InstantiateVAppTemplateParams deploy="false" name="Vapp Name" powerOn="false" xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <Description>you can delete me at anytime</Description>

  <InstantiationParams>

    <NetworkConfigSection networkName="ovdc-network-name">

      <NetworkConfig>

        <Configuration>

          <FenceMode>bridged</FenceMode>

          <ParentNetwork href="https://*******/api/network/********" />

        </Configuration>

      </NetworkConfig>

      <ovf:Info>Configuration parameters for logical networks</ovf:Info>

    </NetworkConfigSection>

  </InstantiationParams>

  <Source href="https://*******/api/vAppTemplate/vappTemplate-************" />

  <SourcedVmInstantiationParams>

    <Source href="https://************"/api/vAppTemplate/vm-************"" />

  </SourcedVmInstantiationParams>

</InstantiateVAppTemplateParams>

-----

0 Kudos
Windspirit
Hot Shot
Hot Shot
Jump to solution

Sorry I took so long.

Your Network Config section is wrong.

    <NetworkConfigSection networkName="ovdc-network-name">

      <NetworkConfig>

        <Configuration>

          <FenceMode>bridged</FenceMode>

          <ParentNetwork href="https://*******/api/network/********" />

        </Configuration>

      </NetworkConfig>

      <ovf:Info>Configuration parameters for logical networks</ovf:Info>

    </NetworkConfigSection>

check against the original, your missing the networkname entry.

NetworkConfigSection>

             <ovf:Info>Configuration parameters for logical networks</ovf:Info>

             <NetworkConfig

               networkName="VApp Network">

                <Configuration>

                   <ParentNetwork

                      href="OvDC Network" />

                   <FenceMode>bridged</FenceMode>

                </Configuration>

             </NetworkConfig>

          </NetworkConfigSection>

The Network name is the name of the network with which the template was provisioned.

0 Kudos