List the snapshots

    :param str name:
        Name/ID of VM whose snapshots will be listed

    :param str snap_id:
        Name/ID of snapshot to display information about.  If ``tree=True`` is
        also specified, display the snapshot subtree having this snapshot as
        the root snapshot

    :param bool tree:
        List snapshots in tree format rather than tabular format

    :param bool names:
        List snapshots as ID, name pairs

    :param str runas:
        The user that the prlctl command will be run as

    Example:

    .. code-block:: bash

        salt '*' parallels.list_snapshots macvm runas=macdev
        salt '*' parallels.list_snapshots macvm tree=True runas=macdev
        salt '*' parallels.list_snapshots macvm snap_name=original runas=macdev
        salt '*' parallels.list_snapshots macvm names=True runas=macdev

def list_snapshots(name, snap_name=None, tree=False, names=False, runas=None):
    '''
    List the snapshots

    :param str name:
        Name/ID of VM whose snapshots will be listed

    :param str snap_id:
        Name/ID of snapshot to display information about.  If ``tree=True`` is
        also specified, display the snapshot subtree having this snapshot as
        the root snapshot

    :param bool tree:
        List snapshots in tree format rather than tabular format

    :param bool names:
        List snapshots as ID, name pairs

    :param str runas:
        The user that the prlctl command will be run as

    Example:

    .. code-block:: bash

        salt '*' parallels.list_snapshots macvm runas=macdev
        salt '*' parallels.list_snapshots macvm tree=True runas=macdev
        salt '*' parallels.list_snapshots macvm snap_name=original runas=macdev
        salt '*' parallels.list_snapshots macvm names=True runas=macdev
    '''
    # Validate VM and snapshot names
    name = salt.utils.data.decode(name)
    if snap_name:
        snap_name = _validate_snap_name(name, snap_name, runas=runas)

    # Construct argument list
    args = [name]
    if tree:
        args.append('--tree')
    if snap_name:
        args.extend(['--id', snap_name])

    # Execute command
    res = prlctl('snapshot-list', args, runas=runas)

    # Construct ID, name pairs
    if names:
        # Find all GUIDs in the result
        snap_ids = _find_guids(res)

        # Try to find the snapshot names
        ret = '{0:<38}  {1}\n'.format('Snapshot ID', 'Snapshot Name')
        for snap_id in snap_ids:
            snap_name = snapshot_id_to_name(name, snap_id, runas=runas)
            ret += ('{{{0}}}  {1}\n'.format(snap_id, salt.utils.data.decode(snap_name)))
        return ret

    # Return information directly from parallels desktop
    else:
        return res