define virtual::vserver::sched($ensure = present, $fill_rate = '', $fill_rate2 = '', $interval = '', $interval2 = '', $tokens_min = '', $tokens_max = '', $tokens = '', $idle_time = false, $priority_bias = '') { file { "/etc/vservers/${name}/sched": ensure => directory, owner => root, group => root, mode => 0755, } 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"], } } } 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"], } } } 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"], } } } 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"], } } } 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"], } } } 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"], } } } 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"], } } } 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, } } } virtual::vserver::flag { "${name}-sched_hard": vserver => $name, flag => "sched_hard", ensure => $ensure, } virtual::vserver::flag { "${name}-sched_prio": vserver => $name, flag => "sched_prio", ensure => $ensure, } case $ensure { present: { $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 { "/usr/sbin/vsched --xid `cat /etc/vservers/$name/context` ${vsched_params} --force": subscribe => File["/etc/vservers/$name/sched/fill-rate", "/etc/vservers/$name/sched/fill-rate2", "/etc/vservers/$name/sched/interval", "/etc/vservers/$name/sched/interval2", "/etc/vservers/$name/sched/tokens-min", "/etc/vservers/$name/sched/tokens-max", "/etc/vservers/$name/sched/tokens", "/etc/vservers/$name/sched/idle-time"], refreshonly => true, require => Exec["vs_create_${name}"], } } } }