Print config using json

This commit is contained in:
vrde 2016-04-07 14:16:01 +02:00
parent 06f45f1dc7
commit 0692fe04d0
No known key found for this signature in database
GPG Key ID: 6581C7C39B3D397D
2 changed files with 46 additions and 24 deletions

View File

@ -5,6 +5,7 @@ import os
import logging
import argparse
import copy
import json
import bigchaindb
import bigchaindb.config_utils
@ -21,8 +22,6 @@ logger = logging.getLogger(__name__)
def run_show_config(args):
"""Show the current configuration"""
from pprint import pprint
# TODO Proposal: remove the "hidden" configuration. Only show config. If
# the system needs to be configured, then display information on how to
# configure the system.
@ -31,7 +30,7 @@ def run_show_config(args):
del config['CONFIGURED']
private_key = config['keypair']['private']
config['keypair']['private'] = 'x' * 45 if private_key else None
pprint(config)
print(json.dumps(config, indent=4, sort_keys=True))
def run_configure(args, skip_if_exists=False):

View File

@ -35,18 +35,25 @@ Note that there is a precedence in reading configuration values:
This means that if the default configuration contains an entry that is:
```
{...
"database": {"host": "localhost",
"port": 28015}
...}
```json
{
"database": {
"host": "localhost",
"port": 28015
}
}
```
while your local file `local.json` contains:
```
{...
"database": {"host": "ec2-xx-xx-xxx-xxx.eu-central-1.compute.amazonaws.com"}
...}
```json
{
"database": {
"host": "ec2-xx-xx-xxx-xxx.eu-central-1.compute.amazonaws.com"
}
}
```
and you run this command:
@ -58,18 +65,34 @@ $ BIGCHAINDB_DATABASE_HOST=anotherhost.com \
```
you will get:
```
Cannot find config file `/home/vrde/.bigchaindb`.
INFO:bigchaindb.config_utils:Configuration loaded from `local.json`
{'CONFIGURED': True,
'api_endpoint': 'http://localhost:8008/api/v1',
'consensus_plugin': 'default',
'database': {'host': 'ec2-xx-xx-xxx-xxx.eu-central-1.compute.amazonaws.com',
'name': 'bigchain',
'port': 4242},
'keypair': {'private': None, 'public': None},
'keyring': ['pubkey0', 'pubkey1'],
'statsd': {'host': 'localhost', 'port': 8125, 'rate': 0.01}}
```json
{
"api_endpoint": "http://localhost:8008/api/v1",
"consensus_plugin": "default",
"database": {
"host": "ec2-xx-xx-xxx-xxx.eu-central-1.compute.amazonaws.com",
"name": "bigchain",
"port": 4242
},
"keypair": {
"private": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"public": "nJq6EmdUkvFjQRB5hFvDmvZtv1deb3W3RgmiAq6dyygC"
},
"keyring": [
"pubkey0",
"pubkey1"
],
"server": {
"bind": "0.0.0.0:9984",
"threads": null,
"workers": null
},
"statsd": {
"host": "localhost",
"port": 8125,
"rate": 0.01
}
}
```
Note that the type of `keyring` is a list. If you want to pass a list as an