def snapshot_id_to_name(name, snap_id, strict=False, runas=None):
 name = _sdecode(name)
 if (not re.match(GUID_REGEX, snap_id)):
  raise SaltInvocationError(u'Snapshot ID "{0}" is not a GUID'.format(_sdecode(snap_id)))
 info = prlctl('snapshot-list', [name, '--id', snap_id], runas=runas)
 if (not len(info)):
  raise SaltInvocationError(u'No snapshots for VM "{0}" have ID "{1}"'.format(name, snap_id))
 try:
  data = yaml.safe_load(info)
 except yaml.YAMLError as err:
  log.warning('Could not interpret snapshot data returned from prlctl: {0}'.format(err))
  data = {}
 if isinstance(data, dict):
  snap_name = data.get('Name', '')
  if (snap_name is None):
   snap_name = ''
 else:
  log.warning(u'Could not interpret snapshot data returned from prlctl: data is not formed as a dictionary: {0}'.format(data))
  snap_name = ''
 if ((not snap_name) and strict):
  raise SaltInvocationError(u'Could not find a snapshot name for snapshot ID "{0}" of VM "{1}"'.format(snap_id, name))
 return _sdecode(snap_name)

def snapshot_id_to_name ( name , snap_id , strict = False , runas = None ) : name = _sdecode ( name ) if ( not re . match ( GUID_REGEX , snap_id ) ) : raise SaltInvocationError ( u'Snapshot ID "{0}" is not a GUID' . format ( _sdecode ( snap_id ) ) ) info = prlctl ( 'snapshot-list' , [ name , '--id' , snap_id ] , runas = runas ) if ( not len ( info ) ) : raise SaltInvocationError ( u'No snapshots for VM "{0}" have ID "{1}"' . format ( name , snap_id ) ) try : data = yaml . safe_load ( info ) except yaml . YAMLError as err : log . warning ( 'Could not interpret snapshot data returned from prlctl: {0}' . format ( err ) ) data = { } if isinstance ( data , dict ) : snap_name = data . get ( 'Name' , '' ) if ( snap_name is None ) : snap_name = '' else : log . warning ( u'Could not interpret snapshot data returned from prlctl: data is not formed as a dictionary: {0}' . format ( data ) ) snap_name = '' if ( ( not snap_name ) and strict ) : raise SaltInvocationError ( u'Could not find a snapshot name for snapshot ID "{0}" of VM "{1}"' . format ( snap_id , name ) ) return _sdecode ( snap_name )
attempt to convert a snapshot id to a snapshot name .