# Using filterflag on CLI

**URL:** <https://forum.opennebula.io/t/using-filterflag-on-cli/2804>\
**Category:** Product Support\
**Created:** [August 22, 2016, 2:57pm UTC](https://forum.opennebula.io/t/using-filterflag-on-cli/2804 "2016-08-22T14:57:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaD](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/dad/32/8466_2.png) [@DaD](https://forum.opennebula.io/u/DaD)\
**Post date:** [August 22, 2016, 2:57pm UTC](https://forum.opennebula.io/t/using-filterflag-on-cli/2804/1 "2016-08-22T14:57:45Z")

</div>

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](http://docs.opennebula.org/doc/5.0/cli/onevnet.1.html) 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.

---

<div class="post-metadata">

**Author:** ![cmartin](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/cmartin/32/4278_2.png) [@cmartin](https://forum.opennebula.io/u/cmartin)\
**Post date:** [August 23, 2016, 2:28pm UTC](https://forum.opennebula.io/t/using-filterflag-on-cli/2804/2 "2016-08-23T14:28:03Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![Paul\_Batchelor](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/paul_batchelor/32/4193_2.png) [@Paul\_Batchelor](https://forum.opennebula.io/u/Paul_Batchelor)\
**Post date:** [August 25, 2016, 9:43am UTC](https://forum.opennebula.io/t/using-filterflag-on-cli/2804/3 "2016-08-25T09:43:56Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![DaD](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/dad/32/8466_2.png) [@DaD](https://forum.opennebula.io/u/DaD)\
**Post date:** [August 25, 2016, 9:59am UTC](https://forum.opennebula.io/t/using-filterflag-on-cli/2804/4 "2016-08-25T09:59:41Z")

</div>

Paul Batchelor [opennebula@discoursemail.com](mailto: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](https://dev.opennebula.org/issues/4437)

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