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)
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())
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)
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()
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)
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)
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)
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)
def setup_config(self): """Tests that need a non-default config can override this method.""" config.init([], default_config_files=[])
def setup_config(self): """Tests that need a non-default config can override this method.""" args = ['--config-file', helper.etcdir('congress.conf.test')] config.init(args)
def setup_config(self): args = ['--config-file', helper.etcdir('congress.conf.test')] config.init(args)
import eventlet eventlet.monkey_patch() from oslo_config import cfg from oslo_log import log as logging from oslo_service import service from congress.common import config from congress.db import api as db_api # FIXME It has to initialize distributed_architecture flag basing on the # config file before the python interpreter imports python file which has # if-statement for deepsix. Since the default value of the flag is False # in current implementation, so it will import dse.deepsix as deepsix # even if you set it to True in congress.conf. # After changing the default to True, remove following one line. # This appears in main() too. Removing either instance breaks something. config.init(sys.argv[1:]) from congress.common import eventlet_server from congress import harness LOG = logging.getLogger(__name__) class ServerWrapper(object): """Wraps an eventlet_server with some launching info & capabilities.""" def __init__(self, server, workers): self.server = server self.workers = workers def launch_with(self, launcher):
import eventlet eventlet.monkey_patch() from oslo_config import cfg from oslo_log import log as logging from oslo_service import service from congress.common import config # FIXME It has to initialize distributed_architecture flag basing on the # config file before the python interpreter imports python file which has # if-statement for deepsix. Since the default value of the flag is False # in current implementation, so it will import dse.deepsix as deepsix # even if you set it to True in congress.conf. # After changing the default to True, remove following one line and unncoment # "Initialize config here!!" config.init(sys.argv[1:]) from congress.common import eventlet_server LOG = logging.getLogger(__name__) class ServerWrapper(object): """Wraps an eventlet_server with some launching info & capabilities.""" def __init__(self, server, workers): self.server = server self.workers = workers def launch_with(self, launcher): self.server.listen() if self.workers > 1: