I want to add a DVD drive to VM on xenserver using Python. I created a VM using Python and now I want to add the DVD Drive attached to host to be accessible in VM also. So I need to create a VBD for the DVD Drive as well. But I am unable to get which property I need to set in VBD.Record as in attaching disk, I set up the VDI property and it got attached. But for the DVD Drive, I am unable to figure out which property I need to set to attach that CD Drive to the XenServer. Do help me regarding this.....
I have written about this on my blog:
sr=session.xenapi.SR.get_by_name_label("DVD drives") record_dvd=session.xenapi.SR.get_record(sr[0]) VDI_dvd=record_dvd["VDIs"] vbdconnectcd={'VDI':VDI_dvd[0], 'VM':VM_ref, 'userdevice':"1", 'mode':"RO", 'type':"cd", 'bootable':True, 'unpluggable':True, 'empty':False, 'other_config':{}, 'qos_algorithm_type':'', 'qos_algorithm_params':{}} vbdref1=session.xenapi.VBD.create(vbdconnectcd)
Here,
VM_ref
refers to theuuid
of newly created VM to which we want to add the DVD Drive. Every physical DVD Drive has its VDI which is stored in its properties and one can get it and pass it as one of the parameters to create a VBD linking DVD Drive with the VM.