Ejemplo n.º 1
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description="Print file system statistics.")

    parser.add_debug()
    parser.add_quiet()
    parser.add_version()
    parser.add_argument("mountpoint", metavar='<mountpoint>',
                        type=(lambda x: x.rstrip('/')),
                        help='Mount point of the file system to examine')

    return parser.parse_args(args)
Ejemplo n.º 2
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description=textwrap.dedent('''\
        Recursively delete files and directories in an S3QL file system,
        including immutable entries. 
        '''))

    parser.add_debug()
    parser.add_quiet()
    parser.add_version()
    
    parser.add_argument('path', metavar='<path>', nargs='+',
                        help='Directories to remove',
                         type=(lambda x: x.rstrip('/')))

    return parser.parse_args(args)
Ejemplo n.º 3
0
Archivo: lock.py Proyecto: drewlu/ossql
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description=textwrap.dedent('''\
        Makes the given directory tree(s) immutable. No changes of any sort can
        be performed on the tree after that. Immutable entries can only be
        deleted with s3qlrm. 
        '''))

    parser.add_debug()
    parser.add_quiet()
    parser.add_version()
    
    parser.add_argument('path', metavar='<path>', nargs='+',
                        help='Directories to make immutable.',
                         type=(lambda x: x.rstrip('/')))

    return parser.parse_args(args)
Ejemplo n.º 4
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description="Create a dummy-copy of the source bucket. The target will "
                    'contain a file system with the same structure, but all files'
                    'will just contain \\0 bytes.')

    parser.add_authfile()
    parser.add_quiet()
    parser.add_debug_modules()
    parser.add_version()
    parser.add_ssl()

    parser.add_argument("src", metavar='<source storage-url>',
                        type=storage_url_type, 
                        help='Source storage URL')

    parser.add_argument("dest", metavar='<dest storage-url>',
                        type=storage_url_type, 
                        help='Destination storage URL')

        
    return parser.parse_args(args)
Ejemplo n.º 5
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description='Batch remove objects from an S3QL backend')

    parser.add_authfile()
    parser.add_quiet()
    parser.add_debug()
    parser.add_backend_options()
    parser.add_version()

    parser.add_argument("storage_url",
                        type=storage_url_type,
                        help='Storage URL of the backend to delete from')

    parser.add_argument(
        "file",
        type=argparse.FileType(mode='r', encoding='utf-8'),
        help='File with newline separated object keys to delete')

    return parser.parse_args(args)
Ejemplo n.º 6
0
def parse_args(args):

    parser = ArgumentParser(description="Checks S3QL file system metadata")

    parser.add_log('~/.s3ql/fsck_db.log')
    parser.add_debug()
    parser.add_quiet()
    parser.add_version()

    def db_path(s):
        s = os.path.splitext(s)[0]
        if not os.path.exists(s + '.db'):
            raise ArgumentTypeError('Unable to read %s.db' % s)
        if not os.path.exists(s + '.params'):
            raise ArgumentTypeError('Unable to read %s.params' % s)
        return s

    parser.add_argument("path",
                        metavar='<path>',
                        type=db_path,
                        help='Database to be checked')

    options = parser.parse_args(args)

    return options
Ejemplo n.º 7
0
def parse_args(args):

    parser = ArgumentParser(
        description="Checks S3QL file system metadata")

    parser.add_log('~/.s3ql/fsck_db.log')
    parser.add_debug()
    parser.add_quiet()
    parser.add_version()

    def db_path(s):
        s = os.path.splitext(s)[0]
        if not os.path.exists(s + '.db'):
            raise ArgumentTypeError('Unable to read %s.db' % s)
        if not os.path.exists(s + '.params'):
            raise ArgumentTypeError('Unable to read %s.params' % s)
        return s

    parser.add_argument("path", metavar='<path>', type=db_path,
                        help='Database to be checked')

    options = parser.parse_args(args)

    return options
