Ejemplo n.º 1
0
    def serveapp(self, config, name=None):
        app = self.loadapp(config, name=name)
        server = wsgi.Server(app, 0)
        server.start(key='socket')

        # Service catalog tests need to know the port we ran on.
        port = server.socket_info['socket'][1]
        self.opt(public_port=port, admin_port=port)
        return server
Ejemplo n.º 2
0
    def serveapp(self, config, name=None, cert=None, key=None, ca=None,
                 cert_required=None, host="127.0.0.1", port=0):
        app = self.loadapp(config, name=name)
        server = wsgi.Server(app, host, port)
        if cert is not None and ca is not None and key is not None:
            server.set_ssl(certfile=cert, keyfile=key, ca_certs=ca,
                           cert_required=cert_required)
        server.start(key='socket')

        # Service catalog tests need to know the port we ran on.
        port = server.socket_info['socket'][1]
        self.opt(public_port=port, admin_port=port)
        return server
Ejemplo n.º 3
0
    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()