def get_connection_settings(): """Get a dict of connections settings.""" global conn_settings if conn_settings is None: # try to get live config from db server, else defaults local_server = get_local_server("postgres") if local_server is not None: default_host, default_port = local_server.split(":") default_port = int(default_port) else: default_host = None default_port = 5432 # build the connection settings base_cfg = config.database.defaults conn_settings = {} stores = config.database.stores for store_name in stores: store_data = getattr(stores, store_name) # optional settings host = store_data.get("host", base_cfg.get("host", default_host)) port = store_data.get("port", base_cfg.get("port", default_port)) pwkey = store_data.get('password_key', base_cfg.get("password_key")) password = config.secret[pwkey] if pwkey else '' ops = store_data.get("options", base_cfg.get("options", None)) options = urllib.urlencode(ops) if ops else None username = store_data.get("user", config.database.user) conn_settings[store_name] = dict( host=host, port=port, username=username, password=password, database=store_data.database, options=options, db_dir=db_dir) return conn_settings.copy()
def development_ports(): """Augment the configuration with branch-local port numbers.""" settings.STATSD_SERVERS = get_local_server('statsd') settings.aws.S3_PORT = settings.aws.KEYSTONE_PORT = get_local_port('s4') settings.aws.S3_PROXY_HOST = settings.aws.KEYSTONE_PROXY_HOST = 'localhost' proxy_port = get_local_port('storage-proxy') settings.aws.S3_PROXY_PORT = settings.aws.KEYSTONE_PROXY_PORT = proxy_port
def development_ports(config): """Augment the configuration with branch-local port numbers.""" config.statsd.servers = localendpoints.get_local_server('statsd') config.aws_s3.port = localendpoints.get_local_port('s4') config.aws_s3.proxy_host = 'localhost' config.aws_s3.proxy_port = localendpoints.get_local_port('storage-proxy') config.keystone.port = localendpoints.get_local_port('s4') config.keystone.proxy_host = 'localhost' config.keystone.proxy_port = localendpoints.get_local_port('storage-proxy')