Ejemplo n.º 8
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description='Recursively copy source(s) to destination using multiple '
        'parallel rsync processes.')

    parser.add_quiet()
    parser.add_debug()
    parser.add_version()

    parser.add_argument("-a",
                        action="store_true",
                        help='Pass -aHAX option to rsync.')
    parser.add_argument(
        "--processes",
        action="store",
        type=int,
        metavar='<no>',
        default=10,
        help='Number of rsync processes to use (default: %(default)s).')

    parser.add_argument('source',
                        metavar='<source>',
                        nargs='+',
                        help='Directories to copy')
    parser.add_argument('dest',
                        metavar='<destination>',
                        help="Target directory")

    options = parser.parse_args(args)
    options.pps = options.source + [options.dest]

    return options
Ejemplo n.º 9
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
                description='Clone an S3QL file system.')

    parser.add_authfile()
    parser.add_quiet()
    parser.add_debug()
    parser.add_backend_options()
    parser.add_version()

    parser.add_argument("src_storage_url", metavar='<source-storage-url>',
                        type=storage_url_type,
                        help='Storage URL of the source backend that contains the file system')

    parser.add_argument("dst_storage_url", metavar='<destination-storage-url>',
                        type=storage_url_type,
                        help='Storage URL of the destination backend')

    parser.add_argument("--threads", type=int, default=3,
                        help='Number of threads to use')

    return parser.parse_args(args)
Ejemplo n.º 10
0
def parse_args(args):
    '''Parse command line'''

    # Parse fstab-style -o options
    if '--' in args:
        max_idx = args.index('--')
    else:
        max_idx = len(args)
    if '-o' in args[:max_idx]:
        pos = args.index('-o')
        val = args[pos + 1]
        del args[pos]
        del args[pos]
        for opt in reversed(val.split(',')):
            if '=' in opt:
                (key, val) = opt.split('=')
                args.insert(pos, val)
                args.insert(pos, '--' + key)
            else:
                if opt in ('rw', 'defaults', 'auto', 'noauto', 'user', 'nouser', 'dev', 'nodev',
                           'suid', 'nosuid', 'atime', 'diratime', 'exec', 'noexec', 'group',
                           'mand', 'nomand', '_netdev', 'nofail', 'norelatime', 'strictatime',
                           'owner', 'users', 'nobootwait'):
                    continue
                elif opt == 'ro':
                    raise QuietError('Read-only mounting not supported.')
                args.insert(pos, '--' + opt)

    parser = ArgumentParser(
        description="Mount an S3QL file system.")

    parser.add_log('~/.s3ql/mount.log')
    parser.add_cachedir()
    parser.add_authfile()
    parser.add_debug_modules()
    parser.add_quiet()
    parser.add_version()
    parser.add_storage_url()
    
    parser.add_argument("mountpoint", metavar='<mountpoint>',
                        type=(lambda x: x.rstrip('/')),
                        help='Where to mount the file system')
        
    parser.add_argument("--cachesize", type=int, default=102400, metavar='<size>', 
                      help="Cache size in kb (default: 102400 (100 MB)). Should be at least 10 times "
                      "the blocksize of the filesystem, otherwise an object may be retrieved and "
                      "written several times during a single write() or read() operation.")
    parser.add_argument("--max-cache-entries", type=int, default=768, metavar='<num>',
                      help="Maximum number of entries in cache (default: %(default)d). "
                      'Each cache entry requires one file descriptor, so if you increase '
                      'this number you have to make sure that your process file descriptor '
                      'limit (as set with `ulimit -n`) is high enough (at least the number ' 
                      'of cache entries + 100).')
    parser.add_argument("--allow-other", action="store_true", default=False, help=
                      'Normally, only the user who called `mount.s3ql` can access the mount '
                      'point. This user then also has full access to it, independent of '
                      'individual file permissions. If the `--allow-other` option is '
                      'specified, other users can access the mount point as well and '
                      'individual file permissions are taken into account for all users.')
    parser.add_argument("--allow-root", action="store_true", default=False,
                      help='Like `--allow-other`, but restrict access to the mounting '
                           'user and the root user.')
    parser.add_argument("--fg", action="store_true", default=False,
                      help="Do not daemonize, stay in foreground")
    parser.add_argument("--single", action="store_true", default=False,
                      help="Run in single threaded mode. If you don't understand this, "
                           "then you don't need it.")
    parser.add_argument("--upstart", action="store_true", default=False,
                      help="Stay in foreground and raise SIGSTOP once mountpoint "
                           "is up.")
    parser.add_argument("--profile", action="store_true", default=False,
                      help="Create profiling information. If you don't understand this, "
                           "then you don't need it.")
    parser.add_argument("--compress", action="store", default='lzma', metavar='<name>',
                      choices=('lzma', 'bzip2', 'zlib', 'none'),
                      help="Compression algorithm to use when storing new data. Allowed "
                           "values: `lzma`, `bzip2`, `zlib`, none. (default: `%(default)s`)")
    parser.add_argument("--metadata-upload-interval", action="store", type=int,
                      default=24*60*60, metavar='<seconds>',
                      help='Interval in seconds between complete metadata uploads. '
                           'Set to 0 to disable. Default: 24h.')
    parser.add_argument("--metadata-download-interval", action="store", type=int,
                      default=10, metavar='<seconds>',
                      help='Interval in seconds between complete metadata downloads. '
                           'Set to 0 to disable. Default: 10s.')
    parser.add_argument("--threads", action="store", type=int,
                      default=None, metavar='<no>',
                      help='Number of parallel upload threads to use (default: auto).')
    parser.add_argument("--nfs", action="store_true", default=False,
                      help='Support export of S3QL file systems over NFS ' 
                           '(default: %(default)s)')
    parser.add_argument("--readonly", action="store_true", default=False,
                      help='readonly file system doesnot commit changes to OSS when umount' 
                           '(default: %(default)s)')
        
    options = parser.parse_args(args)

    if options.allow_other and options.allow_root:
        parser.error("--allow-other and --allow-root are mutually exclusive.")

    if not options.log and not options.fg:
        parser.error("Please activate logging to a file or syslog, or use the --fg option.")
        
    if options.profile:
        options.single = True

    if options.upstart:
        options.fg = True
        
    if options.metadata_upload_interval == 0:
        options.metadata_upload_interval = None
        
    if options.metadata_download_interval == 0:
        options.metadata_download_interval = None
        
    if options.compress == 'none':
        options.compress = None

    return options
