當前位置: 首頁>>代碼示例>>Python>>正文


Python DependencyResolver.parse_stack_reference_value方法代碼示例

本文整理匯總了Python中cfn_sphere.stack_configuration.dependency_resolver.DependencyResolver.parse_stack_reference_value方法的典型用法代碼示例。如果您正苦於以下問題:Python DependencyResolver.parse_stack_reference_value方法的具體用法?Python DependencyResolver.parse_stack_reference_value怎麽用?Python DependencyResolver.parse_stack_reference_value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cfn_sphere.stack_configuration.dependency_resolver.DependencyResolver的用法示例。


在下文中一共展示了DependencyResolver.parse_stack_reference_value方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: resolve_parameter_values

# 需要導入模塊: from cfn_sphere.stack_configuration.dependency_resolver import DependencyResolver [as 別名]
# 或者: from cfn_sphere.stack_configuration.dependency_resolver.DependencyResolver import parse_stack_reference_value [as 別名]
    def resolve_parameter_values(self, stack_name, stack_config, cli_parameters=None):
        resolved_parameters = {}
        stack_outputs = self.cfn.get_stacks_outputs()

        for key, value in stack_config.parameters.items():

            if isinstance(value, list):
                self.logger.debug("List parameter found for {0}".format(key))
                for i, item in enumerate(value):
                    if DependencyResolver.is_parameter_reference(item):
                        referenced_stack, output_name = DependencyResolver.parse_stack_reference_value(item)
                        value[i] = str(self.get_output_value(stack_outputs, referenced_stack, output_name))

                value_string = self.convert_list_to_string(value)
                resolved_parameters[key] = value_string

            elif isinstance(value, str):

                if DependencyResolver.is_parameter_reference(value):
                    referenced_stack, output_name = DependencyResolver.parse_stack_reference_value(value)
                    resolved_parameters[key] = str(self.get_output_value(stack_outputs, referenced_stack, output_name))

                elif self.is_keep_value(value):
                    resolved_parameters[key] = str(self.get_latest_value(key, value, stack_name))

                elif self.is_taupage_ami_reference(value):
                    resolved_parameters[key] = str(self.ec2.get_latest_taupage_image_id())

                elif self.is_kms(value):
                    resolved_parameters[key] = str(self.kms.decrypt(value.split('|', 2)[2]))

                elif self.is_file(value):
                    url = value.split('|', 2)[2]
                    resolved_parameters[key] = FileLoader.get_file(url, stack_config.working_dir)

                else:
                    resolved_parameters[key] = value

            elif isinstance(value, bool):
                resolved_parameters[key] = str(value).lower()
            elif isinstance(value, (int, float)):
                resolved_parameters[key] = str(value)
            else:
                raise NotImplementedError("Cannot handle {0} type for key: {1}".format(type(value), key))

        if cli_parameters:
            return self.update_parameters_with_cli_parameters(resolved_parameters, cli_parameters, stack_name)
        else:
            return resolved_parameters
開發者ID:cfn-sphere,項目名稱:cfn-sphere,代碼行數:51,代碼來源:parameter_resolver.py

示例2: resolve_parameter_values

