<div dir="ltr">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!<div><br></div><div>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.</div><div><br></div><div>Thanks!<br><div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 11, 2018 at 6:47 AM, Giorgio Biacchi <span dir="ltr"><<a href="mailto:giorgio@di.unimi.it" target="_blank">giorgio@di.unimi.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 01/11/2018 11:44 AM, Kapetanakis Giannis wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 10/01/18 22:11, Wesley Stewart wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Marcelo,<br>
<br>
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!<br>
</blockquote>
<br>
I'm using something like this with ovirt-shell<br>
<br>
vm_shutdown:<br>
#!/bin/sh<br>
LOG=/root/ovirt/vm_shutdown_lo<wbr>g<br>
echo `date` >> $LOG<br>
/usr/bin/ovirt-shell -f /root/ovirt/vm_shutdown_script >> $LOG<br>
echo "" >> $LOG<br>
<br>
vm_shutdown_script:<br>
list vms --kwargs status-state=up|grep name | sed s/'name :'/'action vm'/ | sed -e 's/$/ shutdown/' > /root/ovirt/new_vm_shutdown_sc<wbr>ript<br>
file /root/ovirt/new_vm_shutdown_sc<wbr>ript<br>
<br>
new_vm_shutdown_script now lists entries like this:<br>
action vm vm1 shutdown<br>
action vm vm2 shutdown<br>
etc.<br>
<br>
G<br>
<br>
<br>
______________________________<wbr>_________________<br>
Users mailing list<br>
<a href="mailto:Users@ovirt.org" target="_blank">Users@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/mailman<wbr>/listinfo/users</a><br>
<br>
</blockquote>
<br></div></div>
You can use python SDK.<br>
<br>
Somthing like this should work<br>
<br>
#!/usr/bin/env python<br>
<br>
import ovirtsdk4 as sdk<br>
<br>
ovaddress = "<fill correct URL here>"<br>
username="admin@internal"<br>
password="*********"<br>
<br>
connection = sdk.Connection(<br>
url=ovaddress,<br>
username=username,<br>
password=password,<br>
ca_file='ca.crt',<br>
insecure=True<br>
)<br>
<br>
system_service = connection.system_service()<br>
vms_service = system_service.vms_service()<br>
vms = vms_service.list()<br>
<br>
for vm in vms:<br>
vm_service = vms_service.vm_service(<a href="http://vm.id" rel="noreferrer" target="_blank">vm.id</a>)<br>
vm_service.shutdown()<br>
<br>
connection.close()<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
gb<br>
<br>
PGP Key: <a href="http://pgp.mit.edu/" rel="noreferrer" target="_blank">http://pgp.mit.edu/</a><br>
Primary key fingerprint: C510 0765 943E EBED A4F2 69D3 16CC DC90 B9CB 0F34</font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
Users mailing list<br>
<a href="mailto:Users@ovirt.org" target="_blank">Users@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/mailman<wbr>/listinfo/users</a><br>
</div></div></blockquote></div><br></div>