Getting: Incompatible device backing specified for device '0' when trying to add HD

719 views
Skip to first unread message

Rob Marshall

unread,
Apr 27, 2013, 2:25:31 AM4/27/13
to pysp...@googlegroups.com
Hi,

I am trying to setup a script that will allow me to create a group of VMs. In this particular case, it's always the same VMs with the same configuration. I'm new to pysphere so you'll have to forgive me if this is a really dumb question, but:

I created a VM, added one disk to make sure that the SCSI controller was defined, and I set up this method:

def add_disk(server,vm,unit):   
    request = VI.ReconfigVM_TaskRequestMsg()
    _this = request.new__this(vm._mor)
    _this.set_attribute_type(vm._mor.get_attribute_type())
    request.set_element__this(_this)
    spec = request.new_spec()
    dc = spec.new_deviceChange()
    dc.Operation = 'add'
    dc.FileOperation = 'create'
    hd = VI.ns0.VirtualDisk_Def("hd").pyclass()
    hd.Key = -100
    hd.UnitNumber = unit
    hd.CapacityInKB = 26214400
    hd.ControllerKey = 1000
    backing = VI.ns0.VirtualDiskFlatVer2BackingInfo_Def("backing").pyclass()
    backing.FileName = '[datastore1]'
    backing.DiskMode = "persistent"
    hd.backing = backing
    dc.Device = hd
    spec.DeviceChange = [dc]
    request.Spec = spec
    task = server._proxy.ReconfigVM_Task(request)._returnval
    vi_task = VITask(task, server)
    status = vi_task.wait_for_state([vi_task.STATE_SUCCESS,vi_task.STATE_ERROR])
    if status != 'success':
        print "ERROR: %s" % vi_task.get_error_message()

I took this example from another post...

I am running ESXi 4.1 and I do:

>>> add_disk(server,vm2,1)
ERROR: Incompatible device backing specified for device '0'.

I'm sure it's just something really simple, but since I'm new to all of this, I'm not really sure where to begin.

Any help would be greatly appreciated.

Rob

Rob Marshall

unread,
Apr 27, 2013, 6:06:03 PM4/27/13
to pysp...@googlegroups.com
Never mind...Not sure exactly what I was doing wrong, but I used a different script, made some changes to it, and I can create my VMs without problem.

Rob
Reply all
Reply to author
Forward
0 new messages