Merge "Add CentOS 7 cloud image support"

This commit is contained in:
Zuul 2021-06-29 19:43:45 +00:00 committed by Gerrit Code Review
commit 02f1f0d8a0
4 changed files with 39 additions and 9 deletions

View File

@ -28,6 +28,7 @@ OPTIONS = [
GLANCE_IMAGE_NAMES = ['centos',
'centos7',
'cirros',
'rhel',
'ubuntu']

View File

@ -28,6 +28,7 @@ from tobiko.openstack.stacks import _ubuntu
CentosFlavorStackFixture = _centos.CentosFlavorStackFixture
CentosImageFixture = _centos.CentosImageFixture
CentosServerStackFixture = _centos.CentosServerStackFixture
Centos7ServerStackFixture = _centos.Centos7ServerStackFixture
CirrosFlavorStackFixture = _cirros.CirrosFlavorStackFixture
CirrosImageFixture = _cirros.CirrosImageFixture

View File

@ -38,8 +38,25 @@ class CentosImageFixture(glance.URLGlanceImageFixture):
connection_timeout = CONF.tobiko.centos.connection_timeout or 800.
CENTOS7_IMAGE_URL = (
'https://cloud.centos.org/centos/7/images/'
'CentOS-7-x86_64-GenericCloud.qcow2.xz')
class Centos7ImageFixture(glance.URLGlanceImageFixture):
image_url = CONF.tobiko.centos7.image_url or CENTOS7_IMAGE_URL
image_name = CONF.tobiko.centos7.image_name
image_file = CONF.tobiko.centos7.image_file
disk_format = CONF.tobiko.centos7.disk_format or "qcow2"
container_format = CONF.tobiko.centos7.container_format or "bare"
username = CONF.tobiko.centos7.username or 'centos'
password = CONF.tobiko.centos7.password
connection_timeout = CONF.tobiko.centos7.connection_timeout or 800.
class CentosFlavorStackFixture(_nova.FlavorStackFixture):
ram = 256
swap = 1024
class CentosServerStackFixture(_nova.CloudInitServerStackFixture):
@ -50,5 +67,8 @@ class CentosServerStackFixture(_nova.CloudInitServerStackFixture):
#: Flavor used to create a Nova server instance
flavor_stack = tobiko.required_setup_fixture(CentosFlavorStackFixture)
#: Setup SWAP file in bytes
swap_maxsize = 1 * 1024 * 1024 * 1024 # 1 GB
class Centos7ServerStackFixture(CentosServerStackFixture):
#: Glance image used to create a Nova server instance
image_fixture = tobiko.required_setup_fixture(Centos7ImageFixture)

View File

@ -15,8 +15,6 @@
# under the License.
from __future__ import absolute_import
import yaml
import tobiko
from tobiko.shell import sh
from tobiko.openstack import keystone
@ -34,12 +32,9 @@ class CentosServerStackTest(test_cirros.CirrosServerStackTest):
def test_user_data(self):
user_data = self.stack.user_data
self.assertIsInstance(user_data, str)
self.assertTrue(user_data.startswith('#cloud-config\n'), user_data)
self.assertEqual(self.stack.cloud_config,
yaml.safe_load(user_data))
self.assertEqual('', user_data)
def test_platform_python(self):
def test_python(self):
python_version = sh.execute(['/usr/libexec/platform-python',
'--version'],
ssh_client=self.stack.ssh_client).stdout
@ -48,3 +43,16 @@ class CentosServerStackTest(test_cirros.CirrosServerStackTest):
def test_cloud_init_done(self):
nova.wait_for_cloud_init_done(ssh_client=self.stack.ssh_client)
@keystone.skip_unless_has_keystone_credentials()
class Centos7ServerStackTest(CentosServerStackTest):
#: Stack of resources with a server attached to a floating IP
stack = tobiko.required_setup_fixture(stacks.Centos7ServerStackFixture)
def test_python(self):
python_version = sh.execute(['python', '--version'],
ssh_client=self.stack.ssh_client).stderr
self.assertTrue(python_version.startswith('Python 2.'),
python_version)