"""
source_lvref = self.get_volume(source_lv_name)
if source_lvref is None:
- LOG.error(_("Unable to find LV: %s") % source_lv_name)
- return False
+ LOG.error(_("Trying to create snapshot by non-existent LV: %s")
+ % source_lv_name)
+ raise exception.VolumeDeviceNotFound(device=source_lv_name)
cmd = ['lvcreate', '--name', name,
'--snapshot', '%s/%s' % (self.vg_name, source_lv_name)]
if lv_type != 'thin':
import mox
-
+from cinder.brick import exception
from cinder.brick.local_dev import lvm as brick
from cinder.openstack.common import log as logging
from cinder.openstack.common import processutils
pass
elif 'lvcreate, -T, -V, ' in cmd_string:
pass
+ elif 'lvcreate, --name, ' in cmd_string:
+ pass
else:
raise AssertionError('unexpected command called: %s' % cmd_string)
return (data, "")
+ def test_create_lv_snapshot(self):
+ self.assertEqual(self.vg.create_lv_snapshot('snapshot-1', 'fake-1'),
+ None)
+
+ self._mox.StubOutWithMock(self.vg, 'get_volume')
+ self.vg.get_volume('fake-non-existent').AndReturn(None)
+ self._mox.ReplayAll()
+ try:
+ self.vg.create_lv_snapshot('snapshot-1', 'fake-non-existent')
+ except exception.VolumeDeviceNotFound as e:
+ self.assertEqual(e.kwargs['device'], 'fake-non-existent')
+ else:
+ self.fail("Exception not raised")
+
def test_vg_exists(self):
self.assertEqual(self.vg._vg_exists(), True)