15
15
from . import utils
16
16
from .sh import ShellUtils
17
17
from .utils import stdout2list , is_program , to_ascii
18
- from .utils import os_types_list
19
18
from .utils import crm_msec , crm_time_cmp
20
19
from . import log
21
20
@@ -36,23 +35,14 @@ def crm_resource(opts):
36
35
return l
37
36
38
37
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
-
45
38
def ra_classes ():
46
39
'''
47
40
List of RA classes.
48
41
'''
49
42
if cache .is_cached ("ra_classes" ):
50
43
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" )]
56
46
l .sort ()
57
47
return cache .store ("ra_classes" , l )
58
48
@@ -62,18 +52,10 @@ def ra_providers(ra_type, ra_class="ocf"):
62
52
ident = "ra_providers-%s-%s" % (ra_class , ra_type )
63
53
if cache .is_cached (ident ):
64
54
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 )
77
59
l .sort ()
78
60
return cache .store (ident , l )
79
61
@@ -94,45 +76,6 @@ def ra_providers_all(ra_class="ocf"):
94
76
return []
95
77
96
78
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
-
136
79
def ra_types (ra_class = "ocf" , ra_provider = "" ):
137
80
'''
138
81
List of RA type for a class.
@@ -142,11 +85,7 @@ def find_types():
142
85
"""
143
86
Actually go out and ask for the types of a class.
144
87
"""
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 )
150
89
151
90
if not ra_class :
152
91
ra_class = "ocf"
@@ -168,21 +107,9 @@ def ra_meta(ra_class, ra_type, ra_provider):
168
107
"""
169
108
Return metadata for the given class/type/provider
170
109
"""
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 ))
186
113
187
114
188
115
@utils .memoize
@@ -464,14 +391,8 @@ def reqd_params_list():
464
391
def unreq_param (p ):
465
392
'''
466
393
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
471
394
'''
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_" ):
475
396
if p in ("action" , "port" ):
476
397
return True
477
398
return False
0 commit comments