summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Falcon <TheRealFalcon@users.noreply.github.com>2021-03-03 14:40:07 -0600
committerGitHub <noreply@github.com>2021-03-03 15:40:07 -0500
commit3dd3de7c381e870c6bc9b9b7a84d452b57594686 (patch)
tree522013f77ac57a9976b7694f30eadc9cee6c7516
parent3be666306023caf6f236464fb655741b6605bdf7 (diff)
downloadvyos-cloud-init-3dd3de7c381e870c6bc9b9b7a84d452b57594686.tar.gz
vyos-cloud-init-3dd3de7c381e870c6bc9b9b7a84d452b57594686.zip
integration_tests: add OpenStack as a platform (#804)
-rw-r--r--integration-requirements.txt2
-rw-r--r--tests/integration_tests/clouds.py42
-rw-r--r--tests/integration_tests/conftest.py2
-rw-r--r--tests/integration_tests/integration_settings.py8
4 files changed, 51 insertions, 3 deletions
diff --git a/integration-requirements.txt b/integration-requirements.txt
index 6b596426..fb4c3ba1 100644
--- a/integration-requirements.txt
+++ b/integration-requirements.txt
@@ -1,5 +1,5 @@
# PyPI requirements for cloud-init integration testing
# https://cloudinit.readthedocs.io/en/latest/topics/integration_tests.html
#
-pycloudlib @ git+https://github.com/canonical/pycloudlib.git@da8445325875674394ffd85aaefaa3d2d0e0020d
+pycloudlib @ git+https://github.com/canonical/pycloudlib.git@5975c7e60be4a1e95814909a35592634cc145938
pytest
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
diff --git a/tests/integration_tests/conftest.py b/tests/integration_tests/conftest.py
index 61ad8a71..0b93c94f 100644
--- a/tests/integration_tests/conftest.py
+++ b/tests/integration_tests/conftest.py
@@ -20,6 +20,7 @@ from tests.integration_tests.clouds import (
LxdVmCloud,
OciCloud,
_LxdIntegrationCloud,
+ OpenstackCloud,
)
from tests.integration_tests.instances import (
CloudInitSource,
@@ -38,6 +39,7 @@ platforms = {
'oci': OciCloud,
'lxd_container': LxdContainerCloud,
'lxd_vm': LxdVmCloud,
+ 'openstack': OpenstackCloud,
}
os_list = ["ubuntu"]
diff --git a/tests/integration_tests/integration_settings.py b/tests/integration_tests/integration_settings.py
index 157d34ad..0703be58 100644
--- a/tests/integration_tests/integration_settings.py
+++ b/tests/integration_tests/integration_settings.py
@@ -21,6 +21,7 @@ RUN_UNSTABLE = False
# ec2
# gce
# oci
+# openstack
PLATFORM = 'lxd_container'
# The cloud-specific instance type to run. E.g., a1.medium on AWS
@@ -90,6 +91,13 @@ PUBLIC_SSH_KEY = None
KEYPAIR_NAME = None
##################################################################
+# OPENSTACK SETTINGS
+##################################################################
+# Network to use for Openstack. Should be one of the names/ids found
+# in `openstack network list`
+OPENSTACK_NETWORK = None
+
+##################################################################
# USER SETTINGS OVERRIDES
##################################################################
# Bring in any user-file defined settings