def _tosca_policy_test(self, tpl_snippet, expectedprops): nodetemplates = (toscaparser.utils.yamlparser. simple_parse(tpl_snippet)['node_templates']) policies = (toscaparser.utils.yamlparser. simple_parse(tpl_snippet)['policies']) name = list(nodetemplates.keys())[0] policy_name = list(policies[0].keys())[0] for policy in policies: tpl = policy[policy_name] targets = tpl["targets"] try: nodetemplate = NodeTemplate(name, nodetemplates) toscacompute = ToscaCompute(nodetemplate) toscacompute.handle_properties() # adding a property to test that # ToscaPolicies.handle_properties does not overwrite this. toscacompute.properties['scheduler_hints'] = { 'target_cell': 'cell0'} policy = Policy(policy_name, tpl, targets, "node_templates") toscapolicy = ToscaPolicies(policy) nodetemplate = [toscacompute] toscapolicy.handle_properties(nodetemplate) self.assertEqual(toscacompute.properties, expectedprops) except Exception: raise
def _tosca_scaling_test(self, tpl_snippet, expectedprops, hot_template_parameters=None): nodetemplates = (toscaparser.utils.yamlparser. simple_parse(tpl_snippet)['node_templates']) policies = (toscaparser.utils.yamlparser. simple_parse(tpl_snippet)['policies']) name = list(nodetemplates.keys())[0] policy_name = list(policies[0].keys())[0] for policy in policies: tpl = policy[policy_name] targets = tpl["targets"] properties = tpl["properties"] try: nodetemplate = NodeTemplate(name, nodetemplates) toscacompute = ToscaCompute(nodetemplate) toscacompute.handle_properties() policy = Policy(policy_name, tpl, targets, properties, "node_templates") toscascaling = ToscaAutoscaling( policy, hot_template_parameters=hot_template_parameters) parameters = toscascaling.handle_properties([toscacompute]) if hot_template_parameters: substack_template = toscascaling.extract_substack_templates( "output.yaml", HOT_TEMPLATE_VERSION) actual_nested_resource = yaml.load( substack_template['SP1_res.yaml']) self.assertEqual(expectedprops, actual_nested_resource) else: self.assertEqual(parameters[0].properties, expectedprops) except Exception: raise
def _tosca_compute_test(self, tpl_snippet, expectedprops): nodetemplates = (toscaparser.utils.yamlparser. simple_parse(tpl_snippet)['node_templates']) name = list(nodetemplates.keys())[0] nodetemplate = NodeTemplate(name, nodetemplates) nodetemplate.validate() toscacompute = ToscaCompute(nodetemplate) toscacompute.handle_properties() self.assertEqual(expectedprops, toscacompute.properties)
def _tosca_compute_test(self, tpl_snippet, expectedprops): nodetemplates = (toscaparser.utils.yamlparser.simple_parse(tpl_snippet) ['node_templates']) name = list(nodetemplates.keys())[0] nodetemplate = NodeTemplate(name, nodetemplates) nodetemplate.validate() toscacompute = ToscaCompute(nodetemplate) toscacompute.handle_properties() self.assertEqual(expectedprops, toscacompute.properties)
def _tosca_compute_test(self, tpl_snippet, expectedprops): nodetemplates = (translator.toscalib.utils.yamlparser. simple_parse(tpl_snippet)['node_templates']) name = list(nodetemplates.keys())[0] try: nodetemplate = NodeTemplate(name, nodetemplates) toscacompute = ToscaCompute(nodetemplate) toscacompute.handle_properties() if not self._compare_properties(toscacompute.properties, expectedprops): raise Exception(_("Hot Properties are not" " same as expected properties")) except Exception: # for time being rethrowing. Will be handled future based # on new development in Glance and Graffiti raise
def _tosca_compute_test(self, tpl_snippet, expectedprops): nodetemplates = (toscaparser.utils.yamlparser. simple_parse(tpl_snippet)['node_templates']) name = list(nodetemplates.keys())[0] try: nodetemplate = NodeTemplate(name, nodetemplates) nodetemplate.validate() toscacompute = ToscaCompute(nodetemplate) toscacompute.handle_properties() if not self._compare_properties(toscacompute.properties, expectedprops): raise Exception(_("Hot Properties are not" " same as expected properties")) except Exception: # for time being rethrowing. Will be handled future based # on new development in Glance and Graffiti raise
def _tosca_scaling_test(self, tpl_snippet, expectedprops): nodetemplates = (toscaparser.utils.yamlparser.simple_parse(tpl_snippet) ['node_templates']) policies = ( toscaparser.utils.yamlparser.simple_parse(tpl_snippet)['policies']) name = list(nodetemplates.keys())[0] policy_name = list(policies[0].keys())[0] for policy in policies: tpl = policy[policy_name] targets = tpl["targets"] properties = tpl["properties"] try: nodetemplate = NodeTemplate(name, nodetemplates) toscacompute = ToscaCompute(nodetemplate) toscacompute.handle_properties() policy = Policy(policy_name, tpl, targets, properties, "node_templates") toscascaling = ToscaAutoscaling(policy) parameters = toscascaling.handle_properties([toscacompute]) self.assertEqual(parameters[0].properties, expectedprops) except Exception: raise
def _tosca_policy_test(self, tpl_snippet, expectedprops): nodetemplates = (toscaparser.utils.yamlparser. simple_parse(tpl_snippet)['node_templates']) policies = (toscaparser.utils.yamlparser. simple_parse(tpl_snippet)['policies']) name = list(nodetemplates.keys())[0] policy_name = list(policies[0].keys())[0] for policy in policies: tpl = policy[policy_name] targets = tpl["targets"] try: nodetemplate = NodeTemplate(name, nodetemplates) toscacompute = ToscaCompute(nodetemplate) toscacompute.handle_properties() policy = Policy(policy_name, tpl, targets, "node_templates") toscapolicy = ToscaPolicies(policy) nodetemplate = [toscacompute] toscapolicy.handle_properties(nodetemplate) self.assertEqual(toscacompute.properties, expectedprops) except Exception: raise