Example #1
0
def get_options():
    # Initialize a parser for our configuration paramaters
    parser = optparse.OptionParser("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, [])  # pylint: disable=W0612

    return options
Example #2
0
def get_options():
    # Initialize a parser for our configuration paramaters
    parser = optparse.OptionParser("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, [])  # pylint: disable=W0612

    return options
Example #3
0
def get_options(args=None):
    # Initialize a parser for our configuration paramaters
    parser = RaisingOptionParser()
    config.add_common_options(parser)
    config.add_log_options(parser)

    # Parse command-line and load config
    (options, args) = config.parse_options(parser, list(args))

    _config_file, conf = config.load_paste_config('admin', options, args)
    conf.global_conf.update(conf.local_conf)

    return conf.global_conf
Example #4
0
def get_options(args=None):
    # Initialize a parser for our configuration paramaters
    parser = RaisingOptionParser()
    config.add_common_options(parser)
    config.add_log_options(parser)

    # Parse command-line and load config
    (options, args) = config.parse_options(parser, list(args))

    _config_file, conf = config.load_paste_config('admin', options, args)
    conf.global_conf.update(conf.local_conf)

    return conf.global_conf
Example #5
0
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
Example #6
0
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

    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' % 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)

    config.setup_logging(options, conf)

    db.configure_backends(conf.global_conf)

    return args
Example #7
0
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

    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'
        % 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)

    config.setup_logging(options, conf)

    db.configure_backends(conf.global_conf)

    return args
Example #8
0
    def startServer(self):
        """ Starts a Keystone server on random ports for testing """
        self.server = None
        self.admin_server = None

        self.construct_temp_conf_file()

        # Set client certificate for test client
        if self.isSsl:
            logger.debug("SSL testing will use cert_file %s" % TEST_CERT)
            os.environ['cert_file'] = TEST_CERT
        else:
            if 'cert_file' in os.environ:
                del os.environ['cert_file']

        # indicating HP-IDM is disabled
        if self.hpidmDisabled:
            logger.debug("HP-IDM extensions is disabled")
            os.environ['HP-IDM_Disabled'] = 'True'
        else:
            if 'HP-IDM_Disabled' in os.environ:
                del os.environ['HP-IDM_Disabled']

        # run the keystone server
        logger.info("Starting the keystone server...")

        parser = optparse.OptionParser(version='%%prog %s' %
                                       keystone.version.version())
        common_group = config.add_common_options(parser)
        config.add_log_options(parser)

        # Handle a special argument to support starting two endpoints
        common_group.add_option(
            '-a', '--admin-port', dest="admin_port", metavar="PORT",
            help="specifies port for Admin API to listen " \
                 "on (default is 35357)")

        # Parse arguments and load config
        (options, args) = config.parse_options(parser)
        options['config_file'] = self.conf_fp.name

        try:
            # Load Service API Server
            service = keystone.server.Server(
                name="Service API",
                config_name='keystone-legacy-auth',
                options=options,
                args=args)
            service.start(wait=False)

            # Client tests will use these globals to find out where
            # the server is
            client_tests.TEST_TARGET_SERVER_SERVICE_PROTOCOL = service.protocol
            client_tests.TEST_TARGET_SERVER_SERVICE_ADDRESS = service.host
            client_tests.TEST_TARGET_SERVER_SERVICE_PORT = service.port

        except RuntimeError, e:
            logger.exception(e)
            raise e
Example #9
0
    def startServer(self):
        """ Starts a Keystone server on random ports for testing """
        self.server = None
        self.admin_server = None

        self.construct_temp_conf_file()

        # Set client certificate for test client
        if self.isSsl:
            logger.debug("SSL testing will use cert_file %s" % TEST_CERT)
            os.environ["cert_file"] = TEST_CERT
        else:
            if "cert_file" in os.environ:
                del os.environ["cert_file"]

        # indicating HP-IDM is disabled
        if self.hpidmDisabled:
            logger.debug("HP-IDM extensions is disabled")
            os.environ["HP-IDM_Disabled"] = "True"
        else:
            if "HP-IDM_Disabled" in os.environ:
                del os.environ["HP-IDM_Disabled"]

        # run the keystone server
        logger.info("Starting the keystone server...")

        parser = optparse.OptionParser(version="%%prog %s" % keystone.version.version())
        common_group = config.add_common_options(parser)
        config.add_log_options(parser)

        # Handle a special argument to support starting two endpoints
        common_group.add_option(
            "-a",
            "--admin-port",
            dest="admin_port",
            metavar="PORT",
            help="specifies port for Admin API to listen " "on (default is 35357)",
        )

        # Parse arguments and load config
        (options, args) = config.parse_options(parser)
        options["config_file"] = self.conf_fp.name

        try:
            # Load Service API Server
            service = keystone.server.Server(
                name="Service API", config_name="keystone-legacy-auth", options=options, args=args
            )
            service.start(wait=False)

            # Client tests will use these globals to find out where
            # the server is
            client_tests.TEST_TARGET_SERVER_SERVICE_PROTOCOL = service.protocol
            client_tests.TEST_TARGET_SERVER_SERVICE_ADDRESS = service.host
            client_tests.TEST_TARGET_SERVER_SERVICE_PORT = service.port

        except RuntimeError, e:
            logger.exception(e)
            raise e
Example #10
0
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
Example #11
0
    def __init__(self,
                 name='admin',
                 config_name=None,
                 options=None,
                 args=None):
        """Initizalizer which takes the following paramaters:

        :param name: A cosmetic name for the server (ex. Admin API)
        :param config: the paste config name to look for when starting the
            server
        :param options: a mapping of option key/str(value) pairs passed to
            config.load_paste_app
        :param args: override for sys.argv (otherwise sys.argv is used)
        """
        logger.debug("Init server '%s' with config=%s" % (name, config_name))

        if options is None or args is None:
            # Initialize a parser for our configuration paramaters if needed
            parser = optparse.OptionParser()
            config.add_common_options(parser)
            config.add_log_options(parser)

            # Parse arguments and load config
            (poptions, pargs) = config.parse_options(parser, args)

        if options is None:
            self.options = poptions
        else:
            self.options = options
        logger.debug("Server is using options=%s" % self.options)

        if args is None:
            self.args = pargs
        else:
            self.args = args
        logger.debug("Server is using args=%s" % self.args)

        self.name = name
        self.config = config_name or self.name
        self.key = None
        self.server = None
        self.port = None
        self.host = None
        self.protocol = None
Example #12
0
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
Example #13
0
    def __init__(self, name='admin', config_name=None,
                 options=None, args=None):
        """Initizalizer which takes the following paramaters:

        :param name: A cosmetic name for the server (ex. Admin API)
        :param config: the paste config name to look for when starting the
            server
        :param options: a mapping of option key/str(value) pairs passed to
            config.load_paste_app
        :param args: override for sys.argv (otherwise sys.argv is used)
        """
        logger.debug("Init server '%s' with config=%s" % (name, config_name))

        if options is None or args is None:
            # Initialize a parser for our configuration paramaters if needed
            parser = optparse.OptionParser()
            config.add_common_options(parser)
            config.add_log_options(parser)

            # Parse arguments and load config
            (poptions, pargs) = config.parse_options(parser, args)

        if options is None:
            self.options = poptions
        else:
            self.options = options
        logger.debug("Server is using options=%s" % self.options)

        if args is None:
            self.args = pargs
        else:
            self.args = args
        logger.debug("Server is using args=%s" % self.args)

        self.name = name
        self.config = config_name or self.name
        self.key = None
        self.server = None
        self.port = None
        self.host = None
        self.protocol = None
Example #14
0
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
Example #15
0
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
Example #16
0
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)

    config.setup_logging(options, conf)

    db.configure_backends(conf.global_conf)

    return args
