Skip to content

computer configure --non-interactive asks for safe interval despite default value #3273

Open
@ltalirz

Description

@ltalirz

When running verdi computer configure local localhost interactively, I get a default value for the connection cooldown time.

However, this throws an exception:

$ verdi computer configure local localhost -n
Usage: verdi computer configure local [OPTIONS] COMPUTER

Error: Missing option "--safe-interval".

This is unexpected, since it should simply take the default value in non-interactive mode.

I thought that was an easy fix and started looking into the code, only to encounter the fact that the cli setup for transport plugins is really convoluted.

In particular, the options are translated from some custom internal key/value representation

_valid_connect_options = [
('username', {'prompt': 'User name', 'help': 'user name for the computer', 'non_interactive_default': True}),
('port', {'option': options.PORT, 'prompt': 'port Nr', 'non_interactive_default': True}),
('look_for_keys', {'switch': True, 'prompt': 'Look for keys', 'help': 'switch automatic key file discovery on / off', 'non_interactive_default': True}),
('key_filename', {'type': AbsolutePathParamType(dir_okay=False, exists=True), 'prompt': 'SSH key file', 'help': 'Manually pass a key file if default path is not set in ssh config', 'non_interactive_default': True}),
('timeout', {'type': int, 'prompt': 'Connection timeout in s', 'help': 'time in seconds to wait for connection before giving up', 'non_interactive_default': True}),
('allow_agent', {'switch': True, 'prompt': 'Allow ssh agent', 'help': 'switch to allow or disallow ssh agent', 'non_interactive_default': True}),
('proxy_command', {'prompt': 'SSH proxy command', 'help': 'SSH proxy command', 'non_interactive_default': True}), # Managed 'manually' in connect
('compress', {'switch': True, 'prompt': 'Compress file transfers', 'help': 'switch file transfer compression on / off', 'non_interactive_default': True}),
('gss_auth', {'type': bool, 'prompt': 'GSS auth', 'help': 'GSS auth for kerberos', 'non_interactive_default': True}),
('gss_kex', {'type': bool, 'prompt': 'GSS kex', 'help': 'GSS kex for kerberos', 'non_interactive_default': True}),
('gss_deleg_creds', {'type': bool, 'prompt': 'GSS deleg_creds', 'help': 'GSS deleg_creds for kerberos', 'non_interactive_default': True}),
('gss_host', {'prompt': 'GSS host', 'help': 'GSS host for kerberos', 'non_interactive_default': True}),
# for Kerberos support through python-gssapi
]

_common_auth_options = [(
'safe_interval', {
'type': float,
'prompt': 'Connection cooldown time (s)',
'help': 'Minimum time interval in seconds between consecutive connection openings',
'callback': validate_positive_number
}
)]

to click using a lot of "machinery".
Is this really necessary?

This isn't high-priority but couldn't we just use the simpler approach from data plugins, where a plugin simply adds a new command to an existing group?

Mentioning @giovannipizzi @sphuber for comment.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions