def do_snapshot_create(cs, args):
    """Add a new snapshot."""
    share = utils.find_share(cs, args.share)
    snapshot = cs.share_snapshots.create(share,
                                         args.force,
                                         args.name,
                                         args.description)
    _print_share_snapshot(cs, snapshot)
def do_metadata(cs, args):
    """Set or Delete metadata on a share."""
    share = utils.find_share(cs, args.share)
    metadata = _extract_metadata(args)

    if args.action == 'set':
        cs.shares.set_metadata(share, metadata)
    elif args.action == 'unset':
        cs.shares.delete_metadata(share, sorted(metadata.keys(),
                                  reverse=True))
def do_metadata_update_all(cs, args):
    """Update all metadata of a share."""
    share = utils.find_share(cs, args.share)
    metadata = _extract_metadata(args)
    metadata = share.update_all_metadata(metadata)._info['metadata']
    utils.print_dict(metadata, 'Metadata-property')
def do_metadata_show(cs, args):
    """Show metadata of given share."""
    share = utils.find_share(cs, args.share)
    metadata = cs.shares.get_metadata(share)._info
    utils.print_dict(metadata, 'Metadata-property')