# 需要導入模塊: from cfn_sphere.stack_configuration.dependency_resolver import DependencyResolver [as 別名]
# 或者: from cfn_sphere.stack_configuration.dependency_resolver.DependencyResolver import parse_stack_reference_value [as 別名]
    def resolve_parameter_values(self, parameters_dict, stack_name):
        parameters = {}

        for key, value in parameters_dict.items():

            if isinstance(value, list):

                self.logger.debug("List parameter found for {0}".format(key))
                for i, item in enumerate(value):
                    if DependencyResolver.is_parameter_reference(item):
                        referenced_stack, output_name = DependencyResolver.parse_stack_reference_value(item)
                        value[i] = str(self.get_output_value(referenced_stack + '.' + output_name))

                value_string = self.convert_list_to_string(value)
                parameters[key] = value_string

            elif isinstance(value, str):

                if DependencyResolver.is_parameter_reference(value):
                    referenced_stack, output_name = DependencyResolver.parse_stack_reference_value(value)
                    parameters[key] = str(self.get_output_value(referenced_stack + '.' + output_name))

                elif self.is_keep_value(value):
                    parameters[key] = str(self.get_latest_value(key, value, stack_name))

                elif self.is_taupage_ami_reference(value):
                    parameters[key] = str(self.ec2.get_latest_taupage_image_id())

                elif self.is_kms(value):
                    parameters[key] = str(self.kms.decrypt(value.split('|', 2)[2]))

                else:
                    parameters[key] = value

            elif isinstance(value, bool):
                parameters[key] = str(value).lower()
            elif isinstance(value, (int, float)):
                parameters[key] = str(value)
            else:
                raise NotImplementedError("Cannot handle {0} value for key: {1}".format(type(value), key))

        return parameters
開發者ID:philipppahl,項目名稱:cfn-sphere,代碼行數:44,代碼來源:parameter_resolver.py

示例3: test_parse_stack_reference_raises_exception_on_empty_reference

# 需要導入模塊: from cfn_sphere.stack_configuration.dependency_resolver import DependencyResolver [as 別名]
# 或者: from cfn_sphere.stack_configuration.dependency_resolver.DependencyResolver import parse_stack_reference_value [as 別名]
 def test_parse_stack_reference_raises_exception_on_empty_reference(self):
     with self.assertRaises(CfnSphereException):
         DependencyResolver.parse_stack_reference_value('|ref|')
開發者ID:philipppahl,項目名稱:cfn-sphere,代碼行數:5,代碼來源:dependency_resolver_tests.py

示例4: test_parse_stack_reference_raises_exception_on_missing_dot

# 需要導入模塊: from cfn_sphere.stack_configuration.dependency_resolver import DependencyResolver [as 別名]
# 或者: from cfn_sphere.stack_configuration.dependency_resolver.DependencyResolver import parse_stack_reference_value [as 別名]
 def test_parse_stack_reference_raises_exception_on_missing_dot(self):
     with self.assertRaises(CfnSphereException):
         DependencyResolver.parse_stack_reference_value('|ref|foo')
開發者ID:philipppahl,項目名稱:cfn-sphere,代碼行數:5,代碼來源:dependency_resolver_tests.py

示例5: test_parse_stack_reference_value_returns_stack_and_output_name_tuple

# 需要導入模塊: from cfn_sphere.stack_configuration.dependency_resolver import DependencyResolver [as 別名]
# 或者: from cfn_sphere.stack_configuration.dependency_resolver.DependencyResolver import parse_stack_reference_value [as 別名]
 def test_parse_stack_reference_value_returns_stack_and_output_name_tuple(self):
     self.assertEqual(('stack', 'output'), DependencyResolver.parse_stack_reference_value('|ref|stack.output'))
開發者ID:philipppahl,項目名稱:cfn-sphere,代碼行數:4,代碼來源:dependency_resolver_tests.py

示例6: test_parse_stack_reference_value_returns_none_for_non_reference

# 需要導入模塊: from cfn_sphere.stack_configuration.dependency_resolver import DependencyResolver [as 別名]
# 或者: from cfn_sphere.stack_configuration.dependency_resolver.DependencyResolver import parse_stack_reference_value [as 別名]
 def test_parse_stack_reference_value_returns_none_for_non_reference(self):
     self.assertEqual((None, None), DependencyResolver.parse_stack_reference_value('foo'))
開發者ID:philipppahl,項目名稱:cfn-sphere,代碼行數:4,代碼來源:dependency_resolver_tests.py


注:本文中的cfn_sphere.stack_configuration.dependency_resolver.DependencyResolver.parse_stack_reference_value方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。