def add(self, ver, updates): if ver in self.versions: msg = 'Version %s already exists in history.' % ver raise exception.ProgrammingError(reason=msg) self[ver] = self[self.get_current()].copy() self.versions.append(ver) self[ver].update(updates)
def cinder_ovo_cls_init(cls): """This method is called on OVO registration and sets the DB model.""" # Persistent Versioned Objects Classes should have a DB model, and if # they don't, then we have a problem and we must raise an exception on # registration. try: cls.model = db.get_model_for_versioned_object(cls) except (ImportError, AttributeError): msg = _("Couldn't find ORM model for Persistent Versioned " "Object %s.") % cls.obj_name() raise exception.ProgrammingError(reason=msg)
def is_snapshot(self): if self.obj_attr_is_set('snapshot') == self.obj_attr_is_set('volume'): msg = _("Either snapshot or volume field should be set.") raise exception.ProgrammingError(message=msg) return self.obj_attr_is_set('snapshot')