From d034ff1cc12889d3812545a5e1a74c70f66270f5 Mon Sep 17 00:00:00 2001 From: Jian Wen Date: Thu, 16 Aug 2012 22:32:54 +0800 Subject: 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 --- nova/api/openstack/compute/servers.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'nova/api') 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 -- cgit