diff options
| author | Jesse Andrews <jesse@gigantor.local> | 2010-08-24 22:41:34 -0400 |
|---|---|---|
| committer | Jesse Andrews <jesse@gigantor.local> | 2010-08-24 22:41:34 -0400 |
| commit | ac48bf5c1b4701640e69747c43ca10cf3442e6ff (patch) | |
| tree | 3d2c97c5c463da794d2b558f41c1247fad64e3ab /nova/db | |
| parent | ffa1fa54e3c15c12b2b92fab0f2456a2631734b7 (diff) | |
work towards volumes using db layer
Diffstat (limited to 'nova/db')
| -rw-r--r-- | nova/db/api.py | 11 | ||||
| -rw-r--r-- | nova/db/sqlalchemy/api.py | 12 |
2 files changed, 22 insertions, 1 deletions
diff --git a/nova/db/api.py b/nova/db/api.py index e4d79d16f..edc3b7bdc 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -195,7 +195,6 @@ def instance_get_by_name(context, name): return _impl.instance_get_by_project(context, name) - def instance_get_by_project(context, project_id): """Get all instance belonging to a project.""" return _impl.instance_get_by_project(context, project_id) @@ -356,6 +355,16 @@ def volume_get(context, volume_id): return _impl.volume_get(context, volume_id) +def volume_get_all(context): + """Get all volumes.""" + return _impl.volume_get_all(context) + + +def volume_get_by_project(context, project_id): + """Get all volumes belonging to a project.""" + return _impl.volume_get_by_project(context, project_id) + + def volume_get_shelf_and_blade(context, volume_id): """Get the shelf and blade allocated to the volume.""" return _impl.volume_get_shelf_and_blade(context, volume_id) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 2c5434b8f..2ce54a1d7 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -441,6 +441,18 @@ def volume_get(context, volume_id): return models.Volume.find(volume_id) +def volume_get_all(context): + return models.Volume.all() + + +def volume_get_by_project(context, project_id): + session = models.NovaBase.get_session() + query = session.query(models.Volume) + results = query.filter_by(project_id=project_id).all() + session.commit() + return results + + def volume_get_shelf_and_blade(context, volume_id): volume_ref = volume_get(context, volume_id) export_device = volume_ref.export_device |
