Skip to content

Commit

Permalink
More configuration parsing fixes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
sebdah committed Apr 13, 2013
1 parent 03b9441 commit 64d031f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 36 deletions.
39 changes: 4 additions & 35 deletions dynamic_dynamodb/__init__.py
Expand Up @@ -21,48 +21,17 @@
limitations under the License.
"""
from config_parsers import command_line_parser, config_file_parser
from default_configuration import CONFIGURATION

VERSION = '1.0.0'


def main():
""" Main function called from dynamic-dynamodb """
# Default configuration
default_configuration = {
# Command line only
'config': None,
'dry_run': False,
# Read the command line options
cmd_line_config = command_line_parser.parse(CONFIGURATION)

# [global]
'aws_region': 'us-east-1',
'aws_access_key_id': None,
'aws_secret_access_key': None,
'check_interval': 300,

# [logging]
'log_file': None,
'log_level': 'info',

# [table: x]
'table_name': None,
'reads_lower_threshold': 30,
'reads_upper_threshold': 90,
'increase_reads_with': 50,
'decrease_reads_with': 50,
'writes_lower_threshold': 30,
'writes_upper_threshold': 90,
'increase_writes_with': 50,
'decrease_writes_with': 50,
'min_provisioned_reads': None,
'max_provisioned_reads': None,
'min_provisioned_writes': 'apa',
'max_provisioned_writes': None,
'allow_scaling_down_reads_on_0_percent': False,
'allow_scaling_down_writes_on_0_percent': False,
'always_decrease_rw_together': False,
'maintenance_windows': None,
}
cmd_line_config = command_line_parser.parse(default_configuration)
# If a configuration file is specified, read that as well
if cmd_line_config['config']:
file_config = config_file_parser.parse(cmd_line_config['config'])

Expand Down
5 changes: 4 additions & 1 deletion dynamic_dynamodb/config_parsers/config_file_parser.py
Expand Up @@ -236,5 +236,8 @@ def parse(config_path):
config_path)
sys.exit(1)

return dict(global_config.items() + table_config.items())
return dict(
global_config.items() +
logging_config.items() +
table_config.items())

36 changes: 36 additions & 0 deletions dynamic_dynamodb/default_configuration.py
@@ -0,0 +1,36 @@
""" Default configuration options """
# Default configuration
CONFIGURATION = {
# Command line only
'config': None,
'dry_run': False,

# [global]
'aws_region': 'us-east-1',
'aws_access_key_id': None,
'aws_secret_access_key': None,
'check_interval': 300,

# [logging]
'log_file': None,
'log_level': 'info',

# [table: x]
'table_name': None,
'reads_lower_threshold': 30,
'reads_upper_threshold': 90,
'increase_reads_with': 50,
'decrease_reads_with': 50,
'writes_lower_threshold': 30,
'writes_upper_threshold': 90,
'increase_writes_with': 50,
'decrease_writes_with': 50,
'min_provisioned_reads': None,
'max_provisioned_reads': None,
'min_provisioned_writes': 'apa',
'max_provisioned_writes': None,
'allow_scaling_down_reads_on_0_percent': False,
'allow_scaling_down_writes_on_0_percent': False,
'always_decrease_rw_together': False,
'maintenance_windows': None,
}

0 comments on commit 64d031f

Please sign in to comment.