Setting vCloud Custom Properties — don’t try and use the PHP SDK!

It is possible to set Guest Properties for a vCloud VM using the vCloud API — by default the properties of a VM will look like this:

No user-configurable properties — we’ll soon see about that!

As a basic test, you can add a custom property via curl. First, create a file called, for example, “custom-properties” — this contains the request body.

<ProductSectionList xmlns="" xmlns:ovf="">
<ovf:ProductSection ovf:required=”true”>
<ovf:Info ovf:msgid=””>Test Info</ovf:Info>
<ovf:Category ovf:msgid=””>Test Category</ovf:Category>
<ovf:Property ovf:userConfigurable=”true” ovf:value=”test_value” ovf:key=”test_key” ovf:password=”false” ovf:type=”string”>
<ovf:Label ovf:msgid=””>Test Property</ovf:Label>
<ovf:Description>Test Description</ovf:Description>

Next, authenticate as normal and get the x-vcloud-authorization from the output.

curl -i -H “Accept: application/*+xml;version=5.5” -u 'user@org:password' -X POST https://my-vcloud-url/api/sessions

Finally, submit the request.

curl -i -H “Accept:application/*+xml;version=5.5” -H “x-vcloud-authorization: from-previous-output” -H “Content-Type:appcloud.productSections+xml” -X PUT https://my-vcloud-url/api/vApp/vm-id-here/productSections -d @custom-properties

Now, when you re-check the GUI:


All good so far. Onto the PHP SDK. The documentation suggests that modifyProductInfo can be used:

However, no matter what I submitted I found that I received an error 400 — the log suggested that I was submitting null content:

May 12 10:53:19 TEST [info] Put Request URL: https://my-vcloud-url/api/vApp/vm-id-here/productSections
May 12 10:53:19 TEST [info] Put Content-Type:
May 12 10:53:19 TEST [info] Put Request Headers: array (
‘Content-Type’ => NULL,
‘Content-Length’ => 0,
May 12 10:53:19 TEST [debug] Put Request Body: NULL
May 12 10:53:19 TEST [info] Status Code: 400
May 12 10:53:19 TEST [info] Status: Bad Request

How odd. All became clearer after checking the SDK’s VCloud.php:

Farewell, $productInfo…

As shown, nothing happens with the supplied $productInfo so it is not surprising that null content is submitted to the API!

I optimistically hoped that changing the return would help:

return $this->svc->put($url, 202, $type, $productInfo);

However, while this stopped the null content submission it quickly fell over with a whole new bunch of errors. At this point I gave up and opened a case with VMware :-)

Sadly… the response was as follows:

Using vCD 5.5 JAVA SDK code They can modify the “ProductSection”. 
Since this issue is seen only in PHP SDK and we don’t have a future plan to fix the issue.

If you want to see this in a positive light — VMware are encouraging you all to become polyglot programmers! :-D

For completeness, if you do fancy re-writing your requirement in Java, here is the VMware-provided sample code:

List<ProductSectionType> productList = vm.getProductSections();
for (ProductSectionType type : productList) {
List<Object> objList = type.getCategoryOrProperty();
for (Object ob : objList) {
if (ob instanceof ProductSectionProperty) {
ProductSectionProperty property =(ProductSectionProperty) ob;
property.setKey(“SDK.JAVA.Test.” + property.getKey());