LINBIT / linstor-client

Python client for LINSTOR
https://docs.linbit.com/docs/linstor-guide/
GNU General Public License v3.0
22 stars 10 forks source link

Feature request: Get resources by aux-property, show all aux-properties #22

Closed kvaps closed 4 years ago

kvaps commented 5 years ago

The same way like kubectl is working with kubernetes labels:

Get all nodes with Aux/cluster set:

linstor node list -l cluster

Get all nodes with Aux/cluster=1

linstor node list -l cluster=1

Show all aux properties for all nodes:

linstor node list --show-aux-properties
raltnoeder commented 5 years ago

This could possibly be implemented as a filter to the list command on the client side, but will have roughly O(n*m) time and space complexity for n objects with m properties (like the list command if all properties are included), since object properties were not designed to serve as an index for looking up the objects they are associated with. Implementing it on the controller side would serve little purpose, since the disadvantages of doing that outweigh any advantages this would have.

kvaps commented 4 years ago

Anyway, this function would be quite usable for us, we're separating our nodes by roles and availability zones using aux-properties, it would be nice to have an ability to list all the nodes in one availability zone

kvaps commented 4 years ago

BTW here is an example how to get at least somehow grepable output:

linstor -m n l | jq -rc '.[].nodes[] | "\(.name) \([ (.props[] | select(.key | contains("Aux"))) ] | from_entries)"' | sed -e 's/\([{}"]\|Aux\/\)//g' | tr : =

example output:

m1c4 side=a,moonshot=1
m1c5 side=a,moonshot=1
m1c6 side=a,hosting=true,moonshot=1
m1c7 side=b,hosting=true,moonshot=1
m1c8 side=b,hosting=true,moonshot=1
m1c9 side=b,hosting=true,moonshot=1
pve1 
pve2 
pve3 
ddpolyakov commented 4 years ago

This could be very useful in many production cases. Multi-DC, fault domains etc.

frenzymind commented 4 years ago

Yes, it would be nice to have this this feature!

rp- commented 4 years ago

--props and --show-aux-properties was added with release 1.7.0 and 1.1.0