Ejemplo n.º 11
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(description='Clone an S3QL file system.')

    parser.add_authfile()
    parser.add_quiet()
    parser.add_debug()
    parser.add_backend_options()
    parser.add_version()

    parser.add_argument(
        "src_storage_url",
        metavar='<source-storage-url>',
        type=storage_url_type,
        help='Storage URL of the source backend that contains the file system')

    parser.add_argument("dst_storage_url",
                        metavar='<destination-storage-url>',
                        type=storage_url_type,
                        help='Storage URL of the destination backend')

    parser.add_argument("--threads",
                        type=int,
                        default=3,
                        help='Number of threads to use')

    return parser.parse_args(args)
Ejemplo n.º 12
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(description=textwrap.dedent('''\
        ``expire_backups.py`` is a program to intelligently remove old backups
        that are no longer needed.

        To define what backups you want to keep for how long, you define a
        number of *age ranges*. ``expire_backups`` ensures that you will
        have at least one backup in each age range at all times. It will keep
        exactly as many backups as are required for that and delete any
        backups that become redundant.

        Age ranges are specified by giving a list of range boundaries in terms
        of backup cycles. Every time you create a new backup, the existing
        backups age by one cycle.

        Please refer to the S3QL documentation for details.
        '''))

    parser.add_quiet()
    parser.add_debug()
    parser.add_version()

    parser.add_argument('cycles',
                        nargs='+',
                        type=int,
                        metavar='<age>',
                        help='Age range boundaries in terms of backup cycles')
    parser.add_argument(
        '--state',
        metavar='<file>',
        type=str,
        default='.expire_backups.dat',
        # Add quotes around default to prevent groff
        # from choking on leading . generated by buggy
        # docutils man page generator.
        help='File to save state information in (default: "%(default)s")')
    parser.add_argument(
        "-n",
        action="store_true",
        default=False,
        help="Dry run. Just show which backups would be deleted.")
    parser.add_argument(
        '--reconstruct-state',
        action='store_true',
        default=False,
        help='Try to reconstruct a missing state file from backup dates.')

    parser.add_argument("--use-s3qlrm",
                        action="store_true",
                        help="Use `s3qlrm` command to delete backups.")

    options = parser.parse_args(args)

    if sorted(options.cycles) != options.cycles:
        parser.error('Age range boundaries must be in increasing order')

    return options
