assert api.get_pv() is None
def test_single_pv_is_not_matched(self, pvolumes, monkeypatch):
- FooPVolume = api.PVolume(pv_name='/dev/sda', pv_uuid="0000", pv_tags={})
+ FooPVolume = api.PVolume(pv_name='/dev/sda', pv_uuid="0000", pv_tags={}, vg_name="vg")
pvolumes.append(FooPVolume)
monkeypatch.setattr(api, 'PVolumes', lambda: pvolumes)
assert api.get_pv(pv_uuid='foo') is None
def test_single_pv_is_matched(self, pvolumes, monkeypatch):
- FooPVolume = api.PVolume(pv_name='/dev/sda', pv_uuid="0000", pv_tags={})
+ FooPVolume = api.PVolume(vg_name="vg", pv_name='/dev/sda', pv_uuid="0000", pv_tags={})
pvolumes.append(FooPVolume)
monkeypatch.setattr(api, 'PVolumes', lambda: pvolumes)
assert api.get_pv(pv_uuid='0000') == FooPVolume
def test_single_pv_is_matched_by_uuid(self, pvolumes, monkeypatch):
FooPVolume = api.PVolume(
pv_name='/dev/vg/foo',
- pv_uuid='1111', pv_tags="ceph.type=data")
+ pv_uuid='1111', pv_tags="ceph.type=data", vg_name="vg")
pvolumes.append(FooPVolume)
monkeypatch.setattr(api, 'PVolumes', lambda: pvolumes)
assert api.get_pv(pv_uuid='1111') == FooPVolume
+ def test_vg_name_is_set(self, pvolumes, monkeypatch):
+ FooPVolume = api.PVolume(
+ pv_name='/dev/vg/foo',
+ pv_uuid='1111', pv_tags="ceph.type=data", vg_name="vg")
+ pvolumes.append(FooPVolume)
+ monkeypatch.setattr(api, 'PVolumes', lambda: pvolumes)
+ pv = api.get_pv(pv_name="/dev/vg/foo")
+ assert pv.vg_name == "vg"
+
class TestPVolumes(object):
pv_tags = "ceph.type=journal,ceph.osd_id=1,ceph.fsid=000-aaa"
FooPVolume = api.PVolume(
pv_name='/dev/vg/foo',
- pv_uuid='1111', pv_tags=pv_tags)
+ pv_uuid='1111', pv_tags=pv_tags, vg_name='vg')
pvolumes.append(FooPVolume)
pvolumes.filter(pv_tags={'ceph.type': 'journal', 'ceph.osd_id': '2'})
assert pvolumes == []
pv_tags = "ceph.type=journal,ceph.osd_id=1"
FooPVolume = api.PVolume(
pv_name='/dev/vg/foo',
- pv_uuid='1111', pv_tags=pv_tags)
+ pv_uuid='1111', pv_tags=pv_tags, vg_name="vg")
pvolumes.append(FooPVolume)
pvolumes.filter(pv_tags={'ceph.type': 'journal', 'ceph.osd_id': '1'})
assert pvolumes == [FooPVolume]