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.py42
1 files changed, 40 insertions, 2 deletions
diff --git a/tests/integration_tests/clouds.py b/tests/integration_tests/clouds.py
index 9527a413..09a44b3c 100644
--- a/tests/integration_tests/clouds.py
+++ b/tests/integration_tests/clouds.py
@@ -1,8 +1,17 @@
# This file is part of cloud-init. See LICENSE file for license information.
from abc import ABC, abstractmethod
import logging
-
-from pycloudlib import EC2, GCE, Azure, OCI, LXDContainer, LXDVirtualMachine
+from uuid import UUID
+
+from pycloudlib import (
+ EC2,
+ GCE,
+ Azure,
+ OCI,
+ LXDContainer,
+ LXDVirtualMachine,
+ Openstack,
+)
from pycloudlib.lxd.instance import LXDInstance
import cloudinit
@@ -311,3 +320,32 @@ class LxdVmCloud(_LxdIntegrationCloud):
self._profile_list = self.cloud_instance.build_necessary_profiles(
release)
return self._profile_list
+
+
+class OpenstackCloud(IntegrationCloud):
+ datasource = 'openstack'
+ integration_instance_cls = IntegrationInstance
+
+ def _get_cloud_instance(self):
+ if not integration_settings.OPENSTACK_NETWORK:
+ raise Exception(
+ 'OPENSTACK_NETWORK must be set to a valid Openstack network. '
+ 'If using the openstack CLI, try `openstack network list`'
+ )
+ return Openstack(
+ tag='openstack-integration-test',
+ network=integration_settings.OPENSTACK_NETWORK,
+ )
+
+ def _get_initial_image(self):
+ image = ImageSpecification.from_os_image()
+ try:
+ UUID(image.image_id)
+ except ValueError as e:
+ raise Exception(
+ 'When using Openstack, `OS_IMAGE` MUST be specified with '
+ 'a 36-character UUID image ID. Passing in a release name is '
+ 'not valid here.\n'
+ 'OS image id: {}'.format(image.image_id)
+ ) from e
+ return image.image_id