Skip to content

Commit fcdc0d0

Browse files
committed
refactor: modified get_controllers
1 parent f320a39 commit fcdc0d0

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pyslurm/pyslurm.pyx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,33 +247,34 @@ ctypedef struct config_key_pair_t:
247247
def get_controllers():
248248
u"""Get information about slurm controllers.
249249
250-
:return: Name of primary controller, Name of backup controller
250+
:return: Name of primary controller, Name of backup controllers
251251
:rtype: `tuple`
252252
"""
253253
cdef:
254254
slurm.slurm_conf_t *slurm_ctl_conf_ptr = NULL
255255
slurm.time_t Time = <slurm.time_t>NULL
256256
int apiError = 0
257257
int errCode = slurm.slurm_load_ctl_conf(Time, &slurm_ctl_conf_ptr)
258+
uint32_t length = 0
258259

259260
if errCode != 0:
260261
apiError = slurm.slurm_get_errno()
261262
raise ValueError(slurm.stringOrNone(slurm.slurm_strerror(apiError), ''), apiError)
262263

263-
primary = backup = None
264+
control_machs = []
264265
if slurm_ctl_conf_ptr is not NULL:
265266

266267
if slurm_ctl_conf_ptr.control_machine is not NULL:
267-
primary = slurm.stringOrNone(slurm_ctl_conf_ptr.control_machine, '')
268-
if slurm_ctl_conf_ptr.backup_controller is not NULL:
269-
backup = slurm.stringOrNone(slurm_ctl_conf_ptr.backup_controller, '')
268+
length = slurm_ctl_conf_ptr.control_cnt
269+
for index in range(length):
270+
primary = slurm.stringOrNone(slurm_ctl_conf_ptr.control_machine[index], '')
271+
control_machs.append(primary)
270272

271273
slurm.slurm_free_ctl_conf(slurm_ctl_conf_ptr)
272274

273-
return primary, backup
275+
return control_machs
274276

275277

276-
# FIXME
277278
#def is_controller(Host=None):
278279
# u"""Return slurm controller status for host.
279280
#

0 commit comments

Comments
 (0)