apache / cloudstack-cloudmonkey

Apache Cloudstack Cloudmonkey
Apache License 2.0
91 stars 60 forks source link

Provide "NOT" option when querying with cmk #125

Closed serverchief closed 1 year ago

serverchief commented 1 year ago

Lets take listHosts as an example, when running list hosts resourcestate=Enabled state=Up, requires for end user to memorize (or lookup) and separately query other states.

Perhaps we can use NOT (!) operand and do something like this?

list hosts zoneid=33333-4444-5555-1111-2222222 resourcestate=!Enabled state=!Up

this would print all hosts that are NOT Enabled and NOT Up...

rohityadavcloud commented 1 year ago

cmk is fundamentally a dumb CLI that just calls an API and processes the API response, and for API requests it doesn't know what a non-Enabled resourcestate could be. Instead, you can use something like jq to filter out hosts you don't need from the json response. Something like this would be a very large feature (implemented in the backend or CLI). Any PRs and other ideas are welcome!

DaanHoogland commented 1 year ago

I think this is most definately an API request and not a cmk one. If to be implemented in cmk it would be part of an extension on the filter option. There is anothe request for the filter option open (also a larger feature)

rohityadavcloud commented 1 year ago

Based on the discussion, it won't be possible to implement this feature in cmk. It's possible only if the API server (mgmt server) allow for such a feature, for now workaround may be possible by piping the cmk output to something like jq etc.