File tree Expand file tree Collapse file tree 1 file changed +19
-16
lines changed Expand file tree Collapse file tree 1 file changed +19
-16
lines changed Original file line number Diff line number Diff line change @@ -275,22 +275,25 @@ def get_controllers():
275275 return control_machs
276276
277277
278- # def is_controller(Host=None):
279- # u"""Return slurm controller status for host.
280- #
281- # :param string Host: Name of host to check
282- #
283- # :returns: None, primary or backup
284- # :rtype: `string`
285- # """
286- # primary, backup = get_controllers()
287- # if not Host:
288- # Host = gethostname()
289- #
290- # if primary == Host:
291- # return u'primary'
292- # if backup == Host:
293- # return u'backup'
278+ def is_controller (Host = None ):
279+ u """ Return slurm controller status for host.
280+
281+ :param string Host: Name of host to check
282+
283+ :returns: None, primary or backup
284+ :rtype: `string`
285+ """
286+ control_machs = get_controllers()
287+ if not Host:
288+ Host = gethostname()
289+
290+ index = control_machs.index(Host)
291+ if index == - 1 :
292+ return None
293+ if index == 0 :
294+ return u ' primary'
295+ if index > 0 :
296+ return u ' backup'
294297
295298
296299def slurm_api_version ():
You can’t perform that action at this time.
0 commit comments