Skip to content

Instantly share code, notes, and snippets.

@vholer
Created March 12, 2012 15:40
Show Gist options
  • Save vholer/2022752 to your computer and use it in GitHub Desktop.
Save vholer/2022752 to your computer and use it in GitHub Desktop.
Augeas lens for Torque Scheduler
module Test_Torque_sched =
let conf="# First comment
round_robin: False all
by_queue: True prime
by_queue: True non_prime
strict_fifo: false ALL
fair_share: false ALL
help_starving_jobs true ALL
sort_queues true ALL
load_balancing: false ALL
sort_by: shortest_job_first ALL
log_filter: 256
dedicated_prefix: ded
ignore_remote_local_queues: False
local_server: localhost
max_starve: 24:00:00
half_life: 24:00:00
unknown_shares: 10
sync_time: 1:00:00
no_mom_talk: true
server_locking: true
job_moving: true
"
test Torque_sched.lns get conf =
{ "#comment" = "First comment" }
{ }
{ "round_robin" = "False"
{ "option" = "all" } }
{ "by_queue" = "True"
{ "option" = "prime" } }
{ "by_queue" = "True"
{ "option" = "non_prime" } }
{ "strict_fifo" = "false"
{ "option" = "ALL" } }
{ "fair_share" = "false"
{ "option" = "ALL" } }
{ "help_starving_jobs" = "true"
{ "option" = "ALL" } }
{ "sort_queues" = "true"
{ "option" = "ALL" } }
{ "load_balancing" = "false"
{ "option" = "ALL" } }
{ "sort_by" = "shortest_job_first"
{ "option" = "ALL" } }
{ "log_filter" = "256" }
{ }
{ "dedicated_prefix" = "ded" }
{ "ignore_remote_local_queues" = "False" }
{ "local_server" = "localhost" }
{ "max_starve" = "24:00:00" }
{ "half_life" = "24:00:00" }
{ "unknown_shares" = "10" }
{ "sync_time" = "1:00:00" }
{ "no_mom_talk" = "true" }
{ "server_locking" = "true" }
{ "job_moving" = "true" }
{ }
(*
Module: torque_sched
Parses /var/spool/torque/sched_priv/sched_config
Author:
Vlastimil Holer <[email protected]>
About: Licence
This file is licensed under the LGPLv2+, like the rest of Augeas.
About: Lens Usage
Sample usage of this lens in augtool
* Get your current setup
> print /files/var/spool/torque/sched_priv/sched_config
* Set simple value (without prime opt.)
> set /files/var/spool/torque/sched_priv/sched_config/log_filter 256
* Set value with prime opt.
> set /files/var/spool/torque/sched_priv/sched_config/by_queue[option="prime"] "False"
> set /files/var/spool/torque/sched_priv/sched_config/by_queue[option="non_prime"] "False"
* Delete everything else than non_prime/prime opt.
> rm /files/var/spool/torque/sched_priv/sched_config/by_queue[option != "prime" and option != "non_prime" ]
* Saving your file:
> save
About: Configuration files
This lens applies to /var/spool/torque/sched_priv/sched_config. See <filter>.
*)
module Torque_sched =
autoload xfm
let indent = Util.indent
let eol = Util.eol
let comment = Util.comment
let empty = Util.empty
let del_ws_tab = Util.del_ws_tab
let del_wsc = del /[ \t:]+/ ": "
let key_re = /[a-z0-9_]+/i
let val_re = /[a-z0-9_][a-z0-9_:]*/i
let opt_re = /(non_prime|prime|all)/i
let option = [ del_ws_tab . label "option" . store opt_re ]
let entry = [ indent . key key_re . del_wsc . store val_re . option? . eol ]
let lns = ( comment | empty | entry )*
let filter = Util.stdexcl
. incl "/var/spool/torque/sched_priv/sched_config"
let xfm = transform lns filter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment