from teuthology.config import config
from teuthology.contextutil import safe_while
from teuthology.misc import decanonicalize_hostname
+from teuthology.misc import deep_merge
from teuthology.lock import query
log = logging.getLogger(__name__)
Return '' if no executable downburst is found.
"""
if config.downburst:
- return config.downburst
+ if isinstance(config.downburst, dict):
+ if 'path' in config.downburst:
+ return config.downburst['path']
+ else:
+ return config.downburst
path = os.environ.get('PATH', None)
if path:
for p in os.environ.get('PATH', '').split(os.pathsep):
return ''
+def downburst_environment():
+ env = dict()
+ discover_url = os.environ.get('DOWNBURST_DISCOVER_URL')
+ if config.downburst and not discover_url:
+ if isinstance(config.downburst, dict):
+ discover_url = config.downburst.get('discover_url')
+ if discover_url:
+ env['DOWNBURST_DISCOVER_URL'] = discover_url
+ return env
+
+
class Downburst(object):
"""
A class that provides methods for creating and destroying virtual machine
self.logfile = logfile
self.host = decanonicalize_hostname(self.status['vm_host']['name'])
self.executable = downburst_executable()
+ self.environment = downburst_environment()
def create(self):
"""
))
log.debug(args)
proc = subprocess.Popen(args, universal_newlines=True,
+ env=self.environment,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = proc.communicate()
os_version = self.os_version.lower()
mac_address = self.status['mac_address']
-
- cpus = int(os.environ.get('DOWNBURST_CPUS', 1))
- ram_size = os.environ.get('DOWNBURST_RAM_SIZE', '3.8G')
- disk_size = os.environ.get('DOWNBURST_DISK_SIZE', '100G')
- extra_disk_size = os.environ.get('DOWNBURST_EXTRA_DISK_SIZE', '100G')
- extra_disk_number = int(os.environ.get('DOWNBURST_EXTRA_DISK_NUMBER', 4))
+ 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'),
+ ),
+ ),
+ )
+ )
+ 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']
+ log.debug('Using machine config: %s', machine)
file_info = {
- 'disk-size': disk_size,
- 'ram': ram_size,
- 'cpus': cpus,
+ 'disk-size': machine['disk'],
+ 'ram': machine['ram'],
+ 'cpus': machine['cpus'],
'networks': [
{'source': 'front', 'mac': mac_address}],
'distro': os_type,
'distroversion': self.os_version,
- 'additional-disks': extra_disk_number,
- 'additional-disks-size': extra_disk_size,
+ 'additional-disks': machine['volumes']['count'],
+ 'additional-disks-size': machine['volumes']['size'],
'arch': 'x86_64',
}
fqdn = self.name.split('@')[1]
'opensuse': ['12.3', '15.1', '15.2'],
'debian': ['6.0', '7.0', '8.0']}
executable_cmd = downburst_executable()
+ environment_dict = downburst_environment()
if not executable_cmd:
log.warn("Downburst not found!")
log.info('Using default values for supported os_type/os_version')
return default_table
try:
- output = subprocess.check_output([executable_cmd, 'list-json'])
+ log.debug(executable_cmd)
+ output = subprocess.check_output([executable_cmd, 'list-json'],
+ env=environment_dict)
downburst_data = json.loads(output)
return downburst_data
except (subprocess.CalledProcessError, OSError):