summaryrefslogtreecommitdiff
path: root/nova/tests/unit/compute/test_host_api.py
diff options
context:
space:
mode:
authorDan Smith <dansmith@redhat.com>2017-04-20 11:36:07 -0700
committerDan Smith <dansmith@redhat.com>2017-05-23 08:12:42 -0700
commitbb7c6ebb5648150430363c12ebc25a1c405ca79f (patch)
tree6f98accf022217163c216587c097f2d0ec6226cc /nova/tests/unit/compute/test_host_api.py
parentffd6a42c002dff66f45dbb156b1be20c4bd492a2 (diff)
downloadnova-bb7c6ebb5648150430363c12ebc25a1c405ca79f.tar.gz
Move to proper target_cell calling convention
When target_cell was originally written, the intent was to yield the context that should be used. It currently mutates the input context, which means you don't have to actually use the yielded one, because we have a lot of stuff that would break otherwise. This fixes all the current uses of it to be proper, and adjusts tests accordingly. This is separate from changing target_cell's behavior to not mutate the input context specifically to isolate the mechanical changes from ones that actually need different behavior. In addition to code that was already using target_cell() but not depending on the yielded context, the _create_block_device_mapping() method in conductor/manager.py was still depending on the shared context switching to target the BDM objects on create. Since these were prepared with the context prior to having determined where the instanace was going to end up, we need to explicitly target the object context on create (like the rest of the boot workflow does for other objects in schedule_and_build_instances()). Related to blueprint cells-aware-api Change-Id: I35206e665f2c81531a2269dd66f8c5c0df834245
Diffstat (limited to 'nova/tests/unit/compute/test_host_api.py')
-rw-r--r--nova/tests/unit/compute/test_host_api.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/nova/tests/unit/compute/test_host_api.py b/nova/tests/unit/compute/test_host_api.py
index 18e91eb829..376273c5f5 100644
--- a/nova/tests/unit/compute/test_host_api.py
+++ b/nova/tests/unit/compute/test_host_api.py
@@ -176,8 +176,8 @@ class ComputeHostAPITestCase(test.TestCase):
def test_service_get_all_cells(self):
cells = objects.CellMappingList.get_all(self.ctxt)
for cell in cells:
- with context.target_cell(self.ctxt, cell):
- objects.Service(context=self.ctxt,
+ with context.target_cell(self.ctxt, cell) as cctxt:
+ objects.Service(context=cctxt,
binary='nova-compute',
host='host-%s' % cell.uuid).create()
services = self.host_api.service_get_all(self.ctxt, all_cells=True)