def update_partitions()

in src/common/schedulers/slurm_commands.py [0:0]


def update_partitions(partitions, state):
    succeeded_partitions = []
    # Validation to sanitize the input argument and make it safe to use the function affected by B604
    validate_subprocess_argument(state)
    for partition in partitions:
        try:
            # Validation to sanitize the input argument and make it safe to use the function affected by B604
            validate_subprocess_argument(partition)
            run_command(  # nosec B604
                f"{SCONTROL} update partitionname={partition} state={state}", raise_on_error=True, shell=True
            )
            succeeded_partitions.append(partition)
        except Exception as e:
            log.error("Failed when setting partition %s to %s with error %s", partition, state, e)

    return succeeded_partitions