Browse Source

Support another OpenStack provider

keep-around/d26764880622b6bea4dddfb365852696311ccb0e
Pierre-Louis Bonicoli 8 months ago
parent
commit
d267648806
No known key found for this signature in database GPG Key ID: 6914C4A5EDAA6DD
  1. 9
      conftest.py
  2. 1
      enough/common/__init__.py
  3. 10
      enough/common/dotenough.py
  4. 3
      enough/common/host.py
  5. 36
      enough/common/openstack.py
  6. 6
      enough/common/options.py
  7. 3
      enough/common/service.py
  8. 3
      enough/common/ssh.py
  9. 6
      enough/internal/cli/backup.py
  10. 32
      inventory/group_vars/all/openstack.yml
  11. 1
      inventory/group_vars/copy-group.yml
  12. 2
      inventory/host_vars/forum-host/provision.yml
  13. 2
      inventory/host_vars/gitlab-host/provision.yml
  14. 2
      inventory/host_vars/openedx-host/provision.yml
  15. 2
      inventory/host_vars/packages-host/provision.yml
  16. 2
      inventory/host_vars/runner-host/provision.yml
  17. 5
      playbooks/conftest.py
  18. 5
      playbooks/infrastructure/template-host.yaml
  19. 26
      tests/enough/common/conftest.py
  20. 5
      tests/enough/common/test_common_host.py
  21. 3
      tests/enough/common/test_common_service.py
  22. 13
      tests/enough/common/test_common_ssh.py
  23. 72
      tests/enough/common/test_init.py
  24. 42
      tests/enough/common/test_openstack.py

9
conftest.py

@ -7,3 +7,12 @@ from tests.icinga_helper import IcingaHelper
def pytest_configure(config):
IcingaHelper.set_ansible_inventory(config.getoption("--ansible-inventory"))
IcingaHelper.set_ssh_identity_file(config.getoption("--ssh-identity-file"))
def pytest_addoption(parser):
parser.addoption(
'--provider',
choices=('fuga', 'ovh'),
default='ovh',
help='Name of the OpenStack provider used for the tests'
)

1
enough/common/__init__.py

@ -127,6 +127,7 @@ class Enough(object):
kwargs = {
'driver': self.args['driver'],
'domain': target_domain,
'provider': self.args['provider'],
}
clone = Enough(config_dir, self.share_dir, **kwargs)
return clone

10
enough/common/dotenough.py

@ -137,9 +137,10 @@ class DotEnough(object):
class DotEnoughOpenStack(DotEnough):
def __init__(self, config_dir, domain):
def __init__(self, config_dir, domain, provider):
super().__init__(config_dir, domain)
self.clouds_file = f'{self.config_dir}/inventory/group_vars/all/clouds.yml'
self.provider = provider
def set_clouds_file(self, clouds_file):
shutil.copy(clouds_file, self.clouds_file)
@ -149,6 +150,13 @@ class DotEnoughOpenStack(DotEnough):
self.populate_config('letsencrypt')
self.set_missing_config_file_from_openrc(f'{self.config_dir}/openrc.sh', self.clouds_file)
d = f'{self.config_dir}/inventory/group_vars/all'
if not os.path.exists(f'{d}/openstack-provider.yml'):
open(f'{d}/openstack-provider.yml', 'w').write(textwrap.dedent(f"""\
---
openstack_provider: {self.provider}
"""))
@staticmethod
def set_missing_config_file_from_openrc(openrc, config_file):
if os.path.exists(openrc) and not os.path.exists(config_file):

3
enough/common/host.py

@ -79,7 +79,8 @@ class HostOpenStack(Host):
def __init__(self, config_dir, share_dir, **kwargs):
super().__init__(config_dir, share_dir, **kwargs)
self.args = kwargs
self.dotenough = dotenough.DotEnoughOpenStack(config_dir, self.args['domain'])
self.dotenough = dotenough.DotEnoughOpenStack(config_dir, self.args['domain'],
self.args['provider'])
self.dotenough.ensure()
def create_or_update(self):

