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


Python dependency_resolver.DependencyResolver類代碼示例

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


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

示例1: test_get_stack_order_raises_exception_on_cyclic_dependency

    def test_get_stack_order_raises_exception_on_cyclic_dependency(self):
        stacks = {
            "app1": StackConfig({"template-url": "horst.yml", "parameters": {"a": "|Ref|app2.id"}}),
            "app2": StackConfig({"template-url": "horst.yml", "parameters": {"a": "|Ref|app3.id"}}),
            "app3": StackConfig({"template-url": "horst.yml", "parameters": {"a": "|Ref|app1.id"}}),
        }

        with self.assertRaises(CyclicDependencyException):
            DependencyResolver.get_stack_order(stacks)
開發者ID:oliver-schoenherr,項目名稱:cfn-sphere,代碼行數:9,代碼來源:dependency_resolver_tests.py

示例2: test_get_stack_order_raises_exception_on_cyclic_dependency

    def test_get_stack_order_raises_exception_on_cyclic_dependency(self):
        stacks = {
            'app1': StackConfig({'template-url': 'horst.yml', 'parameters': {'a': '|Ref|app2.id'}}),
            'app2': StackConfig({'template-url': 'horst.yml', 'parameters': {'a': '|Ref|app3.id'}}),
            'app3': StackConfig({'template-url': 'horst.yml', 'parameters': {'a': '|Ref|app1.id'}})
        }

        with self.assertRaises(CyclicDependencyException):
            DependencyResolver.get_stack_order(stacks)
開發者ID:philipppahl,項目名稱:cfn-sphere,代碼行數:9,代碼來源:dependency_resolver_tests.py

示例3: resolve_parameter_values

    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,代碼行數:49,代碼來源:parameter_resolver.py

示例4: delete_stacks

    def delete_stacks(self):
        existing_stacks = self.cfn.get_stack_names()
        stacks = self.config.stacks

        stack_processing_order = DependencyResolver().get_stack_order(stacks)
        stack_processing_order.reverse()

        self.logger.info("Will delete stacks in the following order: {0}".format(", ".join(stack_processing_order)))

        for stack_name in stack_processing_order:
            if stack_name in existing_stacks:
                stack = CloudFormationStack(None, None, stack_name, None, None)
                self.cfn.validate_stack_is_ready_for_action(stack)
                self.cfn.delete_stack(stack)
            else:
                self.logger.info("Stack {0} is already deleted".format(stack_name))
開發者ID:programmieramt,項目名稱:cfn-sphere,代碼行數:16,代碼來源:__init__.py

示例5: test_get_stack_order_accepts_stacks_without_parameters_key

    def test_get_stack_order_accepts_stacks_without_parameters_key(self):
        stacks = {'default-sg': {},
                  'app1': None,
                  'app2': {},
                  'vpc': {},
                  }

        result = 4

        self.assertEqual(result, len(DependencyResolver.get_stack_order(stacks)))
開發者ID:philipppahl,項目名稱:cfn-sphere,代碼行數:10,代碼來源:dependency_resolver_tests.py

示例6: resolve_parameter_values

    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,代碼行數:42,代碼來源:parameter_resolver.py

示例7: test_get_stack_order_includes_independent_stacks

    def test_get_stack_order_includes_independent_stacks(self):
        stacks = {'default-sg': StackConfig({'template-url': 'horst.yml'}),
                  'app1': StackConfig(
                      {'template-url': 'horst.yml', 'parameters': {'a': '|Ref|vpc.id', 'b': '|Ref|default-sg.id'}}),
                  'app2': StackConfig({'template-url': 'horst.yml',
                                       'parameters': {'a': '|Ref|vpc.id', 'b': '|Ref|default-sg.id',
                                                      'c': 'Ref::app1.id'}}),
                  'vpc': StackConfig({'template-url': 'horst.yml',
                                      'parameters': {'logBucketName': 'is24-cloudtrail-logs',
                                                     'includeGlobalServices': False}})
                  }

        result = 4

        self.assertEqual(result, len(DependencyResolver.get_stack_order(stacks)))
開發者ID:philipppahl,項目名稱:cfn-sphere,代碼行數:15,代碼來源:dependency_resolver_tests.py

