Hey,  thanks for sending this to me.  Works like a charm.  I have this tied
in with a UPS script that monitors the UPS on another system, and fires off
your script before a shutdown command.  Works pretty well so far!

I am using the default certificates.   Took me a second to find out where
they are stored, but after pointing directly to it, everything is working
like a champ.

Thanks!


On Thu, Jan 11, 2018 at 6:47 AM, Giorgio Biacchi <gior...@di.unimi.it>
wrote:

> On 01/11/2018 11:44 AM, Kapetanakis Giannis wrote:
>
>> On 10/01/18 22:11, Wesley Stewart wrote:
>>
>>> Marcelo,
>>>
>>> I would greatly appreciate seeing a script!  It would be an excellent
>>> chance for me to learn a bit about using ovirt from the command line as
>>> well!
>>>
>>
>> I'm using something like this with ovirt-shell
>>
>> vm_shutdown:
>> #!/bin/sh
>> LOG=/root/ovirt/vm_shutdown_log
>> echo `date` >> $LOG
>> /usr/bin/ovirt-shell -f /root/ovirt/vm_shutdown_script >> $LOG
>> echo "" >> $LOG
>>
>> vm_shutdown_script:
>> list vms --kwargs status-state=up|grep name | sed s/'name
>>  :'/'action vm'/ | sed -e 's/$/ shutdown/' > /root/ovirt/new_vm_shutdown_sc
>> ript
>> file /root/ovirt/new_vm_shutdown_script
>>
>> new_vm_shutdown_script now lists entries like this:
>> action vm vm1 shutdown
>> action vm vm2 shutdown
>> etc.
>>
>> G
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users@ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/users
>>
>>
> You can use python SDK.
>
> Somthing like this should work
>
> #!/usr/bin/env python
>
> import ovirtsdk4 as sdk
>
> ovaddress = "<fill correct URL here>"
> username="admin@internal"
> password="*********"
>
> connection = sdk.Connection(
>   url=ovaddress,
>   username=username,
>   password=password,
>   ca_file='ca.crt',
>   insecure=True
> )
>
> system_service = connection.system_service()
> vms_service = system_service.vms_service()
> vms = vms_service.list()
>
> for vm in vms:
>         vm_service = vms_service.vm_service(vm.id)
>         vm_service.shutdown()
>
> connection.close()
>
> --
> gb
>
> PGP Key: http://pgp.mit.edu/
> Primary key fingerprint: C510 0765 943E EBED A4F2 69D3 16CC DC90 B9CB 0F34
>
> _______________________________________________
> Users mailing list
> Users@ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users
>
_______________________________________________
Users mailing list
Users@ovirt.org
http://lists.ovirt.org/mailman/listinfo/users

Reply via email to