Skip to content

Commit

Permalink
Refactor: cibquery: has_primitive_filesystem_ocfs2 to has_primitive_f…
Browse files Browse the repository at this point in the history
…ilesystem_with_fstype
  • Loading branch information
nicholasyang2022 committed Jan 13, 2025
1 parent 6a637ed commit d9c0449
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crmsh/cibquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def get_configured_resource_agents(cib: lxml.etree.Element) -> typing.Set[Resour
)


def has_primitive_filesystem_ocfs2(cib: lxml.etree.Element) -> bool:
def has_primitive_filesystem_with_fstype(cib: lxml.etree.Element, fstype: str) -> bool:
return bool(cib.xpath(
'/cib/configuration/resources//primitive[@class="ocf" and @provider="heartbeat" and @type="Filesystem"]'
'/instance_attributes/nvpair[@name="fstype" and @value="ocfs2"]'
f'/instance_attributes/nvpair[@name="fstype" and @value="{fstype}"]'
))
2 changes: 1 addition & 1 deletion crmsh/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def _check_removed_resource_agents(


def _check_ocfs2(handler: CheckResultHandler, cib: lxml.etree.Element):
if cibquery.has_primitive_filesystem_ocfs2(cib):
if cibquery.has_primitive_filesystem_with_fstype(cib, 'ocfs2'):
handler.handle_problem(False, 'OCFS2 is not supported in SLES 16.', [

Check warning on line 374 in crmsh/migration.py

View check run for this annotation

Codecov / codecov/patch

crmsh/migration.py#L374

Added line #L374 was not covered by tests
'* Before migrating to SLES 16, replace it with GFS2.',
])
5 changes: 3 additions & 2 deletions test/unittests/test_cibquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,6 @@ def test_get_resource_agents(self):
cibquery.get_configured_resource_agents(self.cib),
)

def test_has_primitive_filesystem_ocfs2(self):
self.assertTrue(cibquery.has_primitive_filesystem_ocfs2(self.cib))
def test_has_primitive_filesystem_with_fstype(self):
self.assertTrue(cibquery.has_primitive_filesystem_with_fstype(self.cib, 'ocfs2'))
self.assertFalse(cibquery.has_primitive_filesystem_with_fstype(self.cib, 'foo'))

0 comments on commit d9c0449

Please sign in to comment.