Re: [Engine-devel] [Users] Related to python script for Attach Cd (.iso) to a vm
by Michael Pasternak
Hi Romil,
In general you can use api guide [1] for this, anyway here is example:
1. create vm
============
...
2. insert cdrom
===============
vm = api.vms.get(name="myvm")
cdrom = vm.cdroms.get(id="00000000-0000-0000-0000-000000000000")
isofile = params.File(id="myiso.iso")
cdrom.set_file(isofile)
cdrom.update()
3. change boot order (to boot from cdrom and then from hd)
==========================================================
os=params.OperatingSystem(boot=[params.Boot(dev='cdrom'), params.Boot(dev='hd')], ...)
api.vms.add(params.VM(name='myvm2',
os=os,
cluster=api.clusters.get('mycluster'),
template=api.templates.get('mytemplate')))
4. run vm
=========
...
[1] https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Virtual...
On 11/02/2012 09:56 AM, Romil Gupta wrote:
>
> Hello ,
>
> *I want to write a script to attach a '.iso' image to a vm *
> so ,can you please help me or tell me some api so that i can continue my work !!!
> I have some '.iso ' file in my storage .
>
> script *rhevm_test.py*
>
> from ovirtsdk.api import API
> from ovirtsdk.xml import params
> import time
>
> rhevm_uri = "https://rhevm301.xxx.xx.com:8443/api"
> rhevm_username = "admin(a)rhevm301.xxx.xx.com <mailto:admin@rhevm301.xxx.xx.com>"
> rhevm_password = "iso*help"
>
> api = API(url=rhevm_uri, username=rhevm_username, password=rhevm_password)
> print "Connected to RHEVM Successful"
>
> MB = 1024*1024
> GB = 1024*MB
> VM_NAME = 'test_vm'
> DESCRIP = 'testing vm'
> CLUSTER_NAME = 'Default'
> STORAGE_NAME = 'rhevmVMdata'
>
> domain_name= 'rhevmiso'
> domain_type = 'ISO'
>
>
> try:
> api.vms.add(params.VM(name=VM_NAME,description=DESCRIP, memory=2*GB,cluster=api.clusters.get(CLUSTER_NAME), template=api.templates.get('Blank') , cdroms =
> 'CentOS-6.2-x86_64-LiveCD.iso '))
>
> print 'VM created'
>
> api.vms.get(VM_NAME).nics.add(params.NIC(name='nic1', network=params.Network(name='rhevm'), interface='Red Hat VirtIO'))
> print 'NIC added to VM'
>
>
> api.vms.get(VM_NAME).disks.add(params.Disk(storage_domains=params.StorageDomains(storage_domain=[api.storagedomains.get(STORAGE_NAME)]),size=512*MB,status=None,interface='VirtIO',format='Preallocated',sparse=True,bootable=True))
>
> print 'Disk added to VM'
> print 'Waiting for VM to reach Down status'
> while api.vms.get(VM_NAME).status.state != 'down':
> time.sleep(1)
> except Exception as e:
> print 'Failed to create VM with disk and NIC\n%s' % str(e)
>
> time.sleep(10)
>
> try:
> if api.vms.get(VM_NAME).status.state != 'up':
> print 'Starting VM'
> api.vms.get(VM_NAME).start()
> print 'Waiting for VM to reach Up status'
> while api.vms.get(VM_NAME).status.state != 'up':
> time.sleep(1)
> else:
> print 'VM already up'
> except Exception as e:
> print 'Failed to Start VM:\n%s' % str(e)
>
>
> and got some exceptions
>
> Connected to RHEVM Successful
> Failed to create VM with disk and NIC
> 'str' object has no attribute 'export'
> Failed to Start VM:
> 'NoneType' object has no attribute 'status'
>
> if i remove this cdroms = 'CentOS-6.2-x86_64-LiveCD.iso ' the code will works fine and it will create a vm with blank template w/o any '.iso' attached !!
>
>
> *
> *
> *
> *
> *
> *
> *
> *
> *With Regards,*
> *Romil*
>
>
>
>
>
> _______________________________________________
> Users mailing list
> Users(a)ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users
--
Michael Pasternak
RedHat, ENG-Virtualization R&D
12 years, 1 month
Re: [Engine-devel] ovirt-sdk at pypi
by Michael Pasternak
Hi Toni,
do:
1. nics = api.hosts.get(name=xxx).nics
2. nics_arr = nics.list()
(change nics_arr as you need, according to __doc__, also see [1])
3. my_nics = params.HostNics(host_nic=[nics_arr[0],nics_arr[1],...])
or
my_nics = params.HostNics(host_nic=nics_arr)
4. nics.setupnetworks(action=params.Action(host_nics=my_nics))
[1] http://wiki.ovirt.org/wiki/SDK#Development_tips
On 11/02/2012 11:29 AM, Antoni Segura Puimedon wrote:
> Hi Michael,
>
> One question though, I would like to use the setupNetworks command
> and the docstring says that I should use params (ovirtsdk.xml.params)
> and inside those ivars. I don't know how or were these ivars are to
> be used. Could you point me where I should look at or, alternatively,
> give me an example?
>
> Thanks a lot for this nice api.
>
> Best,
>
> Toni
>
> ----- Original Message -----
>> From: "Michael Pasternak" <mpastern(a)redhat.com>
>> To: "engine-devel" <engine-devel(a)ovirt.org>
>> Cc: users(a)ovirt.org
>> Sent: Friday, November 2, 2012 8:44:40 AM
>> Subject: [Engine-devel] ovirt-sdk at pypi
>>
>> From now on latest ovirt-sdk will be available at pypi,
>> for more details see [1].
>>
>> [1] http://wiki.ovirt.org/wiki/SDK#pypi
>>
>> --
>>
>> Michael Pasternak
>> RedHat, ENG-Virtualization R&D
>> _______________________________________________
>> Engine-devel mailing list
>> Engine-devel(a)ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/engine-devel
>>
--
Michael Pasternak
RedHat, ENG-Virtualization R&D
12 years, 1 month
[Engine-devel] Time to bump version to 3.2.0?
by Juan Hernandez
I think that it is time to bump the version number in the POMs and in
the RPM spec to 3.2.0:
http://gerrit.ovirt.org/8993
In general I think that we should do this immediately after each
release, bumping to the next expected version number.
Thoughts?
--
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
3ºD, 28016 Madrid, Spain
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.
12 years, 2 months
[Engine-devel] [help]how to get the CA certificate when uploader ISO
by Sheldon
error when I update a iso to iso domain by engine-iso-uploader
# engine-iso-uploader --iso-domain=ISO upload Fedora-17-x86_64-DVD.iso
Please provide the REST API password for the admin@internal oVirt Engine
user (CTRL+D to abort):
ERROR: [ERROR]::ca_file (CA certificate) must be specified for SSL
connection.
INFO: Use the -h option to see usage.
but I manual engine-iso-uploader, there is no any information about
certificate.
# man engine-iso-uploader
--
Sheldon Feng(冯少合)<shaohef(a)linux.vnet.ibm.com>
IBM Linux Technology Center
12 years, 2 months
[Engine-devel] operation mode
by Laszlo Hornyak
Hi,
I have just run into this. Vm's have an OperationMode attribute, it can be FullVirtualized or ParaVirtualized. It appears the attribute does not play in any decision, not sent to vdsm. Can it be removed or anyone need it?
thx,
Laszlo
12 years, 2 months