<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Le 10/05/2017 à 10:29, Ondra Machacek a écrit :<br>
    <blockquote
cite="mid:CAJCqMsUtk7x1ZCPOnZ0jgAMkhd-fS9yd0F0OW4Zo3xOaxkP8iA@mail.gmail.com"
      type="cite">
      <div dir="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>
                      ovirt_vms_facts:<br>
                  </div>
                      auth:<br>
                </div>
                      url: <a moz-do-not-send="true"
                  href="https://ovirt.example.com/ovirt-engine/api">https://ovirt.example.com/ovirt-engine/api</a><br>
              </div>
                    username: admin@internal<br>
            </div>
                  password: password<br>
          </div>
                ca_file: /etc/pki/ovirt-engine/ca.pem<br>
        </div>
            pattern: "status = 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>
      connection: local<br>
      tasks:<br>
      - name: Get stopped VMs<br>
        ovirt_vms_facts:<br>
          auth:<br>
            url: <a class="moz-txt-link-freetext" href="https://acore.v100.abes.fr/ovirt-engine/api">https://acore.v100.abes.fr/ovirt-engine/api</a><br>
            username: admin@internal<br>
            password: ovirt123<br>
            insecure: true<br>
            pattern: name=centos* and cluster=west<br>
      - debug:<br>
          var: ovirt_vms<br>
      - shell: echo "{{ ovirt_vms.name }}"<br>
    <br>
    How can I successfully display this list of vms like described here
    :<br>
    <table border="1" cellpadding="4">
      <tbody>
        <tr>
          <th class="head">name</th>
          <th class="head">description</th>
          <th class="head">returned</th>
          <th class="head">type</th>
          <th class="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="moz-txt-link-freetext" href="https://ovirt.example.com/ovirt-engine/api/model#types/vm">https://ovirt.example.com/ovirt-engine/api/model#types/vm</a>. </td>
          <td align="center"> On success. </td>
          <td align="center"> list </td>
          <td align="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="mid:CAJCqMsUtk7x1ZCPOnZ0jgAMkhd-fS9yd0F0OW4Zo3xOaxkP8iA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>
                <div>
                  <div>
                    <div>
                      <div>
                        <div>
                          <div><br>
                            [1] <a moz-do-not-send="true"
                              href="http://docs.ansible.com/ansible/ovirt_vms_facts_module.html"
                              target="_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="gmail_extra"><br>
        <div class="gmail_quote">On Wed, May 10, 2017 at 10:13 AM,
          Nathanaël Blanchet <span dir="ltr">&lt;<a
              moz-do-not-send="true" href="mailto:blanchet@abes.fr"
              target="_blank">blanchet@abes.fr</a>&gt;</span> wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#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="h5"> <br>
                  <div class="m_-2614652977139427754moz-cite-prefix">Le
                    10/05/2017 à 07:56, Ondra Machacek a écrit :<br>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr"><br>
                      <div class="gmail_extra"><br>
                        <div class="gmail_quote">On Tue, May 9, 2017 at
                          6:52 PM, Nathanaël Blanchet <span dir="ltr">&lt;<a
                              moz-do-not-send="true"
                              href="mailto:blanchet@abes.fr"
                              target="_blank">blanchet@abes.fr</a>&gt;</span>
                          wrote:<br>
                          <blockquote class="gmail_quote"
                            style="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>
                              File "./ovirt4.py", line 262, in
                            &lt;module&gt;<br>
                                main()<br>
                              File "./ovirt4.py", line 254, in main<br>
                                vm_name=args.host,<br>
                              File "./ovirt4.py", line 213, in get_data<br>
                                vms[name] =
                            get_dict_of_struct(connection, vm)<br>
                              File "./ovirt4.py", line 185, in
                            get_dict_of_struct<br>
                                (<a moz-do-not-send="true"
                              href="http://device.name" rel="noreferrer"
                              target="_blank">device.name</a>,
                            [ip.address for ip in device.ips]) for
                            device in devices<br>
                              File "./ovirt4.py", line 185, in
                            &lt;genexpr&gt;<br>
                                (<a moz-do-not-send="true"
                              href="http://device.name" rel="noreferrer"
                              target="_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.<br>
                            <br>
                            [1] <a moz-do-not-send="true"
                              href="http://docs.ansible.com/ansible/ovirt_vms_facts_module.html"
                              target="_blank">http://docs.ansible.com/<wbr>ansible/ovirt_vms_facts_<wbr>module.html</a><br>
                          </div>
                          <div> </div>
                          <blockquote class="gmail_quote"
                            style="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>
                             <a moz-do-not-send="true"
href="https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/list_vms.py"
                              target="_blank">https://github.com/oVirt/<wbr>ovirt-engine-sdk/blob/master/<wbr>sdk/examples/list_vms.py</a><br>
                          </div>
                          <div> </div>
                          <blockquote class="gmail_quote"
                            style="margin:0px 0px 0px
                            0.8ex;border-left:1px solid
                            rgb(204,204,204);padding-left:1ex"> <br>
                            <br>
                            <br>
                            -- <br>
                            Nathanaël Blanchet<br>
                            <br>
                            Supervision réseau<br>
                            Pôle Infrastrutures Informatiques<br>
                            227 avenue Professeur-Jean-Louis-Viala<br>
                            34193 MONTPELLIER CEDEX 5       <br>
                            Tél. 33 (0)4 67 54 84 55<br>
                            Fax  33 (0)4 67 54 84 14<br>
                            <a moz-do-not-send="true"
                              href="mailto:blanchet@abes.fr"
                              target="_blank">blanchet@abes.fr</a><br>
                            <br>
                            ______________________________<wbr>_________________<br>
                            Users mailing list<br>
                            <a moz-do-not-send="true"
                              href="mailto:Users@ovirt.org"
                              target="_blank">Users@ovirt.org</a><br>
                            <a moz-do-not-send="true"
                              href="http://lists.ovirt.org/mailman/listinfo/users"
                              rel="noreferrer" target="_blank">http://lists.ovirt.org/mailman<wbr>/listinfo/users</a><br>
                          </blockquote>
                        </div>
                        <br>
                      </div>
                    </div>
                  </blockquote>
                  <br>
                  <pre class="m_-2614652977139427754moz-signature" cols="72">-- 
Nathanaël Blanchet

Supervision réseau
Pôle Infrastrutures Informatiques
227 avenue Professeur-Jean-Louis-Viala
34193 MONTPELLIER CEDEX 5         
Tél. 33 (0)4 67 54 84 55
Fax  33 (0)4 67 54 84 14
<a moz-do-not-send="true" class="m_-2614652977139427754moz-txt-link-abbreviated" href="mailto:blanchet@abes.fr" target="_blank">blanchet@abes.fr</a> </pre>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Nathanaël Blanchet

Supervision réseau
Pôle Infrastrutures Informatiques
227 avenue Professeur-Jean-Louis-Viala
34193 MONTPELLIER CEDEX 5         
Tél. 33 (0)4 67 54 84 55
Fax  33 (0)4 67 54 84 14
<a class="moz-txt-link-abbreviated" href="mailto:blanchet@abes.fr">blanchet@abes.fr</a> </pre>
  </body>
</html>