def reprovision(vm, image, key='uuid'):
 ret = {}
 vmadm = _check_vmadm()
 if (key not in ['uuid', 'alias', 'hostname']):
  ret['Error'] = 'Key must be either uuid, alias or hostname'
  return ret
 vm = lookup('{0}={1}'.format(key, vm), one=True)
 if ('Error' in vm):
  return vm
 if (image not in __salt__['imgadm.list']()):
  ret['Error'] = 'Image ({0}) is not present on this host'.format(image)
  return ret
 cmd = 'echo {image} | {vmadm} reprovision {uuid}'.format(vmadm=vmadm, uuid=vm, image=_quote_args(json.dumps({'image_uuid': image})))
 res = __salt__['cmd.run_all'](cmd, python_shell=True)
 retcode = res['retcode']
 if (retcode != 0):
  ret['Error'] = (res['stderr'] if ('stderr' in res) else _exit_status(retcode))
  return ret
 return True

def reprovision ( vm , image , key = 'uuid' ) : ret = { } vmadm = _check_vmadm ( ) if ( key not in [ 'uuid' , 'alias' , 'hostname' ] ) : ret [ 'Error' ] = 'Key must be either uuid, alias or hostname' return ret vm = lookup ( '{0}={1}' . format ( key , vm ) , one = True ) if ( 'Error' in vm ) : return vm if ( image not in __salt__ [ 'imgadm.list' ] ( ) ) : ret [ 'Error' ] = 'Image ({0}) is not present on this host' . format ( image ) return ret cmd = 'echo {image} | {vmadm} reprovision {uuid}' . format ( vmadm = vmadm , uuid = vm , image = _quote_args ( json . dumps ( { 'image_uuid' : image } ) ) ) res = __salt__ [ 'cmd.run_all' ] ( cmd , python_shell = True ) retcode = res [ 'retcode' ] if ( retcode != 0 ) : ret [ 'Error' ] = ( res [ 'stderr' ] if ( 'stderr' in res ) else _exit_status ( retcode ) ) return ret return True
reprovision a vm vm : string vm to be reprovisioned image : string uuid of new image key : string [uuid|alias|hostname] value type of vm parameter cli example: .