36
enough/common/openstack.py

@ -79,7 +79,7 @@ class Stack(OpenStackBase):
if 'volumes' in d and int(d['volumes'][0]['size']) > 0:
parameters.append(f"--parameter=volume_size={d['volumes'][0]['size']}")
parameters.append(f"--parameter=volume_name={d['volumes'][0]['name']}")
if 'network' in d:
if d.get('network'):
parameters.append(f'--parameter=network={d["network"]}')
parameters.append(
f'--parameter=network_interface_unconfigured={d["network_interface_unconfigured"]}')
@ -195,31 +195,35 @@ class Heat(OpenStackBase):
return ansible.get_hostvars(variable=None)
def get_stack_definition(self, host):
h = self.get_stack_definitions()[host]
if h.get('network_internal_only', False):
network_interface_unconfigured = h.get('network_primary_interface', 'eth0')
network_interface_routed = h.get('network_secondary_interface', 'eth1')
hostvars = self.get_stack_definitions()[host]
return Heat.hostvars_to_stack(host, hostvars)
@staticmethod
def hostvars_to_stack(host, hv):
if hv.get('network_internal_only'):
network_interface_unconfigured = hv['network_primary_interface']
network_interface_routed = hv['network_secondary_interface']
network_interface_not_routed = 'noname'
else:
network_interface_unconfigured = 'noname'
network_interface_routed = h.get('network_primary_interface', 'eth0')
network_interface_not_routed = h.get('network_secondary_interface', 'eth1')
network_interface_routed = hv['network_primary_interface']
network_interface_not_routed = hv['network_secondary_interface']
definition = {
'name': host,
'port': h.get('ansible_port', '22'),
'flavor': h.get('openstack_flavor', 's1-2'),
'image': h.get('openstack_image', 'Debian 10'),
'network': h.get('openstack_network', 'Ext-Net'),
'network_internal_only': h.get('network_internal_only', False),
'port': hv.get('ansible_port', '22'),
'flavor': hv['openstack_flavor'],
'image': hv['openstack_image'],
'network': hv.get('openstack_network'),
'network_internal_only': hv.get('network_internal_only'),
'network_interface_unconfigured': network_interface_unconfigured,
'network_interface_routed': network_interface_routed,
'network_interface_not_routed': network_interface_not_routed,
'internal_network': OpenStackBase.INTERNAL_NETWORK,
'internal_network_cidr': h.get('openstack_internal_network_cidr',
OpenStackBase.INTERNAL_NETWORK_CIDR),
'internal_network_cidr': hv.get('openstack_internal_network_cidr',
OpenStackBase.INTERNAL_NETWORK_CIDR),
}
if 'openstack_volumes' in h:
definition['volumes'] = h['openstack_volumes']
if 'openstack_volumes' in hv:
definition['volumes'] = hv['openstack_volumes']
return definition
def host_from_volume(self, name):

6
enough/common/options.py

@ -7,4 +7,10 @@ def set_options(parser):
'--cloud',
default='production',
help='Name of the cloud in which resources are provisionned')
o.add_argument(
'--provider',
default='ovh',
choices=('fuga', 'ovh'),
help='Name of the OpenStack provider')
return parser

3
enough/common/service.py

@ -105,7 +105,8 @@ class ServiceOpenStack(Service):
def __init__(self, config_dir, share_dir, **kwargs):
super().__init__(config_dir, share_dir, **kwargs)
self.args = kwargs
self.dotenough = dotenough.DotEnoughOpenStack(config_dir, self.args['domain'])
self.dotenough = dotenough.DotEnoughOpenStack(config_dir, self.args['domain'],
self.args['provider'])
self.dotenough.ensure()
def maybe_delegate_dns(self):

3
enough/common/ssh.py

