-
Notifications
You must be signed in to change notification settings - Fork 94
Dev: ui_node: Enable standby and maintenance on pacemaker remote node #1855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
liangxin1300
wants to merge
7
commits into
ClusterLabs:master
Choose a base branch
from
liangxin1300:20250703_standby_remote
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
28a3c52
Dev: xmlutil: Drop xmlutil.listnodes function
liangxin1300 136045c
Dev: ui_node: Enable standby/online pacemaker remote node
liangxin1300 ac1612e
Dev: ui_node: Enable maintenance pacemaker remote node
liangxin1300 fab40a6
Dev: behave: Add funtional test for previous commits
liangxin1300 966aae2
Dev: unittests: Adjust unit test for previous commit
liangxin1300 9cd20f0
Dev: cibquery: Remove filter condition for pacemaker remote node
liangxin1300 6667f6d
Dev: utils: Skip reachable checking for pacemaker remote node
liangxin1300 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -359,26 +359,14 @@ def mk_rsc_type(n): | |
return ''.join((s1, s2, ra_type)) | ||
|
||
|
||
def listnodes(include_remote_nodes=True): | ||
cib = cibdump2elem() | ||
if cib is None: | ||
return [] | ||
local_nodes = cib.xpath('/cib/configuration/nodes/node/@uname') | ||
if include_remote_nodes: | ||
remote_nodes = cib.xpath('/cib/status/node_state[@remote_node="true"]/@uname') | ||
else: | ||
remote_nodes = [] | ||
return list(set([n for n in local_nodes + remote_nodes if n])) | ||
|
||
|
||
def is_our_node(s): | ||
''' | ||
Check if s is in a list of our nodes (ignore case). | ||
This is not fast, perhaps should be cached. | ||
|
||
Includes remote nodes as well | ||
''' | ||
for n in listnodes(): | ||
for n in CrmMonXmlParser.get_node_list(): | ||
if n.lower() == s.lower(): | ||
return True | ||
return False | ||
|
@@ -1531,20 +1519,61 @@ def is_node_online(self, node): | |
xpath = f'//node[@name="{node}" and @online="true"]' | ||
return bool(self.xml_elem.xpath(xpath)) | ||
|
||
def get_node_list(self, online=True, standby=False, exclude_remote=True) -> list[str]: | ||
def is_node_standby(self, node): | ||
""" | ||
Check if a node is in standby mode | ||
""" | ||
xpath = f'//node[@name="{node}" and @standby="true"]' | ||
return bool(self.xml_elem.xpath(xpath)) | ||
|
||
def is_node_maintenance(self, node): | ||
""" | ||
Check if a node is in maintenance mode | ||
""" | ||
xpath = f'//node[@name="{node}" and @maintenance="true"]' | ||
return bool(self.xml_elem.xpath(xpath)) | ||
|
||
def is_node_remote(self, node): | ||
""" | ||
Check if a node is remote | ||
""" | ||
xpath = f'//node[@name="{node}" and @type="remote"]' | ||
return bool(self.xml_elem.xpath(xpath)) | ||
|
||
@classmethod | ||
def get_node_list( | ||
cls, | ||
online: bool = None, | ||
standby: bool = None, | ||
maintenance: bool = None, | ||
only_member: bool = False, | ||
only_remote: bool = False, | ||
peer: str = None | ||
) -> list[str]: | ||
""" | ||
Get a list of nodes based on the given attribute | ||
Return all nodes if no attributes are given | ||
""" | ||
instance = cls(peer) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you change this to a classmethod and create new instance in the method? This does not make sense. |
||
xpath_str = '//nodes/node' | ||
conditions = [] | ||
online_value = "true" if online else "false" | ||
conditions.append(f'@online="{online_value}"') | ||
standby_value = "true" if standby else "false" | ||
conditions.append(f'@standby="{standby_value}"') | ||
if exclude_remote: | ||
filters = { | ||
"online": online, | ||
"standby": standby, | ||
"maintenance": maintenance | ||
} | ||
conditions = [ | ||
f'@{key}="{str(value).lower()}"' | ||
for key, value in filters.items() if value is not None | ||
] | ||
|
||
if only_member: | ||
conditions.append('@type="member"') | ||
xpath_str += '[' + ' and '.join(conditions) + ']' | ||
return [elem.get('name') for elem in self.xml_elem.xpath(xpath_str)] | ||
elif only_remote: | ||
conditions.append('@type="remote"') | ||
|
||
if conditions: | ||
xpath_str += '[' + ' and '.join(conditions) + ']' | ||
return [elem.get('name') for elem in instance.xml_elem.xpath(xpath_str)] | ||
|
||
def is_resource_configured(self, ra_type): | ||
""" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not test
all_nodes
at the very beginning in this function? Ifall_node
is true, you don't need to do the other complex logic.