LV_FIELDS = 'lv_tags,lv_path,lv_name,vg_name,lv_uuid,lv_size'
LV_CMD_OPTIONS = ['--noheadings', '--readonly', '--separator=";"', '-a']
-def get_api_lvs():
- """
- Return the list of logical volumes available in the system using flags to include common
- metadata associated with them
-
- Command and delimited output should look like::
-
- $ lvs --noheadings --readonly --separator=';' -a -o lv_tags,lv_path,lv_name,vg_name
- ;/dev/ubuntubox-vg/root;root;ubuntubox-vg
- ;/dev/ubuntubox-vg/swap_1;swap_1;ubuntubox-vg
-
- """
- stdout, stderr, returncode = process.call(
- ['lvs'] + LV_CMD_OPTIONS + ['-o', LV_FIELDS],
- verbose_on_failure=False
- )
- return _output_parser(stdout, LV_FIELDS)
-
class Volume(object):
"""
assert result['ceph.fsid'] == '0000'
-class TestGetAPILvs(object):
-
- def test_report_is_emtpy(self, monkeypatch):
- monkeypatch.setattr(api.process, 'call', lambda x, **kw: ('', '', 0))
- assert api.get_api_lvs() == []
-
- def test_report_has_stuff(self, monkeypatch):
- report = [' ;/path;VolGroup00;root']
- monkeypatch.setattr(api.process, 'call', lambda x, **kw: (report, '', 0))
- result = api.get_api_lvs()
- assert result[0]['lv_name'] == 'VolGroup00'
-
- def test_report_has_multiple_items(self, monkeypatch):
- report = [' ;/path;VolName;root', ';/dev/path;ceph_lv;ceph_vg']
- monkeypatch.setattr(api.process, 'call', lambda x, **kw: (report, '', 0))
- result = api.get_api_lvs()
- assert result[0]['lv_name'] == 'VolName'
- assert result[1]['lv_name'] == 'ceph_lv'
-
-
class TestVolume(object):
def test_is_ceph_device(self):