...
1 package configs
2
3 import "fmt"
4
5
6 type blockIODevice struct {
7
8 Major int64 `json:"major"`
9
10 Minor int64 `json:"minor"`
11 }
12
13
14 type WeightDevice struct {
15 blockIODevice
16
17 Weight uint16 `json:"weight"`
18
19 LeafWeight uint16 `json:"leafWeight"`
20 }
21
22
23 func NewWeightDevice(major, minor int64, weight, leafWeight uint16) *WeightDevice {
24 wd := &WeightDevice{}
25 wd.Major = major
26 wd.Minor = minor
27 wd.Weight = weight
28 wd.LeafWeight = leafWeight
29 return wd
30 }
31
32
33 func (wd *WeightDevice) WeightString() string {
34 return fmt.Sprintf("%d:%d %d", wd.Major, wd.Minor, wd.Weight)
35 }
36
37
38 func (wd *WeightDevice) LeafWeightString() string {
39 return fmt.Sprintf("%d:%d %d", wd.Major, wd.Minor, wd.LeafWeight)
40 }
41
42
43 type ThrottleDevice struct {
44 blockIODevice
45
46 Rate uint64 `json:"rate"`
47 }
48
49
50 func NewThrottleDevice(major, minor int64, rate uint64) *ThrottleDevice {
51 td := &ThrottleDevice{}
52 td.Major = major
53 td.Minor = minor
54 td.Rate = rate
55 return td
56 }
57
58
59 func (td *ThrottleDevice) String() string {
60 return fmt.Sprintf("%d:%d %d", td.Major, td.Minor, td.Rate)
61 }
62
63
64 func (td *ThrottleDevice) StringName(name string) string {
65 return fmt.Sprintf("%d:%d %s=%d", td.Major, td.Minor, name, td.Rate)
66 }
67
View as plain text