Ejemplo n.º 13
0
Archivo: adm.py Proyecto: drewlu/ossql
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description="Manage S3QL Buckets.",
        epilog=textwrap.dedent('''\
               Hint: run `%(prog)s <action> --help` to get help on the additional
               arguments that the different actions take.'''))

    pparser = ArgumentParser(add_help=False, epilog=textwrap.dedent('''\
               Hint: run `%(prog)s --help` to get help on other available actions and
               optional arguments that can be used with all actions.'''))
    pparser.add_storage_url()
    
    subparsers = parser.add_subparsers(metavar='<action>', dest='action',
                                       help='may be either of') 
    subparsers.add_parser("passphrase", help="change bucket passphrase", 
                          parents=[pparser])
    subparsers.add_parser("upgrade", help="upgrade file system to newest revision",
                          parents=[pparser])
    subparsers.add_parser("clear", help="delete all S3QL data from the bucket",
                          parents=[pparser])                                        
    subparsers.add_parser("download-metadata", 
                          help="Interactively download metadata backups. "
                               "Use only if you know what you are doing.",
                          parents=[pparser])    
                
    parser.add_debug_modules()
    parser.add_quiet()
    parser.add_log()
    parser.add_authfile()
    parser.add_cachedir()
    parser.add_version()
        
    options = parser.parse_args(args)
        
    return options
Ejemplo n.º 14
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(description='Batch remove objects from an S3QL backend')

    parser.add_authfile()
    parser.add_quiet()
    parser.add_debug()
    parser.add_backend_options()
    parser.add_version()

    parser.add_argument("storage_url", type=storage_url_type,
                        help='Storage URL of the backend to delete from')

    parser.add_argument("file", type=argparse.FileType(mode='r', encoding='utf-8'),
                        help='File with newline separated object keys to delete')

    return parser.parse_args(args)
Ejemplo n.º 15
0
Archivo: cp.py Proyecto: drewlu/ossql
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description=textwrap.dedent('''\
        Replicates the contents of the directory <source> in the
        directory <target>. <source> has to be an existing directory and
        <target>  must not exist. Both directories have to be within
        the same S3QL file system.

        The replication will not take any additional space. Only if one
        of directories is modified later on, the modified data will take
        additional storage space.
        '''))

    parser.add_debug()
    parser.add_quiet()
    parser.add_version()
    
    parser.add_argument('source', help='source directory', 
                        type=(lambda x: x.rstrip('/')))
    parser.add_argument('target', help='target directory',
                        type=(lambda x: x.rstrip('/')))

    options = parser.parse_args(args)

    return options
Ejemplo n.º 16
0
Archivo: mkfs.py Proyecto: drewlu/ossql
def parse_args(args):

    parser = ArgumentParser(
        description="Initializes an S3QL file system")

    parser.add_cachedir()
    parser.add_authfile()
    parser.add_debug_modules()
    parser.add_quiet()
    parser.add_version()
    parser.add_storage_url()
    
    parser.add_argument("-L", default='', help="Filesystem label",
                      dest="label", metavar='<name>',)
    parser.add_argument("--blocksize", type=int, default=10240, metavar='<size>',
                      help="Maximum block size in KB (default: %(default)d)")
    parser.add_argument("--plain", action="store_true", default=False,
                      help="Create unencrypted file system.")
    parser.add_argument("--force", action="store_true", default=False,
                        help="Overwrite any existing data.")

    options = parser.parse_args(args)
        
    return options
