def __init__(self): self.meta = None self.object_size = 0 self.objects = 0 self.export_size = 0 parser = ArgumentParser(description=description, epilog="Contact and support: %s" % project_url ) parser.add_argument("--version", action="version", version="%(prog)s " + version) parser.add_argument("--secrets", dest="secrets_file", default=secrets_file, help="filename containing user/password (default: %s)" % secrets_file) parser.add_argument("-a", "--auth-url", dest="authurl", default=auth_url, help="default authentication URL (default: %s)" % auth_url) parser.add_argument("-k", "--keystone-auth", dest="keystone", action="store_true", help="use auth 2.0 (keystone, requires keystoneclient)") parser.add_argument("--keystone-separator", dest="keystone_separator", default=keystone_separator, help="tenant separator to be used with auth 2.0 (default: %s)" % keystone_separator) parser.add_argument("--keystone-service", dest="keystone_service", default=keystone_service, help="service to be used with auth 2.0 (default: %s)" % keystone_service) parser.add_argument("--keystone-endpoint", dest="keystone_endpoint", default=keystone_endpoint, help="endpoint to be used with auth 2.0 (default: %s)" % keystone_endpoint) parser.add_argument("--keystone-region", dest="keystone_region", default=None, help="region to be used with auth 2.0 (optional)") parser.add_argument("-b", "--bind-address", dest="bind_address", default="127.0.0.1", help="bind address (default: 127.0.0.1)") parser.add_argument("-p", "--bind-port", dest="bind_port", type=int, default=10809, help="bind address (default: 10809)") parser.add_argument("-c", "--cache-limit", dest="cache_limit", type=int, default=64, help="cache memory limit in MB (default: 64)") parser.add_argument("-l", "--log-file", dest="log_file", default=None, help="log into the provided file" ) parser.add_argument("--syslog", dest="syslog", action="store_true", help="log to system logger (local0)" ) parser.add_argument("-f", "--foreground", dest="foreground", action="store_true", help="don't detach from terminal (foreground mode)" ) default_pidfile = os.path.join(tempfile.gettempdir(), "%s.pid" % __package__) parser.add_argument("--pid-file", dest="pidfile", default=default_pidfile, help="filename to store the PID (default: %s)" % default_pidfile ) parser.add_argument("-v", "--verbose", dest="verbose", action="store_true", help="enable verbose logging" ) self.args = parser.parse_args() if self.args.cache_limit < 1: parser.error("Cache limit can't be less than 1MB") self.log = setLog(debug=self.args.verbose, use_syslog=self.args.syslog, use_file=self.args.log_file) try: self.conf = Config(self.args.secrets_file) except OSError as ex: parser.error("Failed to load secrets: %s" % ex)
def __init__(self): parser = ArgumentParser(description="swiftnbd control tool.", epilog="Contact and support: %s" % project_url) subp = parser.add_subparsers(title="commands") subp.required = True subp.dest = "command" p = subp.add_parser('list', help='list all containers and their information') p.add_argument("-s", "--simple-output", dest="simple", action="store_true", help="write simplified output to stdout") p.set_defaults(func=self.do_list) p = subp.add_parser('setup', help='setup a container to be used by the server') p.add_argument("container", help="container to setup") p.add_argument("objects", help="number of objects") p.add_argument("--object-size", dest="object_size", default=object_size, help="object size (default: %s)" % object_size) p.add_argument("-f", "--force", dest="force", action="store_true", help="force operation") p.set_defaults(func=self.do_setup) p = subp.add_parser('unlock', help='unlock a container') p.add_argument("container", help="container to unlock") p.set_defaults(func=self.do_unlock) p = subp.add_parser('lock', help='lock a container') p.add_argument("container", help="container to lock") p.set_defaults(func=self.do_lock) p = subp.add_parser('download', help='download a container as a raw image') p.add_argument("container", help="container to download") p.add_argument("image", help="local file to store the image") p.add_argument("-q", "--quiet", dest="quiet", action="store_true", help="don't show the process bar") p.set_defaults(func=self.do_download) p = subp.add_parser('delete', help='delete a container') p.add_argument("container", help="container to delete") p.set_defaults(func=self.do_delete) parser.add_argument("--version", action="version", version="%(prog)s " + version) parser.add_argument( "--secrets", dest="secrets_file", default=secrets_file, help="filename containing user/password (default: %s)" % secrets_file) parser.add_argument("-a", "--auth-url", dest="authurl", default=auth_url, help="default authentication URL (default: %s)" % auth_url) parser.add_argument( "-k", "--keystone-auth", dest="keystone", action="store_true", help="use auth 2.0 (keystone, requires keystoneclient)") parser.add_argument( "--keystone-separator", dest="keystone_separator", default=keystone_separator, help="tenant separator to be used with auth 2.0 (default: %s)" % keystone_separator) parser.add_argument( "--keystone-service", dest="keystone_service", default=keystone_service, help="service to be used with auth 2.0 (default: %s)" % keystone_service) parser.add_argument( "--keystone-endpoint", dest="keystone_endpoint", default=keystone_endpoint, help="endpoint to be used with auth 2.0 (default: %s)" % keystone_endpoint) parser.add_argument("--keystone-region", dest="keystone_region", default=None, help="region to be used with auth 2.0 (optional)") parser.add_argument("-v", "--verbose", dest="verbose", action="store_true", help="enable verbose logging") self.args = parser.parse_args() self.log = setLog(debug=self.args.verbose) try: self.conf = Config(self.args.secrets_file) except OSError as ex: parser.error("Failed to load secrets: %s" % ex) # setup by _setup_client() self.auth = None
def __init__(self): parser = ArgumentParser(description="swiftnbd control tool.", epilog="Contact and support: %s" % project_url ) subp = parser.add_subparsers(title="commands") p = subp.add_parser('list', help='list all containers and their information') p.add_argument("-s", "--simple-output", dest="simple", action="store_true", help="write simplified output to stdout") p.set_defaults(func=self.do_list) p = subp.add_parser('setup', help='setup a container to be used by the server') p.add_argument("container", help="container to setup") p.add_argument("objects", help="number of objects") p.add_argument("--object-size", dest="object_size", default=object_size, help="object size (default: %s)" % object_size) p.add_argument("-f", "--force", dest="force", action="store_true", help="force operation") p.set_defaults(func=self.do_setup) p = subp.add_parser('unlock', help='unlock a container') p.add_argument("container", help="container to unlock") p.set_defaults(func=self.do_unlock) p = subp.add_parser('lock', help='lock a container') p.add_argument("container", help="container to lock") p.set_defaults(func=self.do_lock) p = subp.add_parser('download', help='download a container as a raw image') p.add_argument("container", help="container to download") p.add_argument("image", help="local file to store the image") p.add_argument("-q", "--quiet", dest="quiet", action="store_true", help="don't show the process bar") p.set_defaults(func=self.do_download) p = subp.add_parser('delete', help='delete a container') p.add_argument("container", help="container to delete") p.set_defaults(func=self.do_delete) parser.add_argument("--version", action="version", version="%(prog)s " + version) parser.add_argument("--secrets", dest="secrets_file", default=secrets_file, help="filename containing user/password (default: %s)" % secrets_file) parser.add_argument("-a", "--auth-url", dest="authurl", default=auth_url, help="default authentication URL (default: %s)" % auth_url) parser.add_argument("-v", "--verbose", dest="verbose", action="store_true", help="enable verbose logging" ) self.args = parser.parse_args() self.log = setLog(debug=self.args.verbose) try: self.conf = Config(self.args.secrets_file, self.args.authurl) except OSError as ex: parser.error("Failed to load secrets: %s" % ex) # setup by _setup_client() self.authurl = None self.username = None self.password = None
def __init__(self): self.meta = None self.object_size = 0 self.objects = 0 self.export_size = 0 parser = ArgumentParser(description=description, epilog="Contact and support: %s" % project_url) parser.add_argument("--version", action="version", version="%(prog)s " + version) parser.add_argument( "--secrets", dest="secrets_file", default=secrets_file, help="filename containing user/password (default: %s)" % secrets_file) parser.add_argument("-a", "--auth-url", dest="authurl", default=auth_url, help="default authentication URL (default: %s)" % auth_url) parser.add_argument( "-k", "--keystone-auth", dest="keystone", action="store_true", help="use auth 2.0 (keystone, requires keystoneclient)") parser.add_argument( "--keystone-separator", dest="keystone_separator", default=keystone_separator, help="tenant separator to be used with auth 2.0 (default: %s)" % keystone_separator) parser.add_argument( "--keystone-service", dest="keystone_service", default=keystone_service, help="service to be used with auth 2.0 (default: %s)" % keystone_service) parser.add_argument( "--keystone-endpoint", dest="keystone_endpoint", default=keystone_endpoint, help="endpoint to be used with auth 2.0 (default: %s)" % keystone_endpoint) parser.add_argument("--keystone-region", dest="keystone_region", default=None, help="region to be used with auth 2.0 (optional)") parser.add_argument("-b", "--bind-address", dest="bind_address", default="127.0.0.1", help="bind address (default: 127.0.0.1)") parser.add_argument("-p", "--bind-port", dest="bind_port", type=int, default=10809, help="bind address (default: 10809)") parser.add_argument("-c", "--cache-limit", dest="cache_limit", type=int, default=64, help="cache memory limit in MB (default: 64)") parser.add_argument("-l", "--log-file", dest="log_file", default=None, help="log into the provided file") parser.add_argument("--syslog", dest="syslog", action="store_true", help="log to system logger (local0)") parser.add_argument( "-f", "--foreground", dest="foreground", action="store_true", help="don't detach from terminal (foreground mode)") default_pidfile = os.path.join(tempfile.gettempdir(), "%s.pid" % __package__) parser.add_argument("--pid-file", dest="pidfile", default=default_pidfile, help="filename to store the PID (default: %s)" % default_pidfile) parser.add_argument("-v", "--verbose", dest="verbose", action="store_true", help="enable verbose logging") self.args = parser.parse_args() if self.args.cache_limit < 1: parser.error("Cache limit can't be less than 1MB") self.log = setLog(debug=self.args.verbose, use_syslog=self.args.syslog, use_file=self.args.log_file) try: self.conf = Config(self.args.secrets_file) except OSError as ex: parser.error("Failed to load secrets: %s" % ex)