Skip to content

Commit 8c82cb6

Browse files
authored
Dev: Remove unused code (#1863)
2 parents 5ebd6a2 + c2b2147 commit 8c82cb6

File tree

3 files changed

+16
-156
lines changed

3 files changed

+16
-156
lines changed

crmsh/log_patterns.py

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -25,122 +25,6 @@
2525

2626
__all__ = ('patterns',)
2727

28-
_patterns_old = {
29-
"resource": (
30-
( # detail 0
31-
"lrmd.*%% (?:start|stop|promote|demote|migrate)",
32-
"lrmd.*RA output: .%%:.*:stderr",
33-
"lrmd.*WARN: Managed %%:.*exited",
34-
"lrmd.*WARN: .* %% .*timed out$",
35-
"crmd.*LRM operation %%_(?:start|stop|promote|demote|migrate)_.*confirmed=true",
36-
"crmd.*LRM operation %%_.*Timed Out",
37-
"[(]%%[)]\\[",
38-
),
39-
( # detail 1
40-
"lrmd.*%% (?:probe|notify)",
41-
"lrmd.*Managed %%:.*exited",
42-
),
43-
),
44-
"node": (
45-
( # detail 0
46-
" %% .*Corosync.Cluster.Engine",
47-
" %% .*Executive.Service.RELEASE",
48-
" %% .*Requesting.shutdown",
49-
" %% .*Shutdown.complete",
50-
" %% .*Configuration.validated..Starting.heartbeat",
51-
"pengine.*Scheduling Node %% for STONITH",
52-
"crmd.* of %% failed",
53-
"stonith-ng.*host '%%'",
54-
"Exec.*on %% ",
55-
"Node %% will be fenced",
56-
"stonith-ng.*for %% timed",
57-
"stonith-ng.*can not fence %%:",
58-
"stonithd.*Succeeded.*node %%:",
59-
"(?:lost|memb): %% ",
60-
"crmd.*(?:NEW|LOST):.* %% ",
61-
"Node return implies stonith of %% ",
62-
),
63-
( # detail 1
64-
),
65-
),
66-
"quorum": (
67-
( # detail 0
68-
"crmd.*Updating.quorum.status",
69-
"crmd.*quorum.(?:lost|ac?quir)",
70-
),
71-
( # detail 1
72-
),
73-
),
74-
"events": (
75-
( # detail 0
76-
"CRIT:",
77-
"ERROR:",
78-
),
79-
( # detail 1
80-
"WARN:",
81-
),
82-
),
83-
}
84-
85-
_patterns_118 = {
86-
"resource": (
87-
( # detail 0
88-
"crmd.*Initiating.*%%_(?:start|stop|promote|demote|migrate)_",
89-
"lrmd.*operation_finished: %%_",
90-
"lrmd.*executing - rsc:%% action:(?:start|stop|promote|demote|migrate)",
91-
"lrmd.*finished - rsc:%% action:(?:start|stop|promote|demote|migrate)",
92-
93-
"crmd.*LRM operation %%_(?:start|stop|promote|demote|migrate)_.*confirmed=true",
94-
"crmd.*LRM operation %%_.*Timed Out",
95-
"[(]%%[)]\\[",
96-
),
97-
( # detail 1
98-
"crmd.*Initiating.*%%_(?:monitor_0|notify)",
99-
"lrmd.*executing - rsc:%% action:(?:monitor_0|notify)",
100-
"lrmd.*finished - rsc:%% action:(?:monitor_0|notify)",
101-
),
102-
),
103-
"node": (
104-
( # detail 0
105-
" %% .*Corosync.Cluster.Engine",
106-
" %% .*Executive.Service.RELEASE",
107-
" %% .*crm_shutdown:.Requesting.shutdown",
108-
" %% .*pcmk_shutdown:.Shutdown.complete",
109-
" %% .*Configuration.validated..Starting.heartbeat",
110-
"pengine.*Scheduling Node %% for STONITH",
111-
"pengine.*Node %% will be fenced",
112-
"crmd.*for %% failed",
113-
"stonith-ng.*host '%%'",
114-
"Exec.*on %% ",
115-
"Node %% will be fenced",
116-
"stonith-ng.*on %% for.*timed out",
117-
"stonith-ng.*can not fence %%:",
118-
"stonithd.*Succeeded.*node %%:",
119-
"(?:lost|memb): %% ",
120-
"crmd.*(?:NEW|LOST|new|lost):.* %% ",
121-
"Node return implies stonith of %% ",
122-
),
123-
( # detail 1
124-
),
125-
),
126-
"quorum": (
127-
( # detail 0
128-
"crmd.*Updating.(quorum).status",
129-
r"crmd.*quorum.(?:lost|ac?quir[^\s]*)",
130-
),
131-
( # detail 1
132-
),
133-
),
134-
"events": (
135-
( # detail 0
136-
"(CRIT|crit|ERROR|error|UNCLEAN|unclean):",
137-
),
138-
( # detail 1
139-
"(WARN|warning):",
140-
),
141-
),
142-
}
143-
14428
_patterns_200 = {
14529
"resource": (
14630
( # detail 0
@@ -280,8 +164,3 @@
280164
def patterns(cib_f=None):
281165
if utils.is_min_pcmk_ver(constants.PCMK_VERSION_DEFAULT, cib_f=cib_f):
282166
return _patterns_200
283-
is118 = utils.is_larger_than_pcmk_118(cib_f=cib_f)
284-
if is118:
285-
return _patterns_118
286-
else:
287-
return _patterns_old

crmsh/ui_node.py

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -257,19 +257,7 @@ class NodeMgmt(command.UI):
257257
node_delete = """cibadmin -D -o nodes -X '<node uname="%s"/>'"""
258258
node_delete_status = """cibadmin -D -o status -X '<node_state uname="%s"/>'"""
259259
node_cleanup_resources = "crm_resource --cleanup --node '%s'"
260-
node_clear_state = _oneline("""cibadmin %s
261-
-o status --xml-text
262-
'<node_state id="%s"
263-
uname="%s"
264-
ha="active"
265-
in_ccm="false"
266-
crmd="offline"
267-
join="member"
268-
expected="down"
269-
crm-debug-origin="manual_clear"
270-
shutdown="0"
271-
/>'""")
272-
node_clear_state_118 = "stonith_admin --confirm %s"
260+
node_clear_state = "stonith_admin --confirm %s"
273261
crm_node = "crm_node"
274262
node_fence = "crm_attribute -t status -N '%s' -n terminate -v true"
275263
dc = "crmadmin -D"
@@ -489,24 +477,21 @@ def do_clearstate(self, context, node=None):
489477
if not config.core.force and \
490478
not utils.ask("Do you really want to drop state for node %s?" % node):
491479
return False
492-
if utils.is_larger_than_pcmk_118():
493-
cib_elem = xmlutil.cibdump2elem()
494-
if cib_elem is None:
495-
return False
496-
crmd = cib_elem.xpath("//node_state[@uname=\"%s\"]/@crmd" % node)
497-
if not crmd:
498-
logger.error("Node '%s' not found in CIB", node)
499-
return False
500-
if crmd == ["online"] or (crmd[0].isdigit() and int(crmd[0]) != 0):
501-
return utils.ext_cmd(self.node_cleanup_resources % node) == 0
502-
in_ccm = cib_elem.xpath("//node_state[@uname=\"%s\"]/@in_ccm" % node)
503-
if in_ccm == ["true"] or (in_ccm[0].isdigit() and int(in_ccm[0]) != 0):
504-
logger.warning("Node is offline according to Pacemaker, but online according to corosync. First shut down node '%s'", node)
505-
return False
506-
return utils.ext_cmd(self.node_clear_state_118 % node) == 0
507-
else:
508-
return utils.ext_cmd(self.node_clear_state % ("-M -c", node, node)) == 0 and \
509-
utils.ext_cmd(self.node_clear_state % ("-R", node, node)) == 0
480+
481+
cib_elem = xmlutil.cibdump2elem()
482+
if cib_elem is None:
483+
return False
484+
crmd = cib_elem.xpath("//node_state[@uname=\"%s\"]/@crmd" % node)
485+
if not crmd:
486+
logger.error("Node '%s' not found in CIB", node)
487+
return False
488+
if crmd == ["online"] or (crmd[0].isdigit() and int(crmd[0]) != 0):
489+
return utils.ext_cmd(self.node_cleanup_resources % node) == 0
490+
in_ccm = cib_elem.xpath("//node_state[@uname=\"%s\"]/@in_ccm" % node)
491+
if in_ccm == ["true"] or (in_ccm[0].isdigit() and int(in_ccm[0]) != 0):
492+
logger.warning("Node is offline according to Pacemaker, but online according to corosync. First shut down node '%s'", node)
493+
return False
494+
return utils.ext_cmd(self.node_clear_state % node) == 0
510495

511496
@classmethod
512497
def call_delnode(cls, node):

crmsh/utils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,10 +1639,6 @@ def is_min_pcmk_ver(min_ver, cib_f=None):
16391639
return is_larger_than_min_version(constants.pcmk_version, min_ver)
16401640

16411641

1642-
def is_larger_than_pcmk_118(cib_f=None):
1643-
return is_min_pcmk_ver("1.1.8", cib_f=cib_f)
1644-
1645-
16461642
# quote function from python module shlex.py in python 3.3
16471643

16481644
_find_unsafe = re.compile(r'[^\w@%+=:,./-]').search

0 commit comments

Comments
 (0)