Ejemplo n.º 17
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(description='Clone an S3QL file system.')

    parser.add_quiet()
    parser.add_log()
    parser.add_debug()
    parser.add_backend_options()
    parser.add_version()

    parser.add_argument("--threads",
                        type=int,
                        default=3,
                        help='Number of threads to use')

    # Can't use parser.add_storage_url(), because we need both a source
    # and destination.
    parser.add_argument("--authfile",
                        type=str,
                        metavar='<path>',
                        default=os.path.expanduser("~/.s3ql/authinfo2"),
                        help='Read authentication credentials from this file '
                        '(default: `~/.s3ql/authinfo2)`')
    parser.add_argument(
        "src_storage_url",
        metavar='<source-storage-url>',
        type=storage_url_type,
        help='Storage URL of the source backend that contains the file system')
    parser.add_argument("dst_storage_url",
                        metavar='<destination-storage-url>',
                        type=storage_url_type,
                        help='Storage URL of the destination backend')

    options = parser.parse_args(args)
    setup_logging(options)

    # Print message so that the user has some idea what credentials are
    # wanted (if not specified in authfile).
    log.info('Connecting to source backend...')
    options.storage_url = options.src_storage_url
    parser._init_backend_factory(options)
    src_options = argparse.Namespace()
    src_options.__dict__.update(options.__dict__)
    options.src_backend_factory = lambda: src_options.backend_class(src_options
                                                                    )

    log.info('Connecting to destination backend...')
    options.storage_url = options.dst_storage_url
    parser._init_backend_factory(options)
    dst_options = argparse.Namespace()
    dst_options.__dict__.update(options.__dict__)
    options.dst_backend_factory = lambda: dst_options.backend_class(dst_options
                                                                    )
    del options.storage_url
    del options.backend_class

    return options
Ejemplo n.º 18
0
def parse_args(args):
    '''Parse command line
     
    This function writes to stdout/stderr and may call `system.exit()` instead 
    of throwing an exception if it encounters errors.
    '''

    parser = ArgumentParser(
        description=textwrap.dedent('''\ 
        Unmounts an S3QL file system. The command returns only after all data
        has been uploaded to the backend.'''))

    parser.add_debug()
    parser.add_quiet()
    parser.add_version()
    parser.add_argument("mountpoint", metavar='<mountpoint>',
                        type=(lambda x: x.rstrip('/')),
                        help='Mount point to un-mount')
    
    parser.add_argument('--lazy', "-z", action="store_true", default=False,
                      help="Lazy umount. Detaches the file system immediately, even if there "
                      'are still open files. The data will be uploaded in the background '
                      'once all open files have been closed.')

    return parser.parse_args(args)
Ejemplo n.º 19
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
                description='Clone an S3QL file system.')

    parser.add_quiet()
    parser.add_debug()
    parser.add_backend_options()
    parser.add_version()

    parser.add_argument("--threads", type=int, default=3,
                        help='Number of threads to use')

    # Can't use parser.add_storage_url(), because we need both a source
    # and destination.
    parser.add_argument("--authfile", type=str, metavar='<path>',
                      default=os.path.expanduser("~/.s3ql/authinfo2"),
                      help='Read authentication credentials from this file '
                      '(default: `~/.s3ql/authinfo2)`')
    parser.add_argument("src_storage_url", metavar='<source-storage-url>',
                        type=storage_url_type,
                        help='Storage URL of the source backend that contains the file system')
    parser.add_argument("dst_storage_url", metavar='<destination-storage-url>',
                        type=storage_url_type,
                        help='Storage URL of the destination backend')


    options = parser.parse_args(args)
    setup_logging(options)

    # Print message so that the user has some idea what credentials are
    # wanted (if not specified in authfile).
    log.info('Connecting to source backend...')
    options.storage_url = options.src_storage_url
    parser._init_backend_factory(options)
    src_options = argparse.Namespace()
    src_options.__dict__.update(options.__dict__)
    options.src_backend_factory = lambda: src_options.backend_class(src_options)

    log.info('Connecting to destination backend...')
    options.storage_url = options.dst_storage_url
    parser._init_backend_factory(options)
    dst_options = argparse.Namespace()
    dst_options.__dict__.update(options.__dict__)
    options.dst_backend_factory = lambda: dst_options.backend_class(dst_options)
    del options.storage_url
    del options.backend_class

    return options
