def force_off(name):
 ret = {}
 client = salt.client.get_local_client(__opts__['conf_file'])
 data = vm_info(name, quiet=True)
 if (not data):
  print('Failed to find VM {0} to destroy'.format(name))
  return 'fail'
 host = next(six.iterkeys(data))
 if (data[host][name]['state'] == 'shutdown'):
  print('VM {0} is already shutdown'.format(name))
  return 'bad state'
 try:
  cmd_ret = client.cmd_iter(host, 'virt.destroy', [name], timeout=600)
 except SaltClientError as client_error:
  return 'Virtual machine {0} could not be forced off: {1}'.format(name, client_error)
 for comp in cmd_ret:
  ret.update(comp)
 __jid_event__.fire_event({'message': 'Powered off VM {0}'.format(name)}, 'progress')
 return 'good'

def force_off ( name ) : ret = { } client = salt . client . get_local_client ( __opts__ [ 'conf_file' ] ) data = vm_info ( name , quiet = True ) if ( not data ) : print ( 'Failed to find VM {0} to destroy' . format ( name ) ) return 'fail' host = next ( six . iterkeys ( data ) ) if ( data [ host ] [ name ] [ 'state' ] == 'shutdown' ) : print ( 'VM {0} is already shutdown' . format ( name ) ) return 'bad state' try : cmd_ret = client . cmd_iter ( host , 'virt.destroy' , [ name ] , timeout = 600 ) except SaltClientError as client_error : return 'Virtual machine {0} could not be forced off: {1}' . format ( name , client_error ) for comp in cmd_ret : ret . update ( comp ) __jid_event__ . fire_event ( { 'message' : 'Powered off VM {0}' . format ( name ) } , 'progress' ) return 'good'
force power down the named virtual machine .