_get_used_dvc.return_value = set()
self.assertEqual('/dev/loop2',
self.drv.find_appropriate_size_device(size))
+
+ def test_extend_volume_exists(self):
+ TEST_VOLUME = {'name': 'vol1', 'id': 123}
+ with mock.patch.object(self.drv, '_get_devices_sizes',
+ return_value={'/dev/loop1': 1024}) as \
+ mock_get_size:
+ with mock.patch.object(self.drv, 'local_path',
+ return_value='/dev/loop1') as lp_mocked:
+ self.assertRaises(cinder.exception.CinderException,
+ self.drv.extend_volume, TEST_VOLUME, 2)
+ lp_mocked.assert_called_once_with(TEST_VOLUME)
+ mock_get_size.assert_called_once_with(['/dev/loop1'])
else:
raise exception.CinderException(_("No big enough free disk"))
+ def extend_volume(self, volume, new_size):
+ dev_path = self.local_path(volume)
+ total_size = self._get_devices_sizes([dev_path])
+ # Convert from Megabytes to Gigabytes
+ size = total_size[dev_path] / units.Ki
+ if size < new_size:
+ msg = _("Insufficient free space available to extend volume.")
+ LOG.error(msg, resource=volume)
+ raise exception.CinderException(msg)
+
# ####### Interface methods for DataPath (Target Driver) ########
def ensure_export(self, context, volume):