@ -11,7 +11,8 @@ class SSH(object):
self.args = kwargs
def ssh(self, host, args, interactive=True):
dot = dotenough.DotEnoughOpenStack(self.config_dir, self.args['domain'])
dot = dotenough.DotEnoughOpenStack(self.config_dir, self.args['domain'],
self.args['provider'])
hosts = dotenough.Hosts(self.config_dir)
ip = hosts.get_ip(host)
if not ip:

6
enough/internal/cli/backup.py

@ -21,7 +21,8 @@ class Create(Command):
def take_action(self, parsed_args):
args = vars(self.app.options)
args.update(vars(parsed_args))
d = dotenough.DotEnoughOpenStack(settings.CONFIG_DIR, args['domain'])
d = dotenough.DotEnoughOpenStack(settings.CONFIG_DIR, args['domain'],
args['provider'])
d.ensure()
o = OpenStack(settings.CONFIG_DIR, **args)
o.backup_create(args['volumes'])
@ -41,7 +42,8 @@ class Prune(Command):
def take_action(self, parsed_args):
args = vars(self.app.options)
args.update(vars(parsed_args))
d = dotenough.DotEnoughOpenStack(settings.CONFIG_DIR, args['domain'])
d = dotenough.DotEnoughOpenStack(settings.CONFIG_DIR, args['domain'],
args['provider'])
d.ensure()
o = OpenStack(settings.CONFIG_DIR, **args)
o.backup_prune(args['days'])

32
inventory/group_vars/all/openstack.yml

@ -7,3 +7,35 @@
# variable is defined in the clouds.yml file.
#
openstack_cloud: production
openstack_providers:
ovh:
flavors:
small: s1-2
medium: s1-4
large: s1-8
image: Debian 10
network: Ext-Net
network_primary_interface: eth0
network_secondary_interface: eth1
fuga:
flavors:
small: s3.small
medium: c3.small
large: t3.small
image: Debian 10.4.1
network: public
network_primary_interface: eth0
network_secondary_interface: eth1
_provider: "{{ openstack_provider|default(lookup('env', 'ENOUGH_PROVIDER'))|default('ovh', true) }}"
openstack_flavor_small: "{{ openstack_providers[_provider].flavors.small }}"
openstack_flavor_medium: "{{ openstack_providers[_provider].flavors.medium }}"
openstack_flavor_large: "{{ openstack_providers[_provider].flavors.large }}"
openstack_flavor: '{{ openstack_flavor_small }}'
openstack_image: "{{ openstack_providers[_provider].image }}"
openstack_network: "{{ openstack_providers[_provider].network }}"
network_primary_interface: "{{ openstack_providers[_provider].network_primary_interface }}"
network_secondary_interface: "{{ openstack_providers[_provider].network_secondary_interface }}"

1
inventory/group_vars/copy-group.yml

@ -1 +0,0 @@
openstack_network: Ext-Net

2
inventory/host_vars/forum-host/provision.yml

@ -1,2 +1,2 @@
---
openstack_flavor: s1-4
openstack_flavor: '{{ openstack_flavor_medium }}'

2
inventory/host_vars/gitlab-host/provision.yml

@ -1,3 +1,3 @@
---
ansible_port: 2222
openstack_flavor: s1-4
openstack_flavor: '{{ openstack_flavor_medium }}'

2
inventory/host_vars/openedx-host/provision.yml

@ -1,2 +1,2 @@
---
openstack_flavor: s1-8
openstack_flavor: '{{ openstack_flavor_large }}'

2
inventory/host_vars/packages-host/provision.yml

@ -1,2 +1,2 @@
---
openstack_flavor: s1-4
openstack_flavor: '{{ openstack_flavor_medium }}'

2
inventory/host_vars/runner-host/provision.yml

@ -1,2 +1,2 @@
---
openstack_flavor: s1-4
openstack_flavor: '{{ openstack_flavor_medium }}'

