issue #510: add mitogen_container_name= variable.

issue510
David Wilson 6 years ago
parent d763570ca2
commit 01840fd0b0

@ -123,7 +123,10 @@ def _connect_docker(spec):
'method': 'docker',
'kwargs': {
'username': spec.remote_user(),
'container': spec.remote_addr(),
'container': (
spec.mitogen_container_name() or
spec.remote_addr()
),
'python_path': spec.python_path(),
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
}
@ -137,7 +140,10 @@ def _connect_kubectl(spec):
return {
'method': 'kubectl',
'kwargs': {
'pod': spec.remote_addr(),
'pod': (
spec.mitogen_container_name() or
spec.remote_addr()
),
'python_path': spec.python_path(),
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
'kubectl_path': spec.mitogen_kubectl_path(),
@ -154,7 +160,10 @@ def _connect_jail(spec):
'method': 'jail',
'kwargs': {
'username': spec.remote_user(),
'container': spec.remote_addr(),
'container': (
spec.mitogen_container_name() or
spec.remote_addr()
),
'python_path': spec.python_path(),
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
}
@ -168,7 +177,10 @@ def _connect_lxc(spec):
return {
'method': 'lxc',
'kwargs': {
'container': spec.remote_addr(),
'container': (
spec.mitogen_container_name() or
spec.remote_addr()
),
'python_path': spec.python_path(),
'lxc_attach_path': spec.mitogen_lxc_attach_path(),
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
@ -183,7 +195,10 @@ def _connect_lxd(spec):
return {
'method': 'lxd',
'kwargs': {
'container': spec.remote_addr(),
'container': (
spec.mitogen_container_name() or
spec.remote_addr()
),
'python_path': spec.python_path(),
'lxc_path': spec.mitogen_lxc_path(),
'connect_timeout': spec.ansible_ssh_timeout() or spec.timeout(),
@ -205,7 +220,10 @@ def _connect_setns(spec, kind=None):
return {
'method': 'setns',
'kwargs': {
'container': spec.remote_addr(),
'container': (
spec.mitogen_container_name() or
spec.remote_addr()
),
'username': spec.remote_user(),
'python_path': spec.python_path(),
'kind': kind or spec.mitogen_kind(),

@ -273,6 +273,13 @@ class Spec(with_metaclass(abc.ABCMeta, object)):
The SSH debug level.
"""
@abc.abstractmethod
def mitogen_container_name(self):
"""
Highest precedence variable for specifying the name of a container to
connect to.
"""
@abc.abstractmethod
def extra_args(self):
"""
@ -398,6 +405,9 @@ class PlayContextSpec(Spec):
def mitogen_ssh_debug_level(self):
return self._connection.get_task_var('mitogen_ssh_debug_level')
def mitogen_container_name(self):
return self._connection.get_task_var('mitogen_container_name')
def extra_args(self):
return self._connection.get_extra_args()
@ -577,5 +587,8 @@ class MitogenViaSpec(Spec):
def mitogen_ssh_debug_level(self):
return self._host_vars.get('mitogen_ssh_debug_level')
def mitogen_container_name(self):
return self._host_vars.get('mitogen_container_name')
def extra_args(self):
return [] # TODO

Loading…
Cancel
Save