summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJian Wen <wenjianhn@gmail.com>2012-08-16 22:32:54 +0800
committerJian Wen <wenjianhn@gmail.com>2012-08-23 16:31:18 +0800
commitd034ff1cc12889d3812545a5e1a74c70f66270f5 (patch)
tree7896ea8a99791e2880ed3e72c20e87074e71442c /nova/api
parent9fecad9e6f7803f3422e7769c01ba3b9076ed308 (diff)
Let admin list instances in vm_states.DELETED
Command 'nova list --status DELETED' returns nothing at the moment. Make 'nova list --status DELETED' work and work for admin only. Fixes LP Bug #1037885 Change-Id: I0bace95df713a767bb17e470e66361e1891e628c
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/servers.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index 104f6ab99..229c3b5aa 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -428,6 +428,13 @@ class Controller(wsgi.Controller):
# No 'changes-since', so we only want non-deleted servers
search_opts['deleted'] = False
+ if search_opts.get("vm_state") == "deleted":
+ if context.is_admin:
+ search_opts['deleted'] = True
+ else:
+ msg = _("Only administrators may list deleted instances")
+ raise exc.HTTPBadRequest(explanation=msg)
+
# NOTE(dprince) This prevents computes' get_all() from returning
# instances from multiple tenants when an admin accounts is used.
# By default non-admin accounts are always limited to project/user