예제 #1
0
    def setUp(self):
        """Setup users, projects, and start a test server."""
        super(S3APITestCase, self).setUp()
        self.flags(buckets_path=os.path.join(OSS_TEMPDIR, 'buckets'),
                   s3_host='127.0.0.1')

        shutil.rmtree(CONF.buckets_path)
        os.mkdir(CONF.buckets_path)

        router = s3server.S3Application(CONF.buckets_path)
        self.server = wsgi.Server("S3 Objectstore",
                                  router,
                                  host=CONF.s3_host,
                                  port=0)
        self.server.start()

        if not boto.config.has_section('Boto'):
            boto.config.add_section('Boto')

        boto.config.set('Boto', 'num_retries', '0')
        conn = s3.S3Connection(aws_access_key_id='fake',
                               aws_secret_access_key='fake',
                               host=CONF.s3_host,
                               port=self.server.port,
                               is_secure=False,
                               calling_format=s3.OrdinaryCallingFormat())
        self.conn = conn

        def get_http_connection(*args):
            """Get a new S3 connection, don't attempt to reuse connections."""
            return self.conn.new_http_connection(*args)

        self.conn.get_http_connection = get_http_connection
예제 #2
0
    def __init__(self, name, loader=None, use_ssl=False, max_url_len=None):
        """Initialize, but do not start the WSGI server.

        :param name: The name of the WSGI server given to the loader.
        :param loader: Loads the WSGI application using the given name.
        :returns: None

        """
        self.name = name
        self.manager = self._get_manager()
        self.loader = loader or wsgi.Loader()
        self.app = self.loader.load_app(name)
        self.host = getattr(CONF, '%s_listen' % name, "0.0.0.0")
        self.port = getattr(CONF, '%s_listen_port' % name, 0)
        self.workers = getattr(CONF, '%s_workers' % name, None)
        self.use_ssl = use_ssl
        self.server = wsgi.Server(name,
                                  self.app,
                                  host=self.host,
                                  port=self.port,
                                  use_ssl=self.use_ssl,
                                  max_url_len=max_url_len)
        # Pull back actual port used
        self.port = self.server.port
        self.backdoor_port = None
예제 #3
0
    def __init__(self, name, loader=None, use_ssl=False, max_url_len=None):
        """Initialize, but do not start the WSGI server.

        :param name: The name of the WSGI server given to the loader.
        :param loader: Loads the WSGI application using the given name.
        :returns: None

        """
        self.name = name
        self.manager = self._get_manager()
        self.loader = loader or wsgi.Loader()
        self.app = self.loader.load_app(name)
        self.host = getattr(CONF, '%s_listen' % name, "0.0.0.0")
        self.port = getattr(CONF, '%s_listen_port' % name, 0)
        self.workers = (getattr(CONF, '%s_workers' % name, None)
                        or processutils.get_worker_count())
        if self.workers and self.workers < 1:
            worker_name = '%s_workers' % name
            msg = (_("%(worker_name)s value of %(workers)s is invalid, "
                     "must be greater than 0") % {
                         'worker_name': worker_name,
                         'workers': str(self.workers)
                     })
            raise exception.InvalidInput(msg)
        self.use_ssl = use_ssl
        self.server = wsgi.Server(name,
                                  self.app,
                                  host=self.host,
                                  port=self.port,
                                  use_ssl=self.use_ssl,
                                  max_url_len=max_url_len)
        # Pull back actual port used
        self.port = self.server.port
        self.backdoor_port = None
