# all in one shot. If we are passed 'plana,mira,burnupi,vps', do one query
# for 'plana,mira,burnupi' and one for 'vps'
machine_types_list = misc.get_multi_machine_types(machine_type)
- if machine_types_list == ['vps']:
+ downburst_types = teuthology.provision.downburst.get_types()
+ if all(t in downburst_types for t in machine_types_list):
machine_types = machine_types_list
elif machine_types_list == ['openstack']:
return lock_many_openstack(ctx, num, machine_type,
user=user,
description=description,
arch=arch)
- elif 'vps' in machine_types_list:
- machine_types_non_vps = list(machine_types_list)
- machine_types_non_vps.remove('vps')
- machine_types_non_vps = '|'.join(machine_types_non_vps)
- machine_types = [machine_types_non_vps, 'vps']
+ elif any(t in downburst_types for t in machine_types_list):
+ the_vps = list(t for t in machine_types_list
+ if t in downburst_types)
+ non_vps = list(t for t in machine_types_list
+ if not t in downburst_types)
+ machine_types = ['|'.join(non_vps), '|'.join(the_vps)]
else:
machine_types_str = '|'.join(machine_types_list)
machine_types = [machine_types_str, ]
)
# Only query for os_type/os_version if non-vps and non-libcloud, since
# in that case we just create them.
- vm_types = ['vps'] + teuthology.provision.cloud.get_types()
+ vm_types = downburst_types + teuthology.provision.cloud.get_types()
reimage_types = teuthology.provision.get_reimage_types()
- if machine_type not in vm_types + reimage_types:
+ if machine_type not in (vm_types + reimage_types):
if os_type:
data['os_type'] = os_type
if os_version:
log = logging.getLogger(__name__)
+def get_types():
+ types = ['vps']
+ if 'downburst' in config and 'machine' in config.downburst:
+ machine = config.downburst.get('machine')
+ if isinstance(machine, list):
+ types = list(m.get('type') for m in machine)
+ return types
+
+
def downburst_executable():
"""
First check for downburst in the user's path.
os_version = self.os_version.lower()
mac_address = self.status['mac_address']
- defaults = dict(
- downburst=dict(
- machine=dict(
- disk=os.environ.get('DOWNBURST_DISK_SIZE', '100G'),
- ram=os.environ.get('DOWNBURST_RAM_SIZE', '3.8G'),
- cpus=int(os.environ.get('DOWNBURST_CPUS', 1)),
- volumes=dict(
- count=int(os.environ.get('DOWNBURST_EXTRA_DISK_NUMBER', 4)),
- size=os.environ.get('DOWNBURST_EXTRA_DISK_SIZE', '100G'),
- ),
- ),
- )
+ machine = dict(
+ disk=os.environ.get('DOWNBURST_DISK_SIZE', '100G'),
+ ram=os.environ.get('DOWNBURST_RAM_SIZE', '3.8G'),
+ cpus=int(os.environ.get('DOWNBURST_CPUS', 1)),
+ volumes=dict(
+ count=int(os.environ.get('DOWNBURST_EXTRA_DISK_NUMBER', 4)),
+ size=os.environ.get('DOWNBURST_EXTRA_DISK_SIZE', '100G'),
+ ),
)
- downburst_config = defaults['downburst']
- if config.downburst and isinstance(config.downburst, dict):
- deep_merge(downburst_config, config.downburst)
- log.debug('downburst_config: %s', downburst_config)
- machine = downburst_config['machine']
+ def belongs_machine_type(machine_config: dict, machine_type: str) -> bool:
+ if isinstance(machine_config, dict):
+ t = machine_config.get('type', None)
+ if isinstance(t, str):
+ return machine_type == t
+ elif isinstance(t, list):
+ return machine_type in t
+ return False
+ if isinstance(config.downburst, dict) and isinstance(config.downburst.get('machine'), list):
+ machine_type = self.status['machine_type']
+ machine_config = next((m for m in config.downburst.get('machine')
+ if belongs_machine_type(m, machine_type)), None)
+ if machine_config is None:
+ raise RuntimeError(f"Cannot find config for machine type {machine_type}.")
+ elif isinstance(config.downburst, dict) and isinstance(config.downburst.get('machine'), dict):
+ machine_config = config.downburst.get('machine')
+ deep_merge(machine, machine_config)
log.debug('Using machine config: %s', machine)
file_info = {
'disk-size': machine['disk'],