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)
How to add DVD drive to VM in XenServer using Python