示例#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
文件: models.py 项目: rmyers/reddwarf
 def get_by(cls, **kwargs):
     return get_db_api().find_by(cls, **cls._process_conditions(kwargs))
示例#8
0
文件: models.py 项目: rmyers/reddwarf
 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
文件: models.py 项目: jrodom/reddwarf
 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)