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