Beispiel #1
0
    def setUp(self):
        super(DbTestCase, self).setUp()

        self.dbapi = dbapi.get_instance()

        global _DB_CACHE
        if not _DB_CACHE:
            _DB_CACHE = Database(sqla_api, migration,
                                 sql_connection=CONF.database.connection)
        self.useFixture(_DB_CACHE)
class Handler(object):

    dbapi = dbapi.get_instance()

    def __init__(self):
        super(Handler, self).__init__()

    def create_account(cls, context, **kwargs):
        LOG.debug('create account: Received message from RPC.')
        account = db_models.Account(**kwargs)
        return cls.dbapi.create_account(context, account)

    def get_account(cls, context, **kwargs):
        LOG.debug('get account: Received message from RPC.')
        account = cls.dbapi.get_account(context, **kwargs)
        return account

    def get_accounts(cls, context, **kwargs):
        LOG.debug('get accounts: Received message from RPC.')
        accounts = cls.dbapi.get_accounts(context, **kwargs)
        return accounts

    def get_accounts_count(cls, context, **kwargs):
        LOG.debug('get accounts count: Received message from RPC.')
        accounts = cls.dbapi.get_accounts_count(context, **kwargs)
        return accounts

    def delete_account(cls, context, **kwargs):
        LOG.debug('delete account: Received message from RPC.')
        cls.dbapi.delete_account(context, **kwargs)

    def change_account_level(cls, context, **kwargs):
        LOG.debug('change account level: Received message from RPC.')
        return cls.dbapi.change_account_level(context, **kwargs)

    def charge_account(cls, context, **kwargs):
        LOG.debug('update account: Received message from RPC.')
        return cls.dbapi.charge_account(context,
                                        kwargs.pop('user_id'),
                                        **kwargs)

    def update_account(cls, context, **kwargs):
        LOG.debug('update account: Received message from RPC.')
        return cls.dbapi.update_account(context,
                                        kwargs.pop('user_id'),
                                        **kwargs)

    def get_charges(cls, context, **kwargs):
        LOG.debug('get charges: Received message from RPC.')
        return cls.dbapi.get_charges(context, **kwargs)

    def get_charges_price_and_count(cls, context, **kwargs):
        LOG.debug('get_charges_price_and_count: Received message from RPC.')
        return cls.dbapi.get_charges_price_and_count(context, **kwargs)
class Handler(object):

    dbapi = dbapi.get_instance()

    def get_billing_owner(cls, context, **kwargs):
        LOG.debug('Conductor Function: get_billing_owner.')
        billing_owner = cls.dbapi.get_billing_owner(context,
                                                    kwargs['project_id'])
        return billing_owner

    def change_billing_owner(cls, context, **kwargs):
        LOG.debug('Conductor Function: change_billing_owner.')
        cls.dbapi.change_billing_owner(context, kwargs['project_id'],
                                       kwargs['user_id'])

    def create_project(cls, context, **kwargs):
        LOG.debug('Conductor Function: create_project.')
        project = db_models.Project(**kwargs)
        return cls.dbapi.create_project(context, project)

    def get_project(cls, context, **kwargs):
        LOG.debug('Conductor Function: get_project.')
        project = cls.dbapi.get_project(context, kwargs['project_id'])
        return project

    def delete_project(cls, context, **kwargs):
        LOG.debug('Conductor Function: delete_project.')
        cls.dbapi.delete_project(context, kwargs['project_id'])

    def get_relation(cls, context, **kwargs):
        LOG.debug('Conductor Function: get_user_projects.')
        return cls.dbapi.get_relation(context, **kwargs)

    def get_projects(cls, context, **kwargs):
        LOG.debug('Conductor Function: get_projects.')
        return cls.dbapi.get_projects(context, **kwargs)
Beispiel #4
0
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from shadowfiend.tests.unit.db import utils as db_utils
from shadowfiend.db import models as db_models
from shadowfiend.db import api as dbapi

dbapi = dbapi.get_instance()


def _create_temp_account(**kwargs):
    db_account = db_utils.get_test_account(**kwargs)
    account = db_models.Account(**db_account)
    return account


def _create_temp_project(**kwargs):
    db_project = db_utils.get_test_project(**kwargs)
    project = db_models.Project(**db_project)
    return project


def _create_temp_relation(**kwargs):
Beispiel #5
0
def create_test_account(context, **kwargs):
    account = get_test_account(**kwargs)
    dbapi = db_api.get_instance()
    return dbapi.create_account(context, db_models.Account(**account))