1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
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}"],
}
}
}
}
|