diff options
Diffstat (limited to 'manifests/vserver.pp')
-rw-r--r-- | manifests/vserver.pp | 214 |
1 files changed, 135 insertions, 79 deletions
diff --git a/manifests/vserver.pp b/manifests/vserver.pp index 7d758f7..b21d3ca 100644 --- a/manifests/vserver.pp +++ b/manifests/vserver.pp @@ -399,52 +399,155 @@ define vs_sched($ensure = present, $fill_rate = '', $fill_rate2 = '', mode => 0755, } - file { "/etc/vservers/${name}/sched/fill-rate": - ensure => $ensure, - content => "$fill_rate\n", - require => File["/etc/vservers/${name}/sched"], + case $fill_rate { + '': { + file { "/etc/vservers/${name}/sched/fill-rate": + ensure => absent, + } + } + default: { + $set_fill_rate = "--fill-rate $fill_rate" + + file { "/etc/vservers/${name}/sched/fill-rate": + ensure => $ensure, + content => "$fill_rate\n", + require => File["/etc/vservers/${name}/sched"], + } + } } - file { "/etc/vservers/${name}/sched/fill-rate2": - ensure => $ensure, - content => "$fill_rate2\n", - require => File["/etc/vservers/${name}/sched"], + case $fill_rate2 { + '': { + file { "/etc/vservers/${name}/sched/fill-rate2": + ensure => absent, + } + } + default: { + $set_fill_rate2 = "--fill-rate2 $fill_rate2" + + file { "/etc/vservers/${name}/sched/fill-rate2": + ensure => $ensure, + content => "$fill_rate2\n", + require => File["/etc/vservers/${name}/sched"], + } + } } - file { "/etc/vservers/${name}/sched/interval": - ensure => $ensure, - content => "$interval\n", - require => File["/etc/vservers/${name}/sched"], + case $interval { + '': { + file { "/etc/vservers/${name}/sched/interval": + ensure => absent, + } + } + default: { + $set_interval = "--interval $interval" + + file { "/etc/vservers/${name}/sched/interval": + ensure => $ensure, + content => "$interval\n", + require => File["/etc/vservers/${name}/sched"], + } + } } - file { "/etc/vservers/${name}/sched/interval2": - ensure => $ensure, - content => "$interval2\n", - require => File["/etc/vservers/${name}/sched"], + case $interval2 { + '': { + file { "/etc/vservers/${name}/sched/interval2": + ensure => absent, + } + } + default: { + $set_interval2 = "--interval2 $interval2" + + file { "/etc/vservers/${name}/sched/interval2": + ensure => $ensure, + content => "$interval2\n", + require => File["/etc/vservers/${name}/sched"], + } + } } - file { "/etc/vservers/${name}/sched/tokens-min": - ensure => $ensure, - content => "$tokens_min\n", - require => File["/etc/vservers/${name}/sched"], + case $tokens_min { + '': { + file { "/etc/vservers/${name}/sched/tokens-min": + ensure => absent, + } + } + default: { + $set_tokens_min = "--tokens-min $tokens_min" + + file { "/etc/vservers/${name}/sched/tokens-min": + ensure => $ensure, + content => "$tokens_min\n", + require => File["/etc/vservers/${name}/sched"], + } + } } - file { "/etc/vservers/${name}/sched/tokens-max": - ensure => $ensure, - content => "$tokens_max\n", - require => File["/etc/vservers/${name}/sched"], + case $tokens_max { + '' { + file { "/etc/vservers/${name}/sched/tokens-max": + ensure => absent, + } + } + default: { + $set_tokens_max = "--tokens-max $tokens_max" + + file { "/etc/vservers/${name}/sched/tokens-max": + ensure => $ensure, + content => "$tokens_max\n", + require => File["/etc/vservers/${name}/sched"], + } + } } - file { "/etc/vservers/${name}/sched/tokens": - ensure => $ensure, - content => "$tokens\n", - require => File["/etc/vservers/${name}/sched"], + case $tokens { + '' { + file { "/etc/vservers/${name}/sched/tokens": + ensure => absent, + } + } + default: { + $set_tokens = "--tokens $tokens" + + file { "/etc/vservers/${name}/sched/tokens": + ensure => $ensure, + content => "$tokens\n", + require => File["/etc/vservers/${name}/sched"], + } + } } - file { "/etc/vservers/${name}/sched/priority-bias": - ensure => $ensure, - content => "$priority_bias\n", - require => File["/etc/vservers/${name}/sched"], + case $priority_bias { + '': { + file { "/etc/vservers/${name}/sched/priority-bias": + ensure => absent, + } + } + default: { + $set_priority_bias = "--prio-bias $priority_bias" + + file { "/etc/vservers/${name}/sched/priority-bias": + ensure => $ensure, + content => "$priority_bias\n", + require => File["/etc/vservers/${name}/sched"], + } + } + } + + case $idle_time { + true: { + $set_idle_time = "--idle-time" + + file { "/etc/vservers/${name}/sched/idle-time": + ensure => $ensure, + } + } + default: { + file { "/etc/vservers/${name}/sched/idle-time": + ensure => absent, + } + } } vs_cflags { "${name}-sched_hard": @@ -462,53 +565,6 @@ define vs_sched($ensure = present, $fill_rate = '', $fill_rate2 = '', case $ensure { present: { - if $fill_rate != '' { - $set_fill_rate = "--fill-rate $fill_rate" - } - - if $fill_rate2 != '' { - $set_fill_rate2 = "--fill-rate2 $fill_rate2" - } - - if $interval != '' { - $set_interval = "--interval $interval" - } - - if $interval2 != '' { - $set_interval2 = "--interval2 $interval2" - } - - if $tokens_min != '' { - $set_tokens_min = "--tokens-min $tokens_min" - } - - if $tokens_max != '' { - $set_tokens_max = "--tokens-max $tokens_max" - } - - if $tokens != '' { - $set_tokens = "--tokens $tokens" - } - - if $priority_bias != '' { - $set_priority_bias = "--prio-bias $priority_bias" - } - - case $idle_time { - true: { - $set_idle_time = "--idle-time" - - file { "/etc/vservers/${name}/sched/idle-time": - ensure => present, - } - } - default: { - file { "/etc/vservers/${name}/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 { "vsched --xid `cat /etc/vservers/$name/context` ${vsched_params} --force": |