diff options
| author | Dan Prince <dprince@redhat.com> | 2012-04-22 19:34:38 -0400 |
|---|---|---|
| committer | Dan Prince <dprince@redhat.com> | 2012-05-03 14:12:16 -0400 |
| commit | 6a53bf90d0c1ea547a1c920c45e0eeef7ddfba2e (patch) | |
| tree | 60726cbcc244ee2d9ed9072aeab1ef1ff2b81efa /nova/db | |
| parent | 8fc533699d8ae02da951e0443853159bed80199f (diff) | |
Implement key pair quotas.
Fixes LP Bug #987058.
Change-Id: Ibefcdc448cb60754d5358fd08d74f7d279c8b16e
Diffstat (limited to 'nova/db')
| -rw-r--r-- | nova/db/api.py | 5 | ||||
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/nova/db/api.py b/nova/db/api.py index 5de921667..1d4103c2d 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -703,6 +703,11 @@ def key_pair_get_all_by_user(context, user_id): return IMPL.key_pair_get_all_by_user(context, user_id) +def key_pair_count_by_user(context, user_id): + """Count number of key pairs for the given user ID.""" + return IMPL.key_pair_count_by_user(context, user_id) + + #################### diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 1d7509aef..105bce004 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1816,6 +1816,13 @@ def key_pair_get_all_by_user(context, user_id): all() +def key_pair_count_by_user(context, user_id): + authorize_user_context(context, user_id) + return model_query(context, models.KeyPair, read_deleted="no").\ + filter_by(user_id=user_id).\ + count() + + ################### |