示例8: test_get_stack_order_returns_a_valid_order_from_ref_in_list

    def test_get_stack_order_returns_a_valid_order_from_ref_in_list(self):
        stacks = {'default-sg': StackConfig({'template-url': 'horst.yml', 'parameters': {'a': ['|Ref|vpc.id']}}),
                  'app1': StackConfig(
                      {'template-url': 'horst.yml', 'parameters': {'a': ['|Ref|vpc.id'], 'b': ['|Ref|default-sg.id']}}),
                  'app2': StackConfig({'template-url': 'horst.yml',
                                       'parameters': {'a': ['|Ref|vpc.id'], 'b': ['|Ref|default-sg.id'],
                                                      'c': ['|Ref|app1.id']}}),
                  'vpc': StackConfig({'template-url': 'horst.yml',
                                      'parameters': {'logBucketName': 'is24-cloudtrail-logs',
                                                     'includeGlobalServices': False}})
                  }

        expected = ['vpc', 'default-sg', 'app1', 'app2']

        self.assertEqual(expected, DependencyResolver.get_stack_order(stacks))
開發者ID:philipppahl,項目名稱:cfn-sphere,代碼行數:15,代碼來源:dependency_resolver_tests.py

示例9: test_get_stack_order_returns_a_valid_order

    def test_get_stack_order_returns_a_valid_order(self):
        stacks = {
            "default-sg": StackConfig({"template-url": "horst.yml", "parameters": {"a": "|Ref|vpc.id"}}),
            "app1": StackConfig(
                {"template-url": "horst.yml", "parameters": {"a": "|Ref|vpc.id", "b": "|Ref|default-sg.id"}}
            ),
            "app2": StackConfig(
                {
                    "template-url": "horst.yml",
                    "parameters": {"a": "|Ref|vpc.id", "b": "|Ref|default-sg.id", "c": "|Ref|app1.id"},
                }
            ),
            "vpc": StackConfig(
                {
                    "template-url": "horst.yml",
                    "parameters": {"logBucketName": "is24-cloudtrail-logs", "includeGlobalServices": False},
                }
            ),
        }

        expected = ["vpc", "default-sg", "app1", "app2"]

        self.assertEqual(expected, DependencyResolver.get_stack_order(stacks))
開發者ID:oliver-schoenherr,項目名稱:cfn-sphere,代碼行數:23,代碼來源:dependency_resolver_tests.py

示例10: test_get_stack_order_includes_independent_stacks

    def test_get_stack_order_includes_independent_stacks(self):
        stacks = {
            "default-sg": StackConfig({"template-url": "horst.yml"}),
            "app1": StackConfig(
                {"template-url": "horst.yml", "parameters": {"a": "|Ref|vpc.id", "b": "|Ref|default-sg.id"}}
            ),
            "app2": StackConfig(
                {
                    "template-url": "horst.yml",
                    "parameters": {"a": "|Ref|vpc.id", "b": "|Ref|default-sg.id", "c": "Ref::app1.id"},
                }
            ),
            "vpc": StackConfig(
                {
                    "template-url": "horst.yml",
                    "parameters": {"logBucketName": "is24-cloudtrail-logs", "includeGlobalServices": False},
                }
            ),
        }

        result = 4

        self.assertEqual(result, len(DependencyResolver.get_stack_order(stacks)))
開發者ID:oliver-schoenherr,項目名稱:cfn-sphere,代碼行數:23,代碼來源:dependency_resolver_tests.py

示例11: test_is_parameter_reference_returns_true_on_empty_reference

 def test_is_parameter_reference_returns_true_on_empty_reference(self):
     self.assertTrue(DependencyResolver.is_parameter_reference('|ref|'))
開發者ID:philipppahl,項目名稱:cfn-sphere,代碼行數:2,代碼來源:dependency_resolver_tests.py

示例12: test_is_parameter_reference_returns_false_for_boolean_values

 def test_is_parameter_reference_returns_false_for_boolean_values(self):
     self.assertFalse(DependencyResolver.is_parameter_reference(True))
開發者ID:philipppahl,項目名稱:cfn-sphere,代碼行數:2,代碼來源:dependency_resolver_tests.py

示例13: test_is_parameter_reference_returns_false_for_simple_string

 def test_is_parameter_reference_returns_false_for_simple_string(self):
     self.assertFalse(DependencyResolver.is_parameter_reference("vpc.id"))
開發者ID:philipppahl,項目名稱:cfn-sphere,代碼行數:2,代碼來源:dependency_resolver_tests.py

示例14: test_filter_unmanaged_stacks

    def test_filter_unmanaged_stacks(self):
        stacks = ["a", "b", "c"]
        managed_stacks = ["a", "c"]

        self.assertListEqual(managed_stacks, DependencyResolver.filter_unmanaged_stacks(managed_stacks, stacks))
開發者ID:oliver-schoenherr,項目名稱:cfn-sphere,代碼行數:5,代碼來源:dependency_resolver_tests.py

示例15: test_parse_stack_reference_value_returns_stack_and_output_name_tuple

 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,代碼行數:2,代碼來源:dependency_resolver_tests.py


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