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 _get_solution_stack(): solution_string = solution_stack_ops.get_default_solution_stack() soln_stk = None if solution_string: if PlatformVersion.is_custom_platform_arn(solution_string): try: platform_version_ops.describe_custom_platform_version( solution_string) except NotFoundError: raise NotFoundError( alerts['platform.invalidstring'].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 _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 platform_arn_to_solution_stack(platform_arn): """ Method determines the EB-managed solution stack represented by a PlatformArn :param platform_arn: PlatformArn of a solution stack :return: SolutionStack representing the PlatformArn if it an EB-managed platform, otherwise None """ if not PlatformVersion.is_eb_managed_platform_arn(platform_arn): return platform_description = elasticbeanstalk.describe_platform_version(platform_arn) return SolutionStack(platform_description['SolutionStackName'])
def find_solution_stack_from_string(solution_string, find_newer=False): """ Method returns a SolutionStack object representing the given `solution_string`. If the `solution_string` matches ARNs and complete names of solution stacks, the exact match is returned. In the event when there are multiple matches, the latest version is returned. :param solution_string: A string in one of the following (case-insensitive) forms: - PlatformArn: - EB-managed: 'arn:aws:elasticbeanstalk:us-west-2::platform/Multi-container Docker running on 64bit Amazon Linux/2.8.0' - Custom: arn:aws:elasticbeanstalk:us-west-2:123412341234:platform/custom_platform/1.0.0 - complete name: '64bit Amazon Linux 2017.03 v2.7.5 running Multi-container Docker 17.03.2-ce (Generic)' - shorthand: 'Multi-container Docker 17.03.2-ce (Generic)' - language name: 'Multi-container Docker' - pythonified shorthand: 'multi-container-docker-17.03.2-ce-(generic)' :param find_newer: If solution_string is a complete name or a PlatformArn that uniquely matches a solution stack or platform, find the newest version of the solution stack. :return: A SolutionStack object representing the latest version of the `solution_string`. In case of a custom platform, the return value is a PlatformVersion object. """ # Compare input with PlatformARNs match = None if PlatformVersion.is_eb_managed_platform_arn(solution_string): if find_newer: match = platformops.get_latest_eb_managed_platform(solution_string) else: match = platform_arn_to_solution_stack(solution_string) elif PlatformVersion.is_custom_platform_arn(solution_string): if find_newer: match = platformops.get_latest_custom_platform(solution_string) else: match = platformops.find_custom_platform_from_string(solution_string) # Compare input with complete SolutionStack name and retrieve latest SolutionStack # in the series if `find_newer` is set to True if not match: available_solution_stacks = elasticbeanstalk.get_available_solution_stacks() match = SolutionStack.match_with_complete_solution_string(available_solution_stacks, solution_string) if match and find_newer: language_name = SolutionStack(solution_string).language_name match = SolutionStack.match_with_solution_string_language_name(available_solution_stacks, language_name) # Compare input with other forms for solution_string_matcher in [ SolutionStack.match_with_solution_string_shorthand, SolutionStack.match_with_solution_string_language_name, SolutionStack.match_with_pythonified_solution_string, ]: if not match: match = solution_string_matcher(available_solution_stacks, solution_string) # Compare input with custom platform names if not match: match = platformops.find_custom_platform_from_string(solution_string) if not match: raise NotFoundError('Platform "{}" does not appear to be valid'.format(solution_string)) return match
def test_is_eb_managed_platform(self): arn = 'arn:aws:elasticbeanstalk:us-west-2::platform/Multi-container Docker running on 64bit Amazon Linux/2.7.5' self.assertTrue(PlatformVersion.is_eb_managed_platform_arn(arn))