Пример #1
0
def main():
    config.init(sys.argv[1:])
    if not cfg.CONF.config_file:
        sys.exit("ERROR: Unable to find configuration file via default "
                 "search paths ~/.congress/, ~/, /etc/congress/, /etc/) and "
                 "the '--config-file' option!")
    config.setup_logging()
    LOG.info("Starting congress server")

    # TODO(pballand): Fix the policy enginge registration to work with the
    #                latest policy changes.
    # engine = loop.register_service(
    #    "engine", "PolicyEngine", "policy/dsepolicy.py",
    #    "Policy Engine (DseRuntime instance)")
    # engine.initialize_table_subscriptions()

    # API resource runtime encapsulation:
    #   event loop -> wsgi server -> webapp -> resource manager

    #TODO(arosen): find api-paste.conf for keystonemiddleware
    paste_config = None
    servers = []
    servers.append(create_api_server(paste_config,
                                     "congress-api-server",
                                     cfg.CONF.bind_host,
                                     cfg.CONF.bind_port,
                                     cfg.CONF.api_workers))
    serve(*servers)
Пример #2
0
    def setUp(self):
        """Run before each test method to initialize test environment."""

        super(TestCase, self).setUp()

        self.mox = mox.Mox()
        self.setup_config()
        self.addCleanup(cfg.CONF.reset)
        config.setup_logging()

        test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
        try:
            test_timeout = int(test_timeout)
        except ValueError:
            # If timeout value is invalid do not set a timeout.
            test_timeout = 0
        if test_timeout > 0:
            self.useFixture(fixtures.Timeout(test_timeout, gentle=True))

        self.useFixture(fixtures.NestedTempfile())
        self.useFixture(fixtures.TempHomeDir())
        self.addCleanup(mock.patch.stopall)

        if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES:
            stdout = self.useFixture(fixtures.StringStream('stdout')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
        if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES:
            stderr = self.useFixture(fixtures.StringStream('stderr')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))

        self.log_fixture = self.useFixture(fixtures.FakeLogger())
        self.policy = self.useFixture(policy_fixture.PolicyFixture())
        # cage is a singleton so we delete it here and
        # recreate it after each test
        self.addCleanup(d6cage.delete_cage)
Пример #3
0
    def setUp(self):
        """Run before each test method to initialize test environment."""

        super(TestCase, self).setUp()

        config.init([], default_config_files=[])
        self.addCleanup(cfg.CONF.reset)
        config.setup_logging()

        test_timeout = os.environ.get('OS_TEST_TIMEOUT', 0)
        try:
            test_timeout = int(test_timeout)
        except ValueError:
            # If timeout value is invalid do not set a timeout.
            test_timeout = 0
        if test_timeout > 0:
            self.useFixture(fixtures.Timeout(test_timeout, gentle=True))

        self.useFixture(fixtures.NestedTempfile())
        self.useFixture(fixtures.TempHomeDir())

        if os.environ.get('OS_STDOUT_CAPTURE') in _TRUE_VALUES:
            stdout = self.useFixture(fixtures.StringStream('stdout')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stdout', stdout))
        if os.environ.get('OS_STDERR_CAPTURE') in _TRUE_VALUES:
            stderr = self.useFixture(fixtures.StringStream('stderr')).stream
            self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))

        self.log_fixture = self.useFixture(fixtures.FakeLogger())
        self.policy = self.useFixture(policy_fixture.PolicyFixture())
Пример #4
0
 def setUp(self):
     super(AdminRolePolicyTestCase, self).setUp()
     config.setup_logging()
     self.policy = self.useFixture(policy_fixture.RoleBasedPolicyFixture())
     self.context = context.RequestContext('fake', 'fake', roles=['member'])
     self.actions = policy.get_rules().keys()
     self.target = {}
Пример #5
0
 def setUp(self):
     super(AdminRolePolicyTestCase, self).setUp()
     config.setup_logging()
     self.policy = self.useFixture(policy_fixture.RoleBasedPolicyFixture())
     self.context = context.RequestContext('fake', 'fake', roles=['member'])
     self.actions = policy.get_rules().keys()
     self.target = {}
