Beispiel #1
0
my_host = socket.gethostname()

if "ernie" not in my_host:
    sys.exit()

now = int(time.time())

SLURM_FILE = "/tmp/slurm.xml"
xml_file = open(SLURM_FILE, "w", encoding="iso-8859-1")

##################
# Get controllers
##################

primary, backup = pyslurm.get_controllers()
xml_file.write('<?xml version="1.0" encoding="iso-8859-1" ?>\n')
xml_file.write("<slurm>\n")
xml_file.write(f"\t<lastUpdate>{now}</lastUpdate>\n")

####################
# XML output of Jobs
####################

a = pyslurm.job()
jobs = a.get()

xml_file.write("\t<jobs>\n")
for key, value in jobs.items():

    xml_file.write("\t\t<job>\n")
if __name__ == "__main__":

	print()
	print("PySLURM\t\t{0}".format(pyslurm.version()))
	print("SLURM API\t{0}-{1}-{2}\n".format(*pyslurm.slurm_api_version()))

	host = socket.gethostname()
	print("Checking host.....{0}".format(host))

	try:
		a = pyslurm.is_controller(host)
		print("\tHost is controller ({0})\n".format(a))

		print("Querying SLURM controllers")
		primary, backup = pyslurm.get_controllers()

		print("\tPrimary - {0}".format(primary))
		print("\tBackup  - {0}".format(backup))

		print("\nPinging SLURM controllers")

		if primary:
			print("\tPrimary .....", end=' ')
			controller_up()

		if backup:
			print("\tBackup .....", end=' ')
			controller_up(2)
	except ValueError as e:
		print("Error - {0}".format(e.args[0]))
Beispiel #3
0
def test_slurm_get_controllers():
    """Misc: Test slurm_get_controllers()."""
    controllers = pyslurm.get_controllers()
    assert_equals(controllers[0], gethostname())
Beispiel #4
0
if __name__ == "__main__":

    print()
    print(f"PySLURM\t\t{pyslurm.version()}")
    major, minor, micro = pyslurm.slurm_api_version()
    print(f"SLURM API\t{major}-{minor}-{micro}\n")

    host = socket.gethostname()
    print(f"Checking host.....{host}")

    try:
        a = pyslurm.is_controller(host)
        print(f"\tHost is controller ({a})\n")

        print("Querying SLURM controllers")
        control_machs = pyslurm.get_controllers()

        X = 0
        for machine in control_machs:
            if X == 0:
                print(f"\tPrimary - {machine}")
                print("\t\tPing .....", end=" ")
                controller_up()
            else:
                print(f"\tBackup{X}  - {machine}")
                print("\t\tPing .....", end=" ")
                controller_up(X)
            X = X + 1

    except ValueError as value_error:
        print(f"Error - {value_error.args[0]}")
Beispiel #5
0
 def GetSlurmServer(self):
     return slurm.get_controllers()[0]