I upload ISO image using this script upload.py:
==================================================================================
import os
os.system('mkdir mount_dir')
os.system('mount -t nfs 15.15.158.2:/iso/rhevmisonfs mount_dir')
print 'mounted'
print 'start copying'
os.system('cp -f CentOS-6.2-x86_64-LiveDVD.iso mount_dir/e3e3b0cd-48a4-4bb8-a75b-07813f2c165e/images/11111111-1111-1111-1111-111111111111/')
print 'file copied'
os.system('umount -a nfs 15.15.158.2:/iso/rhevmisonfs mount_dir')
print 'unmounted'
os.system('rmdir mount_dir')
print 'dir removed'
==================================================================================
and I created a rhevm_test.py
api.vms.add(params.VM(name=VM_NAME, memory=2*GB,os=params.OperatingSystem(boot=[params.Boot(dev='cdrom'), params.Boot(dev='hd')]),cluster=api.clusters.get(name='Default'), template=api.templates.get('Blank')))
print 'VM created'
domain=api.storagedomains.list()
for d in domain:
print ' domain name : %s ' %d.name
api.storagedomains.get(name='rhevmiso').update()
rhevmiso=api.storagedomains.get(name='rhevmiso').files.list()
for iso in rhevmiso:
image = api.storagedomains.get(name='rhevmiso').files.get(name=' CentOS-6.2-x86_64-LiveDVD.iso ')
print 'image found %s' %image
api.vms.get(VM_NAME).cdroms.add(params.CdRom(name='cdrom',file=image))
print 'image added to VM'
==================================================================================
now i got the following exception :
image found none
Note : the reason is image is copied to "rhevmiso" storage domain but it not reflected in RHEVM user interface unless and untill I refresh it !
whenever listing files in api should force iso-refresh but its not working :(
Do we have any refresh or update function in ovirt sdk so that after coping the image RHEVM ISO domain will get refresh automatically ??
With Regards,
Romil