Пример #6
0
    def setUp(self):
        """Run before each test method to initialize test environment."""

        super(TestCase, self).setUp()

        self.mox = mox.Mox()
        self.setup_config()
        self.addCleanup(cfg.CONF.reset)
        config.setup_logging()

        test_timeout = os.environ.get("OS_TEST_TIMEOUT", 0)
        try:
            test_timeout = int(test_timeout)
        except ValueError:
            # If timeout value is invalid do not set a timeout.
            test_timeout = 0
        if test_timeout > 0:
            self.useFixture(fixtures.Timeout(test_timeout, gentle=True))

        self.useFixture(fixtures.NestedTempfile())
        self.useFixture(fixtures.TempHomeDir())
        self.addCleanup(mock.patch.stopall)

        if os.environ.get("OS_STDOUT_CAPTURE") in _TRUE_VALUES:
            stdout = self.useFixture(fixtures.StringStream("stdout")).stream
            self.useFixture(fixtures.MonkeyPatch("sys.stdout", stdout))
        if os.environ.get("OS_STDERR_CAPTURE") in _TRUE_VALUES:
            stderr = self.useFixture(fixtures.StringStream("stderr")).stream
            self.useFixture(fixtures.MonkeyPatch("sys.stderr", stderr))

        self.log_fixture = self.useFixture(fixtures.FakeLogger())
        self.policy = self.useFixture(policy_fixture.PolicyFixture())
        # cage is a singleton so we delete it here and
        # recreate it after each test
        self.addCleanup(d6cage.delete_cage)
Пример #7
0
def main():
    args = sys.argv[1:]

    # TODO(thinrichs): find the right way to do deployment configuration.
    # For some reason we need to config.init(args) in 2 places; here and
    # at the top of the file.  Remove either one, and things break.
    # Note: config.init() will delete the deploy args, so grab them before.
    config.init(args)
    if not cfg.CONF.config_file:
        sys.exit("ERROR: Unable to find configuration file via default "
                 "search paths ~/.congress/, ~/, /etc/congress/, /etc/) and "
                 "the '--config-file' option!")
    config.setup_logging()

    if not (cfg.CONF.api or cfg.CONF.policy_engine or cfg.CONF.datasources):
        # No flags provided, start all services
        cfg.CONF.api = True
        cfg.CONF.policy_engine = True
        cfg.CONF.datasources = True

    # Construct requested deployment
    servers = launch_servers(cfg.CONF.node_id, cfg.CONF.api,
                             cfg.CONF.policy_engine, cfg.CONF.datasources)

    serve(*servers)
Пример #8
0
def main():
    # Initialize config here!! after completing to migrate the new architecture
    # config.init(args)
    if not cfg.CONF.config_file:
        sys.exit("ERROR: Unable to find configuration file via default "
                 "search paths ~/.congress/, ~/, /etc/congress/, /etc/) and "
                 "the '--config-file' option!")
    config.setup_logging()

    servers = launch_api_server()

    serve(*servers)
Пример #9
0
def main():
    """Agent entry point"""
    validator_opts.register_validator_agent_opts(cfg.CONF)
    config.init(sys.argv[1:])
    config.setup_logging()

    if not cfg.CONF.config_file:
        sys.exit("ERROR: Unable to find configuration file via default "
                 "search paths ~/.congress/, ~/, /etc/congress/, /etc/) and "
                 "the '--config-file' option!")

    agent = ValidatorAgentEndpoint()
    server = rpc.AgentService(utils.AGENT_TOPIC, [agent])
    service.launch(agent.conf, server).wait()
Пример #10
0
def main():
    """Agent entry point"""
    validator_opts.register_validator_agent_opts(cfg.CONF)
    config.init(sys.argv[1:])
    config.setup_logging()

    if not cfg.CONF.config_file:
        sys.exit("ERROR: Unable to find configuration file via default "
                 "search paths ~/.congress/, ~/, /etc/congress/, /etc/) and "
                 "the '--config-file' option!")

    agent = ValidatorAgentEndpoint()
    server = rpc.AgentService(utils.AGENT_TOPIC, [agent])
    service.launch(agent.conf, server).wait()
Пример #11
0
def main():
    config.init(sys.argv[1:])
    if not cfg.CONF.config_file:
        sys.exit("ERROR: Unable to find configuration file via default "
                 "search paths ~/.congress/, ~/, /etc/congress/, /etc/) and "
                 "the '--config-file' option!")
    config.setup_logging()
    LOG.info("Starting congress server")

    # API resource runtime encapsulation:
    #   event loop -> wsgi server -> webapp -> resource manager

    paste_config = config.find_paste_config()
    servers = []
    servers.append(
        create_api_server(paste_config, "congress", cfg.CONF.bind_host,
                          cfg.CONF.bind_port, cfg.CONF.api_workers))
    serve(*servers)
