def _get_solution_stack(): solution_string = solution_stack_ops.get_default_solution_stack() soln_stk = None # Test out sstack and tier before we ask any questions (Fast Fail) if solution_string: if PlatformVersion.is_custom_platform_arn(solution_string): try: platformops.describe_custom_platform_version(solution_string) except NotFoundError: raise NotFoundError( 'Platform arn {} does not appear to be valid'.format(solution_string) ) soln_stk = PlatformVersion(solution_string) else: try: soln_stk = solution_stack_ops.find_solution_stack_from_string(solution_string) if PlatformVersion.is_eb_managed_platform_arn(soln_stk): soln_stk = PlatformVersion.get_platform_name(soln_stk) except NotFoundError: raise NotFoundError('Solution stack {} does not appear to be valid'.format(solution_string)) if not soln_stk: raise NotInitializedError return soln_stk
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 do_command(self): verbose = self.app.pargs.verbose solution_stacks = platformops.get_all_platforms() if verbose: platform_arns = platformops.list_custom_platform_versions() lst = [s.name for s in solution_stacks] lst.extend(platform_arns) else: platform_arns = platformops.list_custom_platform_versions(platform_version='latest') lst = sorted(set([s.pythonify() for s in solution_stacks])) lst.extend([PlatformVersion.get_platform_name(arn) for arn in platform_arns]) if len(lst) > 20: io.echo_with_pager(os.linesep.join(lst)) else: io.echo(*lst, sep=os.linesep)
def do_command(self): verbose = self.app.pargs.verbose solution_stacks = platformops.get_all_platforms() if verbose: platform_arns = platformops.list_custom_platform_versions() lst = [s.name for s in solution_stacks] lst.extend(platform_arns) else: platform_arns = platformops.list_custom_platform_versions( platform_version='latest') lst = sorted(set([s.pythonify() for s in solution_stacks])) lst.extend([ PlatformVersion.get_platform_name(arn) for arn in platform_arns ]) if len(lst) > 20: io.echo_with_pager(os.linesep.join(lst)) else: io.echo(*lst, sep=os.linesep)
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 group_custom_platforms_by_platform_name(custom_platforms): return sorted(set([PlatformVersion.get_platform_name(custom_platform) for custom_platform in custom_platforms]))
def test_get_platform_name__custom_platform_arn(self): arn = 'arn:aws:elasticbeanstalk:us-east-1:00000000000:platform/Name/0.0.0' self.assertEqual('Name', PlatformVersion.get_platform_name(arn))
def group_custom_platforms_by_platform_name(custom_platforms): return sorted( set([ PlatformVersion.get_platform_name(custom_platform) for custom_platform in custom_platforms ]))