From fbae8d09fdb9ad370fa827aab0f9bfe0c0c7041f Mon Sep 17 00:00:00 2001 From: Craig Vyvial Date: Mon, 7 May 2012 14:03:04 -0500 Subject: 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 --- nova/db/api.py | 7 +++++++ nova/db/sqlalchemy/api.py | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'nova/db') 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() + + #################### -- cgit