Esempio n. 1
0
    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))
                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_actual_value(key, value, stack_name))

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

                else:
                    parameters[key] = value

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

        return parameters
 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'))
 def test_parse_stack_reference_raises_exception_on_empty_reference(self):
     with self.assertRaises(CfnSphereException):
         DependencyResolver.parse_stack_reference_value('|ref|')
 def test_parse_stack_reference_value_returns_none_for_non_reference(self):
     self.assertIsNone(DependencyResolver.parse_stack_reference_value('foo'))
 def test_parse_stack_reference_raises_exception_on_missing_dot(self):
     with self.assertRaises(CfnSphereException):
         DependencyResolver.parse_stack_reference_value('|ref|foo')