VMware Cloud Community
bazinga47
Contributor
Contributor

Get Blueprint / custspec from VcVirtualMachine

I trying to get the blueprint name or the customization spec from a vm.

My problem is that I didn't get this information from the vc:virtualmachine properties.

Any help / pointers would be very much appreciated.  Thanks in advance!

Reply
0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee

Looking at virtual machine docs - https://www.vmware.com/support/orchestrator/doc/vro-vsphere60-api/html/VcVirtualMachine.html - it seems that layoutEx attribute may contain the info about the files of the virtual machine, including customization file.

Here is some sample scripting to dump values inside this property and check if there is something helpful (vm is the input object of type VC:Virtualmachine)

var files = vm.layoutEx.file;

for each (var f in files) {

  System.log("key: " + f.key + "  type: " + f.type + "  name: " + f.name);

}

Run it and check if there is an entry with type guestCustomization

Sorry, I don't have a suitable environment atm to verify the code above so it might not work.

Reply
0 Kudos
bazinga47
Contributor
Contributor

Thank you for your fast response.

Unfortunately the output of this code does not return the customization spec.

Here the result:

[2016-08-22 13:56:45.543] [I] key: 0  type: config  name: [DATASTORE-5] vm10031/vm10031.vmx

[2016-08-22 13:56:45.543] [I] key: 1  type: extendedConfig  name: [DATASTORE-5] vm10031/vm10031.vmxf

[2016-08-22 13:56:45.543] [I] key: 2  type: nvram  name: [DATASTORE-5] vm10031/vm10031.nvram

[2016-08-22 13:56:45.543] [I] key: 3  type: snapshotList  name: [DATASTORE-5] vm10031/vm10031.vmsd

[2016-08-22 13:56:45.544] [I] key: 4  type: diskDescriptor  name: [DATASTORE-5] vm10031/vm10031_2-000001.vmdk

[2016-08-22 13:56:45.544] [I] key: 5  type: diskExtent  name: [DATASTORE-5] vm10031/vm10031_2-000001-flat.vmdk

[2016-08-22 13:56:45.544] [I] key: 10  type: swap  name: [DATASTORE-5] vm10031/vm10031-89b4c3b8.vswp

[2016-08-22 13:56:45.544] [I] key: 9  type: uwswap  name: [DATASTORE-5] vm10031/vmx-vm10031-2210325176-1.vswp

I also checked the content of the files without a result.

Just to avoid any misunderstanding. Here a bit more detailed what I'm trying to do:

I try to find out which custspec was used to created a vm (given type vc:virtualmachine)

I need either the customization spec as string or object - or the blueprint/name as string or object because our name policy is that blueprint name and custspec name are the same.

Reply
0 Kudos