[ovirt-users] ovirt-shell
Juan Hernandez
jhernand at redhat.com
Thu Jul 10 11:42:09 EDT 2014
On 07/10/2014 05:28 PM, Juan Hernandez wrote:
> On 07/10/2014 05:07 PM, Sven Kieske wrote:
>> Well there is no guide on the web which I'm aware of.
>> But to my experience, scripting the shell has it's limitations
>> you might want to try the python sdk, which is more useful
>> or if you need some webapp anyway use the rest api.
>> you could also script the rest api using e.g. curl
>> but I wouldn't recommend that.
>>
>> there is documentation on this here:
>>
>> https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Virtualization/3.3/html/Developer_Guide/index.html
>>
>> https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Virtualization/3.3/html/Command_Line_Shell_Guide/index.html
>>
>> you can basically substitute rhev with ovirt.
>>
>> there still seems to be no updated dev guides for 3.4 though.
>>
>
> The location of that documentation has changed a bit for 3.4:
>
> https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Virtualization/3.4/html/Technical_Guide/part-The_REST_Application_Programming_Interface.html
>
> https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Virtualization/3.4/html/Technical_Guide/part-The_Command_Line_Interface.html
>
>> I have automated everything via REST, as I have php devs
>> who did the work ;)
>>
>> There are still some things you can't do via rest, like
>> creating network qos entities (attaching them to a vm works
>> but you need to create them manually).
>>
>> But in the future everything will use rest, so I guess this
>> is the best way to go.
>>
>> HTH
>>
>> Am 10.07.2014 16:46, schrieb Steve Kilduff:
>>> Excellent, thanks for the quick reply guys.
>>>
>>> I am trying to automate 100 vm creations so... If anyone has a good guide
>>> that exists I would be very appreciative, otherwise I will keep tipping
>>> away :)
>>>
>>> Steve
>>
>
> Did you consider using templates and pools?
>
>
If you have a template with all the characteristics you need, you can
easily create the 100 VMs with a Python script like this:
#!/usr/bin/python
import ovirtsdk.api
import ovirtsdk.xml
# Connect to the server:
api = ovirtsdk.api.API(
url="https://rhel.example.com/ovirt-engine/api",
username="admin at internal",
password="******",
insecure=True,
debug=False,
)
# Locate the cluster:
cluster = api.clusters.get(name="mycluster")
cluster = ovirtsdk.xml.params.Cluster(id=cluster.get_id())
# Locate the template:
template = api.templates.get(name="mytemplate")
template = ovirtsdk.xml.params.Template(id=template.get_id())
# Create the VMs:
for i in range(0, 99):
name = "vm%d" % i
print("Creating VM %s ..." % name)
vm = ovirtsdk.xml.params.VM(name=name, cluster=cluster,
template=template)
api.vms.add(vm)
# Disconnect:
api.disconnect()
--
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.
More information about the Users
mailing list