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") pvolumes.append(FooPVolume) monkeypatch.setattr(api, 'PVolumes', lambda: pvolumes) assert api.get_pv(pv_uuid='1111') == FooPVolume
def test_single_pv_is_matched(self, pvolumes, monkeypatch): FooPVolume = api.PVolume(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_filter_by_tags_matches(self, pvolumes, monkeypatch): pv_tags = "ceph.type=journal,ceph.osd_id=1" FooPVolume = api.PVolume(pv_name='/dev/vg/foo', pv_uuid='1111', pv_tags=pv_tags) pvolumes.append(FooPVolume) pvolumes.filter(pv_tags={'ceph.type': 'journal', 'ceph.osd_id': '1'}) assert pvolumes == [FooPVolume]
def test_filter_by_tag_does_not_match_one(self, pvolumes, monkeypatch): 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) pvolumes.append(FooPVolume) pvolumes.filter(pv_tags={'ceph.type': 'journal', 'ceph.osd_id': '2'}) assert pvolumes == []