File 0001-Fix-instance-filtering.patch of Package openstack-nova
From 563328d3af3a915561f8faf9391582005c167fa0 Mon Sep 17 00:00:00 2001
From: Michal Jura <mjura@suse.com>
Date: Wed, 28 Oct 2015 14:58:59 +0100
Subject: [PATCH] This patch allows for tenant filtering. For example: nova
list --tenant <tenant_id> Previously, tenant_id was accepted but did not give
desirable output. If you don't pass tenant_id, the current context tenant
will be used.
Closes-Bug: #1398329
(cherry picked from commit b4e50819833d1f1e7983add35a925db4c1e7cd86)
Change-Id: I9a23fb754384fd35b872a5174779d18211581078
---
nova/api/openstack/compute/plugins/v3/servers.py | 9 ++++++---
nova/api/openstack/compute/servers.py | 9 ++++++---
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/nova/api/openstack/compute/plugins/v3/servers.py b/nova/api/openstack/compute/plugins/v3/servers.py
index 6d526cc..a0a0010 100644
--- a/nova/api/openstack/compute/plugins/v3/servers.py
+++ b/nova/api/openstack/compute/plugins/v3/servers.py
@@ -355,10 +355,13 @@ class ServersController(wsgi.Controller):
authorize(context, action="index:get_all_tenants")
del search_opts['all_tenants']
else:
- if context.project_id:
- search_opts['project_id'] = context.project_id
+ if 'tenant_id' in search_opts:
+ search_opts['project_id'] = search_opts['tenant_id']
else:
- search_opts['user_id'] = context.user_id
+ if context.project_id:
+ search_opts['project_id'] = context.project_id
+ else:
+ search_opts['user_id'] = context.user_id
limit, marker = common.get_limit_and_marker(req)
sort_keys, sort_dirs = common.get_sort_params(req.params)
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index d3d52ae..36b037d 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -203,10 +203,13 @@ class Controller(wsgi.Controller):
'user_id': context.user_id})
del search_opts['all_tenants']
else:
- if context.project_id:
- search_opts['project_id'] = context.project_id
+ if 'tenant_id' in search_opts:
+ search_opts['project_id'] = search_opts['tenant_id']
else:
- search_opts['user_id'] = context.user_id
+ if context.project_id:
+ search_opts['project_id'] = context.project_id
+ else:
+ search_opts['user_id'] = context.user_id
limit, marker = common.get_limit_and_marker(req)
# Sorting by multiple keys and directions is conditionally enabled
--
2.1.4