Due to this code:
|
def _run_command(self, command, stdin): |
|
"""Run command in the instance.""" |
|
if self.key_pair: |
|
return super()._run_command(command, stdin) |
|
|
|
base_cmd = [ |
|
'lxc', 'exec', self.name, '--', 'sudo', '-u', self.username, '--' |
|
] |
|
return subp(base_cmd + list(command), rcs=None) |
This also interacts badly with LXD's SSH key defaults. For most clouds, the key_pair used by default is
|
self.key_pair = KeyPair( |
|
'/home/%s/.ssh/id_rsa.pub' % _username, name=_username |
|
) |
LXD, however, has a different default:
|
# User must manually specify the key pair to be used |
|
self.key_pair = None |
This means that in the default case, LXD will
exec. In itself, this is not a problem.
However, it also means that if a consumer chooses to specify a non-default key (via .use_key), LXD's behaviour changes. self.key_pair is no longer None, and so LXD will start using SSH to access instances.
This is biting us in the cloud-init integration testing: we have a configuration option to specify an SSH key (and we call use_key if provided). If it isn't set, then we want to use pycloudlib's default (i.e. we don't call use_key at all). This means that users who do specify the configuration option see test failures on LXD: we rely on the fact that LXD does not require functioning networking to access the instance for some tests, and so using SSH (as pycloudlib does for such users) is guaranteed to fail.
Due to this code:
pycloudlib/pycloudlib/lxd/instance.py
Lines 31 to 39 in 1ac9d4c
This also interacts badly with LXD's SSH key defaults. For most clouds, the
key_pairused by default ispycloudlib/pycloudlib/cloud.py
Lines 30 to 32 in 1ac9d4c
pycloudlib/pycloudlib/lxd/cloud.py
Lines 49 to 50 in 1ac9d4c
exec. In itself, this is not a problem.However, it also means that if a consumer chooses to specify a non-default key (via
.use_key), LXD's behaviour changes.self.key_pairis no longerNone, and so LXD will start using SSH to access instances.This is biting us in the cloud-init integration testing: we have a configuration option to specify an SSH key (and we call
use_keyif provided). If it isn't set, then we want to use pycloudlib's default (i.e. we don't calluse_keyat all). This means that users who do specify the configuration option see test failures on LXD: we rely on the fact that LXD does not require functioning networking to access the instance for some tests, and so using SSH (as pycloudlib does for such users) is guaranteed to fail.