There has been very good coverage and code samples for working with Metadata in vCloud Director 1.5 (See posts from William, Alan, and Clinton), so this will simply be an update post for Metadata in vCloud Director 5.1.
- Typed Values - Metadata must now be put into a certain type. No more throwing random junk into a single metadata entry.
- Domain and Visibility – Providers now have the ability to provide System metadata entries on objects, which is not editable by users. Providers can additionally make the metadata private, meaning the users cannot see the System metadata on the object at all.
- Objects – Metadata can now be added to new vCloud Director 5.1 objects, including disks and storage profiles. Additionally, I believe that because OrgVDC networks are now user manageable, vCloud users can add their own metadata to networks.
For more instruction on Metadata in the vCloud API, read “Working with Object Metadata” in the vCloud Programming Guide.
PowerCLI 5.1 R2 example:
$vapp = Get-CIVapp “MyVApp”
$metadata = $vapp.extensiondata.GetMetadata()
$metadata.MetadataEntry = New-Object VMware.VimAutomation.Cloud.Views.MetadataEntry
# I don’t have any other metadata, so index is .
$metadata.MetadataEntry.Key = “Jake”
$metadata.MetadataEntry.TypedValue = New-Object VMware.VimAutomation.Cloud.Views.MetadataStringValue
$metadata.MetadataEntry.TypedValue.Value = “vCloudNerd”