예제 #4
0
    def setUp(self):
        super(PlacementFixture, self).setUp()

        self.useFixture(ConfPatcher(group='api', auth_strategy='noauth2'))
        app = placement_deploy.loadapp(CONF)
        # in order to run these in tests we need to bind only to local
        # host, and dynamically allocate ports
        self.service = wsgi.Server('placement', app, host='127.0.0.1')
        self.service.start()
        self.addCleanup(self.service.stop)

        self._client = ks.Session(auth=None)
        # NOTE(sbauza): We need to mock the scheduler report client because
        # we need to fake Keystone by directly calling the endpoint instead
        # of looking up the service catalog, like we did for the OSAPIFixture.
        self.useFixture(fixtures.MonkeyPatch(
            'nova.scheduler.client.report.SchedulerReportClient.get',
            self._fake_get))
        self.useFixture(fixtures.MonkeyPatch(
            'nova.scheduler.client.report.SchedulerReportClient.post',
            self._fake_post))
        self.useFixture(fixtures.MonkeyPatch(
            'nova.scheduler.client.report.SchedulerReportClient.put',
            self._fake_put))
        self.useFixture(fixtures.MonkeyPatch(
            'nova.scheduler.client.report.SchedulerReportClient.delete',
            self._fake_delete))
    def setUp(self):
        """Setup users, projects, and start a test server."""
        super(S3APITestCase, self).setUp()
        self.flags(auth_driver='nova.auth.ldapdriver.FakeLdapDriver',
                   buckets_path=os.path.join(OSS_TEMPDIR, 'buckets'),
                   s3_host='127.0.0.1')

        self.auth_manager = manager.AuthManager()
        self.admin_user = self.auth_manager.create_user('admin', admin=True)
        self.admin_project = self.auth_manager.create_project('admin',
                                                              self.admin_user)

        shutil.rmtree(FLAGS.buckets_path)
        os.mkdir(FLAGS.buckets_path)

        router = s3server.S3Application(FLAGS.buckets_path)
        server = wsgi.Server()
        server.start(router, FLAGS.s3_port, host=FLAGS.s3_host)

        if not boto.config.has_section('Boto'):
            boto.config.add_section('Boto')
        boto.config.set('Boto', 'num_retries', '0')
        conn = s3.S3Connection(aws_access_key_id=self.admin_user.access,
                               aws_secret_access_key=self.admin_user.secret,
                               host=FLAGS.s3_host,
                               port=FLAGS.s3_port,
                               is_secure=False,
                               calling_format=s3.OrdinaryCallingFormat())
        self.conn = conn

        def get_http_connection(host, is_secure):
            """Get a new S3 connection, don't attempt to reuse connections."""
            return self.conn.new_http_connection(host, is_secure)

        self.conn.get_http_connection = get_http_connection
def get_wsgi_server():
    LOG.audit(_("Starting nova-ajaxterm-proxy node (version %s)"),
        version.version_string_with_vcs())

    return  wsgi.Server("AjaxTerm console proxy",
        AjaxTermConsoleProxy(),
        host=FLAGS.ajaxterm_proxy_host,
        port=FLAGS.ajaxterm_proxy_port)
예제 #7
0
    def __init__(self, name, loader=None, use_ssl=False, max_url_len=None):
        """Initialize, but do not start the WSGI server.

        :param name: The name of the WSGI server given to the loader.
        :param loader: Loads the WSGI application using the given name.
        :returns: None

        """
        self.name = name
        # NOTE(danms): Name can be metadata, osapi_compute, per
        # nova.service's enabled_apis
        self.binary = 'nova-%s' % name

        LOG.warning(
            'Running %s using eventlet is deprecated. Deploy with '
            'a WSGI server such as uwsgi or mod_wsgi.', self.binary)

        self.topic = None
        self.manager = self._get_manager()
        self.loader = loader or api_wsgi.Loader()
        self.app = self.loader.load_app(name)
        # inherit all compute_api worker counts from osapi_compute
        if name.startswith('openstack_compute_api'):
            wname = 'osapi_compute'
        else:
            wname = name
        self.host = getattr(CONF, '%s_listen' % name, "0.0.0.0")
        self.port = getattr(CONF, '%s_listen_port' % name, 0)
        self.workers = (getattr(CONF, '%s_workers' % wname, None)
                        or processutils.get_worker_count())
        if self.workers and self.workers < 1:
            worker_name = '%s_workers' % name
            msg = (_("%(worker_name)s value of %(workers)s is invalid, "
                     "must be greater than 0") % {
                         'worker_name': worker_name,
                         'workers': str(self.workers)
                     })
            raise exception.InvalidInput(msg)
        self.use_ssl = use_ssl
        self.server = wsgi.Server(name,
                                  self.app,
                                  host=self.host,
                                  port=self.port,
                                  use_ssl=self.use_ssl,
                                  max_url_len=max_url_len)
        # Pull back actual port used
        self.port = self.server.port
        self.backdoor_port = None
        setup_profiler(name, self.host)