Example #17
0
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)

    config.setup_logging(options, conf)

    db.configure_backends(conf.global_conf)

    return args
Example #18
0
    def startServer(self):
        """ Starts a Keystone server on random ports for testing """
        self.server = None
        self.admin_server = None

        self.construct_temp_conf_file()

        # Set client certificate for test client
        if self.isSsl:
            logger.debug("SSL testing will use cert_file %s" % TEST_CERT)
            os.environ['cert_file'] = TEST_CERT
        else:
            if 'cert_file' in os.environ:
                del os.environ['cert_file']

        # indicating HP-IDM is disabled
        if self.hpidmDisabled:
            logger.debug("HP-IDM extensions is disabled")
            os.environ['HP-IDM_Disabled'] = 'True'
        else:
            if 'HP-IDM_Disabled' in os.environ:
                del os.environ['HP-IDM_Disabled']

        # run the keystone server
        logger.info("Starting the keystone server...")

        class SilentOptParser(optparse.OptionParser):
            """ Class used to prevent OptionParser from exiting when it detects
            options coming in for nose/testing """
            def exit():
                pass

            def error(self, msg):
                pass

        parser = SilentOptParser(version='%%prog %s' %
                                       keystone.version.version())
        common_group = config.add_common_options(parser)
        config.add_log_options(parser)

        # Handle a special argument to support starting two endpoints
        common_group.add_option(
            '-a', '--admin-port', dest="admin_port", metavar="PORT",
            help="specifies port for Admin API to listen "
                 "on (default is 35357)")

        # Parse arguments and load config
        (options, args) = config.parse_options(parser)
        options['config_file'] = self.conf_fp.name

        # Populate the CONF module
        CONF.reset()
        CONF(config_files=[self.conf_fp.name])

        try:
            # Load Service API Server
            service = keystone.server.Server(name="Service API",
                                            config_name='keystone-legacy-auth',
                                            args=args)
            service.start(wait=False)

            # Client tests will use these globals to find out where
            # the server is
            client_tests.TEST_TARGET_SERVER_SERVICE_PROTOCOL = service.protocol
            client_tests.TEST_TARGET_SERVER_SERVICE_ADDRESS = service.host
            client_tests.TEST_TARGET_SERVER_SERVICE_PORT = service.port

        except RuntimeError, e:
            logger.exception(e)
            raise e