summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSatyanarayana Patibandla <satya.patibandlai@tcs.com>2013-04-27 14:44:23 -0400
committerSatyanarayana Patibandla <satya.patibandla@tcs.com>2013-05-19 22:22:09 +0530
commit37abdd9968ad19fc29abde5783e6e07c9a4637cb (patch)
treeee51c603c902e37c1af8e678e86d19b4e85eb77f
parent5c3113b066e61cbc5d8d4d464f8200d4cb5e8395 (diff)
downloadnova-37abdd9968ad19fc29abde5783e6e07c9a4637cb.tar.gz
nova-37abdd9968ad19fc29abde5783e6e07c9a4637cb.tar.xz
nova-37abdd9968ad19fc29abde5783e6e07c9a4637cb.zip
Added attribute 'ip' to server search options.
Allows all tenants to use attribute 'ip' in server search options. For this fix, added attribute 'ip' to server search options. Modified the existing test case to verify 'ip' search for all tenants. Implements: blueprint add-attribute-ip-in-server-search-options Change-Id: Ic24ee67d729f77d56c4fe3e1d4110865550c2154
-rw-r--r--nova/api/openstack/compute/servers.py2
-rw-r--r--nova/tests/api/openstack/compute/test_servers.py11
2 files changed, 5 insertions, 8 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index 2df16c886..166c8b10e 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -1392,7 +1392,7 @@ class Controller(wsgi.Controller):
def _get_server_search_options(self):
"""Return server search options allowed by non-admin."""
return ('reservation_id', 'name', 'status', 'image', 'flavor',
- 'changes-since', 'all_tenants')
+ 'ip', 'changes-since', 'all_tenants')
def create_resource(ext_mgr):
diff --git a/nova/tests/api/openstack/compute/test_servers.py b/nova/tests/api/openstack/compute/test_servers.py
index 5d2118564..22aecf020 100644
--- a/nova/tests/api/openstack/compute/test_servers.py
+++ b/nova/tests/api/openstack/compute/test_servers.py
@@ -935,10 +935,10 @@ class ServersControllerTest(test.TestCase):
self.assertNotEqual(search_opts, None)
# Allowed by user
self.assertTrue('name' in search_opts)
+ self.assertTrue('ip' in search_opts)
# OSAPI converts status to vm_state
self.assertTrue('vm_state' in search_opts)
# Allowed only by admins with admin API on
- self.assertFalse('ip' in search_opts)
self.assertFalse('unknown_option' in search_opts)
return [fakes.stub_instance(100, uuid=server_uuid)]
@@ -981,10 +981,8 @@ class ServersControllerTest(test.TestCase):
self.assertEqual(len(servers), 1)
self.assertEqual(servers[0]['id'], server_uuid)
- def test_get_servers_admin_allows_ip(self):
- """Test getting servers by ip with admin_api enabled and
- admin context
- """
+ def test_get_servers_allows_ip(self):
+ """Test getting servers by ip."""
server_uuid = str(uuid.uuid4())
def fake_get_all(compute_self, context, search_opts=None,
@@ -997,8 +995,7 @@ class ServersControllerTest(test.TestCase):
self.stubs.Set(compute_api.API, 'get_all', fake_get_all)
- req = fakes.HTTPRequest.blank('/v2/fake/servers?ip=10\..*',
- use_admin_context=True)
+ req = fakes.HTTPRequest.blank('/v2/fake/servers?ip=10\..*')
servers = self.controller.index(req)['servers']
self.assertEqual(len(servers), 1)