Skip to content

Commit 3245bfb

Browse files
[crmsh-4.6] Refactor: cibquery: replace has_primitive_filesystem_with_fstype with PrimitiveFilesystemQuery
1 parent 6da586b commit 3245bfb

File tree

3 files changed

+2
-13
lines changed

3 files changed

+2
-13
lines changed

crmsh/cibquery.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ def get_configured_resource_agents(cib: lxml.etree.Element) -> typing.Set[Resour
1818
)
1919

2020

21-
def has_primitive_filesystem_with_fstype(cib: lxml.etree.Element, fstype: str) -> bool:
22-
return bool(cib.xpath(
23-
'/cib/configuration/resources//primitive[@class="ocf" and @provider="heartbeat" and @type="Filesystem"]'
24-
f'/instance_attributes/nvpair[@name="fstype" and @value="{fstype}"]'
25-
))
26-
27-
2821
class PrimitiveFilesystemQuery:
2922
PRIMITIVE_XPATH = '/cib/configuration/resources//primitive[@class="ocf" and @provider="heartbeat" and @type="Filesystem"]'
3023

crmsh/migration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ def _check_removed_resource_agents(
428428

429429

430430
def _check_ocfs2(handler: CheckResultHandler, cib: lxml.etree.Element):
431-
if cibquery.has_primitive_filesystem_with_fstype(cib, 'ocfs2'):
431+
if cibquery.PrimitiveFilesystemQuery(cib).fstype('ocfs2').exists():
432432
handler.handle_problem(False, 'OCFS2 is not supported in SLES 16. Please use GFS2.', [
433433
])
434434

test/unittests/test_cibquery.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ def test_get_resource_agents(self):
105105
cibquery.get_configured_resource_agents(self.cib),
106106
)
107107

108-
def test_has_primitive_filesystem_with_fstype(self):
109-
self.assertTrue(cibquery.has_primitive_filesystem_with_fstype(self.cib, 'ocfs2'))
110-
self.assertFalse(cibquery.has_primitive_filesystem_with_fstype(self.cib, 'foo'))
111-
112108

113109
class TestPrimitiveFilesystemQuery(unittest.TestCase):
114110
def setUp(self) -> None:
@@ -141,4 +137,4 @@ def test_exists_directory_no_match(self):
141137

142138
def test_exists_fstype_and_directory_match(self):
143139
query = cibquery.PrimitiveFilesystemQuery(self.cib)
144-
self.assertTrue(query.fstype('ocfs2').directory('/srv/clusterfs').exists())
140+
self.assertTrue(query.fstype('ocfs2').directory('/srv/clusterfs').exists())

0 commit comments

Comments
 (0)