Пример #1
0
 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)
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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)
Пример #5
0
 def load(cls, context, instance_id):
     history = get_db_api().find_by(cls, id=instance_id)
     return history
Пример #6
0
 def save(self):
     LOG.debug(_("Saving %s: %s") % (self.__class__.__name__,
                                     self.__dict__))
     return get_db_api().save(self)
Пример #7
0
 def get_by(cls, **kwargs):
     return get_db_api().find_by(cls, **cls._process_conditions(kwargs))
Пример #8
0
 def db_api(self):
     return get_db_api()
Пример #9
0
 def load(cls, context, instance_id):
     history = get_db_api().find_by(cls, id=instance_id)
     return history
Пример #10
0
 def save(self):
     LOG.debug(
         _("Saving %s: %s") % (self.__class__.__name__, self.__dict__))
     return get_db_api().save(self)
Пример #11
0
 def get_by(cls, **kwargs):
     return get_db_api().find_by(cls, **cls._process_conditions(kwargs))
Пример #12
0
 def query(cls):
     return get_db_api()._base_query(cls)
Пример #13
0
 def db_api(self):
     return get_db_api()
Пример #14
0
 def query(cls):
     return get_db_api()._base_query(cls)
Пример #15
0
 def delete(self):
     LOG.debug(_("Deleting %s: %s") %
               (self.__class__.__name__, self.__dict__))
     return get_db_api().delete(self)
Пример #16
0
 def delete(self):
     LOG.debug(_("Deleting %s: %s") %
               (self.__class__.__name__, self.__dict__))
     return get_db_api().delete(self)