Hello,
I'm able to create a VM container using the CreateVM_Task method for a Folder managed object, using the sample VirtualMachineConfigSpec below. I've been unsuccessful in creating any devices beyond the default ones. I've tried various configurations with deviceChange for a CD-ROM, none of which have worked. The deviceChange object below mimics an existing VM that does have a CD-ROM. I've used environmentBrowser along with the methods QueryConfigOptionDescriptor and QueryConfigOption to ensure that the HostSystem supports this particular VirtualDeviceConfigSpec that I'm passing to the vCenter Web Service. Looking in the vCenter logs and tracing the CreateVM_Task didn't yield any errors. Querying the returned Task object after calling CreateVM_Task doesn't show any errors either. I'm at a loss for why the device isn't being created. Any help is appreciated.
Sample VirtualMachineConfigSpec:
bless( {
'cpuAllocation' => bless( {
'expandableReservation' => 0,
'limit' => '2000',
'reservation' => 2000,
'shares' => bless( {
'level' => bless( {
'val' => 'low'
}, 'SharesLevel' ),
'shares' => 1
}, 'SharesInfo' )
}, 'ResourceAllocationInfo' ),
'cpuHotAddEnabled' => '0',
'cpuHotRemoveEnabled' => '0',
'deviceChange' => [
bless( {
'device' => bless( {
'busNumber' => 0,
'controllerKey' => 100,
'device' => [
16000
],
'deviceInfo' => bless( {
'label' => 'SATA controller 0',
'summary' => 'AHCI'
}, 'Description' ),
'key' => 15000,
'unitNumber' => 24
}, 'VirtualAHCIController' )
}, 'VirtualDeviceConfigSpec' ),
bless( {
'device' => bless( {
'backing' => bless( {
'deviceName' => '',
'exclusive' => 0,
'useAutoDetect' => 0
}, 'VirtualCdromRemotePassthroughBackingInfo' ),
'connectable' => bless( {
'allowGuestControl' => 1,
'connected' => 0,
'startConnected' => 0,
'status' => 'untried'
}, 'VirtualDeviceConnectInfo' ),
'controllerKey' => 15000,
'deviceInfo' => bless( {
'label' => 'CD/DVD drive 1',
'summary' => 'Remote device'
}, 'Description' ),
'key' => 16000,
'unitNumber' => 0
}, 'VirtualCdrom' )
}, 'VirtualDeviceConfigSpec' )
],
'files' => bless( {
'snapshotDirectory' => '[<ESX servier name>] hq-toolsint-test027',
'vmPathName' => '[<ESX server name>] hq-toolsint-test027'
}, 'VirtualMachineFileInfo' ),
'guestId' => 'rhel6_64Guest',
'memoryAllocation' => bless( {
'expandableReservation' => 0,
'limit' => 1000,
'reservation' => 1000,
'shares' => bless( {
'level' => bless( {
'val' => 'low'
}, 'SharesLevel' ),
'shares' => 1
}, 'SharesInfo' )
}, 'ResourceAllocationInfo' ),
'memoryHotAddEnabled' => '0',
'memoryMB' => '1000',
'name' => 'hq-toolsint-test027',
'numCPUs' => '1',
'tools' => bless( {
'afterPowerOn' => 1,
'afterResume' => 1,
'beforeGuestReboot' => 1,
'beforeGuestShutdown' => 1,
'beforeGuestStandby' => 1
}, 'ToolsConfigInfo' )
}, 'VirtualMachineConfigSpec' );
Best,
Rene
I've identified that argument "operation" of enum VirtualDeviceConfigSpecOperation needs to be set to "add" so that the VirtualDeviceConfigSpec is not ignored. Also, if the device requires backing, argument "fileOperation" of enum VirtualDeviceConfigSpecFileOperation for the VirtualDeviceConfigSpec needs to be set to "create". I'm now receiving an error for the device I'm attempting to create, but at least there's an error message this time and not a black hole.
Following is a working VirtualMachineConfigSpec:
bless( {
'cpuAllocation' => bless( {
'expandableReservation' => 0,
'limit' => '2000',
'reservation' => 2000,
'shares' => bless( {
'level' => bless( {
'val' => 'low'
}, 'SharesLevel' ),
'shares' => 1
}, 'SharesInfo' )
}, 'ResourceAllocationInfo' ),
'cpuHotAddEnabled' => '0',
'cpuHotRemoveEnabled' => '0',
'deviceChange' => [
bless( {
'device' => bless( {
'backing' => bless( {
'deviceName' => 'CD/DVD drive 1',
'useAutoDetect' => 0
}, 'VirtualCdromRemoteAtapiBackingInfo' ),
'connectable' => bless( {
'allowGuestControl' => 1,
'connected' => 0,
'startConnected' => 0,
'status' => 'untried'
}, 'VirtualDeviceConnectInfo' ),
'controllerKey' => 200,
'deviceInfo' => bless( {
'label' => 'CD/DVD drive 1',
'summary' => 'Remote ATAPI CD/DVD drive 1'
}, 'Description' ),
'key' => -11,
'unitNumber' => 0
}, 'VirtualCdrom' ),
'operation' => bless( {
'val' => 'add'
}, 'VirtualDeviceConfigSpecOperation' )
}, 'VirtualDeviceConfigSpec' ),
bless( {
'device' => bless( {
'addressType' => 'assigned',
'backing' => bless( {
'deviceName' => '<network name>',
'network' => bless( {
'mo_ref' => bless( {
'type' => 'Network',
'value' => '<network managed object value>'
}, 'ManagedObjectReference' ),
'name' => '<network name>',
'vim' => bless( {<ServiceContent data>
}, 'ServiceContent' ),
'service_url' => '<service url>',
'vim_service' => bless( {<VimService data>
}, 'VimService' )
}, 'Vim' )
}, 'Network' ),
'useAutoDetect' => 0
}, 'VirtualEthernetCardNetworkBackingInfo' ),
'connectable' => bless( {
'allowGuestControl' => 1,
'connected' => 0,
'startConnected' => 1,
'status' => 'untried'
}, 'VirtualDeviceConnectInfo' ),
'controllerKey' => 100,
'deviceInfo' => bless( {
'label' => 'Network adapter 1',
'summary' => '<network name>'
}, 'Description' ),
'key' => -22,
'unitNumber' => 0,
'wakeOnLanEnabled' => 1
}, 'VirtualE1000' ),
'operation' => bless( {
'val' => 'add'
}, 'VirtualDeviceConfigSpecOperation' )
}, 'VirtualDeviceConfigSpec' )
],
'files' => bless( {
'snapshotDirectory' => '[<datastore name>] <vm name>,
'vmPathName' => '[<datastore name>] <vm name>'
}, 'VirtualMachineFileInfo' ),
'guestId' => 'rhel6_64Guest',
'memoryAllocation' => bless( {
'expandableReservation' => 0,
'limit' => 1000,
'reservation' => 1000,
'shares' => bless( {
'level' => bless( {
'val' => 'low'
}, 'SharesLevel' ),
'shares' => 1
}, 'SharesInfo' )
}, 'ResourceAllocationInfo' ),
'memoryHotAddEnabled' => '0',
'memoryMB' => '1000',
'name' => '<vm name>',
'numCPUs' => '1',
'tools' => bless( {
'afterPowerOn' => 1,
'afterResume' => 1,
'beforeGuestReboot' => 1,
'beforeGuestShutdown' => 1,
'beforeGuestStandby' => 1
}, 'ToolsConfigInfo' )
}, 'VirtualMachineConfigSpec' );