The hostlist_expression filter is used to convert a list of hostnames from an inventory group into a nice short slurm hostlist expression IF those hosts have a numerical suffix. However currently it doesn't cope with padding, e.g. [compute-001, compute-002] gets converted into compute-[0-2] which breaks slurm (as those aren't actually the hostnames).
This PR fixes this and copes even with a pretty pathological case (see example in docstring below).
The
hostlist_expression
filter is used to convert a list of hostnames from an inventory group into a nice short slurm hostlist expression IF those hosts have a numerical suffix. However currently it doesn't cope with padding, e.g.[compute-001, compute-002]
gets converted intocompute-[0-2]
which breaks slurm (as those aren't actually the hostnames).This PR fixes this and copes even with a pretty pathological case (see example in docstring below).