/
operatingconfig.go
125 lines (109 loc) · 4.19 KB
/
operatingconfig.go
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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"github.com/stmcginnis/gofish/common"
)
// BaseSpeedPrioritySettings shall specify the clock speed for a set of cores.
type BaseSpeedPrioritySettings struct {
// BaseSpeedMHz shall contain the clock speed to configure the set of cores in MHz.
BaseSpeedMHz int
// CoreCount shall contain the number of cores to configure with the speed specified by the BaseSpeedMHz property.
// The sum of all CoreCount properties shall equal the value of the TotalAvailableCoreCount property.
CoreCount int
// CoreIDs shall contain an array identifying the cores to configure with the speed specified by the BaseSpeedMHz
// property. The length of the array shall equal the value of the CoreCount property.
CoreIDs []int
}
// OperatingConfig shall represent an operational configuration for a processor in the Redfish Specification.
type OperatingConfig struct {
common.Entity
// ODataContext is the odata context.
ODataContext string `json:"@odata.context"`
// ODataEtag is the odata etag.
ODataEtag string `json:"@odata.etag"`
// ODataType is the odata type.
ODataType string `json:"@odata.type"`
// BaseSpeedMHz shall contain the base (nominal) clock speed of the processor in MHz.
BaseSpeedMHz int
// BaseSpeedPrioritySettings shall contain an array of objects that specify the clock speed for sets of cores when
// the configuration is operational.
BaseSpeedPrioritySettings []BaseSpeedPrioritySettings
// Description provides a description of this resource.
Description string
// MaxJunctionTemperatureCelsius shall contain the maximum temperature of the junction in degree Celsius units.
MaxJunctionTemperatureCelsius int
// MaxSpeedMHz shall contain the maximum clock speed to which the processor can be configured in MHz.
MaxSpeedMHz int
// Oem shall contain the OEM extensions. All values for properties that this object contains shall conform to the
// Redfish Specification-described requirements.
OEM json.RawMessage `json:"Oem"`
// TDPWatts shall contain the thermal design point of the processor in watt units.
TDPWatts int
// TotalAvailableCoreCount shall contain the number of cores in the processor that can be configured.
TotalAvailableCoreCount int
// TurboProfile shall contain an array of objects that specify the turbo profile for a set of active cores.
TurboProfile []TurboProfileDatapoint
}
// GetOperatingConfig will get a OperatingConfig instance from the service.
func GetOperatingConfig(c common.Client, uri string) (*OperatingConfig, error) {
resp, err := c.Get(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var operatingconfig OperatingConfig
err = json.NewDecoder(resp.Body).Decode(&operatingconfig)
if err != nil {
return nil, err
}
operatingconfig.SetClient(c)
return &operatingconfig, nil
}
// ListReferencedOperatingConfigs gets the collection of OperatingConfig from
// a provided reference.
func ListReferencedOperatingConfigs(c common.Client, link string) ([]*OperatingConfig, error) {
var result []*OperatingConfig
if link == "" {
return result, nil
}
type GetResult struct {
Item *OperatingConfig
Link string
Error error
}
ch := make(chan GetResult)
collectionError := common.NewCollectionError()
get := func(link string) {
operatingconfig, err := GetOperatingConfig(c, link)
ch <- GetResult{Item: operatingconfig, Link: link, Error: err}
}
go func() {
err := common.CollectList(get, c, link)
if err != nil {
collectionError.Failures[link] = err
}
close(ch)
}()
for r := range ch {
if r.Error != nil {
collectionError.Failures[r.Link] = r.Error
} else {
result = append(result, r.Item)
}
}
if collectionError.Empty() {
return result, nil
}
return result, collectionError
}
// TurboProfileDatapoint shall specify the turbo profile for a set of active cores.
type TurboProfileDatapoint struct {
// ActiveCoreCount shall contain the number of cores to be configured with the maximum turbo clock speed. The value
// shall be less than or equal to the TotalAvailableCoreCount property.
ActiveCoreCount int
// MaxSpeedMHz shall contain the maximum turbo clock speed that correspond to the number of active cores in MHz.
MaxSpeedMHz int
}