def setup_method(self):
self.vg = api.VolumeGroup(vg_name='ceph',
- vg_extent_size=1073741824,
- vg_free_count=1024)
+ vg_extent_size=1073741824,
+ vg_free_count=1024)
def test_parts_and_size_errors(self):
with pytest.raises(ValueError) as error:
@patch('ceph_volume.api.lvm.get_single_lv')
def test_uses_size(self, m_get_single_lv, m_call, m_run, monkeypatch):
m_get_single_lv.return_value = self.foo_volume
- api.create_lv('foo', 0, vg=self.foo_group, size=419430400, tags={'ceph.type': 'data'})
- expected = (['lvcreate', '--yes', '-l', '100', '-n', 'foo-0', 'foo_group'])
+ api.create_lv('foo', '1234-abcd', vg=self.foo_group, size=419430400, tags={'ceph.type': 'data'})
+ expected = (['lvcreate', '--yes', '-l', '100', '-n', 'foo-1234-abcd', 'foo_group'])
m_run.assert_called_with(expected, run_on_host=True)
@patch('ceph_volume.api.lvm.process.run')
vg_free_count="1000")
m_get_single_lv.return_value = foo_volume
# 423624704 should be just under 1% off of the available size 419430400
- api.create_lv('foo', 0, vg=foo_group, size=4232052736, tags={'ceph.type': 'data'})
- expected = ['lvcreate', '--yes', '-l', '1000', '-n', 'foo-0', 'foo_group']
+ api.create_lv('foo', '1234-abcd', vg=foo_group, size=4232052736, tags={'ceph.type': 'data'})
+ expected = ['lvcreate', '--yes', '-l', '1000', '-n', 'foo-1234-abcd', 'foo_group']
m_run.assert_called_with(expected, run_on_host=True)
@patch('ceph_volume.api.lvm.process.run')
def test_uses_size_too_large(self, m_get_single_lv, m_call, m_run, monkeypatch):
m_get_single_lv.return_value = self.foo_volume
with pytest.raises(RuntimeError):
- api.create_lv('foo', 0, vg=self.foo_group, size=5368709120, tags={'ceph.type': 'data'})
+ api.create_lv('foo', '1234-abcd', vg=self.foo_group, size=5368709120, tags={'ceph.type': 'data'})
@patch('ceph_volume.api.lvm.process.run')
@patch('ceph_volume.api.lvm.process.call')
@patch('ceph_volume.api.lvm.get_single_lv')
def test_uses_extents(self, m_get_single_lv, m_call, m_run, monkeypatch):
m_get_single_lv.return_value = self.foo_volume
- api.create_lv('foo', 0, vg=self.foo_group, extents='50', tags={'ceph.type': 'data'})
- expected = ['lvcreate', '--yes', '-l', '50', '-n', 'foo-0', 'foo_group']
+ api.create_lv('foo', '1234-abcd', vg=self.foo_group, extents='50', tags={'ceph.type': 'data'})
+ expected = ['lvcreate', '--yes', '-l', '50', '-n', 'foo-1234-abcd', 'foo_group']
m_run.assert_called_with(expected, run_on_host=True)
@pytest.mark.parametrize("test_input,expected",
@patch('ceph_volume.api.lvm.get_single_lv')
def test_uses_slots(self, m_get_single_lv, m_call, m_run, monkeypatch, test_input, expected):
m_get_single_lv.return_value = self.foo_volume
- api.create_lv('foo', 0, vg=self.foo_group, slots=test_input, tags={'ceph.type': 'data'})
- expected = ['lvcreate', '--yes', '-l', str(expected), '-n', 'foo-0', 'foo_group']
+ api.create_lv('foo', '1234-abcd', vg=self.foo_group, slots=test_input, tags={'ceph.type': 'data'})
+ expected = ['lvcreate', '--yes', '-l', str(expected), '-n', 'foo-1234-abcd', 'foo_group']
m_run.assert_called_with(expected, run_on_host=True)
@patch('ceph_volume.api.lvm.process.run')
@patch('ceph_volume.api.lvm.get_single_lv')
def test_uses_all(self, m_get_single_lv, m_call, m_run, monkeypatch):
m_get_single_lv.return_value = self.foo_volume
- api.create_lv('foo', 0, vg=self.foo_group, tags={'ceph.type': 'data'})
- expected = ['lvcreate', '--yes', '-l', '100%FREE', '-n', 'foo-0', 'foo_group']
+ api.create_lv('foo', '1234-abcd', vg=self.foo_group, tags={'ceph.type': 'data'})
+ expected = ['lvcreate', '--yes', '-l', '100%FREE', '-n', 'foo-1234-abcd', 'foo_group']
m_run.assert_called_with(expected, run_on_host=True)
@patch('ceph_volume.api.lvm.process.run')
@patch('ceph_volume.api.lvm.get_single_lv')
def test_calls_to_set_tags_default(self, m_get_single_lv, m_set_tags, m_call, m_run, monkeypatch):
m_get_single_lv.return_value = self.foo_volume
- api.create_lv('foo', 0, vg=self.foo_group)
+ api.create_lv('foo', '1234-abcd', vg=self.foo_group)
tags = {
"ceph.osd_id": "null",
"ceph.type": "null",
@patch('ceph_volume.api.lvm.get_single_lv')
def test_calls_to_set_tags_arg(self, m_get_single_lv, m_set_tags, m_call, m_run, monkeypatch):
m_get_single_lv.return_value = self.foo_volume
- api.create_lv('foo', 0, vg=self.foo_group, tags={'ceph.type': 'data'})
+ api.create_lv('foo', '1234-abcd', vg=self.foo_group, tags={'ceph.type': 'data'})
tags = {
"ceph.type": "data",
"ceph.data_device": "/path"
m_run, monkeypatch):
m_get_single_lv.return_value = self.foo_volume
m_get_device_vgs.return_value = []
- api.create_lv('foo', 0, device='dev/foo', size='5G', tags={'ceph.type': 'data'})
+ api.create_lv('foo', '1234-abcd', device='dev/foo', size='5G', tags={'ceph.type': 'data'})
m_create_vg.assert_called_with('dev/foo', name_prefix='ceph')
monkeypatch.setattr(lvm.listing.api, 'get_lvs', lambda **kwargs: lvs)
listing = lvm.listing.List([])
- result = listing.single_report(0)
+ result = listing.single_report('0')
assert result['0'][0]['name'] == 'lv1'
assert result['0'][0]['lv_tags'] == tags
assert result['0'][0]['lv_path'] == '/dev/vg/lv1'
monkeypatch.setattr(lvm.listing.api, 'get_lvs', lambda **kwargs: lvs)
listing = lvm.listing.List([])
- result = listing.single_report(0)
+ result = listing.single_report('0')
assert result['0'][0]['name'] == 'lv1'
assert result['0'][0]['lv_tags'] == tags
assert result['0'][0]['lv_path'] == '/dev/vg/lv1'
monkeypatch.setattr(lvm.listing.api, 'get_lvs', lambda **kwargs: lvs)
listing = lvm.listing.List([])
- result = listing.single_report(0)
+ result = listing.single_report('0')
assert result['0'][0]['name'] == 'lv1'
assert result['0'][0]['lv_tags'] == tags1
assert result['0'][0]['lv_path'] == '/dev/vg/lv1'
monkeypatch.setattr(lvm.listing.api, 'get_lvs', lambda **kwargs: lvs)
listing = lvm.listing.List([])
- result = listing.single_report(0)
+ result = listing.single_report('0')
assert result['0'][0]['name'] == 'lv1'
assert result['0'][0]['lv_tags'] == tags1
assert result['0'][0]['lv_path'] == '/dev/vg/lv1'
assert ('Cannot use device (/dev/foo). '
'A vg/lv path or an existing device is needed') == str(error.value)
- @patch('ceph_volume.api.lvm.is_ceph_device', Mock(return_value=True))
- @patch('ceph_volume.api.lvm.get_single_lv')
- def test_safe_prepare_is_ceph_device(self, m_get_single_lv, factory):
- args = factory(data='/dev/foo')
- self.lvm_bs.args = args
- m_get_single_lv.return_value = Volume(lv_name='lv_foo',
- lv_path='/fake-path',
- vg_name='vg_foo',
- lv_tags='',
- lv_uuid='fake-uuid')
- self.lvm_bs.prepare = MagicMock()
- with pytest.raises(RuntimeError) as error:
- self.lvm_bs.safe_prepare(args)
- assert str(error.value) == 'skipping /dev/foo, it is already prepared'
-
@patch('ceph_volume.api.lvm.is_ceph_device', Mock(return_value=False))
@patch('ceph_volume.api.lvm.get_single_lv')
def test_safe_prepare(self, m_get_single_lv, factory):
{},
1,
1)
- assert m_create_lv.mock_calls == [call('osd-block',
- 'd83fa1ca-bd68-4c75-bdc2-464da58e8abd',
+ assert m_create_lv.mock_calls == [call(name_prefix='osd-block',
+ uuid='d83fa1ca-bd68-4c75-bdc2-464da58e8abd',
+ vg=None,
device='/dev/foo',
+ slots=1,
+ extents=None,
+ size=1,
tags={'ceph.type': 'block',
'ceph.vdo': '0',
'ceph.block_device': '/fake-path',
- 'ceph.block_uuid': 'fake-uuid'},
- slots=1,
- size=1)]
+ 'ceph.block_uuid': 'fake-uuid'})]
assert result == ('/fake-path',
'fake-uuid',
{'ceph.type': 'block',