Merge "Stop caching compute nodes in the request"

This commit is contained in:
Jenkins 2017-06-15 19:10:15 +00:00 committed by Gerrit Code Review
commit 4a0fb6ae79
3 changed files with 2 additions and 37 deletions

View File

@ -116,7 +116,7 @@ class HypervisorsController(wsgi.Controller):
except exception.MarkerNotFound:
msg = _('marker [%s] not found') % marker
raise webob.exc.HTTPBadRequest(explanation=msg)
req.cache_db_compute_nodes(compute_nodes)
hypervisors_list = []
for hyp in compute_nodes:
try:
@ -163,7 +163,7 @@ class HypervisorsController(wsgi.Controller):
except exception.MarkerNotFound:
msg = _('marker [%s] not found') % marker
raise webob.exc.HTTPBadRequest(explanation=msg)
req.cache_db_compute_nodes(compute_nodes)
hypervisors_list = []
for hyp in compute_nodes:
try:
@ -194,7 +194,6 @@ class HypervisorsController(wsgi.Controller):
context.can(hv_policies.BASE_POLICY_NAME)
try:
hyp = self.host_api.compute_node_get(context, id)
req.cache_db_compute_node(hyp)
service = self.host_api.service_get_by_compute_host(
context, hyp.host)
except (ValueError, exception.ComputeHostNotFound,
@ -210,7 +209,6 @@ class HypervisorsController(wsgi.Controller):
context.can(hv_policies.BASE_POLICY_NAME)
try:
hyp = self.host_api.compute_node_get(context, id)
req.cache_db_compute_node(hyp)
except (ValueError, exception.ComputeHostNotFound):
msg = _("Hypervisor with ID '%s' could not be found.") % id
raise webob.exc.HTTPNotFound(explanation=msg)

View File

@ -147,18 +147,6 @@ class Request(wsgi.Request):
def get_db_flavor(self, flavorid):
return self.get_db_item('flavors', flavorid)
def cache_db_compute_nodes(self, compute_nodes):
self.cache_db_items('compute_nodes', compute_nodes, 'id')
def cache_db_compute_node(self, compute_node):
self.cache_db_items('compute_nodes', [compute_node], 'id')
def get_db_compute_nodes(self):
return self.get_db_items('compute_nodes')
def get_db_compute_node(self, id):
return self.get_db_item('compute_nodes', id)
def best_match_content_type(self):
"""Determine the requested response content-type."""
if 'nova.best_content_type' not in self.environ:

View File

@ -98,27 +98,6 @@ class RequestTest(MicroversionedTest):
'uuid1': instances[1],
'uuid2': instances[2]})
def test_cache_and_retrieve_compute_nodes(self):
request = wsgi.Request.blank('/foo')
compute_nodes = []
for x in range(3):
compute_nodes.append({'id': 'id%s' % x})
# Store 2
request.cache_db_compute_nodes(compute_nodes[:2])
# Store 1
request.cache_db_compute_node(compute_nodes[2])
self.assertEqual(request.get_db_compute_node('id0'),
compute_nodes[0])
self.assertEqual(request.get_db_compute_node('id1'),
compute_nodes[1])
self.assertEqual(request.get_db_compute_node('id2'),
compute_nodes[2])
self.assertIsNone(request.get_db_compute_node('id3'))
self.assertEqual(request.get_db_compute_nodes(),
{'id0': compute_nodes[0],
'id1': compute_nodes[1],
'id2': compute_nodes[2]})
def test_from_request(self):
request = wsgi.Request.blank('/')
accepted = 'bogus;q=1.1, en-gb;q=0.7,en-us,en;q=.5,*;q=.7'