5
playbooks/conftest.py

@ -63,6 +63,8 @@ def get_hosts(session, enough):
def pytest_sessionstart(session):
service_directory = session.config.getoption("--enough-service")
provider = session.config.getoption("--provider")
os.environ['ENOUGH_PROVIDER'] = provider
domain = f'{service_directory}.test'
config_dir = prepare_config_dir(domain, session.config.cache)
@ -72,6 +74,7 @@ def pytest_sessionstart(session):
e = Enough(config_dir, '.',
domain=domain,
driver='openstack',
provider=provider,
inventory=[f'playbooks/{service_directory}/inventory'],
route_to_internal=False)
(needs_vpn, hosts) = get_hosts(session, e)
@ -115,11 +118,13 @@ def pytest_sessionfinish(session, exitstatus):
return
service_directory = session.config.getoption("--enough-service")
provider = session.config.getoption("--provider")
domain = f'{service_directory}.test'
config_dir = make_config_dir(domain, session.config.cache)
e = Enough(config_dir, '.',
domain=domain,
driver='openstack',
provider=provider,
inventory=[f'playbooks/{service_directory}/inventory'])
(_, hosts) = get_hosts(session, e)
e.host.delete_hosts(hosts)

5
playbooks/infrastructure/template-host.yaml

@ -9,15 +9,12 @@ parameters:
flavor:
type: string
default: "s1-2"
image:
type: string
default: "Debian 10"
network:
type: string
default: Ext-Net
network_interface_unconfigured:
type: string
@ -25,11 +22,9 @@ parameters:
network_interface_routed:
type: string
default: eth0
network_interface_not_routed:
type: string
default: eth1
public_key:
type: string

26
tests/enough/common/conftest.py

@ -1,3 +1,29 @@
import os
import pytest
from enough import settings
from enough.common import ansible_utils
def pytest_configure(config):
config.addinivalue_line("markers", "openstack_integration: mark tests "
"which require OpenStack credentials")
@pytest.fixture(scope='session')
def openstack_provider(request):
ansible = ansible_utils.Ansible(settings.CONFIG_DIR, settings.SHARE_DIR)
# enforce 'small' flavor
os_variables = ('openstack_flavor', 'openstack_image', 'openstack_network',
'network_primary_interface', 'network_secondary_interface',
'_provider')
os_variables = "{%s}" % ', '.join(f'"{x}": {x}' for x in os_variables)
try:
os.environ['ENOUGH_PROVIDER'] = request.config.option.provider
# Any host could be used
hostvars = ansible.get_variable(os_variables, 'bind-host')
finally:
del os.environ['ENOUGH_PROVIDER']
hostvars['openstack_provider'] = hostvars.pop('_provider')
return hostvars

5
tests/enough/common/test_common_host.py

@ -69,8 +69,9 @@ def test_docker_delete(tmpdir, docker_name, tcp_port):
assert count() == 0
def test_host_factory():
def test_host_factory(request):
h = host.host_factory(driver='docker', domain='a.b')
assert type(h).__name__ == 'HostDocker'
h = host.host_factory(driver='openstack', domain='a.b')
h = host.host_factory(driver='openstack', domain='a.b',
provider=request.config.option.provider)
assert type(h).__name__ == 'HostOpenStack'

3
tests/enough/common/test_common_service.py

@ -9,7 +9,7 @@ from enough.common import service
@pytest.mark.openstack_integration
def test_openstack_create_or_update(tmpdir, requests_mock):
def test_openstack_create_or_update(request, tmpdir, requests_mock):
try:
shutil.copy('infrastructure_key', f'{tmpdir}/infrastructure_key')
shutil.copy('infrastructure_key.pub', f'{tmpdir}/infrastructure_key.pub')
@ -23,6 +23,7 @@ def test_openstack_create_or_update(tmpdir, requests_mock):
'domain': domain,
'name': 'essential',
'cloud': 'production',
'provider': request.config.option.provider,
})
s.dotenough.set_certificate('ownca')
s.dotenough.set_clouds_file('inventory/group_vars/all/clouds.yml')

