This is a multi-part message in MIME format.
--------------6F6C690A5B8D4656D6BC0A18
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 10/05/2017 =C3=A0 10:29, Ondra Machacek a =C3=A9crit :
Not sure I understand. You can use Ansible module to list VMs, you
can use ovirt_vms _facts[1] module.
For example to get only stopped VMs, you can use following:
- name: Get stopped VMs
ovirt_vms_facts:
auth:
url:
https://ovirt.example.com/ovirt-engine/api
username: admin@internal
password: password
ca_file: /etc/pki/ovirt-engine/ca.pem
pattern: "status =3D down"
I want a list of vms sorted by any
possible attributes, i.e. sorted by=20
datacenter or cluster, not only by status.
* For example, ovirt_vms_facts doesn't allow to get the datacenter the
vm belongs to , and the pattern filter doesn't return a list of vms
as expected:
- hosts: localhost
connection: local
tasks:
- name: Get stopped VMs
ovirt_vms_facts:
auth:
url:
https://acore.v100.abes.fr/ovirt-engine/api
username: admin@internal
password: ovirt123
insecure: true
pattern: name=3Dcentos* and cluster=3Dwest
- debug:
var: ovirt_vms
- shell: echo "{{ ovirt_vms.name }}"
How can I successfully display this list of vms like described here :
name description returned type sample
ovirt_vms List of dictionaries describing the VMs. VM attribues are=20
mapped to dictionary keys, all VMs attributes can be found at following=20
url:
https://ovirt.example.com/ovirt-engine/api/model#types/vm. On=20
success. list =09
* About the python SDK:
list_vms.py could be what I expect, but vm.datacenter_name doesn't exist
s.fr=20
<mailto:blanchet@abes.fr>> wrote:
Thanks, I knew this python script, but I believed it was possible
to do the same with an ansible module.
That's mean we need several tools to do different tasks, it is not
a very convergent way to proceed... but it is feasable.
Le 10/05/2017 =C3=A0 07:56, Ondra Machacek a =C3=A9crit :
> On Tue, May 9, 2017 at 6:52
PM, Nathana=C3=ABl Blanchet
> <blanchet(a)abes.fr <mailto:blanchet@abes.fr>> wrote:
> Hello,
> I didn't find anyway to easy list all my vms
thanks to the
> ansible modules...
> I tried the ovirt4.py script which is able to list the whole
> facts, so vms list, when the number of them is small in a
> test datacenter, but in a production datacenter, I get an issu=
e:
> File
"./ovirt4.py", line 262, in <module
>
main()
> File "./ovirt4.py", line 254, in main
> vm_name=3Dargs.host,
> File "./ovirt4.py", line 213, in get_data
> vms[name] =3D get_dict_of_struct(connection, vm)
> File "./ovirt4.py", line 185, in get_dict_of_struct
> (device.name <
http://device.name>, [ip.address for ip in
> device.ips]) for device in devices
> File "./ovirt4.py", line 185, in <genexpr
> (device.name <
http://device.name>,
[ip.address for ip in
> device.ips]) for device in devices
> TypeError: 'NoneType' object is not iterable
> This error was fixed
already, try to download latest ovirt4.py fil=
e.
> The other way is to use
fatcs[1] module.
> [1]
http://docs.ansible.com/ansible/ovirt_vms_facts_module.html
> <
http://docs.ansible.com/ansible/ovirt_vms_facts_module.html
> What is the simpliest way to get this basic
information with
> sdk4??? (with sdk3 : ovirt-shell -E "list vms")
> Please take a look at the
following example:
>
https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples= /list_vms.py
s/list_vms.py
> --=20
> Nathana=C3=ABl Blanchet
> Supervision r=C3=A9seau
> P=C3=B4le Infrastrutures Informatiques
> 227 avenue Professeur-Jean-Louis-Viala
> 34193 MONTPELLIER CEDEX 5
> T=C3=A9l. 33 (0)4 67 54 84 55
> Fax 33 (0)4 67 54 84 14
> blanchet(a)abes.fr <mailto:blanchet@abes.fr
> _______________________________________________
> Users mailing list
> Users(a)ovirt.org <mailto:Users@ovirt.org
>
http://lists.ovirt.org/mailman/listinfo/users
> <
http://lists.ovirt.org/mailman/listinfo/users
--=20
Nathana=C3=ABl Blanchet
Supervision r=C3=A9seau
P=C3=B4le Infrastrutures Informatiques
227 avenue Professeur-Jean-Louis-Viala
34193 MONTPELLIER CEDEX 5 =09
T=C3=A9l. 33 (0)4 67 54 84 55
Fax 33 (0)4 67 54 84 14
blanchet(a)abes.fr <mailto:blanchet@abes.fr> =20
--=20
Nathana=C3=ABl Blanchet
Supervision r=C3=A9seau
P=C3=B4le Infrastrutures Informatiques
227 avenue Professeur-Jean-Louis-Viala
34193 MONTPELLIER CEDEX 5 =09
T=C3=A9l. 33 (0)4 67 54 84 55
Fax 33 (0)4 67 54 84 14
blanchet(a)abes.fr
--------------6F6C690A5B8D4656D6BC0A18
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<html
<head
<meta content=3D"text/html; charset=3Dutf-8"
http-equiv=3D"Content-Ty=
pe"
</head
<body bgcolor=3D"#FFFFFF"
text=3D"#000000"
Le 10/05/2017 =C3=A0 10:29,
Ondra Machacek a =C3=A9crit=C2=A0:<br
<blockquote
cite=3D"mid:CAJCqMsUtk7x1ZCPOnZ0jgAMkhd-fS9yd0F0OW4Zo3xOaxkP8iA@mail.gmai=
l.com"
type=3D"cite"
<div
dir=3D"ltr"
<div
<div
<div
<div
<div
<div
<div
<div
<div
<div>Not sure I understand. You can use
Ansible module to list VMs, you<br
</div
can use ovirt_vms _facts[1] module.<br
<br
</div
For example to get only stopped VMs,
you can use
following:<br
<br
</div
- name: Get stopped VMs<br
</div
=C2=A0 ovirt_vms_facts:<br
</div
=C2=A0=C2=A0=C2=A0
auth:<br
</div
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 url: <a
moz-do-not-send=3D=
"true"
href=3D"https://ovirt.example.com/ovirt-engine/api">htt=
ps://ovirt.example.com/ovirt-engine/api</a><br
</div
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 username: admin@internal<br
</div
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 password: password<br
</div
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ca_file: /etc/pki/ovirt-engine/c=
a.pem<br
</div
=C2=A0=C2=A0=C2=A0 pattern: "status =3D
down"<br
</div
</blockquote
I
want a list of vms sorted by any possible attributes, i.e. sorted
by datacenter or cluster, not only by status.<br
<ul
<li>For example, ovirt_vms_facts doesn't allow
to get the
datacenter the vm belongs to , and the pattern filter doesn't
return a list of vms as expected:</li
</ul
<br
-
hosts: localhost<br
=C2=A0 connection:
local<br
=C2=A0 tasks:<br
=C2=A0 - name: Get stopped VMs<br
=C2=A0=C2=A0=C2=A0 ovirt_vms_facts:<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 auth:<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 url: <a
class=3D"moz-txt-l=
ink-freetext"
href=3D"https://acore.v100.abes.fr/ovirt-engine/api">https:=
//acore.v100.abes.fr/ovirt-engine/api</a><br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 username: admin@internal<b=
r
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 password:
ovirt123<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 insecure: true<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pattern:
name=3Dcentos* an=
d cluster=3Dwest<br
=C2=A0 - debug:<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 var: ovirt_vms<br
=C2=A0 - shell: echo "{{ ovirt_vms.name
}}"<br
<br
How can I successfully display this list of vms like
described here
:<br
<table border=3D"1"
cellpadding=3D"4"
<tbody
<tr
<th class=3D"head">name</th
<th class=3D"head">description</th
<th class=3D"head">returned</th
<th class=3D"head">type</th
<th class=3D"head">sample</th
</tr
<tr
<td> ovirt_vms </td
<td> List of
dictionaries describing the VMs. VM attribues are
mapped to dictionary keys, all VMs attributes can be found
at following url:
<a class=3D"moz-txt-link-freetext"
href=3D"https://ovirt.exam=
ple.com/ovirt-engine/api/model#types/vm">https://ovirt.example.co...
engine/api/model#types/vm</a>. </td
<td align=3D"center"> On success. </td
<td align=3D"center"> list </td
<td align=3D"center"> <br
</td
</tr
</tbody
</table
<br
<ul
<li>About the python SDK:</li
</ul
list_vms.py could be what I expect, but vm.datacenter_name doesn't
exist<br
<blockquote
cite=3D"mid:CAJCqMsUtk7x1ZCPOnZ0jgAMkhd-fS9yd0F0OW4Zo3xOaxkP8iA@mail.gmai=
l.com"
type=3D"cite"
<div
dir=3D"ltr"
<div
<div
<div
<div
<div
<div
<div
<div
<div
<div><br
[1]
<a moz-do-not-send=3D"true"
href=3D"http://docs.ansible.com/ansible/ovi=
rt_vms_facts_module.html"
target=3D"_blank">http://docs.ansible.com/<=
wbr>ansible/ovirt_vms_facts_<wbr>module.html</a></div
</div
</div
</div
</div
</div
</div
</div
</div
</div
</div
<div class=3D"gmail_extra"><br
<div class=3D"gmail_quote">On Wed, May 10, 2017 at 10:13 AM,
Nathana=C3=ABl Blanchet <span dir=3D"ltr"><<a
moz-do-not-send=3D"true"
href=3D"mailto:blanchet@abes.fr"
target=3D"_blank">blanchet(a)abes.fr</a>&gt;</span>
wrote:<br=
<blockquote class=3D"gmail_quote"
style=3D"margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex"
<div bgcolor=3D"#FFFFFF"
text=3D"#000000"
<p>Thanks, I
knew this python script, but I believed it
was possible to do the same with an ansible module.</p
<p>That's mean we need several tools to
do different
tasks, it is not a very convergent way to proceed... but
it is feasable.<br
</p
<div
<div class=3D"h5"> <br
<div
class=3D"m_-2614652977139427754moz-cite-prefix">Le
10/05/2017 =C3=A0 07:56, Ondra Machacek a =C3=A9crit=C2=
=A0:<br
</div
<blockquote type=3D"cite"
<div dir=3D"ltr"><br
<div
class=3D"gmail_extra"><br
<div class=3D"gmail_quote">On Tue, May 9, 2017 at
6:52 PM, Nathana=C3=ABl Blanchet <span dir=3D"l=
tr"><<a
moz-do-not-send=3D"true"
href=3D"mailto:blanchet@abes.fr"
target=3D"_blank">blanchet(a)abes.fr</a>&gt;<=
/span
wrote:<br
<blockquote
class=3D"gmail_quote"
style=3D"margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">Hello,<br
<br
I didn't find anyway to easy list all my vms
thanks to the ansible modules...<br
I tried the ovirt4.py script which
is able
to list the whole facts, so vms list, when
the number of them is small in a test
datacenter, but in a production datacenter,
I get an issue:<br
<br
=C2=A0
File "./ovirt4.py", line 262, in
<module><br
=C2=A0 =C2=A0 main()<br
=C2=A0 File "./ovirt4.py", line 254, in main<=
br
=C2=A0 =C2=A0
vm_name=3Dargs.host,<br
=C2=A0
File "./ovirt4.py", line 213, in get_d=
ata<br
=C2=A0
=C2=A0 vms[name] =3D
get_dict_of_struct(connection, vm)<br
=C2=A0 File
"./ovirt4.py", line 185, in
get_dict_of_struct<br
=C2=A0 =C2=A0 (<a moz-do-not-send=3D"true"
href=3D"http://device.name" rel=3D"noreferr=
er"
target=3D"_blank">device.name</a>,
[ip.address for ip in device.ips]) for
device in devices<br
=C2=A0 File "./ovirt4.py", line 185, in
<genexpr><br
=C2=A0 =C2=A0 (<a moz-do-not-send=3D"true"
href=3D"http://device.name" rel=3D"noreferr=
er"
target=3D"_blank">device.name</a>,
[ip.address for ip in device.ips]) for
device in devices<br
TypeError: 'NoneType' object is not iterable<=
br
</blockquote
<div><br
</div
<div>This error was fixed already, try to
download latest ovirt4.py file.<br
<br
</div
<div>The other way is to use fatcs[1] module.<b=
r
<br
[1] <a moz-do-not-send=3D"true"
href=3D"http://docs.ansible.com/ansible/ovi=
rt_vms_facts_module.html"
target=3D"_blank">http://docs.ansible.com/<=
wbr>ansible/ovirt_vms_facts_<wbr>module.html</a><br
</div
<div>=C2=A0</div
<blockquote class=3D"gmail_quote"
style=3D"margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex"> <br
<br
What is the simpliest way to get this basic
information with sdk4??? (with sdk3 :
ovirt-shell -E "list vms")<br
</blockquote
<div><br
</div
<div>Please take a look at the following
example:<br
<br
=C2=A0<a moz-do-not-send=3D"true"
href=3D"https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/ex...
s/list_vms.py"
target=3D"_blank">https://github.com/oVirt/=
<wbr>ovirt-engine-sdk/blob/master/<wbr>sdk/examples/list_vms.py</a><br
</div
<div>=C2=A0</div
<blockquote class=3D"gmail_quote"
style=3D"margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex"> <br
<br
<br
--
<br
Nathana=C3=ABl Blanchet<br
<br
Supervision r=C3=A9seau<br
P=C3=B4le Infrastrutures Informatiques<br
227 avenue
Professeur-Jean-Louis-Viala<br
34193
MONTPELLIER CEDEX 5=C2=A0 =C2=A0 =C2=A0=
=C2=A0<br
T=C3=A9l. 33 (0)4 67 54 84 55<br
Fax=C2=A0 33 (0)4 67 54 84 14<br
<a moz-do-not-send=3D"true"
href=3D"mailto:blanchet@abes.fr"
target=3D"_blank">blanchet(a)abes.fr</a><br
<br
______________________________<wbr>__________=
_______<br
Users
mailing list<br
<a
moz-do-not-send=3D"true"
href=3D"mailto:Users@ovirt.org"
target=3D"_blank">Users(a)ovirt.org</a><br
<a
moz-do-not-send=3D"true"
href=3D"http://lists.ovirt.org/mailman/list=
info/users"
rel=3D"noreferrer"
target=3D"_blank">http:/=
/lists.ovirt.org/mailman<wbr>/listinfo/users</a><br
</blockquote
</div
<br
</div
</div
</blockquote
<br
<pre
class=3D"m_-2614652977139427754moz-signature" cols=
=3D"72">--=20
Nathana=C3=ABl Blanchet
Supervision r=C3=A9seau
P=C3=B4le Infrastrutures Informatiques
227 avenue Professeur-Jean-Louis-Viala
34193 MONTPELLIER CEDEX 5 =09
T=C3=A9l. 33 (0)4 67 54 84 55
Fax 33 (0)4 67 54 84 14
<a moz-do-not-send=3D"true"
class=3D"m_-2614652977139427754moz-txt-link-a=
bbreviated" href=3D"mailto:blanchet@abes.fr"
target=3D"_blank">blanchet@a=
bes.fr</a> </pre
</div
</div
</div
</blockquote
</div
<br
</div
</blockquote
<br
<pre class=3D"moz-signature"
cols=3D"72">--=20
Nathana=C3=ABl Blanchet
Supervision r=C3=A9seau
P=C3=B4le Infrastrutures Informatiques
227 avenue Professeur-Jean-Louis-Viala
34193 MONTPELLIER CEDEX 5 =09
T=C3=A9l. 33 (0)4 67 54 84 55
Fax 33 (0)4 67 54 84 14
<a class=3D"moz-txt-link-abbreviated"
href=3D"mailto:blanchet@abes.fr">bl=
anchet(a)abes.fr</a> </pre
</body
</html
--------------6F6C690A5B8D4656D6BC0A18--