예제 #8
0
파일: service.py 프로젝트: cp16net/reddwarf
    def __init__(self, name, loader=None):
        """Initialize, but do not start the WSGI service.

        :param name: The name of the WSGI service given to the loader.
        :param loader: Loads the WSGI application using the given name.
        :returns: None

        """
        self.name = name
        self.loader = loader or wsgi.Loader()
        self.app = self.loader.load_app(name)
        self.host = getattr(FLAGS, '%s_listen' % name, "0.0.0.0")
        self.port = getattr(FLAGS, '%s_listen_port' % name, 0)
        self.server = wsgi.Server(name,
                                  self.app,
                                  host=self.host,
                                  port=self.port)
예제 #9
0
def _run_wsgi(paste_config_file, apis):
    logging.debug(_("Using paste.deploy config at: %s"), paste_config_file)
    apps = []
    for api in apis:
        config = wsgi.load_paste_configuration(paste_config_file, api)
        if config is None:
            logging.debug(_("No paste configuration for app: %s"), api)
            continue
        logging.debug(_("App Config: %(api)s\n%(config)r") % locals())
        logging.info(_("Running %s API"), api)
        app = wsgi.load_paste_app(paste_config_file, api)
        apps.append((app, getattr(FLAGS, "%s_listen_port" % api),
                     getattr(FLAGS, "%s_listen" % api)))
    if len(apps) == 0:
        logging.error(_("No known API applications configured in %s."),
                      paste_config_file)
        return

    server = wsgi.Server()
    for app in apps:
        server.start(*app)
    return server
예제 #10
0
파일: server.py 프로젝트: yamahata/nova
def get_wsgi_server():
    LOG.audit(_("Starting nova-vncproxy node (version %s)"),
              version.version_string_with_vcs())

    if not (os.path.exists(FLAGS.vncproxy_wwwroot)
            and os.path.exists(FLAGS.vncproxy_wwwroot + '/vnc_auto.html')):
        LOG.info(_("Missing vncproxy_wwwroot (version %s)"),
                 FLAGS.vncproxy_wwwroot)
        LOG.info(
            _("You need a slightly modified version of noVNC "
              "to work with the nova-vnc-proxy"))
        LOG.info(_("Check out the most recent nova noVNC code: %s"),
                 "git://github.com/sleepsonthefloor/noVNC.git")
        LOG.info(_("And drop it in %s"), FLAGS.vncproxy_wwwroot)
        sys.exit(1)

    app = proxy.WebsocketVNCProxy(FLAGS.vncproxy_wwwroot)

    LOG.audit(_("Allowing access to the following files: %s"),
              app.get_whitelist())

    with_logging = auth.LoggingMiddleware(app)

    if FLAGS.vnc_debug:
        with_auth = proxy.DebugMiddleware(with_logging)
    else:
        with_auth = auth.VNCNovaAuthMiddleware(with_logging)

    wsgi_server = wsgi.Server("VNC Proxy",
                              with_auth,
                              host=FLAGS.vncproxy_host,
                              port=FLAGS.vncproxy_port)
    wsgi_server.start_tcp(handle_flash_socket_policy,
                          host=FLAGS.vncproxy_flash_socket_policy_host,
                          port=FLAGS.vncproxy_flash_socket_policy_port)
    return wsgi_server
예제 #11
0
def get_wsgi_server():
    return wsgi.Server("S3 Objectstore",
                       S3Application(FLAGS.buckets_path),
                       port=FLAGS.s3_listen_port,
                       host=FLAGS.s3_listen)