def test_get_platform_version__returns_none_when_arn_is_not_found(self): arn = 'node.js' with self.assertRaises( PlatformVersion.UnableToParseArnException) as context_manager: PlatformVersion.get_platform_version(arn) self.assertEqual("Unable to parse arn 'node.js'", context_manager.exception.message)
def __formatted_platform_descriptions(platforms_list, show_status): platform_tuples = [] for platform in platforms_list: platform_tuples.append( { 'PlatformArn': platform['PlatformArn'], 'PlatformStatus': platform['PlatformStatus'] } ) # Sort by name, then by version platform_tuples.sort( key=lambda platform_tuple: ( PlatformVersion.get_platform_name(platform_tuple['PlatformArn']), Version(PlatformVersion.get_platform_version(platform_tuple['PlatformArn'])) ), reverse=True ) formatted_platform_descriptions = [] for index, platform_tuple in enumerate(platform_tuples): if show_status: formatted_platform_description = '{platform_arn} Status: {platform_status}'.format( platform_arn=platform_tuple['PlatformArn'], platform_status=platform_tuple['PlatformStatus'] ) else: formatted_platform_description = platform_tuple['PlatformArn'] formatted_platform_descriptions.append(formatted_platform_description) return formatted_platform_descriptions
def __formatted_platform_descriptions(platforms_list, show_status): platform_tuples = [] for platform in platforms_list: platform_tuples.append({ 'PlatformArn': platform['PlatformArn'], 'PlatformStatus': platform['PlatformStatus'] }) # Sort by name, then by version platform_tuples.sort( key=lambda platform_tuple: (PlatformVersion.get_platform_name(platform_tuple['PlatformArn']), Version( PlatformVersion.get_platform_version(platform_tuple['PlatformArn'] ))), reverse=True) formatted_platform_descriptions = [] for index, platform_tuple in enumerate(platform_tuples): if show_status: formatted_platform_description = '{platform_arn} Status: {platform_status}'.format( platform_arn=platform_tuple['PlatformArn'], platform_status=platform_tuple['PlatformStatus']) else: formatted_platform_description = platform_tuple['PlatformArn'] formatted_platform_descriptions.append(formatted_platform_description) return formatted_platform_descriptions
def generate_version_to_arn_mappings(custom_platforms, specified_platform_name): version_to_arn_mappings = {} for custom_platform in custom_platforms: custom_platform_name = PlatformVersion.get_platform_name(custom_platform) if custom_platform_name == specified_platform_name: version_to_arn_mappings[PlatformVersion.get_platform_version(custom_platform)] = custom_platform return version_to_arn_mappings
def generate_version_to_arn_mappings(custom_platforms, specified_platform_name): version_to_arn_mappings = {} for custom_platform in custom_platforms: custom_platform_name = PlatformVersion.get_platform_name(custom_platform) if custom_platform_name == specified_platform_name: version_to_arn_mappings[PlatformVersion.get_platform_version(custom_platform)] = custom_platform return version_to_arn_mappings
def list_platform_versions_sorted_by_name(platform_name=None, status=None, owner=None, show_status=False, excludeEBOwned=True): platform_list = elasticbeanstalk.list_platform_versions( platform_name=platform_name, status=status, owner=owner) platform_tuples = list() platforms = list() arn_index = 0 status_index = 1 for platform in platform_list: arn = platform['PlatformArn'] owner = platform['PlatformOwner'] if excludeEBOwned and owner == Constants.AWS_ELASTIC_BEANSTALK_ACCOUNT: continue _, platform_name, _ = PlatformVersion.arn_to_platform(arn) platform_tuples.append((arn, platform['PlatformStatus'])) # Sort by name, then by version platform_tuples.sort( key=lambda platform: (PlatformVersion.get_platform_name(platform[arn_index]), Version(PlatformVersion.get_platform_version(platform[arn_index]))), reverse=True) for platform in platform_tuples: if show_status: platforms.append("%s Status: %s" % (platform[arn_index], platform[status_index])) else: platforms.append(platform[arn_index]) return platforms
def test_get_platform_version__custom_platform_arn(self): arn = 'arn:aws:elasticbeanstalk:us-east-1:00000000000:platform/Name/0.0.0' self.assertEqual('0.0.0', PlatformVersion.get_platform_version(arn))
def test_get_platform_version__managed_platform_arn(self): arn = 'arn:aws:elasticbeanstalk:us-east-1::platform/Name/1.0.0' self.assertEqual('1.0.0', PlatformVersion.get_platform_version(arn))