def save(self): if not self.is_valid(): raise exception.InvalidModelError(errors=self.errors) self['updated_at'] = utils.utcnow() LOG.debug(_("Saving %s: %s") % (self.__class__.__name__, self.__dict__)) return get_db_api().save(self)
def init_db(): from reddwarf.common import cfg from reddwarf.db import get_db_api from reddwarf.db.sqlalchemy import session CONF = cfg.CONF db_api = get_db_api() db_api.db_sync(CONF) session.configure_db(CONF)
def initialize_database(): from reddwarf.db import get_db_api from reddwarf.instance import models from reddwarf.db.sqlalchemy import session db_api = get_db_api() db_api.drop_db(CONF) # Destroys the database, if it exists. db_api.db_sync(CONF) session.configure_db(CONF) # Adds the image for mysql (needed to make most calls work). models.ServiceImage.create(service_name="mysql", image_id="fake") db_api.configure_db(CONF)
def load(cls, context, instance_id): history = get_db_api().find_by(cls, id=instance_id) return history
def save(self): LOG.debug(_("Saving %s: %s") % (self.__class__.__name__, self.__dict__)) return get_db_api().save(self)
def get_by(cls, **kwargs): return get_db_api().find_by(cls, **cls._process_conditions(kwargs))
def db_api(self): return get_db_api()
def save(self): LOG.debug( _("Saving %s: %s") % (self.__class__.__name__, self.__dict__)) return get_db_api().save(self)
def query(cls): return get_db_api()._base_query(cls)
def delete(self): LOG.debug(_("Deleting %s: %s") % (self.__class__.__name__, self.__dict__)) return get_db_api().delete(self)