VG_CMD_OPTIONS = ['--noheadings', '--readonly', '--units=b', '--nosuffix', '--separator=";"']
-def get_api_vgs():
- """
- Return the list of group volumes available in the system using flags to
- include common metadata associated with them
-
- Command and sample delimited output should look like::
-
- $ vgs --noheadings --units=b --readonly --separator=';' \
- -o vg_name,pv_count,lv_count,vg_attr,vg_free_count,vg_extent_size
- ubuntubox-vg;1;2;wz--n-;12;
-
- To normalize sizing, the units are forced in 'g' which is equivalent to
- gigabytes, which uses multiples of 1024 (as opposed to 1000)
- """
- stdout, stderr, returncode = process.call(
- ['vgs'] + VG_CMD_OPTIONS + ['-o', VG_FIELDS],
- verbose_on_failure=False
- )
- return _output_parser(stdout, VG_FIELDS)
-
-
class VolumeGroup(object):
"""
Represents an LVM group, with some top-level attributes like ``vg_name``
assert result['ceph.fsid'] == '0000'
-class TestGetAPIVgs(object):
-
- def test_report_is_emtpy(self, monkeypatch):
- monkeypatch.setattr(api.process, 'call', lambda x,**kw: ('\n\n', '', 0))
- assert api.get_api_vgs() == []
-
- def test_report_has_stuff(self, monkeypatch):
- report = [' VolGroup00']
- monkeypatch.setattr(api.process, 'call', lambda x, **kw: (report, '', 0))
- assert api.get_api_vgs() == [{'vg_name': 'VolGroup00'}]
-
- def test_report_has_stuff_with_empty_attrs(self, monkeypatch):
- report = [' VolGroup00 ;;;;;;4194304']
- monkeypatch.setattr(api.process, 'call', lambda x, **kw: (report, '', 0))
- result = api.get_api_vgs()[0]
- assert len(result.keys()) == 7
- assert result['vg_name'] == 'VolGroup00'
- assert result['vg_extent_size'] == '4194304'
-
- def test_report_has_multiple_items(self, monkeypatch):
- report = [' VolGroup00;;;;;;;', ' ceph_vg;;;;;;;']
- monkeypatch.setattr(api.process, 'call', lambda x, **kw: (report, '', 0))
- result = api.get_api_vgs()
- assert result[0]['vg_name'] == 'VolGroup00'
- assert result[1]['vg_name'] == 'ceph_vg'
-
-
class TestGetAPILvs(object):
def test_report_is_emtpy(self, monkeypatch):