forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ioperformanceloscapabilities.go
197 lines (170 loc) · 6.71 KB
/
ioperformanceloscapabilities.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
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
191
192
193
194
195
196
197
//
// SPDX-License-Identifier: BSD-3-Clause
//
package swordfish
import (
"encoding/json"
"reflect"
"github.com/stmcginnis/gofish/common"
)
// IOAccessPattern is used to specify an IO access pattern.
type IOAccessPattern string
const (
// ReadWriteIOAccessPattern shall indicate a Uniform distribution of
// reads and writes.
ReadWriteIOAccessPattern IOAccessPattern = "ReadWrite"
// SequentialReadIOAccessPattern shall indicate a sequential read pattern
// of access.
SequentialReadIOAccessPattern IOAccessPattern = "SequentialRead"
// SequentialWriteIOAccessPattern shall indicate a sequential write
// pattern of access.
SequentialWriteIOAccessPattern IOAccessPattern = "SequentialWrite"
// RandomReadNewIOAccessPattern shall indicate an access pattern of
// random reads of uncached data.
RandomReadNewIOAccessPattern IOAccessPattern = "RandomReadNew"
// RandomReadAgainIOAccessPattern shall indicate an access pattern of
// random reads of cached data.
RandomReadAgainIOAccessPattern IOAccessPattern = "RandomReadAgain"
)
// IOPerformanceLoSCapabilities shall describe the capabilities of the
// system to support various IO performance service options.
type IOPerformanceLoSCapabilities struct {
common.Entity
// ODataContext is the odata context.
ODataContext string `json:"@odata.context"`
// ODataType is the odata type.
ODataType string `json:"@odata.type"`
// Description provides a description of this resource.
Description string
// IOLimitingIsSupported if true, the system should limit IOPS to
// MaxIOOperationsPerSecondPerTerabyte * (Volume Size in Terabytes).
// Otherwise, the system shall not enforce a limit. The default value for
// this property is false.
IOLimitingIsSupported bool
// Identifier shall be unique within the managed ecosystem.
Identifier common.Identifier
// MaxSamplePeriod shall be an ISO 8601 duration specifying the maximum
// sampling period over which average values are calculated.
MaxSamplePeriod string
// MinSamplePeriod shall be an ISO 8601 duration specifying the minimum
// sampling period over which average values are calculated.
MinSamplePeriod string
// MinSupportedIoOperationLatencyMicroseconds shall be the minimum supported
// average IO latency in microseconds calculated over the SamplePeriod
MinSupportedIoOperationLatencyMicroseconds int
// SupportedIOWorkloads shall be a collection of supported workloads.
SupportedIOWorkloads []IOWorkload
// SupportedLinesOfService shall be a collection of supported IO performance
// service options.
SupportedLinesOfService []IOPerformanceLineOfService
// SupportedLinesOfServiceCount is
SupportedLinesOfServiceCount int `json:"SupportedLinesOfService@odata.count"`
// rawData holds the original serialized JSON so we can compare updates.
rawData []byte
}
// UnmarshalJSON unmarshals a IOPerformanceLoSCapabilities object from the raw JSON.
func (ioperformanceloscapabilities *IOPerformanceLoSCapabilities) UnmarshalJSON(b []byte) error {
type temp IOPerformanceLoSCapabilities
var t struct {
temp
}
err := json.Unmarshal(b, &t)
if err != nil {
return err
}
*ioperformanceloscapabilities = IOPerformanceLoSCapabilities(t.temp)
// Extract the links to other entities for later
// This is a read/write object, so we need to save the raw object data for later
ioperformanceloscapabilities.rawData = b
return nil
}
// Update commits updates to this object's properties to the running system.
func (ioperformanceloscapabilities *IOPerformanceLoSCapabilities) Update() error {
// Get a representation of the object's original state so we can find what
// to update.
original := new(IOPerformanceLoSCapabilities)
err := original.UnmarshalJSON(ioperformanceloscapabilities.rawData)
if err != nil {
return err
}
readWriteFields := []string{
"IOLimitingIsSupported",
"MaxSamplePeriod",
"MinSamplePeriod",
"MinSupportedIoOperationLatencyMicroseconds",
"SupportedLinesOfService",
}
originalElement := reflect.ValueOf(original).Elem()
currentElement := reflect.ValueOf(ioperformanceloscapabilities).Elem()
return ioperformanceloscapabilities.Entity.Update(originalElement, currentElement, readWriteFields)
}
// GetIOPerformanceLoSCapabilities will get a IOPerformanceLoSCapabilities instance from the service.
func GetIOPerformanceLoSCapabilities(c common.Client, uri string) (*IOPerformanceLoSCapabilities, error) {
var ioPerformanceLoSCapabilities IOPerformanceLoSCapabilities
return &ioPerformanceLoSCapabilities, ioPerformanceLoSCapabilities.Get(c, uri, &ioPerformanceLoSCapabilities)
}
// ListReferencedIOPerformanceLoSCapabilitiess gets the collection of IOPerformanceLoSCapabilities from
// a provided reference.
func ListReferencedIOPerformanceLoSCapabilitiess(c common.Client, link string) ([]*IOPerformanceLoSCapabilities, error) { //nolint:dupl
var result []*IOPerformanceLoSCapabilities
if link == "" {
return result, nil
}
type GetResult struct {
Item *IOPerformanceLoSCapabilities
Link string
Error error
}
ch := make(chan GetResult)
collectionError := common.NewCollectionError()
get := func(link string) {
ioperformanceloscapabilities, err := GetIOPerformanceLoSCapabilities(c, link)
ch <- GetResult{Item: ioperformanceloscapabilities, 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
}
// IOWorkload is used to describe an IO Workload.
type IOWorkload struct {
// Components shall be an array of IO workload component
// descriptions.
Components []IOWorkloadComponent
}
// IOWorkloadComponent is used to describe a component of an IO workload.
type IOWorkloadComponent struct {
// AverageIOBytes shall be the expected average I/O size.
AverageIOBytes int
// Duration is The value of each entry shall be an ISO 8601 duration that
// shall specify the expected length of time that this component is
// applied to the workload. This attribute shall be specified if a
// schedule is specified and otherwise shall not be specified.
Duration string
// IOAccessPattern is The enumeration literal shall be the expected
// access pattern.
IOAccessPattern IOAccessPattern
// PercentOfData shall be the expected percent of the data
// referenced by the workload that is covered by this component.
PercentOfData int
// PercentOfIOPS shall be the expected percent of the total
// IOPS for this workload that is covered by this component
PercentOfIOPS int
// Schedule shall specifies when this workload component is
// applied to the overall workload.
Schedule common.Schedule
}