File 0001-Fix-instance-filtering.patch of Package openstack-nova
From 05b39c9f2db34143e77d6eaee2e0942a5c813cff Mon Sep 17 00:00:00 2001
From: Michal Jura <mjura@suse.com>
Date: Wed, 28 Oct 2015 14:35:34 +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: I9e5d7acd662b15b78ac6d7fc85ae7a4b5489d52b
---
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 28830ab..687e414 100644
--- a/nova/api/openstack/compute/plugins/v3/servers.py
+++ b/nova/api/openstack/compute/plugins/v3/servers.py
@@ -316,10 +316,13 @@ class ServersController(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)
try:
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index b306fd8..ecb0e78 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -590,10 +590,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)
try:
--
2.1.4