machine_type=machine_type,
description=description,
)
- # Only query for os_type/os_version if non-vps, since in that case we
- # just create them.
- if machine_type != 'vps':
+ # Only query for os_type/os_version if non-vps and non-libcloud, since
+ # in that case we just create them.
+ if machine_type not in ['vps'] + provision.cloud.get_types():
if os_type:
data['os_type'] = os_type
if os_version:
machine['ssh_pub_key'] for machine in response.json()}
log.debug('locked {machines}'.format(
machines=', '.join(machines.keys())))
- if machine_type == 'vps':
+ if machine_type in ['vps'] + provision.cloud.get_types():
ok_machs = {}
for machine in machines:
if provision.create_if_vm(ctx, machine):
machine)
unlock_one(ctx, machine, user)
return ok_machs
+ if machine_type in provision.cloud.get_types():
+ machines = do_update_keys(machines.keys())
return machines
elif response.status_code == 503:
log.error('Insufficient nodes available to lock %d %s nodes.',
from .downburst import Downburst
from .openstack import ProvisionOpenStack
+import cloud
+
log = logging.getLogger(__name__)
status_info = _downburst.status
else:
status_info = get_status(machine_name)
- if not status_info.get('is_vm', False):
- return False
+ shortname = decanonicalize_hostname(machine_name)
+ machine_type = status_info['machine_type']
os_type = get_distro(ctx)
os_version = get_distro_version(ctx)
+ if not status_info.get('is_vm', False):
+ return False
+
+ if machine_type in cloud.get_types():
+ return cloud.get_provisioner(
+ machine_type,
+ shortname,
+ os_type,
+ os_version,
+ conf=getattr(ctx, 'config', dict()),
+ ).create()
has_config = hasattr(ctx, 'config') and ctx.config is not None
if has_config and 'downburst' in ctx.config:
log.error(msg.format(node=machine_name, desc_arg=description,
desc_lock=status_info['description']))
return False
- if status_info.get('machine_type') == 'openstack':
- return ProvisionOpenStack().destroy(
- decanonicalize_hostname(machine_name))
+ machine_type = status_info.get('machine_type')
+ shortname = decanonicalize_hostname(machine_name)
+ if machine_type == 'openstack':
+ return ProvisionOpenStack().destroy(shortname)
+ elif machine_type in cloud.get_types():
+ return cloud.get_provisioner(
+ machine_type, shortname, None, None).destroy()
dbrst = _downburst or Downburst(name=machine_name, os_type=None,
os_version=None, status=status_info)
self.status = dict(
vm_host=dict(name='host999'),
is_vm=True,
+ machine_type='mtype',
)
def test_create_if_vm_success(self):
ctx = self.ctx
status = self.status
- dbrst = provision.Downburst(name, ctx.os_type, ctx.os_version, status)
+ dbrst = provision.Downburst(
+ name, ctx.os_type, ctx.os_version, status)
dbrst.executable = '/fake/path'
dbrst.build_config = MagicMock(name='build_config')
dbrst._run_create = MagicMock(name='_run_create')
ctx = self.ctx
status = self.status
- dbrst = provision.Downburst(name, ctx.os_type, ctx.os_version, status)
+ dbrst = provision.Downburst(
+ name, ctx.os_type, ctx.os_version, status)
dbrst.destroy = MagicMock(name='destroy')
dbrst.destroy.return_value = True
status = self.status
status['locked_by'] = 'user@a'
- dbrst = provision.Downburst(name, ctx.os_type, ctx.os_version, status)
+ dbrst = provision.Downburst(
+ name, ctx.os_type, ctx.os_version, status)
dbrst.destroy = MagicMock(name='destroy', side_effect=RuntimeError)
result = provision.destroy_if_vm(ctx, name, user='user@b',
status = self.status
status['description'] = 'desc_a'
- dbrst = provision.Downburst(name, ctx.os_type, ctx.os_version, status)
+ dbrst = provision.Downburst(
+ name, ctx.os_type, ctx.os_version, status)
dbrst.destroy = MagicMock(name='destroy')
dbrst.destroy = MagicMock(name='destroy', side_effect=RuntimeError)
_downburst=dbrst)
assert result is False
- @patch('teuthology.provision.downburst.downburst_executable')
+ @patch('teuthology.provision_executable')
def test_create_fails_without_executable(self, m_exec):
name = self.name
ctx = self.ctx
status = self.status
m_exec.return_value = ''
- dbrst = provision.Downburst(name, ctx.os_type, ctx.os_version, status)
+ dbrst = provision.Downburst(
+ name, ctx.os_type, ctx.os_version, status)
result = dbrst.create()
assert result is False
- @patch('teuthology.provision.downburst.downburst_executable')
+ @patch('teuthology.provision_executable')
def test_destroy_fails_without_executable(self, m_exec):
name = self.name
ctx = self.ctx
status = self.status
m_exec.return_value = ''
- dbrst = provision.Downburst(name, ctx.os_type, ctx.os_version, status)
+ dbrst = provision.Downburst(
+ name, ctx.os_type, ctx.os_version, status)
result = dbrst.destroy()
assert result is False