summaryrefslogtreecommitdiff
path: root/tests/integration_tests/clouds.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration_tests/clouds.py')
-rw-r--r--tests/integration_tests/clouds.py44
1 files changed, 42 insertions, 2 deletions
diff --git a/tests/integration_tests/clouds.py b/tests/integration_tests/clouds.py
index fe89c0c6..2841261b 100644
--- a/tests/integration_tests/clouds.py
+++ b/tests/integration_tests/clouds.py
@@ -4,6 +4,8 @@ import logging
from pycloudlib import EC2, GCE, Azure, OCI, LXD
+import cloudinit
+from cloudinit.subp import subp
from tests.integration_tests import integration_settings
from tests.integration_tests.instances import (
IntegrationEc2Instance,
@@ -55,6 +57,11 @@ class IntegrationCloud(ABC):
pass
return image_id
+ def _perform_launch(self, launch_kwargs):
+ pycloudlib_instance = self.cloud_instance.launch(**launch_kwargs)
+ pycloudlib_instance.wait(raise_on_cloudinit_failure=False)
+ return pycloudlib_instance
+
def launch(self, user_data=None, launch_kwargs=None,
settings=integration_settings):
if self.settings.EXISTING_INSTANCE_ID:
@@ -77,8 +84,9 @@ class IntegrationCloud(ABC):
"\n".join("{}={}".format(*item) for item in kwargs.items())
)
)
- pycloudlib_instance = self.cloud_instance.launch(**kwargs)
- pycloudlib_instance.wait(raise_on_cloudinit_failure=False)
+
+ pycloudlib_instance = self._perform_launch(kwargs)
+
log.info('Launched instance: %s', pycloudlib_instance)
return self.get_instance(pycloudlib_instance, settings)
@@ -141,3 +149,35 @@ class LxdContainerCloud(IntegrationCloud):
def _get_cloud_instance(self):
return LXD(tag='lxd-integration-test')
+
+ def _perform_launch(self, launch_kwargs):
+ launch_kwargs['inst_type'] = launch_kwargs.pop('instance_type', None)
+ launch_kwargs.pop('wait')
+
+ pycloudlib_instance = self.cloud_instance.init(
+ launch_kwargs.pop('name', None),
+ launch_kwargs.pop('image_id'),
+ **launch_kwargs
+ )
+ if self.settings.CLOUD_INIT_SOURCE == 'IN_PLACE':
+ self._mount_source(pycloudlib_instance)
+ pycloudlib_instance.start(wait=False)
+ pycloudlib_instance.wait(raise_on_cloudinit_failure=False)
+ return pycloudlib_instance
+
+ def _mount_source(self, instance):
+ container_path = '/usr/lib/python3/dist-packages/cloudinit'
+ format_variables = {
+ 'name': instance.name,
+ 'cloudinit_path': cloudinit.__path__[0],
+ 'container_path': container_path,
+ }
+ log.info(
+ 'Mounting source {cloudinit_path} directly onto LXD container/vm '
+ 'named {name} at {container_path}'.format(**format_variables))
+ command = (
+ 'lxc config device add {name} host-cloud-init disk '
+ 'source={cloudinit_path} '
+ 'path={container_path}'
+ ).format(**format_variables)
+ subp(command.split())