def verify(test, reality, tmpl): LOG.info('Verifying %s', tmpl) for name in tmpl.resources: rsrc_count = len(reality.resources_by_logical_name(name)) test.assertEqual(1, rsrc_count, 'Found %d copies of resource "%s"' % (rsrc_count, name)) all_rsrcs = reality.all_resources() for name, defn in tmpl.resources.items(): phys_rsrc = reality.resources_by_logical_name(name)[0] for prop_name, prop_def in defn.properties.items(): real_value = reality.resource_properties(phys_rsrc, prop_name) if isinstance(prop_def, scenario_template.GetAtt): targs = reality.resources_by_logical_name(prop_def.target_name) prop_def = targs[0].rsrc_prop_data.data[prop_def.attr] elif isinstance(prop_def, scenario_template.GetRes): targs = reality.resources_by_logical_name(prop_def.target_name) prop_def = targs[0].physical_resource_id test.assertEqual(prop_def, real_value, 'Unexpected value for %s prop %s' % (name, prop_name)) len_rsrc_prop_data = 0 if phys_rsrc.rsrc_prop_data: len_rsrc_prop_data = len(phys_rsrc.rsrc_prop_data.data) test.assertEqual(len(defn.properties), len_rsrc_prop_data) test.assertEqual(set(tmpl.resources), set(r.name for r in all_rsrcs))
def verify(test, reality, tmpl): for name in tmpl.resources: rsrc_count = len(reality.resources_by_logical_name(name)) test.assertEqual(1, rsrc_count, 'Found %d copies of resource "%s"' % (rsrc_count, name)) all_rsrcs = reality.all_resources() for name, defn in tmpl.resources.items(): phys_rsrc = reality.resources_by_logical_name(name)[0] for prop_name, prop_def in defn.properties.items(): real_value = reality.resource_properties(phys_rsrc, prop_name) if isinstance(prop_def, scenario_template.GetAtt): targs = reality.resources_by_logical_name(prop_def.target_name) att_value = targs[0].properties_data[prop_def.attr] test.assertEqual(att_value, real_value) elif isinstance(prop_def, scenario_template.GetRes): targs = reality.resources_by_logical_name(prop_def.target_name) test.assertEqual(targs[0].nova_instance, real_value) else: test.assertEqual(prop_def, real_value) test.assertEqual(len(defn.properties), len(phys_rsrc.properties_data)) test.assertEqual(len(tmpl.resources), len(all_rsrcs))
def verify(test, reality, tmpl): LOG.info('Verifying %s', tmpl) for name in tmpl.resources: rsrc_count = len(reality.resources_by_logical_name(name)) test.assertEqual( 1, rsrc_count, 'Found %d copies of resource "%s"' % (rsrc_count, name)) all_rsrcs = reality.all_resources() for name, defn in tmpl.resources.items(): phys_rsrc = reality.resources_by_logical_name(name)[0] for prop_name, prop_def in defn.properties.items(): real_value = reality.resource_properties(phys_rsrc, prop_name) if isinstance(prop_def, scenario_template.GetAtt): targs = reality.resources_by_logical_name(prop_def.target_name) prop_def = targs[0].rsrc_prop_data.data[prop_def.attr] elif isinstance(prop_def, scenario_template.GetRes): targs = reality.resources_by_logical_name(prop_def.target_name) prop_def = targs[0].physical_resource_id test.assertEqual( prop_def, real_value, 'Unexpected value for %s prop %s' % (name, prop_name)) len_rsrc_prop_data = 0 if phys_rsrc.rsrc_prop_data: len_rsrc_prop_data = len(phys_rsrc.rsrc_prop_data.data) test.assertEqual(len(defn.properties), len_rsrc_prop_data) test.assertEqual(set(tmpl.resources), set(r.name for r in all_rsrcs))