Пример #12
0
def main():
    args = sys.argv[1:]

    # TODO(thinrichs): find the right way to do deployment configuration.
    # For some reason we need to config.init(args) in 2 places; here and
    # at the top of the file (now moved to bin/congress-server).
    # Remove either one, and things break.
    # Note: config.init() will delete the deploy args, so grab them before.
    config.init(args)
    if not cfg.CONF.config_file:
        sys.exit("ERROR: Unable to find configuration file via default "
                 "search paths ~/.congress/, ~/, /etc/congress/, /etc/) and "
                 "the '--config-file' option!")
    if cfg.CONF.replicated_policy_engine and not (
            db_api.is_mysql() or db_api.is_postgres()):
        if db_api.is_sqlite():
            LOG.warning("Deploying replicated policy engine with SQLite "
                        "backend is not officially supported. Unexpected "
                        "behavior may occur. Officially supported backends "
                        "are MySQL and PostgresSQL.")
        else:
            sys.exit("ERROR: replicated_policy_engine option can be used only "
                     "with MySQL or PostgreSQL database backends. Please set "
                     "the connection option in [database] section of "
                     "congress.conf to use a supported backend.")
    config.setup_logging()

    if not (cfg.CONF.api or cfg.CONF.policy_engine or cfg.CONF.datasources):
        # No flags provided, start all services
        cfg.CONF.api = True
        cfg.CONF.policy_engine = True
        cfg.CONF.datasources = True

    # initialize encryption key if datasource services enabled in this instance
    if cfg.CONF.datasources:
        encryption.initialize_key()
        LOG.debug("Initialized encryption key on datasource node")

    # Construct requested deployment
    servers = launch_servers(cfg.CONF.node_id, cfg.CONF.api,
                             cfg.CONF.policy_engine, cfg.CONF.datasources)

    serve(*servers)
Пример #13
0
def main():
    config.init(sys.argv[1:])
    if not cfg.CONF.config_file:
        sys.exit("ERROR: Unable to find configuration file via default "
                 "search paths ~/.congress/, ~/, /etc/congress/, /etc/) and "
                 "the '--config-file' option!")
    config.setup_logging()
    LOG.info("Starting congress server on port %d", cfg.CONF.bind_port)

    # API resource runtime encapsulation:
    #   event loop -> wsgi server -> webapp -> resource manager

    paste_config = config.find_paste_config()
    servers = []
    servers.append(create_api_server(paste_config,
                                     "congress",
                                     cfg.CONF.bind_host,
                                     cfg.CONF.bind_port,
                                     cfg.CONF.api_workers))
    serve(*servers)
Пример #14
0
def main():
    args = sys.argv[1:]

    # TODO(thinrichs): find the right way to do deployment configuration.
    # For some reason we need to config.init(args) in 2 places; here and
    # at the top of the file.  Remove either one, and things break.
    # Note: config.init() will delete the deploy args, so grab them before.
    config.init(args)
    if not cfg.CONF.config_file:
        sys.exit("ERROR: Unable to find configuration file via default "
                 "search paths ~/.congress/, ~/, /etc/congress/, /etc/) and "
                 "the '--config-file' option!")
    config.setup_logging()

    # grab deployment options from command line
    deploy_api = cfg.CONF.api
    deploy_policy = cfg.CONF.policy_engine
    deploy_datasources = cfg.CONF.datasources

    if deploy_api or deploy_policy or deploy_datasources:
        if not cfg.CONF.distributed_architecture:
            sys.exit("ERROR: can only be used with distributed arch")
        if (cfg.CONF.node_id is None and
           not (deploy_api and deploy_policy and deploy_datasources)):
            sys.exit("ERROR: must supply unique node_id")

    else:
        # Start all services
        deploy_api = True
        deploy_policy = True
        deploy_datasources = True

    # Construct requested deployment
    servers = launch_servers(cfg.CONF.node_id, deploy_api, deploy_policy,
                             deploy_datasources)

    serve(*servers)
Пример #15
0
 def setUp(self):
     super(PolicyFileTestCase, self).setUp()
     config.setup_logging()
     self.context = context.RequestContext('fake', 'fake')
     self.target = {}
Пример #16
0
 def setUp(self):
     super(ConfigurationTest, self).setUp()
     config.setup_logging()
Пример #17
0
 def setUp(self):
     super(ServerTest, self).setUp()
     self.host = '127.0.0.1'
     self.port = '1234'
     #FIXME(arosen) - we need to inherit from a base class that does this.
     config.setup_logging()
Пример #18
0
 def setUp(self):
     super(PolicyFileTestCase, self).setUp()
     config.setup_logging()
     self.context = context.RequestContext('fake', 'fake')
     self.target = {}