Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Improve 'vcd search' #575

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

odraghi
Copy link

@odraghi odraghi commented Oct 5, 2022

New options for 'vcd search':
-t, --fields [fields] fields to show
--show-id / --hide-id show id [default: show-id]
--sort-asc [field] sort in ascending order on a field
--sort-desc [field] sort in descending order on a field

I also create a function 'query' to import it in other script.
It's a good way to speedup other command with this function.
Futur use cases:

  • implementation of 'vm list' (I've already code this in my fork)
  • speedup of 'vcd org list' as a provider when there is a lot of organization (current code take 24s for 102 orgs)

Allow to hide id with '--do-not-show-id'.
Allow to call _search() function from other click commands.
( useful to implement 'vm list' )

Signed-off-by: Olivier DRAGHI <[email protected]>
Add sort-asc and sort-desc to 'vcd search'.

Signed-off-by: Olivier DRAGHI <[email protected]>
Rename function _search by query to be proprely called by other script

Signed-off-by: Olivier DRAGHI <[email protected]>
@odraghi odraghi changed the title Imporve 'vcd search' Improve 'vcd search' Oct 5, 2022
In --fields option, you can now specify custom name with 'as'.

exemple:
vcd search vm --fields 'name,ownerName as owner,isAutoNature as standalone'
name          owner    standalone
------------  -------  ------------
web1          johndoe  flase
web2          johndoe  flase
bdd           johndoe  true

Signed-off-by: Olivier DRAGHI <[email protected]>
AttributeError: 'dict_keys' object has no attribute 'remove'

When sort_headers=False headers need to be a list to call remove()

Signed-off-by: Olivier DRAGHI <[email protected]>
Init field with a default of None.

For exemple query api 'vm' doesn't return ipAddress if the vm do not have newtork interface.

Signed-off-by: Olivier DRAGHI <[email protected]>
Add option --sort-next to add sort on a second field.
This option must be used with --sort-asc or --sort-desc

Signed-off-by: Olivier DRAGHI <[email protected]>
Change in query():
- Remove param show_id
- Don't show the result but return it to the caller

This add flexibility to the caller.

Signed-off-by: Olivier DRAGHI <[email protected]>
Signed-off-by: Olivier DRAGHI <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant