

def test_extend_qcow_success(self):
    imgfile = tempfile.NamedTemporaryFile()
    self.addCleanup(imgfile.close)
    imgsize = 10
    device = '/dev/sdh'
    image = imgmodel.LocalFileImage(imgfile, imgmodel.FORMAT_QCOW2)
    self.flags(resize_fs_using_block_device=True)
    mounter = FakeMount.instance_for_format(image, None, None)
    mounter.device = device
    self.mox.StubOutWithMock(api, 'can_resize_image')
    self.mox.StubOutWithMock(utils, 'execute')
    self.mox.StubOutWithMock(api, 'is_image_extendable')
    self.mox.StubOutWithMock(mounter, 'get_dev')
    self.mox.StubOutWithMock(mounter, 'unget_dev')
    self.mox.StubOutWithMock(api, 'resize2fs')
    self.mox.StubOutWithMock(mount.Mount, 'instance_for_format', use_mock_anything=True)
    api.can_resize_image(imgfile, imgsize).AndReturn(True)
    utils.execute('qemu-img', 'resize', device, imgsize)
    api.is_image_extendable(image).AndReturn(True)
    mount.Mount.instance_for_format(image, None, None).AndReturn(mounter)
    mounter.get_dev().AndReturn(True)
    api.resize2fs(mounter.device, run_as_root=True, check_exit_code=[0])
    mounter.unget_dev()
    self.mox.ReplayAll()
    api.extend(image, imgsize)

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/tests/unit/virt/disk/test_api.py APITestCase.test_extend_qcow_success/VarMisuse@181/288 `imgfile`->`device`