This is a multi-part message in MIME format.
--------------31946F579A8C58BAAAA5B9A2
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Great, it works like a charm!
But how could I obtain a several map display?
For example, I need to display the vm name ; its relative snaphost id=20
and snaphot description.
I tried to change filter, but notyhing works
msg: "{{ ovirt_snapshots | map(attribute=3D'description') |=20
map(attribute=3D'id') | join(' ') }}"
or something like
msg: "{{ ovirt_snapshots.vm | map(attribute=3D'name') |=20
map(attribute=3D'id') | join(' ') }}"
Thanks for helping.
ps: I tried nearly all modules, and the permissions one is bugged, only=20
internal-authz domain displays users, none of ldap one can display.
Le 11/05/2017 =C3=A0 20:14, Ondra Machacek a =C3=A9crit :
I am not Ansible expert, this maybe worth asking on Ansible users
list,
but one thing which you can do is following:
in tasks/main.yml
- include: "{{ item }}"
with_items: "{{ resources | default('vms') }}.yml"
then have following files:
- tasks/vms.yml
- tasks/clusters.yml
- tasks/disks.yml
- ...
then run it as:
$ ansible-playbook -e "resources: [vms,disks]" play.yml
$ ansible-playbook -e "resources: [clusters]=20
clusters_pattern=3Dname=3Dx*" play.yml
On Thu, May 11, 2017 at 6:34 PM, Nathana=C3=ABl Blanchet <blanchet@abes=
.fr=20
<mailto:blanchet@abes.fr>> wrote:
Thanks, all works as expected.
Now, I try make roles.
here it is :
*cat /etc/ansible/roles/ovirt_vm_facts/tasks/main.yml*
- name: get vm facts
ovirt_vms_facts:
auth:
url: https://{{ engine }}.v100.abes.fr/ovirt-engine/api
<
http://v100.abes.fr/ovirt-engine/api
username: "{{ username }}"
password: "{{ password }}"
insecure: "{{ insecure }}"
pattern: "{{ pattern }}"
- debug:
msg: "{{ ovirt_vms | map(attribute=3D'name') | join(' ')
}}"
*cat /etc/ansible/roles/ovirt_vm_facts/vars/main.yml*
pattern: "os=3Drhel_5x64 or os=3Drhel_5"
engine: air
username: admin@internal
password: ovirt123
insecure: true
and I call those files with */tmp/ovirt_vm_facts.yml* with extra
variables if needed
- hosts: localhost
connection: local
roles:
- ovirt_vm_fact
running ansible-playbook /tmp/ovirt_vm_facts.ym -e
'pattern=3D"name=3Dacier* and cluster=3DDev"'
*But..*
I don't want to do the same for each ansible module shipped with 2.=
3.
Knowing that each *facts module has the same structure
auth/pattern, is there a way to play a generic playbook
independant from the role, like:
- hosts: localhost
connection: local
roles:
- ovirt_facts (with somewhere a variable "myfact")
which would play an unique role
*/etc/ansible/roles/ovirt_facts/tasks/main.yml with*
- name: get vm facts
myfact
auth:
....
Hope to be clear enough, thank your for your help.
Le 10/05/2017 =C3=A0 13:14, Ondra Machacek a =C3=A9crit :
> On Wed, May 10, 2017 at
12:38 PM, Nathana=C3=ABl Blanchet
> <blanchet(a)abes.fr <mailto:blanchet@abes.fr>> wrote:
> 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
>> <
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 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
> <
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 <
http://ovirt_vms.name>
}}"
>
Ok, I understand, now.
> You have few options here.
> If you want for example only VMs from datacenter 'X', you can use
> following:
> - hosts: localhost
> connection: local
> tasks:
> - name: Get VMs from datacenter X
> ovirt_vms_facts:
> pattern: datacenter=3DX
> auth:
> url:
https://acore.v100.abes.fr/ovirt-engine/api
> <
https://acore.v100.abes.fr/ovirt-engine/api
>
username: admin@internal
> password: ovirt123
> insecure: true
> - debug:
> msg: "{{ ovirt_vms | map(attribute=3D'name') | list }}"
> 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 mapped to dictionary keys, all VMs attributes
> can be found at following url:
>
https://ovirt.example.com/ovirt-engine/api/model#types/vm
> <
https://ovirt.example.com/ovirt-engine/api/model#types/vm>.
> On success. list =09
> * About the python
SDK:
> list_vms.py could be what I expect, but
vm.datacenter_name
> doesn't exist
> Yes, because the
'data_center' parameter isn't part of the VM
> type. Take a look here[1],
> you will find there all attributes the VM has. As you can see
> there is no 'datacenter', but
> there is a 'cluster', but as said in documentation, it's just a
> reference to the cluster. That
> means that it contains the ID of the cluster and the 'href' to
> the cluster, so you can get
> the cluster object by following that reference using this code:
> vm_cluster =3D connection.follow_link(vm.cluster)
> print vm_cluster.name <
http://vm_cluster.name
> # Same for datacenter:
> vm_dc =3D connection.follow_link(vm_cluster.data_center)
> print vm_dc.name <
http://vm_dc.name
> What you need to understand is, what is the difference
between
> the 'full'
> object and the reference to the object. It's good to take a look
> at the XML
> output of the API and learn to read the API specification
> documentation,
> when working with oVirt Ansible and Python SDK.
> [1]
>
http://ovirt.github.io/ovirt-engine-api-model/master/#types/vm
> <
http://ovirt.github.io/ovirt-engine-api-model/master/#types/vm
>
>> [1]
>>
http://docs.ansible.com/ansible/ovirt_vms_facts_module.html
>> <
http://docs.ansible.com/ansible/ovirt_vms_facts_module.html
>
>> On Wed, May 10,
2017 at 10:13 AM, Nathana=C3=ABl Blanchet
>> <blanchet(a)abes.fr <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 issue:
>>
>>> 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_struc=
t
>>> (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 file.
>>
>>> The other
way is to use fatcs[1] module.
>>
>>> [1]
>>>
http://docs.ansible.com/ansible/ovirt_vms_facts_module.h=
tml
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/sd= k/examples/list_vms.py
dk/examples/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 <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 <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
--------------31946F579A8C58BAAAA5B9A2
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"
<p>Great, it works like a
charm!</p
<p>But how could I obtain
a several map display?</p
<p>For example, I need to
display the vm name ; its relative
snaphost id and snaphot description.</p
<p> I tried to change filter, but notyhing works<br
</p
<p>msg: "{{ ovirt_snapshots |
map(attribute=3D'description') |
map(attribute=3D'id') | join(' ') }}"</p
<p>or something like<br
</p
<p>msg: "{{ ovirt_snapshots.vm | map(attribute=3D'name') |
map(attribute=3D'id') | join(' ') }}"</p
<p>Thanks for helping.</p
<p>ps: I tried nearly all modules, and the
permissions one is
bugged, only internal-authz domain displays users, none of ldap
one can display.<br
</p
<br
<div class=3D"moz-cite-prefix">Le 11/05/2017 =C3=A0 20:14, Ondra Mach=
acek a
=C3=A9crit=C2=A0:<br
</div
<blockquote
cite=3D"mid:CAJCqMsWhWVHGrXdtaOonqp93_p8jbjG6k4+7333+M+vT3-TmvA@mail.gmai=
l.com"
type=3D"cite"
<div
dir=3D"ltr"
<div
<div
<div
<div
<div
<div
<div>I am
not Ansible expert, this maybe worth
asking on Ansible users list,<br
</div
but one thing
which you can do is following:<br
<br
</div
in tasks/main.yml<br
<br
</div
- include: "{{
item }}"<br
</div
=C2=A0 with_items: "{{ resources |
default('vms') }}.yml"<b=
r
<br
then have following files:<br
=C2=A0- tasks/vms.yml<br
=C2=A0-
tasks/clusters.yml<br
=C2=A0-
tasks/disks.yml<br
=C2=A0- ...<br
<br
</div
then run it
as:<br
<br
</div
=C2=A0$ ansible-playbook -e "resources: [vms,disks]" play.yml<b=
r
=C2=A0$ ansible-playbook -e "resources:
[clusters]
clusters_pattern=3Dname=3Dx*" play.yml<br
<br
</div
</div
<div
class=3D"gmail_extra"><br
<div class=3D"gmail_quote">On Thu, May 11, 2017 at 6:34 PM,
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, all
works as expected.</p
<p>Now, I try
make roles.</p
<p>here it is :
<br
</p
<p><b>cat /etc/ansible/roles/ovirt_vm_<wbr>facts/tasks/main=
.yml</b></p
<p>=C2=A0 -
name: get vm facts<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 moz-do=
-not-send=3D"true"
class=3D"m_7298570659494759391moz-txt-link-freetext">ht=
tps://</a>{{
engine }}.<a moz-do-not-send=3D"true"
href=3D"http://v100.abes.fr/ovirt-engine/api"
target=3D"_blank">v100.abes.fr/ovirt-engine/<wbr>api</a=
><br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 username: "{{ =
username }}"<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 password: "{{ =
password }}"<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 insecure: "{{ =
insecure }}"<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pattern: "{{ pattern }}"<b=
r
=C2=A0 - debug:<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 msg: "{{
ovirt_vms | map(a=
ttribute=3D'name') |
join(' ') }}"</p
<p><b>cat /etc/ansible/roles/ovirt_vm_<wbr>facts/vars/main.=
yml</b></p
<p>pattern:
"os=3Drhel_5x64 or os=3Drhel_5"<br
engine: air<span class=3D""><br
username: admin@internal<br
password: ovirt123<br
insecure:
true</span></p
<p>and I call
those files with <b>/tmp/ovirt_vm_facts.yml</=
b
with extra variables if needed<br
</p
<p><span class=3D"">- hosts: localhost<br
=C2=A0 connection: local<br
</span> =C2=A0 roles:<br
=C2=A0=C2=A0=C2=A0 - ovirt_vm_fact</p
<p>running ansible-playbook
/tmp/ovirt_vm_facts.ym -e
'pattern=3D"name=3Dacier* and cluster=3DDev"'<br
</p
<p><b>But..</b></p
<p>I don't want to do the same for each ansible module
shipped with 2.3.</p
<p>Knowing that each *facts module has the same structure
auth/pattern, is there a way to play a generic playbook
independant from the role, like:</p
<p><span class=3D"">- hosts: localhost<br
=C2=A0 connection: local<br
</span> =C2=A0 roles:<br
=C2=A0=C2=A0=C2=A0 - ovirt_facts (with
somewhere a variab=
le "myfact")<br
</p
<p>which would play an unique role
<b>/etc/ansible/roles/ov=
irt_<wbr>facts/tasks/main.yml
with</b></p
<p><br
- name: get vm
facts<br
=C2=A0=C2=A0=C2=A0
myfact<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 ....<br
</p
<p>Hope to be
clear enough, thank your for your help.<br
</p
<div
<div class=3D"h5"> <br
<div
class=3D"m_7298570659494759391moz-cite-prefix">Le
10/05/2017 =C3=A0 13:14, 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 Wed, May 10, 2017 a=
t
12:38 PM, 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:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex"
<div
bgcolor=3D"#FFFFFF"><span
class=3D"m_7298570659494759391gmail-"> Le
10/05/2017 =C3=A0 10:29, Ondra Machacek a
=C3=A9crit=C2=A0:<br
<blockquote 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.<b=
r
<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:<b=
r
</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.examp=
le.com/ovirt-engine/api"
target=3D"_blank">https://o=
virt.example.com/ovir<wbr>t-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 pa=
ssword: password<br
</div
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ca_f=
ile:
/etc/pki/ovirt-engine/ca.pem<br
</div
=C2=A0=C2=A0=C2=A0 pattern:
"status =3D=
down"<br
</div
</blockquote
</span> 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:<span
class=3D"m_7298570659494759391gmail-"><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
</span>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 url: <a
moz-do-not-send=3D"true"
class=3D"m_7298570659494759391gmail-m_344037001981379143moz-txt-link-free=
text"
href=3D"https://acore.v100.abes.fr/ovirt-engine/api"
target=3D"_blank">ht=
tps://acore.v100.abes.fr/ovi<wbr>rt-engine/api</a><br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =
username: admin@internal<br
=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* and
cluster=3Dwest<br
=C2=A0 - debug:<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 var: ovirt_v=
ms<br
=C2=A0
- shell: echo "{{ <a
moz-do-not-send=3D"true"
href=3D"http://ovirt_vms.name"
target=3D"_blank">ovirt_vms.name</a>
}}"<=
br
</div
</blockquote
<div><br
<br
</div
<div>Ok, I understand, now.<br
</div
<div>You have few options here.<br
</div
<div>If you want for example only VMs from
datacenter 'X', you can use following:<br
<br
- hosts: localhost<br
=C2=A0 connection: local<br
=C2=A0 tasks:<span
class=3D"m_7298570659494759391gmail-im"><br=
=C2=A0 - name: Get VMs from
datacenter X<br=
=C2=A0=C2=A0=C2=A0
ovirt_vms_facts:</span><=
br
<span
class=3D"m_7298570659494759391gmail-im"=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
pattern: dat=
acenter=3DX<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 auth:<br
</span> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 url: <a
moz-do-not-send=3D"true"
class=3D"m_7298570659494759391gmail-m_344037001981379143moz-txt-link-free=
text"
href=3D"https://acore.v100.abes.fr/ovirt-engine/api"
target=3D"_blank">ht=
tps://acore.v100.abes.fr/ovi<wbr>rt-engine/api</a><br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 us=
ername: admin@internal<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pa=
ssword: ovirt123<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 in=
secure: true<br
=C2=A0 -
debug:<br
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 msg: "{{ ovirt=
_vms |
map(attribute=3D'name') | list }}"<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"
<div
bgcolor=3D"#FFFFFF"> <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"m_7298570659494759391gmail=
-m_344037001981379143head">name</th
<th
class=3D"m_7298570659494759391gmail=
-m_344037001981379143head">description</th
<th
class=3D"m_7298570659494759391gmail=
-m_344037001981379143head">returned</th
<th
class=3D"m_7298570659494759391gmail=
-m_344037001981379143head">type</th
<th
class=3D"m_7298570659494759391gmail=
-m_344037001981379143head">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
moz-do-not-send=3D"true"
class=3D"m_7298570659494759391gmail-m_344037001981379143moz-txt-link-free=
text"
href=3D"https://ovirt.example.com/ovirt-engine/api/model#types/vm"
target=3D"_blank">https://ovirt.e=
xample.com/ovir<wbr>t-engine/api/model#types/vm</a>.
</td
<td align=3D"center"> On success. </t=
d
<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</div
</blockquote
<div><br
</div
<div>Yes, because the 'data_center' parameter
isn't part of the VM type. Take a look
here[1],<br
</div
<div>you will find there all attributes the VM
has. As you can see there is no
'datacenter', but<br
</div
<div>there is a 'cluster', but as said in
documentation, it's just a reference to the
cluster. That<br
</div
<div>means that it contains the ID of the
cluster and the 'href' to the cluster, so
you can get<br
</div
<div>the cluster object by following that
reference using this code:<br
<br
</div
<div>=C2=A0vm_cluster =3D connection.follow_lin=
k(vm.<wbr>cluster)<br
</div
<div>=C2=A0print <a moz-do-not-send=3D"true"
href=3D"http://vm_cluster.name"
target=3D"_blank">vm_cluster.name</a><br
<br
</div
<div>=C2=A0# Same for datacenter:<br
</div
<div>=C2=A0vm_dc =3D connection.follow_link(vm_=
<wbr>cluster.data_center)<br
</div
<div>=C2=A0print <a moz-do-not-send=3D"true"
href=3D"http://vm_dc.name" target=3D"_blank=
">vm_dc.name</a><br
<br
</div
What you
need to understand is, what is the
difference between the 'full'<br
</div
<div class=3D"gmail_quote">object and the
reference to the object. It's good to take a
look at the XML<br
</div
<div
class=3D"gmail_quote">output of the API and
learn to read the API specification
documentation,<br
</div
<div
class=3D"gmail_quote">when working with oVir=
t
Ansible and Python SDK.<br
</div
<div
class=3D"gmail_quote"
<div><br
[1]
<a moz-do-not-send=3D"true"
href=3D"http://ovirt.github.io/ovirt-engine=
-api-model/master/#types/vm"
target=3D"_blank">http://ovirt.github.io/ov=
irt-<wbr>engine-api-model/master/#<wbr>types/vm</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"
<div
bgcolor=3D"#FFFFFF"
<div
<div
class=3D"m_7298570659494759391gmail-h5"=
><br
<blockquote 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/ovirt_vms_facts_module.html&...
target=3D"_blan=
k">http://docs.ansible.com/ansibl<wbr>e/ovirt_vms_facts_mod...
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@ab=
es.fr</a>></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:1=
ex"
<div bgcolor=3D"#FFFFFF"
<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"m_72985706594947=
59391gmail-m_344037001981379143h5"
<br
<div
class=3D"m_7298570659494759391gmail-m_344037001981379143m_-26146529771394=
27754moz-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_extr=
a"><br
<div
class=3D"gmail_qu=
ote">On
Tue, May 9, 2017
at 6:52 PM,
Nathana=C3=ABl
Blanchet <span
dir=3D"ltr"><=
;<a
moz-do-not-send=3D"true" href=3D"mailto:blanchet@abes.fr"
target=3D"_blan=
k">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:<b=
r
<br
=C2=A0 File
"./ovirt4.py",
line 262, in
<module><=
br
=C2=A0 =C2=A0 m=
ain()<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_data<br
=C2=A0 =C2=A0 v=
ms[name]
=3D
get_dict_of_str=
uct(connection,
vm)<br
=C2=A0 File
"./ovirt4.py",
line 185, in
get_dict_of_str=
uct<br
=C2=A0 =C2=A0 (=
<a
moz-do-not-send=
=3D"true"
href=3D"http://device.name" rel=3D"noreferrer"
target=3D"_blank">device.n=
ame</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"noreferrer"
target=3D"_blank">device.n=
ame</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.<br
<br
[1]
<a
moz-do-not-send=
=3D"true"
href=3D"http://docs.ansible.com/ansible/ovirt_vms_facts_module.html&...
target=3D"_blan=
k">http://docs.ansible.com/ansibl<wbr>e/ovirt_vms_facts_mod...
r
</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/ovir<wbr>t-...
ter/sdk/e<wbr>xamples/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<b=
r
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><b=
r
<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/listinfo/users"
rel=3D"noreferrer"
target=3D"_blan=
k">http://lists.ovirt.org/mailman<wbr>/listinfo/users</a...
</blockquote
</div
<br
</div
</div
</blockquote
<br
<pre class=3D"m_729857065=
9494759391gmail-m_344037001981379143m_-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_7298570659494759391gmail-m_3440370=
01981379143m_-2614652977139427754moz-txt-link-abbreviated" href=3D"mailto=
:blanchet@abes.fr" target=3D"_blank">blanchet(a)abes.fr</a>
</pre
</div
</div
</div
</blockquote
</div
<br
</div
</blockquote
<br
<pre
class=3D"m_7298570659494759391gmai=
l-m_344037001981379143moz-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_7298570659494759391gmail-m_3440370=
01981379143moz-txt-link-abbreviated" href=3D"mailto:blanchet@abes.fr" tar=
get=3D"_blank">blanchet(a)abes.fr</a> </pre
</div
</div
</div
</blockquote
</div
<br
</div
</div
</blockquote
<br
<pre
class=3D"m_7298570659494759391moz-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_7298570659494759391moz-txt-link-ab=
breviated" href=3D"mailto:blanchet@abes.fr"
target=3D"_blank">blanchet@ab=
es.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
--------------31946F579A8C58BAAAA5B9A2--