summaryrefslogtreecommitdiff
path: root/tests/integration_tests/clouds.py
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2021-01-06 16:19:15 -0500
committerGitHub <noreply@github.com>2021-01-06 16:19:15 -0500
commite5c67478136e1942a981ee18785ceb26579d0041 (patch)
treecfe45c5bbac1c30faaa4b859f92de077147ae4f8 /tests/integration_tests/clouds.py
parent48b2c5f16bd4ef754fef137ea19894908d4bf1db (diff)
downloadvyos-cloud-init-e5c67478136e1942a981ee18785ceb26579d0041.tar.gz
vyos-cloud-init-e5c67478136e1942a981ee18785ceb26579d0041.zip
integration_tests: add SSH key selection settings (#754)
This introduces PUBLIC_SSH_KEY, to configure what public SSH key should be used to access systems under test, and KEYPAIR_NAME, to configure the name used in clouds for that SSH key (or the default SSH key, in PUBLIC_SSH_KEY's absence).
Diffstat (limited to 'tests/integration_tests/clouds.py')
-rw-r--r--tests/integration_tests/clouds.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/integration_tests/clouds.py b/tests/integration_tests/clouds.py
index 9f6a6380..8ae20442 100644
--- a/tests/integration_tests/clouds.py
+++ b/tests/integration_tests/clouds.py
@@ -91,6 +91,15 @@ class IntegrationCloud(ABC):
def __init__(self, settings=integration_settings):
self.settings = settings
self.cloud_instance = self._get_cloud_instance()
+ if settings.PUBLIC_SSH_KEY is not None:
+ # If we have a non-default key, use it.
+ self.cloud_instance.use_key(
+ settings.PUBLIC_SSH_KEY, name=settings.KEYPAIR_NAME
+ )
+ elif settings.KEYPAIR_NAME is not None:
+ # Even if we're using the default key, it may still have a
+ # different name in the clouds, so we need to set it separately.
+ self.cloud_instance.key_pair.name = settings.KEYPAIR_NAME
self._released_image_id = self._get_initial_image()
self.snapshot_id = None