Fix mis-named context object

Multiattach will fail with an AttributeError because the authorize
is called on the wrong object. This corrects that.

Change-Id: I439f2afe34afc9399a5592e8cb75fb6a287d02ab
Closes-Bug: 1745209
This commit is contained in:
Steve Noyes 2018-01-24 15:13:30 -05:00
parent 6bbab2ff57
commit 6039ab6add
2 changed files with 16 additions and 1 deletions

View File

@ -1737,6 +1737,21 @@ class VolumeTestCase(base.BaseVolumeTestCase):
volume)
db.volume_destroy(self.context, volume.id)
def test_attachment_reserve_with_bootable_volume(self):
# test the private _attachment_reserve method with a bootable,
# in-use, multiattach volume.
instance_uuid = fake.UUID1
volume = tests_utils.create_volume(self.context, status='in-use')
tests_utils.attach_volume(self.context, volume.id, instance_uuid,
'attached_host', 'mountpoint', mode='rw')
volume.multiattach = True
volume.bootable = True
attachment = self.volume_api._attachment_reserve(
self.context, volume, instance_uuid)
self.assertEqual(attachment.attach_status, 'reserved')
def test_unreserve_volume_success_in_use(self):
UUID = six.text_type(uuid.uuid4())
volume = tests_utils.create_volume(self.context, status='attaching')

View File

@ -2060,7 +2060,7 @@ class API(base.Base):
if (vref.get('multiattach', False) and
vref.status == 'in-use' and
vref.bootable):
context.authorize(
ctxt.authorize(
attachment_policy.MULTIATTACH_BOOTABLE_VOLUME_POLICY)
# FIXME(JDG): We want to be able to do things here like reserve a