forked from pepabo/go-netapp
/
aggregate.go
286 lines (250 loc) · 10.4 KB
/
aggregate.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
package netapp
import (
"encoding/xml"
"net/http"
)
type Aggregate struct {
Base
Params struct {
XMLName xml.Name
AggrOptions
}
}
type AggrOptions struct {
DesiredAttributes *AggrInfo `xml:"desired-attributes>aggr-attributes,omitempty"`
MaxRecords int `xml:"max-records,omitempty"`
Query *AggrInfo `xml:"query>aggr-attributes,omitempty"`
Tag string `xml:"tag,omitempty"`
}
type AggrListResponse struct {
XMLName xml.Name `xml:"netapp"`
Results struct {
ResultBase
AggrAttributes []AggrInfo `xml:"attributes-list>aggr-attributes"`
NextTag string `xml:"next-tag"`
} `xml:"results"`
}
func (a Aggregate) List(options *AggrOptions) (*AggrListResponse, *http.Response, error) {
a.Params.XMLName = xml.Name{Local: "aggr-get-iter"}
a.Params.AggrOptions = *options
r := AggrListResponse{}
res, err := a.get(a, &r)
return &r, res, err
}
type AggrListPagesResponse struct {
Response *AggrListResponse
Error error
RawResponse *http.Response
}
type AggregatePageHandler func(AggrListPagesResponse) (shouldContinue bool)
func (a *Aggregate) ListPages(options *AggrOptions, fn AggregatePageHandler) {
requestOptions := options
for shouldContinue := true; shouldContinue; {
aggregateResponse, res, err := a.List(requestOptions)
handlerResponse := false
handlerResponse = fn(AggrListPagesResponse{Response: aggregateResponse, Error: err, RawResponse: res})
nextTag := ""
if err == nil {
nextTag = aggregateResponse.Results.NextTag
requestOptions = &AggrOptions{
Tag: nextTag,
MaxRecords: options.MaxRecords,
}
}
shouldContinue = nextTag != "" && handlerResponse
}
}
type AggrInfo struct {
AggregateName string `xml:"aggregate-name,omitempty"`
AggrInodeAttributes *AggrInodeAttributes `xml:"aggr-inode-attributes,omitempty"`
AggrSpaceAttributes *AggrSpaceAttributes `xml:"aggr-space-attributes,omitempty"`
AggrOwnershipAttributes *AggrOwnershipAttributes `xml:"aggr-ownership-attributes,omitempty"`
AggrRaidAttributes *AggrRaidAttributes `xml:"aggr-raid-attributes,omitempty"`
}
type AggrRaidAttributes struct {
AggregateType string `xml:"aggregate-type,omitempty"`
CacheRaidGroupSize int `xml:"cache-raid-group-size,omitempty"`
ChecksumStatus string `xml:"checksum-status,omitempty"`
ChecksumStyle string `xml:"checksum-style,omitempty"`
DiskCount int `xml:"disk-count,omitempty"`
EncryptionKeyID string `xml:"encryption-key-id,omitempty"`
HaPolicy string `xml:"ha-policy,omitempty"`
HasLocalRoot *bool `xml:"has-local-root"`
HasPartnerRoot *bool `xml:"has-partner-root"`
IsChecksumEnabled *bool `xml:"is-checksum-enabled"`
IsEncrypted *bool `xml:"is-encrypted"`
IsHybrid *bool `xml:"is-hybrid"`
IsHybridEnabled *bool `xml:"is-hybrid-enabled"`
IsInconsistent *bool `xml:"is-inconsistent"`
IsMirrored *bool `xml:"is-mirrored"`
IsRootAggregate *bool `xml:"is-root-aggregate"`
MirrorStatus string `xml:"mirror-status,omitempty"`
MountState string `xml:"mount-state,omitempty"`
PlexCount int `xml:"plex-count,omitempty"`
RaidLostWriteState string `xml:"raid-lost-write-state,omitempty"`
RaidSize int `xml:"raid-size,omitempty"`
RaidStatus string `xml:"raid-status,omitempty"`
RaidType string `xml:"raid-type,omitempty"`
State string `xml:"state,omitempty"`
UsesSharedDisks *bool `xml:"uses-shared-disks"`
}
// AggrOwnershipAttributes describe aggregate's ownership
type AggrOwnershipAttributes struct {
Cluster string `xml:"cluster"`
HomeID int `xml:"home-id"`
HomeName string `xml:"home-name"`
OwnerID int `xml:"owner-id"`
OwnerName string `xml:"owner-name"`
}
type AggrInodeAttributes struct {
FilesPrivateUsed int `xml:"files-private-used"`
FilesTotal int `xml:"files-total"`
FilesUsed int `xml:"files-used"`
InodefilePrivateCapacity int `xml:"inodefile-private-capacity"`
InodefilePublicCapacity int `xml:"inodefile-public-capacity"`
MaxfilesAvailable int `xml:"maxfiles-available"`
MaxfilesPossible int `xml:"maxfiles-possible"`
MaxfilesUsed int `xml:"maxfiles-used"`
PercentInodeUsedCapacity int `xml:"percent-inode-used-capacity"`
}
type AggrSpaceAttributes struct {
AggregateMetadata string `xml:"aggregate-metadata"`
HybridCacheSizeTotal string `xml:"hybrid-cache-size-total"`
PercentUsedCapacity string `xml:"percent-used-capacity"`
PhysicalUsed int `xml:"physical-used"`
PhysicalUsedPercent int `xml:"physical-used-percent"`
SizeAvailable int `xml:"size-available"`
SizeTotal int `xml:"size-total"`
SizeUsed int `xml:"size-used"`
TotalReservedSpace int `xml:"total-reserved-space"`
UsedIncludingSnapshotReserve string `xml:"used-including-snapshot-reserve"`
VolumeFootprints string `xml:"volume-footprints"`
}
type AggregateSpace struct {
Base
Params struct {
XMLName xml.Name
*AggrSpaceOptions
}
}
type AggrSpaceInfoQuery struct {
AggrSpaceInfo *AggrSpaceInfo `xml:"space-information,omitempty"`
}
type AggrSpaceOptions struct {
DesiredAttributes *AggrSpaceInfoQuery `xml:"desired-attributes,omitempty"`
MaxRecords int `xml:"max-records,omitempty"`
Query *AggrSpaceInfoQuery `xml:"query,omitempty"`
Tag string `xml:"tag,omitempty"`
}
type AggrSpaceInfo struct {
Aggregate string `xml:"aggregate,omitempty"`
AggregateMetadata string `xml:"aggregate-metadata,omitempty"`
AggregateMetadataPercent string `xml:"aggregate-metadata-percent,omitempty"`
AggregateSize string `xml:"aggregate-size,omitempty"`
PercentSnapshotSpace string `xml:"percent-snapshot-space,omitempty"`
PhysicalUsed string `xml:"physical-used,omitempty"`
PhysicalUsedPercent string `xml:"physical-used-percent,omitempty"`
SnapSizeTotal string `xml:"snap-size-total,omitempty"`
SnapshotReserveUnusable string `xml:"snapshot-reserve-unusable,omitempty"`
SnapshotReserveUnusablePercent string `xml:"snapshot-reserve-unusable-percent,omitempty"`
UsedIncludingSnapshotReserve string `xml:"used-including-snapshot-reserve,omitempty"`
UsedIncludingSnapshotReservePercent string `xml:"used-including-snapshot-reserve-percent,omitempty"`
VolumeFootprints string `xml:"volume-footprints,omitempty"`
VolumeFootprintsPercent string `xml:"volume-footprints-percent,omitempty"`
}
type AggrSpaceListResponse struct {
XMLName xml.Name `xml:"netapp"`
Results struct {
ResultBase
AttributesList struct {
AggrAttributes []AggrSpaceInfo `xml:"space-information"`
} `xml:"attributes-list"`
} `xml:"results"`
}
func (a *AggregateSpace) List(options *AggrSpaceOptions) (*AggrSpaceListResponse, *http.Response, error) {
a.Params.XMLName = xml.Name{Local: "aggr-space-get-iter"}
a.Params.AggrSpaceOptions = options
r := AggrSpaceListResponse{}
res, err := a.get(a, &r)
return &r, res, err
}
type AggregateSpares struct {
Base
Params struct {
XMLName xml.Name
*AggrSparesOptions
}
}
func (a *AggregateSpares) List(options *AggrSparesOptions) (*AggrSparesListResponse, *http.Response, error) {
a.Params.XMLName = xml.Name{Local: "aggr-spare-get-iter"}
a.Params.AggrSparesOptions = options
r := AggrSparesListResponse{}
res, err := a.get(a, &r)
return &r, res, err
}
func (a *AggregateSpares) ListPages(options *AggrSparesOptions, fn AggregateSparesPageHandler) {
requestOptions := options
for shouldContinue := true; shouldContinue; {
aggregateResponse, res, err := a.List(requestOptions)
handlerResponse := false
handlerResponse = fn(AggrSparesListPagesResponse{Response: aggregateResponse, Error: err, RawResponse: res})
nextTag := ""
if err == nil {
nextTag = aggregateResponse.Results.NextTag
requestOptions = &AggrSparesOptions{
Tag: nextTag,
MaxRecords: options.MaxRecords,
}
}
shouldContinue = nextTag != "" && handlerResponse
}
}
type AggrSpareDiskInfoQuery struct {
AggrSpareDiskInfo *AggrSpareDiskInfo `xml:"aggr-spare-disk-info,omitempty"`
}
type AggrSparesOptions struct {
DesiredAttributes *AggrSpareDiskInfoQuery `xml:"desired-attributes,omitempty"`
MaxRecords int `xml:"max-records,omitempty"`
Query *AggrSpareDiskInfoQuery `xml:"query,omitempty"`
Tag string `xml:"tag,omitempty"`
}
type AggregateSparesPageHandler func(AggrSparesListPagesResponse) (shouldContinue bool)
type AggrSpareDiskInfo struct {
ChecksumStyle string `xml:"checksum-style"`
Disk string `xml:"disk"`
DiskRpm int `xml:"disk-rpm"`
DiskType string `xml:"disk-type"`
EffectiveDiskRpm int `xml:"effective-disk-rpm"`
EffectiveDiskType string `xml:"effective-disk-type"`
IsDiskLeftBehind bool `xml:"is-disk-left-behind"`
IsDiskShared bool `xml:"is-disk-shared"`
IsDiskZeroed bool `xml:"is-disk-zeroed"`
IsDiskZeroing bool `xml:"is-disk-zeroing"`
IsSparecore bool `xml:"is-sparecore"`
LocalUsableDataSize int `xml:"local-usable-data-size"`
LocalUsableDataSizeBlks int `xml:"local-usable-data-size-blks"`
LocalUsableRootSize int `xml:"local-usable-root-size"`
LocalUsableRootSizeBlks int `xml:"local-usable-root-size-blks"`
OriginalOwner string `xml:"original-owner"`
SyncmirrorPool string `xml:"syncmirror-pool"`
TotalSize int `xml:"total-size"`
UsableSize int `xml:"usable-size"`
UsableSizeBlks int `xml:"usable-size-blks"`
ZeroingPercent int `xml:"zeroing-percent"`
}
type AggrSparesListResponse struct {
XMLName xml.Name `xml:"netapp"`
Results struct {
ResultBase
AttributesList struct {
AggrAttributes []AggrSpareDiskInfo `xml:"aggr-spare-disk-info"`
} `xml:"attributes-list"`
NextTag string `xml:"next-tag"`
NumRecords int `xml:"num-records"`
} `xml:"results"`
}
type AggrSparesListPagesResponse struct {
Response *AggrSparesListResponse
Error error
RawResponse *http.Response
}