summaryrefslogtreecommitdiffstats
path: root/nova/db
diff options
context:
space:
mode:
authorCraig Vyvial <cp16net@gmail.com>2012-05-07 14:03:04 -0500
committerCraig Vyvial <cp16net@gmail.com>2012-05-14 16:34:08 -0500
commitfbae8d09fdb9ad370fa827aab0f9bfe0c0c7041f (patch)
treeb84449522d27586243a9994e704ab6bc06d3d0cf /nova/db
parentb3e2bae38177583201dd7dcdd2d9c16929724573 (diff)
Adding notifications for volumes
Added notifications for volumes have been added with tests. This includes create/delete/exists events for volumes. blueprint nova-notifications Change-Id: I21b74974fac22c3621ccf7564dc5c0d339f8751a
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/api.py7
-rw-r--r--nova/db/sqlalchemy/api.py17
2 files changed, 24 insertions, 0 deletions
diff --git a/nova/db/api.py b/nova/db/api.py
index ca1e420d7..fed92072d 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -1612,6 +1612,13 @@ def volume_type_destroy(context, name):
return IMPL.volume_type_destroy(context, name)
+def volume_get_active_by_window(context, begin, end=None, project_id=None):
+ """Get all the volumes inside the window.
+
+ Specifying a project_id will filter for a certain project."""
+ return IMPL.volume_get_active_by_window(context, begin, end, project_id)
+
+
####################
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 56ce054d3..4e8e69313 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -4109,6 +4109,23 @@ def volume_type_destroy(context, name):
'updated_at': literal_column('updated_at')})
+@require_context
+def volume_get_active_by_window(context, begin, end=None,
+ project_id=None):
+ """Return volumes that were active during window."""
+ session = get_session()
+ query = session.query(models.Volume)
+
+ query = query.filter(or_(models.Volume.deleted_at == None,
+ models.Volume.deleted_at > begin))
+ if end:
+ query = query.filter(models.Volume.created_at < end)
+ if project_id:
+ query = query.filter_by(project_id=project_id)
+
+ return query.all()
+
+
####################