def parse_args(args=None): usage = "usage: %prog [options] type command [id [attributes]]" # Initialize a parser for our configuration paramaters parser = RaisingOptionParser(usage, version='%%prog %s' % keystone.version()) _common_group = config.add_common_options(parser) config.add_log_options(parser) # Parse command-line and load config (options, args) = config.parse_options(parser, args) _config_file, conf = config.load_paste_config('admin', options, args) # Set things up to run the command debug = options.get('debug') or conf.get('debug', False) debug = debug in [True, "True", "1"] verbose = options.get('verbose') or conf.get('verbose', False) verbose = verbose in [True, "True", "1"] if debug or verbose: _config_file = config.find_config_file(options, args) config.setup_logging(options, conf) db.configure_backends(conf.global_conf) return args
def init_config(): """Uses legacy config module to parse out legacy settings and provide them to the new cfg.py parser. This is a hack until we find a better way to have cfg.py ignore unknown arguments """ class SilentOptParser(optparse.OptionParser): """ Class used to prevent OptionParser from exiting when it detects invalid options coming in """ def exit(self, status=0, msg=None): pass def error(self, msg): pass # Initialize a parser for our configuration paramaters parser = SilentOptParser() legacy_config.add_common_options(parser) legacy_config.add_log_options(parser) # Parse command-line and load config (options, args) = legacy_config.parse_options(parser) (legacy_args, unknown_args) = parser.parse_args() cfgfile = getattr(legacy_args, 'config_file', None) if cfgfile: known_args = ['--config-file', cfgfile] else: known_args = [] # Use the legacy code to find the config file config_file = legacy_config.find_config_file(options, known_args) # Now init the CONF for the backends using only known args old_args = sys.argv[:] sys.argv = known_args try: CONF(config_files=[config_file]) except StandardError: raise finally: sys.argv = old_args
def init_config(): """Uses legacy config module to parse out legacy settings and provide them to the new cfg.py parser. This is a hack until we find a better way to have cfg.py ignore unknown arguments """ class SilentOptParser(optparse.OptionParser): """ Class used to prevent OptionParser from exiting when it detects invalid options coming in """ def exit(self, status=0, msg=None): pass def error(self, msg): pass # Initialize a parser for our configuration paramaters parser = SilentOptParser() legacy_config.add_common_options(parser) legacy_config.add_log_options(parser) # Parse command-line and load config (options, args) = legacy_config.parse_options(parser) (legacy_args, unknown_args) = parser.parse_args() cfgfile = getattr(legacy_args, 'config_file', None) if cfgfile: known_args = ['--config-file', cfgfile] else: known_args = [] # Use the legacy code to find the config file config_file = legacy_config.find_config_file(options, known_args) # Now init the CONF for the backends using only known args old_args = sys.argv[:] sys.argv = known_args try: CONF(config_files=[config_file]) except StandardError: raise finally: sys.argv = old_args
def init_managers(): """Initializes backend storage and return managers""" if new_config.CONF.backends is None: # Get merged config and CLI options and admin-specific settings options = get_options() config_file = config.find_config_file(options, sys.argv[1:]) new_config.CONF(config_files=[config_file]) backends.configure_backends() managers = {} managers['credential_manager'] = CredentialManager() managers['token_manager'] = TokenManager() managers['tenant_manager'] = TenantManager() managers['endpoint_manager'] = EndpointManager() managers['endpoint_template_manager'] = EndpointTemplateManager() managers['user_manager'] = UserManager() managers['role_manager'] = RoleManager() managers['grant_manager'] = GrantManager() managers['service_manager'] = ServiceManager() return managers
def init_managers(): """Initializes backend storage and return managers""" if new_config.CONF.backends is None: # Get merged config and CLI options and admin-specific settings options = get_options() config_file = config.find_config_file(options, sys.argv[1:]) new_config.CONF(config_files=[config_file]) backends.configure_backends() managers = {} managers['credential_manager'] = CredentialManager() managers['token_manager'] = TokenManager() managers['tenant_manager'] = TenantManager() managers['endpoint_manager'] = EndpointManager() managers['endpoint_template_manager'] = EndpointTemplateManager() managers['user_manager'] = UserManager() managers['role_manager'] = RoleManager() managers['grant_manager'] = GrantManager() managers['service_manager'] = ServiceManager() return managers
def parse_args(args=None): usage = """ Usage: keystone-manage [options] type action [id [attributes]] type : %s action : %s id : name or id attributes : depending on type... users : password, tenant tokens : user, tenant, expiration role list [tenant] will list roles granted on that tenant database [sync | downgrade | upgrade | version_control | version] options -c | --config-file : config file to use -d | --debug : debug mode Example: keystone-manage user add Admin P@ssw0rd """ % (", ".join(OBJECTS), ", ".join(ACTIONS)) # Initialize a parser for our configuration paramaters parser = RaisingOptionParser(usage, version='%%prog %s' % version.version()) config.add_common_options(parser) config.add_log_options(parser) # Parse command-line and load config (options, args) = config.parse_options(parser, args) if not args or args[0] != 'database': # Use the legacy code to find the config file config_file = config.find_config_file(options, sys.argv[1:]) # Now init the CONF for the backends CONF(config_files=[config_file]) db.configure_backends() return args
def parse_args(args=None): usage = """ Usage: keystone-manage [options] type action [id [attributes]] type : %s action : %s id : name or id attributes : depending on type... users : password, tenant tokens : user, tenant, expiration role list [tenant] will list roles granted on that tenant database [sync | downgrade | upgrade | version_control | version] options -c | --config-file : config file to use -d | --debug : debug mode Example: keystone-manage user add Admin P@ssw0rd """ % (", ".join(OBJECTS), ", ".join(ACTIONS)) # Initialize a parser for our configuration paramaters parser = RaisingOptionParser(usage, version='%%prog %s' % version.version()) config.add_common_options(parser) config.add_log_options(parser) # Parse command-line and load config (options, args) = config.parse_options(parser, args) if not args or args[0] != 'database': # Use the legacy code to find the config file config_file = config.find_config_file(options, sys.argv[1:]) # Now init the CONF for the backends CONF(config_files=[config_file]) db.configure_backends() return args
def start(self, host=None, port=None, wait=True): """Starts the Keystone server :param host: the IP address to listen on :param port: the TCP/IP port to listen on :param wait: whether to wait (block) for the server to terminate or return to the caller without waiting """ logger.debug("Starting API server") conf, app = common_config.load_paste_app(self.config, self.options, self.args) debug = CONF.debug in [True, "True", "1"] verbose = CONF.verbose in [True, "True", "1"] if debug or verbose: config_file = common_config.find_config_file(self.options, self.args) logger.info("Starting '%s' with config: %s" % (self.config, config_file)) if port is None: if self.config == 'admin': # Legacy port = int(CONF.admin_port or 35357) else: port = int(CONF.service_port or CONF.bind_port or 5000) if host is None: host = CONF.bind_host or CONF.service_host or "0.0.0.0" self.key = "%s-%s:%s" % (self.name, host, port) # Safely get SSL options service_ssl = CONF.service_ssl in [True, "True", "1"] # Load the server if service_ssl: cert_required = conf.get('cert_required', False) cert_required = cert_required in [True, "True", "1"] certfile = conf.get('certfile') keyfile = conf.get('keyfile') ca_certs = conf.get('ca_certs') self.server = wsgi.SslServer() self.server.start(app, port, host, certfile=certfile, keyfile=keyfile, ca_certs=ca_certs, cert_required=cert_required, key=self.key) self.protocol = 'https' else: self.server = wsgi.Server() self.server.start(app, port, host, key="%s-%s:%s" % (self.config, host, port)) self.protocol = 'http' self.port = port self.host = host logger.info("%s listening on %s://%s:%s" % ( self.name, ['http', 'https'][service_ssl], host, port)) # Wait until done if wait: self.server.wait()
def start(self, host=None, port=None, wait=True): """Starts the Keystone server :param host: the IP address to listen on :param port: the TCP/IP port to listen on :param wait: whether to wait (block) for the server to terminate or return to the caller without waiting """ logger.debug("Starting API server") conf, app = config.load_paste_app( self.config, self.options, self.args) debug = self.options.get('debug') or conf.get('debug', False) debug = debug in [True, "True", "1"] verbose = self.options.get('verbose') or conf.get('verbose', False) verbose = verbose in [True, "True", "1"] if debug or verbose: config_file = config.find_config_file(self.options, self.args) logger.info("Starting '%s' with config: %s" % (self.config, config_file)) if port is None: if self.config == 'admin': # Legacy port = int(self.options.get('bind_port') or conf.get('admin_port', 35357)) else: port = int(self.options.get('bind_port') or conf.get('service_port', 5000)) if host is None: host = self.options.get('bind_host', conf.get('service_host', '0.0.0.0')) self.key = "%s-%s:%s" % (self.name, host, port) # Safely get SSL options service_ssl = conf.get('service_ssl', False) service_ssl = service_ssl in [True, "True", "1"] # Load the server if service_ssl: cert_required = conf.get('cert_required', False) cert_required = cert_required in [True, "True", "1"] certfile = conf.get('certfile') keyfile = conf.get('keyfile') ca_certs = conf.get('ca_certs') self.server = wsgi.SslServer() self.server.start(app, port, host, certfile=certfile, keyfile=keyfile, ca_certs=ca_certs, cert_required=cert_required, key=self.key) self.protocol = 'https' else: self.server = wsgi.Server() self.server.start(app, port, host, key="%s-%s:%s" % (self.config, host, port)) self.protocol = 'http' self.port = port self.host = host logger.info("%s listening on %s://%s:%s" % ( self.name, ['http', 'https'][service_ssl], host, port)) if not (debug or verbose): print "%s listening on %s://%s:%s" % ( self.name, ['http', 'https'][service_ssl], host, port) # Wait until done if wait: self.server.wait()
def start(self, host=None, port=None, wait=True): """Starts the Keystone server :param host: the IP address to listen on :param port: the TCP/IP port to listen on :param wait: whether to wait (block) for the server to terminate or return to the caller without waiting """ logger.debug("Starting API server") conf, app = common_config.load_paste_app(self.config, self.options, self.args) debug = CONF.debug in [True, "True", "1"] verbose = CONF.verbose in [True, "True", "1"] if debug or verbose: config_file = common_config.find_config_file(self.options, self.args) logger.info("Starting '%s' with config: %s" % (self.config, config_file)) if port is None: if self.config == "admin": # Legacy port = int(CONF.admin_port or 35357) else: port = int(CONF.service_port or CONF.bind_port or 5000) if host is None: host = CONF.bind_host or CONF.service_host or "0.0.0.0" self.key = "%s-%s:%s" % (self.name, host, port) # Safely get SSL options service_ssl = CONF.service_ssl in [True, "True", "1"] # Load the server if service_ssl: cert_required = conf.get("cert_required", False) cert_required = cert_required in [True, "True", "1"] certfile = conf.get("certfile") keyfile = conf.get("keyfile") ca_certs = conf.get("ca_certs") self.server = wsgi.SslServer() self.server.start( app, port, host, certfile=certfile, keyfile=keyfile, ca_certs=ca_certs, cert_required=cert_required, key=self.key, ) self.protocol = "https" else: self.server = wsgi.Server() self.server.start(app, port, host, key="%s-%s:%s" % (self.config, host, port)) self.protocol = "http" self.port = port self.host = host logger.info("%s listening on %s://%s:%s" % (self.name, ["http", "https"][service_ssl], host, port)) # Wait until done if wait: self.server.wait()