Ejemplo n.º 20
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description=textwrap.dedent('''\
        ``expire_backups.py`` is a program to intelligently remove old backups
        that are no longer needed.

        To define what backups you want to keep for how long, you define a
        number of *age ranges*. ``expire_backups`` ensures that you will
        have at least one backup in each age range at all times. It will keep
        exactly as many backups as are required for that and delete any
        backups that become redundant.
        
        Age ranges are specified by giving a list of range boundaries in terms
        of backup cycles. Every time you create a new backup, the existing
        backups age by one cycle.

        Please refer to the S3QL documentation for details.
        '''))

    parser.add_quiet()
    parser.add_debug()
    parser.add_version() 

    parser.add_argument('cycles', nargs='+',  type=int, metavar='<age>',
                        help='Age range boundaries in terms of backup cycles')
    parser.add_argument('--state', metavar='<file>', type=str,
                        default='.expire_backups.dat',
                        # Add quotes around default to prevent groff
                        # from choking on leading . generated by buggy
                        # docutils man page generator.
                        help='File to save state information in (default: "%(default)s")')
    parser.add_argument("-n", action="store_true", default=False,
                        help="Dry run. Just show which backups would be deleted.")
    parser.add_argument('--reconstruct-state', action='store_true', default=False,
                        help='Try to reconstruct a missing state file from backup dates.')

    parser.add_argument("--use-s3qlrm", action="store_true",
                      help="Use `s3qlrm` command to delete backups.")
    
    options = parser.parse_args(args) 
    
    if sorted(options.cycles) != options.cycles:
        parser.error('Age range boundaries must be in increasing order')
        
    return options
Ejemplo n.º 21
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description='Measure S3QL write performance, uplink bandwidth and '
        'compression speed and determine limiting factor.')

    parser.add_quiet()
    parser.add_debug()
    parser.add_backend_options()
    parser.add_version()
    parser.add_storage_url()
    parser.add_argument('file',
                        metavar='<file>',
                        type=argparse.FileType(mode='rb'),
                        help='File to transfer')
    parser.add_argument(
        '--threads',
        metavar='<n>',
        type=int,
        default=None,
        help='Also include statistics for <n> threads in results.')

    parser.add_cachedir()
    return parser.parse_args(args)
Ejemplo n.º 22
0
def parse_args(args):

    parser = ArgumentParser(
        description="Create metadata copy where all file- and directory names, "
                    "and extended attribute names and values have been scrambled. "
                    "This is intended to preserve privacy when a metadata copy "
                    "needs to be provided to the developers for debugging.")

    parser.add_debug_modules()
    parser.add_quiet()
    parser.add_version()
    parser.add_cachedir()
    parser.add_storage_url()

    options = parser.parse_args(args)

    return options
