def configure_region(environment, regions, bastion_instance_type, bastion_coreos_channel, bastion_coreos_version, nat_per_az, admins): if not regions: logger.warn('Must specify region(s) to update.') return updates = get_updates(bastion_instance_type, bastion_coreos_channel, bastion_coreos_version, nat_per_az, admins) if not updates: logger.warn('No updates to do!') return for aws_region in regions: dynamo = boto.dynamodb2.connect_to_region(aws_region) tables = DynamoDbTables(dynamo, environment=environment) tables.setup(['regions', 'users']) db = FlotillaClientDynamo(None, tables.regions, None, None, None, tables.users, None) admins = updates.get('admins') if admins: missing_users = db.check_users(admins) if len(missing_users) > 0: logger.error('User(s): %s do not exist in %s.', ', '.join(missing_users), region) continue db.configure_region(aws_region, updates) logger.info('Region(s): %s updated.', ', '.join(regions))
def configure_service(environment, regions, service_name, updates): for region in regions: dynamo = boto.dynamodb2.connect_to_region(region) kms = boto.kms.connect_to_region(region) tables = DynamoDbTables(dynamo, environment=environment) tables.setup(['services']) db = FlotillaClientDynamo(None, None, None, tables.services, None, None, kms) db.configure_service(service_name, updates)
def configure_user(environment, regions, name, ssh_keys, active): updates = get_updates(ssh_keys, active) if not updates: logger.warn('No updates to do!') return for region in regions: dynamo = boto.dynamodb2.connect_to_region(region) tables = DynamoDbTables(dynamo, environment=environment) tables.setup(['users']) db = FlotillaClientDynamo(None, None, None, None, None, tables.users, None) db.configure_user(name, updates) logger.info('User: %s updated in region(s): %s updated.', name, ', '.join(regions))