Using filterflag on CLI

Hello,

I want to select all VNET assigned to a cluster, some of them are assigned to multiple clusters, I tried:

  • onevnet list -f CLUSTERS=0 → produce no result as no VNET is assigned uniquely to this cluster
  • onevnet list -f CLUSTERS="0,100" → produce the error Expression '100' incorrect

How could I list only those assigned to cluster 0 regardless of any other assignment?

I read the documentation but the filterflag description is quite cryptic to me:

filterflag a, all all the known VNETs m, mine the VNET belonging to the user in ONE_AUTH g, group ‘mine’ plus the VNET belonging to the groups the user is member of uid VNET of the user identified by this uid user VNET of the user identified by the username

Regards.

Hi,

Unfortunately I think the CLI can’t currently do what you want.
The -f option does a search on the exact string, so it won’t work in your case.

And that “filterflag” is not related to the -f option, it refers to this:

   * filterflag
        a, all       all the known VMTEMPLATEs
        m, mine      the VMTEMPLATE belonging to the user in ONE_AUTH
        g, group     'mine' plus the VMTEMPLATE belonging to the groups
                     the user is member of
        uid          VMTEMPLATE of the user identified by this uid
        user         VMTEMPLATE of the user identified by the username

If you don’t mind installing xmlstarlet, you can use it to do this kind of filtering (pretty much anything you can write XPath for) - e.g.

onevnet list -x | xmlstarlet sel -T -t -m "/VNET_POOL/VNET[CLUSTER_ID=0]" -v "concat(ID,',',UNAME,',',NAME,',',CLUSTER)" -n | column -s, -t

(change the cluster ID to the cluster you want to filter for)

Paul Batchelor opennebula@discoursemail.com writes:

If you don’t mind installing xmlstarlet, you can use it to do this kind of filtering (pretty much anything you can write XPath for) - e.g.

onevnet list -x | xmlstarlet sel -T -t -m "/VNET_POOL/VNET[CLUSTER_ID=0]" -v "concat(ID,',',UNAME,',',NAME,',',CLUSTER)" -n | column -s, -t

(change the cluster ID to the cluster you want to filter for)

I mostly wrote bash scripts with xpath utility to make some sysadmin
work.

Now I’m progressively switching to ruby API like for my hooks[1].

Regards.

Footnotes:
[1] Backlog #4437: Automatically create first initial snapshot - OpenNebula - OpenNebula Development pages

Daniel Dehennin
Récupérer ma clef GPG: gpg --recv-keys 0xCC1E9E5B7A6FE2DF
Fingerprint: 3E69 014E 5C23 50E8 9ED6 2AAD CC1E 9E5B 7A6F E2DF