Skip to content

Commit

Permalink
Added missing checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Malinovsky committed Dec 9, 2013
1 parent fa1c9c4 commit daf074c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions salt/runners/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,14 @@ def init(
if name in data[hyper]['vm_info']:
print('Virtual machine {0} is already deployed'.format(name))
return 'fail'
if hyper:
if hyper not in data:
print('Hypervisor {0} was not found'.format(hyper))
return 'fail'
else:

if hyper is None:
hyper = _determine_hyper(data)

if hyper not in data or not hyper:
print('Hypervisor {0} was not found'.format(hyper))
return 'fail'

if seed:
print('Minion will be preseeded')
kv = salt.utils.virt.VirtKey(hyper, name, __opts__)
Expand All @@ -183,13 +184,16 @@ def init(
image,
'seed={0}'.format(seed),
'nic={0}'.format(nic),
'install={0}'.format(install)
'install={0}'.format(install),
],
timeout=600)

next(cmd_ret)
print('VM {0} initialized on hypervisor {1}'.format(name, hyper))
ret = next(cmd_ret)
if not ret:
print('VM {0} was not initialized.'.format(name))
return 'fail'

print('VM {0} initialized on hypervisor {1}'.format(name, hyper))
return 'good'


Expand Down

0 comments on commit daf074c

Please sign in to comment.