13
tests/enough/common/test_common_ssh.py

@ -1,21 +1,18 @@
import pytest
from enough import settings
from enough.common.openstack import Stack
from enough.common.openstack import Heat, Stack
from enough.common.ssh import SSH
@pytest.mark.openstack_integration
def test_ssh(openstack_name):
d = {
'name': openstack_name,
'flavor': 's1-2',
'port': '22',
}
def test_ssh(request, openstack_name, openstack_provider):
d = Heat.hostvars_to_stack(openstack_name, openstack_provider)
s = Stack(settings.CONFIG_DIR, d)
s.set_public_key('infrastructure_key.pub')
s.create_or_update()
ssh = SSH(settings.CONFIG_DIR, domain='enough.community')
ssh = SSH(settings.CONFIG_DIR, domain='enough.community',
provider=request.config.option.provider)
r = ssh.ssh(openstack_name, ['uptime'], interactive=False)
s.delete()
assert r.returncode == 0

72
tests/enough/common/test_init.py

@ -11,7 +11,7 @@ from enough.common.openstack import OpenStackBase, OpenStack
@pytest.mark.openstack_integration
def test_clone_and_destroy(tmpdir):
def test_clone_and_destroy(request, tmpdir):
test_clouds = 'inventory/group_vars/all/clouds.yml'
clone_override_dir = f'{tmpdir}/clone-override'
@ -33,7 +33,8 @@ def test_clone_and_destroy(tmpdir):
original = Enough(original_config_dir, settings.SHARE_DIR,
domain=original_domain,
driver='openstack')
driver='openstack',
provider=request.config.option.provider)
assert original.openstack.o.server.list().strip() == ''
clone_domain = 'clone.com'
@ -51,7 +52,7 @@ def test_clone_and_destroy(tmpdir):
assert not os.path.exists(clone.config_dir)
def create_enough(tmpdir, dotenough, **kwargs):
def create_enough(provider, tmpdir, dotenough, **kwargs):
clouds = 'inventory/group_vars/all/clouds.yml'
enough_domain = 'enough.com'
@ -68,12 +69,14 @@ def create_enough(tmpdir, dotenough, **kwargs):
enough = Enough(enough_config_dir, settings.SHARE_DIR,
domain=enough_domain,
driver='openstack',
provider=provider,
**kwargs)
return enough
def test_clone_clobber(tmpdir):
original = create_enough(tmpdir, 'copy')
def test_clone_clobber(request, tmpdir):
provider = request.config.option.provider
original = create_enough(provider, tmpdir, 'copy')
clone_domain = 'clone.com'
clone = original.clone(clone_domain, 'clone', False)
assert os.path.exists(f'{clone.config_dir}')
@ -87,8 +90,8 @@ def test_clone_clobber(tmpdir):
assert not os.path.exists(stone)
def create_and_clone_server_and_volume(tmpdir):
original = create_enough(tmpdir, 'backup')
def create_and_clone_server_and_volume(provider, tmpdir):
original = create_enough(provider, tmpdir, 'backup')
original.set_args(name='sample', playbook='enough-playbook.yml')
original.service.create_or_update()
@ -101,9 +104,10 @@ def create_and_clone_server_and_volume(tmpdir):
@pytest.mark.openstack_integration
def test_clone_create_service(tmpdir):
def test_clone_create_service(request, tmpdir):
provider = request.config.option.provider
try:
(original, clone) = create_and_clone_server_and_volume(tmpdir)
(original, clone) = create_and_clone_server_and_volume(provider, tmpdir)
assert 'sample-host' in original.openstack.o.server.list()
assert 'sample-volume' in original.openstack.o.volume.list()
assert 'sample-host' in clone.openstack.o.server.list()
@ -116,9 +120,10 @@ def test_clone_create_service(tmpdir):
@pytest.mark.openstack_integration
def test_create_copy_host(tmpdir):
def test_create_copy_host(request, tmpdir):
provider = request.config.option.provider
try:
enough = create_enough(tmpdir, 'copy')
enough = create_enough(provider, tmpdir, 'copy')
if 'copy-volume' not in enough.openstack.o.volume.list():
enough.openstack.o.volume.create('--size', '1', 'copy-volume')
ip = enough.create_copy_host('copy-from-host', 'some-volume', 'copy-volume')
@ -135,9 +140,10 @@ def test_create_copy_host(tmpdir):
@pytest.mark.openstack_integration
def test_create_volume_from_snapshot(tmpdir):
def test_create_volume_from_snapshot(request, tmpdir):
provider = request.config.option.provider
try:
e = create_enough(tmpdir, 'backup')
e = create_enough(provider, tmpdir, 'backup')
e.set_args(name='sample', playbook='enough-playbook.yml')
e.service.create_or_update()
e.openstack.backup_create(['sample-volume'])
@ -156,9 +162,10 @@ def test_create_volume_from_snapshot(tmpdir):
@pytest.mark.openstack_integration
def test_clone_volume_from_snapshot(tmpdir):
def test_clone_volume_from_snapshot(request, tmpdir):
provider = request.config.option.provider
try:
original = create_enough(tmpdir, 'backup')
original = create_enough(provider, tmpdir, 'backup')
original.set_args(name='sample', playbook='enough-playbook.yml')
original.service.create_or_update()
ip = original.hosts.load().get_ip('sample-host')
@ -197,9 +204,10 @@ def test_clone_volume_from_snapshot(tmpdir):
@pytest.mark.openstack_integration
def test_create_service_matching_snapshot(tmpdir):
def test_create_service_matching_snapshot(request, tmpdir):
provider = request.config.option.provider
try:
enough = create_enough(tmpdir, 'backup')
enough = create_enough(provider, tmpdir, 'backup')
host = enough.create_service_matching_snapshot('2020-02-20-sample-volume')
assert host == 'sample-host'
assert 'sample-volume' in enough.openstack.o.volume.list()
@ -211,9 +219,10 @@ def test_create_service_matching_snapshot(tmpdir):
@pytest.mark.openstack_integration
def test_restore_remote(tmpdir):
def test_restore_remote(request, tmpdir):
provider = request.config.option.provider
try:
original = create_enough(tmpdir, 'backup')
original = create_enough(provider, tmpdir, 'backup')
original.set_args(name='sample', playbook='enough-playbook.yml')
original.service.create_or_update()
ip = original.hosts.load().get_ip('sample-host')
@ -240,9 +249,10 @@ def test_restore_remote(tmpdir):
@pytest.mark.openstack_integration
def test_restore_local(tmpdir):
def test_restore_local(request, tmpdir):
provider = request.config.option.provider
try:
e = create_enough(tmpdir, 'backup')
e = create_enough(provider, tmpdir, 'backup')
e.set_args(name='sample', playbook='enough-playbook.yml')
e.service.create_or_update()
ip = e.hosts.load().get_ip('sample-host')
@ -269,9 +279,10 @@ def test_restore_local(tmpdir):
@pytest.mark.openstack_integration
def test_create_missings(tmpdir):
def test_create_missings(request, tmpdir):
provider = request.config.option.provider
try:
enough = create_enough(tmpdir, 'create-missings')
enough = create_enough(provider, tmpdir, 'create-missings')
r = enough.create_missings(['bind-host'])
assert 'bind-host' in r
internal_dns = enough.openstack.o.subnet.show(
@ -308,17 +319,19 @@ def test_volume_from_snapshot():
assert Enough.volume_from_snapshot(snapshot) == volume
def test_host_from_snapshot(tmpdir):
e = create_enough(tmpdir, 'backup')
def test_host_from_snapshot(request, tmpdir):
provider = request.config.option.provider
e = create_enough(provider, tmpdir, 'backup')
host = 'sample-host'
snapshot = f'2010-07-08-sample-volume'
assert e.host_from_snapshot(snapshot) == host
@pytest.mark.openstack_integration
def test_volume_resize(tmpdir):
def test_volume_resize(request, tmpdir):
provider = request.config.option.provider
try:
enough = create_enough(tmpdir, 'resize')
enough = create_enough(provider, tmpdir, 'resize')
enough.set_args(name='sample', playbook='enough-playbook.yml')
enough.service.create_or_update()
# False because the size does not change
@ -337,9 +350,10 @@ def test_volume_resize(tmpdir):
# Host
#
@pytest.mark.openstack_integration
def test_host_create_or_update(tmpdir, openstack_name):
def test_host_create_or_update(request, tmpdir, openstack_name):
provider = request.config.option.provider
try:
enough = create_enough(tmpdir, 'host')
enough = create_enough(provider, tmpdir, 'host')
enough.set_args(name='new-host')
info = enough.host.create_or_update()
assert 'ipv4' in info

42
tests/enough/common/test_openstack.py

@ -16,18 +16,16 @@ from enough.common.openstack import Stack, Heat, OpenStack
# Stack
#
@pytest.mark.openstack_integration
def test_stack_create_or_update(openstack_name):
def test_stack_create_or_update(openstack_name, openstack_provider):
name = openstack_name
network = openstack_name
class_c = '10.101.30'
cidr = f'{class_c}.0/24'
d = {
'name': name,
'flavor': 's1-2',
'port': '22',
'internal_network': network,
'internal_network_cidr': cidr,
}
d = Heat.hostvars_to_stack(openstack_name, openstack_provider)
d.update(
internal_network=network,
internal_network_cidr=cidr
)
s = Stack(settings.CONFIG_DIR, d)
s.set_public_key('infrastructure_key.pub')
r = s.create_or_update()
@ -178,18 +176,16 @@ def test_backup_create_no_names(openstack_name, caplog):
@pytest.mark.openstack_integration
def test_openstack_replace_volume(openstack_name):
d = {
'name': openstack_name,
'flavor': 's1-2',
'port': '22',
def test_openstack_replace_volume(openstack_name, openstack_provider):
d = Heat.hostvars_to_stack(openstack_name, openstack_provider)
d.update({
'volumes': [
{
'size': '1',
'name': openstack_name,
},
],
}
})
s = Stack(settings.CONFIG_DIR, d)
s.set_public_key('infrastructure_key.pub')
s.create_or_update()
@ -219,19 +215,17 @@ def test_openstack_replace_volume(openstack_name):
@pytest.mark.openstack_integration
def test_openstack_volume_resize_ok(openstack_name):
def test_openstack_volume_resize_ok(openstack_name, openstack_provider):
size = 1
d = {
'name': openstack_name,
'flavor': 's1-2',
'port': '22',
d = Heat.hostvars_to_stack(openstack_name, openstack_provider)
d.update({
'volumes': [
{
'size': str(size),
'name': openstack_name,
},
],
}
})
s = Stack(settings.CONFIG_DIR, d)
s.set_public_key('infrastructure_key.pub')
s.create_or_update()
@ -257,12 +251,8 @@ def test_openstack_volume_resize_ok(openstack_name):
@pytest.mark.openstack_integration
def test_openstack_volume_resize_no_volume(openstack_name):
d = {
'name': openstack_name,
'flavor': 's1-2',
'port': '22',
}
def test_openstack_volume_resize_no_volume(openstack_name, openstack_provider):
d = Heat.hostvars_to_stack(openstack_name, openstack_provider)
s = Stack(settings.CONFIG_DIR, d)
s.set_public_key('infrastructure_key.pub')
s.create_or_update()

Loading…
Cancel
Save