def _row_to_db_account_model(row): return db_models.Account(user_id=row.user_id, domain_id=row.domain_id, balance=row.balance, consumption=row.consumption, level=row.level, owed=row.owed, deleted=row.deleted, owed_at=row.owed_at, created_at=row.created_at, updated_at=row.updated_at, deleted_at=row.deleted_at)
def synchronize_database(): ctx = context.make_admin_context(all_tenants=True) context.set_ctx(ctx) def _generate_group(_set, _type): ids_set = [] for subset in _set: ids_set.append(subset[_type]) return ids_set rate_projects_id = _generate_group(dbapi.get_projects(ctx), 'project_id') rate_accounts_id = _generate_group(dbapi.get_accounts(ctx), 'user_id') ks_projects = keystone_client.get_project_list() ks_users = keystone_client.get_user_list() billing_admin = keystone_client.get_user_list(name='billing_admin')[0] billing_admin_id = billing_admin.id domain_id = billing_admin.domain_id for ks_project in ks_projects: if ks_project.id not in rate_projects_id: dbapi.create_project(ctx, db_models.Project( user_id=billing_admin_id, project_id=ks_project.id, domain_id=domain_id, consumption=0)) for ks_user in ks_users: if ks_user.id not in rate_accounts_id: dbapi.create_account(ctx, db_models.Account( user_id=ks_user.id, domain_id=domain_id, balance=0, consumption=0, level=4)) dbapi.charge_account(ctx, user_id=ks_user.id, value=10, type='bonus', come_from='system') context.set_ctx(None)
def _create_temp_account(**kwargs): db_account = db_utils.get_test_account(**kwargs) account = db_models.Account(**db_account) return account
def get(self): LOG.info("get_billing_owner") user_account = HOOK.conductor_rpcapi.get_billing_owner( HOOK.context, self.project_id) return db_models.Account(**user_account)
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))
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)