def rollback_snapshot(vm, name, 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
 vmobj = get(vm)
 if ('datasets' in vmobj):
  ret['Error'] = 'VM cannot have datasets'
  return ret
 if (vmobj['brand'] in ['kvm']):
  ret['Error'] = 'VM must be of type OS'
  return ret
 cmd = '{vmadm} rollback-snapshot {uuid} {snapshot}'.format(vmadm=vmadm, snapshot=name, uuid=vm)
 res = __salt__['cmd.run_all'](cmd)
 retcode = res['retcode']
 if (retcode != 0):
  ret['Error'] = (res['stderr'] if ('stderr' in res) else _exit_status(retcode))
  return ret
 return True

def rollback_snapshot ( vm , name , 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 vmobj = get ( vm ) if ( 'datasets' in vmobj ) : ret [ 'Error' ] = 'VM cannot have datasets' return ret if ( vmobj [ 'brand' ] in [ 'kvm' ] ) : ret [ 'Error' ] = 'VM must be of type OS' return ret cmd = '{vmadm} rollback-snapshot {uuid} {snapshot}' . format ( vmadm = vmadm , snapshot = name , uuid = vm ) res = __salt__ [ 'cmd.run_all' ] ( cmd ) retcode = res [ 'retcode' ] if ( retcode != 0 ) : ret [ 'Error' ] = ( res [ 'stderr' ] if ( 'stderr' in res ) else _exit_status ( retcode ) ) return ret return True
rollback snapshot of a vm vm : string vm to be targeted name : string snapshot name the snapname must be 64 characters or less and must only contain alphanumeric characters and characters in the set [-_ .