Exemplo n.º 1
0
    def __init__(self, options):
        if not options.echo in ECHO_CHOICES:
            raise ValueError('--echo="{echo}" is not in {choices}'.format(
                echo=options.echo, choices=ECHO_CHOICES))

        if not options.front50 in FRONT50_CHOICES:
            raise ValueError(
                '--front50="{front50}" is not in {choices}'.format(
                    echo=options.front50, choices=FRONT50_CHOICES))

        # The configurator holds our "old" configuration so we can reference it later.
        self.__configurator = Configurator()

        self.__bindings = YamlBindings()
        self.__options = options

        config = {
            'echo': {
                'cassandra': {
                    'enabled': options.echo == 'cassandra'
                },
                'inMemory': {
                    'enabled': options.echo == 'inMemory'
                },
            },
            'front50': {
                'cassandra': {
                    'enabled': options.front50 == 'cassandra'
                },
                'redis': {
                    'enabled': options.front50 == 'redis'
                },
                's3': {
                    'enabled': options.front50 == 's3'
                },
                'gcs': {
                    'enabled': options.front50 == 'gcs'
                },
                'azs': {
                    'enabled': options.front50 == 'azs'
                }
            }
        }
        if options.bucket:
            config['front50']['storage_bucket'] = options.bucket
        self.__bindings.import_dict(config)