diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2010-09-03 11:51:29 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2010-09-03 11:51:29 -0300 |
commit | aba70cfed5b870625bcd0d805bfcb46a1487a95d (patch) | |
tree | e05f2ec86ce4b8d5c00375f4b436ea9845def19c /manifests | |
parent | b0b42aed88bf9f255fb4dbd8c98fb0ab6106006d (diff) | |
download | puppet-virtual-aba70cfed5b870625bcd0d805bfcb46a1487a95d.tar.gz puppet-virtual-aba70cfed5b870625bcd0d805bfcb46a1487a95d.tar.bz2 |
Adding support for vserver scheduling
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/vserver.pp | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/manifests/vserver.pp b/manifests/vserver.pp index 9f7fd1c..6913659 100644 --- a/manifests/vserver.pp +++ b/manifests/vserver.pp @@ -387,3 +387,154 @@ define vs_ip_binding($vserver, $ip, $ensure) { } } } + +define vs_sched($vserver, $ensure = present, $fill_rate = '', $fill_rate2 = '', + $interval = '', $interval2 = '', $tokens_min = '', $tokens_max = '', + $tokens = '', $idle_time = false, $priority_bias = '') { + + file { "/etc/vservers/${vserver}/sched/fill-rate": + ensure => $ensure, + content => "$fill_rate\n", + } + + file { "/etc/vservers/${vserver}/sched/fill-rate2": + ensure => $ensure, + content => "$fill_rate2\n", + } + + file { "/etc/vservers/${vserver}/sched/interval": + ensure => $ensure, + content => "$interval\n", + } + + file { "/etc/vservers/${vserver}/sched/interval2": + ensure => $ensure, + content => "$interval2\n", + } + + file { "/etc/vservers/${vserver}/sched/tokens-min": + ensure => $ensure, + content => "$tokens_min\n", + } + + file { "/etc/vservers/${vserver}/sched/tokens-max": + ensure => $ensure, + content => "$tokens_max\n", + } + + file { "/etc/vservers/${vserver}/sched/tokens": + ensure => $ensure, + content => "$tokens\n", + } + + file { "/etc/vservers/${vserver}/sched/priority-bias": + ensure => $ensure, + content => "$priority_bias\n", + } + + case $ensure { + present: { + + case $fill_rate { + '' => { } + default => { + $set_fill_rate = '--fill-rate $fill_rate' + } + } + + case $fill_rate2 { + '' => { } + default => { + $set_fill_rate2 = '--fill-rate2 $fill_rate2' + } + } + + case $interval { + '' => { } + default => { + $set_interval = '--interval $interval' + } + } + + case $interval2 { + '' => { } + default => { + $set_interval2 = '--interval2 $interval2' + } + } + + case $tokens_min { + '' => { } + default => { + $set_tokens_min = '--tokens-min $tokens_min' + } + } + + case $tokens_max { + '' => { } + default => { + $set_tokens_max = '--tokens-max $tokens_max' + } + } + + case $tokens { + '' => { } + default => { + $set_tokens = '--tokens $tokens' + } + } + + case $priority_bias { + '' => { } + default => { + $set_priority_bias = '--prio-bias $priority_bias' + } + } + + case $idle_time { + true: { + $set_idle_time = '--idle-time' + + file { "/etc/vservers/${vserver}/sched/idle-time": + ensure => present, + } + } + default: { + file { "/etc/vservers/${vserver}/sched/idle-time": + ensure => absent, + } + } + } + + $vsched_params = "$set_fill_rate $set_fill_rate2 $set_interval $set_interval2 $set_tokens_min $set_tokens_max $set_tokens $set_idle_time $set_priority_bias" + + exec { "vattribute --set --xid `cat /etc/vservers/$vserver/context` --flag sched_hard": + subscribe => File["/etc/vservers/$vserver/sched/fill_rate", "/etc/vservers/$vserver/sched/fill_rate2", + "/etc/vservers/$vserver/sched/interval", "/etc/vservers/$vserver/sched/interval2", + "/etc/vservers/$vserver/sched/tokens-min", "/etc/vservers/$vserver/sched/tokens-max", + "/etc/vservers/$vserver/sched/tokens", "/etc/vservers/$vserver/sched/idle-time"], + refreshonly => true, + require => Exec["vs_create_${vserver}"], + } + + exec { "vsched --xid `cat /etc/vservers/$vserver/context` ${vsched_params} --force": + subscribe => File["/etc/vservers/$vserver/sched/fill_rate", "/etc/vservers/$vserver/sched/fill_rate2", + "/etc/vservers/$vserver/sched/interval", "/etc/vservers/$vserver/sched/interval2", + "/etc/vservers/$vserver/sched/tokens-min", "/etc/vservers/$vserver/sched/tokens-max", + "/etc/vservers/$vserver/sched/tokens", "/etc/vservers/$vserver/sched/idle-time"], + refreshonly => true, + require => Exec["vs_create_${vserver}"], + } + } + default { + exec { "vattribute --set --xid `cat /etc/vservers/$vserver/context` --flag ~sched_hard": + subscribe => File["/etc/vservers/$vserver/sched/fill_rate", "/etc/vservers/$vserver/sched/fill_rate2", + "/etc/vservers/$vserver/sched/interval", "/etc/vservers/$vserver/sched/interval2", + "/etc/vservers/$vserver/sched/tokens-min", "/etc/vservers/$vserver/sched/tokens-max", + "/etc/vservers/$vserver/sched/tokens", "/etc/vservers/$vserver/sched/idle-time"], + refreshonly => true, + require => Exec["vs_create_${vserver}"], + } + } + } +} |