Skip to content

Add 'keepalive' option to SSHClientBase() #31

@dis-xcom

Description

@dis-xcom

SSHClientBase can re-use existing connection to the node if exists, or create a new one.
But it doesn't close the opened connections if the class is used as a context manager. This allows to use many different ssh accesses to the same nodes without re-connecting for each command.

Existing approach is suitable for small amount of nodes when many different ssh command are using the same connections.
For cases when there are many different nodes, it will be necessary to close the connections after leaving the SSHClient context.

Let's add to the SSHClientBase() a new option: 'keepalive', default to True, which will leave the existing connection working if True, and close the existing connection after leaving the context manager if False.

For example:

remote = SSHClient(....)
with remote.keepalive(enforce=True):  # default
   # connection will be preserved at the context exit
   ...
with remote.keepalive(enforce=False):
   # connection will be closed at the context exit
   ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions