Skip to content

Commit

Permalink
move version check to another place, thanks to @s-hertel
Browse files Browse the repository at this point in the history
  • Loading branch information
stefangweichinger committed Jun 21, 2021
1 parent e15f68c commit faa7f94
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lxc_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ def __init__(self, play_context, new_stdin, *args, **kwargs):
self.user = self._play_context.remote_user
self.control_path = None
self.control_path_dir = None
self.lxc_version = None

def _set_version(self):
# LXC v1 uses 'lxc-info', 'lxc-attach' and so on
# LXC v2 uses just 'lxc'
(returncode2, stdout2, stderr2) = self._exec_command("which lxc", None, False)
Expand All @@ -535,6 +535,10 @@ def __init__(self, play_context, new_stdin, *args, **kwargs):
raise AnsibleConnectionFailure("Cannot identify LXC version")
sys.exit(1)

def set_options(self, *args, **kwargs):
super(Connection, self).set_options(*args, **kwargs)
self._set_version()

# The connection is created by running ssh/scp/sftp from the exec_command,
# put_file, and fetch_file methods, so we don't need to do any connection
# management here.
Expand Down

0 comments on commit faa7f94

Please sign in to comment.