Skip to content

Commit

Permalink
Move script part into if __name == "__main__"
Browse files Browse the repository at this point in the history
  • Loading branch information
milliams committed Oct 11, 2019
1 parent 8a1f309 commit a53da1c
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions roles/slurm/files/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,19 @@ def get_node_configs(limits, shapes, mgmt_info):
yield create_slurmconf_line(i, shape_info, shape, ad)


# TODO Make sure that any nodes which are no longer managed due to service limit reductions are terminated.
if __name__ == "__main__":
# TODO Make sure that any nodes which are no longer managed due to service limit reductions are terminated.

slurm_conf_filename = "/mnt/shared/etc/slurm/slurm.conf"
slurm_conf_filename = "/mnt/shared/etc/slurm/slurm.conf"

node_config = "\n".join(get_node_configs(get_limits(), get_shapes(), get_mgmt_info()))
node_config = "\n".join(get_node_configs(get_limits(), get_shapes(), get_mgmt_info()))

chop = re.compile('(?<=# STARTNODES\n)(.*?)(?=\n?# ENDNODES)', re.DOTALL)
chop = re.compile('(?<=# STARTNODES\n)(.*?)(?=\n?# ENDNODES)', re.DOTALL)

with open(slurm_conf_filename) as f:
all_config = f.read()
with open(slurm_conf_filename) as f:
all_config = f.read()

new_config = chop.sub('{}'.format(node_config), all_config)
new_config = chop.sub('{}'.format(node_config), all_config)

with open(slurm_conf_filename, "w") as f:
f.write(new_config)
with open(slurm_conf_filename, "w") as f:
f.write(new_config)

0 comments on commit a53da1c

Please sign in to comment.