def _get_actions_from_matches(self, scenario_version, combined_matches, mode, action_spec): actions = [] for is_switch_mode, matches in combined_matches: new_mode = mode if is_switch_mode: new_mode = ActionMode.UNDO \ if mode == ActionMode.DO else ActionMode.DO template_schema = \ TemplateSchemaFactory().template_schema(scenario_version) for match in matches: match_action_spec = self._get_action_spec(action_spec, match) items_ids = \ [match_item[1].vertex_id for match_item in match.items()] match_hash = md5(tuple(sorted(items_ids))) self._evaluate_property_functions(template_schema, match, match_action_spec.properties) actions.append( ActionInfo(match_action_spec, new_mode, match_action_spec.id, match_hash)) return actions
def uuid_from_deprecated_vitrage_id(cls, vitrage_id): old_vitrage_id = md5(vitrage_id) new_uuid = cls.key_to_uuid_cache.get(old_vitrage_id) if not new_uuid: new_uuid = uuidutils.generate_uuid() cls.key_to_uuid_cache[old_vitrage_id] = new_uuid return new_uuid
def update_uuid_in_vertex(self, vertex): if not vertex: return # TODO(annarez): remove IS_REAL_VITRAGE_ID prop if vertex.get(VProps.IS_REAL_VITRAGE_ID): return vertex new_uuid = self.uuid_from_deprecated_vitrage_id(vertex.vertex_id) vertex.properties[VProps.VITRAGE_CACHED_ID] = md5(vertex.vertex_id) vertex.vertex_id = new_uuid vertex.properties[VProps.VITRAGE_ID] = new_uuid vertex.properties[VProps.IS_REAL_VITRAGE_ID] = True return vertex