def test_component_subnet_auto_configuration(monkeypatch): configuration = { 'PublicOnly': True, 'VpcId': 'vpc-123' } info = {'StackName': 'foobar', 'StackVersion': '0.1'} definition = {"Resources": {}} args = MagicMock() args.region = "foo" subnet1 = MagicMock() subnet1.id = 'subnet-1' subnet2 = MagicMock() subnet2.id = 'subnet-2' ec2 = MagicMock() ec2.subnets.filter.return_value = [subnet1, subnet2] monkeypatch.setattr('boto3.resource', lambda *args: ec2) result = component_subnet_auto_configuration(definition, configuration, args, info, False, MagicMock()) assert ['subnet-1', 'subnet-2'] == result['Mappings']['ServerSubnets']['foo']['Subnets'] configuration = { 'PublicOnly': False, 'VpcId': 'vpc-123' } result = component_subnet_auto_configuration(definition, configuration, args, info, False, MagicMock()) assert ['subnet-1', 'subnet-2'] == result['Mappings']['ServerSubnets']['foo']['Subnets']
def component_coreos_auto_configuration(definition, configuration, args, info, force, account_info): ami_id = find_coreos_image(configuration.get('ReleaseChannel') or 'stable', args.region) configuration = ensure_keys(configuration, "Images", 'LatestCoreOSImage', args.region) configuration["Images"]['LatestCoreOSImage'][args.region] = ami_id component_subnet_auto_configuration(definition, configuration, args, info, force, account_info) return definition
def component_stups_auto_configuration(definition, configuration, args, info, force, account_info): most_recent_image = find_taupage_image(args.region) configuration = ensure_keys(configuration, "Images", 'LatestTaupageImage', args.region) configuration["Images"]['LatestTaupageImage'][args.region] = most_recent_image.id component_subnet_auto_configuration(definition, configuration, args, info, force, account_info) return definition
def component_coreos_auto_configuration(definition, configuration, args, info, force, account_info): ami_id = find_coreos_image( configuration.get('ReleaseChannel') or 'stable', args.region) configuration = ensure_keys(configuration, "Images", 'LatestCoreOSImage', args.region) configuration["Images"]['LatestCoreOSImage'][args.region] = ami_id component_subnet_auto_configuration(definition, configuration, args, info, force, account_info) return definition
def component_stups_auto_configuration(definition, configuration, args, info, force, account_info): most_recent_image = find_taupage_image(args.region) configuration = ensure_keys(configuration, "Images", 'LatestTaupageImage', args.region) configuration["Images"]['LatestTaupageImage'][ args.region] = most_recent_image.id component_subnet_auto_configuration(definition, configuration, args, info, force, account_info) return definition
def component_stups_auto_configuration(definition, configuration, args, info, force, account_info): for channel in taupage.CHANNELS.values(): most_recent_image = taupage.find_image(args.region, channel) if most_recent_image: configuration = ensure_keys(configuration, "Images", channel.image_mapping, args.region) configuration["Images"][channel.image_mapping][args.region] = most_recent_image.id elif channel == taupage.DEFAULT_CHANNEL: # Require at least one image from the stable channel raise Exception('No Taupage AMI found') component_subnet_auto_configuration(definition, configuration, args, info, force, account_info) return definition
def component_stups_auto_configuration(definition, configuration, args, info, force, account_info): for mapping, suffix in _TAUPAGE_CHANNELS.items(): most_recent_image = find_taupage_image(args.region, suffix) if most_recent_image: configuration = ensure_keys(configuration, "Images", mapping, args.region) configuration["Images"][mapping][ args.region] = most_recent_image.id component_subnet_auto_configuration(definition, configuration, args, info, force, account_info) return definition