Skip to content

Commit 1442a04

Browse files
authored
Drop deprecated codes (#1723)
- Dev: Drop node type normal and ping According to the nodes-4.0.rng schema, only supports node type "member" and "remote" - Dev: Remove codes that include rhcs term - Dev: ra: Drop legacy codes to fetch ra informations
2 parents c807da2 + 5128a33 commit 1442a04

File tree

9 files changed

+23
-111
lines changed

9 files changed

+23
-111
lines changed

crmsh/constants.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@
164164
date_spec_names = '''hours monthdays weekdays yearsdays months \
165165
weeks years weekyears'''.split()
166166
in_range_attrs = ('start', 'end')
167-
node_default_type = "normal"
167+
node_default_type = "member"
168168
node_attributes_keyw = ("attributes", "utilization")
169169
shadow_envvar = "CIB_shadow"
170170
attr_defaults = {
171-
"node": {"type": "normal"},
171+
"node": {"type": "member"},
172172
"resource_set": {"sequential": "true", "require-all": "true"},
173173
"rule": {"boolean-op": "and"},
174174
}

crmsh/parse.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
_ACL_RIGHT_RE = re.compile(r'(%s)$' % ('|'.join(constants.acl_rule_names)), re.IGNORECASE)
4242
_ROLE_REF_RE = re.compile(r'role:(.+)$', re.IGNORECASE)
4343
_PERM_RE = re.compile(r"([^:]+)(?::(.+))?$", re.I)
44-
_UNAME_RE = re.compile(r'([^:]+)(:(normal|member|ping|remote))?$', re.IGNORECASE)
44+
_UNAME_RE = re.compile(r'([^:]+)(:(member|remote))?$', re.IGNORECASE)
4545
_TEMPLATE_RE = re.compile(r'@(.+)$')
4646
_RA_TYPE_RE = re.compile(r'[a-z0-9_:-]+$', re.IGNORECASE)
4747
_TAG_RE = re.compile(r"([a-zA-Z_][^\s:]*):?$")
@@ -865,7 +865,7 @@ def parse_node(self, cmd):
865865
[attributes <param>=<value> [<param>=<value>...]]
866866
[utilization <param>=<value> [<param>=<value>...]]
867867
868-
type :: normal | member | ping | remote
868+
type :: member | remote
869869
"""
870870
self.begin(cmd, min_args=1)
871871
self.match('node')

crmsh/ra.py

+11-90
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from . import utils
1616
from .sh import ShellUtils
1717
from .utils import stdout2list, is_program, to_ascii
18-
from .utils import os_types_list
1918
from .utils import crm_msec, crm_time_cmp
2019
from . import log
2120

@@ -36,23 +35,14 @@ def crm_resource(opts):
3635
return l
3736

3837

39-
@utils.memoize
40-
def can_use_crm_resource():
41-
_rc, s = ShellUtils().get_stdout("crm_resource --list-ocf-providers", stderr_on=False)
42-
return s != ""
43-
44-
4538
def ra_classes():
4639
'''
4740
List of RA classes.
4841
'''
4942
if cache.is_cached("ra_classes"):
5043
return cache.retrieve("ra_classes")
51-
if can_use_crm_resource():
52-
l = crm_resource("--list-standards")
53-
l = [x for x in l if x not in ("lsb", "service")]
54-
else:
55-
l = ["ocf", "stonith", "systemd"]
44+
l = crm_resource("--list-standards")
45+
l = [x for x in l if x not in ("lsb", "service")]
5646
l.sort()
5747
return cache.store("ra_classes", l)
5848

@@ -62,18 +52,10 @@ def ra_providers(ra_type, ra_class="ocf"):
6252
ident = "ra_providers-%s-%s" % (ra_class, ra_type)
6353
if cache.is_cached(ident):
6454
return cache.retrieve(ident)
65-
if can_use_crm_resource():
66-
if ra_class != "ocf":
67-
logger.error("no providers for class %s", ra_class)
68-
return []
69-
l = crm_resource("--list-ocf-alternatives %s" % ra_type)
70-
else:
71-
l = []
72-
if ra_class == "ocf":
73-
for s in glob.glob("%s/resource.d/*/%s" % (os.environ["OCF_ROOT"], ra_type)):
74-
a = s.split("/")
75-
if len(a) == 7:
76-
l.append(a[5])
55+
if ra_class != "ocf":
56+
logger.error("no providers for class %s", ra_class)
57+
return []
58+
l = crm_resource("--list-ocf-alternatives %s" % ra_type)
7759
l.sort()
7860
return cache.store(ident, l)
7961

@@ -94,45 +76,6 @@ def ra_providers_all(ra_class="ocf"):
9476
return []
9577

9678

97-
def os_types(ra_class):
98-
'List of types for a class.'
99-
def stonith_types():
100-
rc, l = stdout2list("stonith -L")
101-
if rc != 0:
102-
# stonith(8) may not be installed
103-
logger.debug("stonith exited with code %d", rc)
104-
l = []
105-
for ra in os_types_list("/usr/sbin/fence_*"):
106-
if ra not in ("fence_ack_manual", "fence_pcmk", "fence_legacy"):
107-
l.append(ra)
108-
return l
109-
110-
def systemd_types():
111-
l = []
112-
rc, lines = stdout2list("systemctl list-unit-files --full")
113-
if rc != 0:
114-
return l
115-
t = re.compile(r'^(.+)\.service')
116-
for line in lines:
117-
m = t.search(line)
118-
if m:
119-
l.append(m.group(1))
120-
return l
121-
122-
l = []
123-
if ra_class == "ocf":
124-
l = os_types_list("%s/resource.d/*/*" % (os.environ["OCF_ROOT"]))
125-
elif ra_class == "lsb":
126-
l = os_types_list("/etc/init.d/*")
127-
elif ra_class == "stonith":
128-
l = stonith_types()
129-
elif ra_class == "systemd":
130-
l = systemd_types()
131-
l = list(set(l))
132-
l.sort()
133-
return l
134-
135-
13679
def ra_types(ra_class="ocf", ra_provider=""):
13780
'''
13881
List of RA type for a class.
@@ -142,11 +85,7 @@ def find_types():
14285
"""
14386
Actually go out and ask for the types of a class.
14487
"""
145-
if can_use_crm_resource():
146-
l = crm_resource("--list-agents %s" % ra_class)
147-
else:
148-
l = os_types(ra_class)
149-
return l
88+
return crm_resource("--list-agents %s" % ra_class)
15089

15190
if not ra_class:
15291
ra_class = "ocf"
@@ -168,21 +107,9 @@ def ra_meta(ra_class, ra_type, ra_provider):
168107
"""
169108
Return metadata for the given class/type/provider
170109
"""
171-
if can_use_crm_resource():
172-
if ra_provider:
173-
return crm_resource("--show-metadata %s:%s:%s" % (ra_class, ra_provider, ra_type))
174-
return crm_resource("--show-metadata %s:%s" % (ra_class, ra_type))
175-
else:
176-
l = []
177-
if ra_class == "ocf":
178-
_rc, l = stdout2list("%s/resource.d/%s/%s meta-data" %
179-
(os.environ["OCF_ROOT"], ra_provider, ra_type))
180-
elif ra_class == "stonith":
181-
if ra_type.startswith("fence_") and os.path.exists("/usr/sbin/%s" % ra_type):
182-
_rc, l = stdout2list("/usr/sbin/%s -o metadata" % ra_type)
183-
else:
184-
_rc, l = stdout2list("stonith -m -t %s" % ra_type)
185-
return l
110+
if ra_provider:
111+
return crm_resource("--show-metadata %s:%s:%s" % (ra_class, ra_provider, ra_type))
112+
return crm_resource("--show-metadata %s:%s" % (ra_class, ra_type))
186113

187114

188115
@utils.memoize
@@ -464,14 +391,8 @@ def reqd_params_list():
464391
def unreq_param(p):
465392
'''
466393
Allow for some exceptions.
467-
468-
- the rhcs stonith agents sometimes require "action" (in
469-
the meta-data) and "port", but they're automatically
470-
supplied by stonithd
471394
'''
472-
if self.ra_class == "stonith" and \
473-
(self.ra_type.startswith("rhcs/") or
474-
self.ra_type.startswith("fence_")):
395+
if self.ra_class == "stonith" and self.ra_type.startswith("fence_"):
475396
if p in ("action", "port"):
476397
return True
477398
return False

crmsh/rsctest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ def test_resource(self, node):
363363
"""
364364
Run test for stonith resource
365365
"""
366-
for prefix in ['rhcs/', 'fence_']:
366+
for prefix in ['fence_', ]:
367367
if self.ra_type.startswith(prefix):
368-
self.err("Cannot test RHCS STONITH resources!")
368+
self.err("Cannot test STONITH resources!")
369369
return False
370370
return RADriver.test_resource(self, node)
371371

crmsh/ui_configure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ def do_rsctest(self, context, *args):
12581258
rsc_l += el.node.findall("primitive")
12591259
else:
12601260
rsc_l.append(el.node)
1261-
elif xmlutil.is_normal_node(el.node):
1261+
elif xmlutil.is_member_node(el.node):
12621262
current = "n"
12631263
node_l.append(el.node.get("uname"))
12641264
else:

crmsh/utils.py

-9
Original file line numberDiff line numberDiff line change
@@ -440,15 +440,6 @@ def append(self, key):
440440
super(olist, self).append(key.lower())
441441

442442

443-
def os_types_list(path):
444-
l = []
445-
for f in glob.glob(path):
446-
if os.access(f, os.X_OK) and os.path.isfile(f):
447-
a = f.split("/")
448-
l.append(a[-1])
449-
return l
450-
451-
452443
def listtemplates():
453444
l = []
454445
templates_dir = os.path.join(config.path.sharedir, 'templates')

crmsh/xmlutil.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ def resources_xml():
324324
return cibdump2elem("resources")
325325

326326

327-
def is_normal_node(n):
328-
return n.tag == "node" and (n.get("type") in (None, "normal", "member", ""))
327+
def is_member_node(n):
328+
return n.tag == "node" and (n.get("type") in (None, "member", ""))
329329

330330

331331
def unique_ra(typ, klass, provider):

doc/crm.8.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3427,7 +3427,7 @@ node [$id=<id>] <uname>[:<type>]
34273427
[utilization [$id=<id>] [<score>:] [rule...]
34283428
<param>=<value> [<param>=<value>...]] | $id-ref=<ref>
34293429
3430-
type :: normal | member | ping | remote
3430+
type :: member | remote
34313431
...............
34323432
Example:
34333433
...............

test/unittests/test_parse.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ def test_node(self, mock_error):
132132
self.assertEqual(out.get('id'), 'testid')
133133
self.assertEqual(out.get('uname'), 'node-1')
134134

135-
out = self._parse('node $id=testid node-1:ping')
135+
out = self._parse('node $id=testid node-1:remote')
136136
self.assertEqual(out.get('id'), 'testid')
137137
self.assertEqual(out.get('uname'), 'node-1')
138-
self.assertEqual(out.get('type'), 'ping')
138+
self.assertEqual(out.get('type'), 'remote')
139139

140140
out = self._parse('node node-1:unknown')
141141
self.assertFalse(out)

0 commit comments

Comments
 (0)