Ejemplo n.º 23
0
Archivo: ctrl.py Proyecto: drewlu/ossql
def parse_args(args):
    '''Parse command line'''
    
    parser = ArgumentParser(
        description='''Control a mounted S3QL File System''',
        epilog=textwrap.dedent('''\
               Hint: run `%(prog)s <action> --help` to get help on the additional
               arguments that the different actions take.'''))

    pparser = ArgumentParser(add_help=False, epilog=textwrap.dedent('''\
               Hint: run `%(prog)s --help` to get help on other available actions and
               optional arguments that can be used with all actions.'''))
    pparser.add_argument("mountpoint", metavar='<mountpoint>',
                         type=(lambda x: x.rstrip('/')),
                         help='Mountpoint of the file system')    
        
    parser.add_debug()
    parser.add_quiet()
    parser.add_version()
    
    subparsers = parser.add_subparsers(metavar='<action>', dest='action',
                                       help='may be either of')                               
    subparsers.add_parser('flushcache', help='flush file system cache',
                          parents=[pparser])
    subparsers.add_parser('upload-meta', help='Upload metadata',
                          parents=[pparser])
    
    sparser = subparsers.add_parser('cachesize', help='Change cache size',
                                    parents=[pparser])          
    sparser.add_argument('cachesize', metavar='<size>', type=int,
                         help='New cache size in KB')
    
    sparser = subparsers.add_parser('log', help='Change log level',
                                    parents=[pparser])

    sparser.add_argument('level', choices=('debug', 'info', 'warn'),
                         metavar='<level>', 
                         help='Desired new log level for mount.s3ql process. '
                              'Allowed values: %(choices)s')
    sparser.add_argument('modules', nargs='*', metavar='<module>', 
                         help='Modules to enable debugging output for. Specify '
                              '`all` to enable debugging for all modules.')
                
    options = parser.parse_args(args)
    
    if options.action == 'log':
        if options.level != 'debug' and options.modules:
            parser.error('Modules can only be specified with `debug` logging level.')
        if not options.modules:
            options.modules = [ 'all' ]
        
        if options.level:
            # Protected member ok, hopefully this won't break
            #pylint: disable=W0212
            options.level = logging._levelNames[options.level.upper()]
                             
    return options
Ejemplo n.º 24
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
        description='Recursively copy source(s) to destination using multiple '
                    'parallel rsync processes.')

    parser.add_quiet()
    parser.add_debug()
    parser.add_version()

    parser.add_argument("-a", action="store_true",
                      help='Pass -aHAX option to rsync.')
    parser.add_argument("--processes", action="store", type=int, metavar='<no>',
                      default=10,
                      help='Number of rsync processes to use (default: %(default)s).')

    parser.add_argument('source', metavar='<source>', nargs='+',
                        help='Directories to copy')
    parser.add_argument('dest', metavar='<destination>',
                        help="Target directory")

    options = parser.parse_args(args)
    options.pps = options.source + [ options.dest ]

    return options
Ejemplo n.º 25
0
Archivo: fsck.py Proyecto: drewlu/ossql
def parse_args(args):

    parser = ArgumentParser(
        description="Checks and repairs an S3QL filesystem.")

    parser.add_log('~/.s3ql/fsck.log')
    parser.add_cachedir()
    parser.add_authfile()
    parser.add_debug_modules()
    parser.add_quiet()
    parser.add_version()
    parser.add_storage_url()

    parser.add_argument("--batch", action="store_true", default=False,
                      help="If user input is required, exit without prompting.")
    parser.add_argument("--force", action="store_true", default=False,
                      help="Force checking even if file system is marked clean.")

    options = parser.parse_args(args)

    return options
Ejemplo n.º 26
0
def parse_args(args):
    '''Parse command line'''

    parser = ArgumentParser(
                description='Measure S3QL write performance, uplink bandwidth and '
                            'compression speed and determine limiting factor.')

    parser.add_authfile()
    parser.add_quiet()
    parser.add_debug()
    parser.add_ssl()
    parser.add_version()
    parser.add_storage_url()
    parser.add_argument('file', metavar='<file>', type=argparse.FileType(mode='rb'),
                        help='File to transfer')
    parser.add_argument('--threads', metavar='<n>', type=int, default=None,
                        help='Also include statistics for <n> threads in results.')
    
    parser.add_cachedir()
    return parser.parse_args(args)
Ejemplo n.º 27
0
def parse_args(args):

    parser = ArgumentParser(
        description="Create metadata copy where all file- and directory names, "
                    "and extended attribute names and values have been scrambled. "
                    "This is intended to preserve privacy when a metadata copy "
                    "needs to be provided to the developers for debugging.")

    parser.add_debug()
    parser.add_quiet()
    parser.add_version()
    parser.add_cachedir()
    parser.add_storage_url()

    options = parser.parse_args(args)

    return options