forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemorydomain.go
178 lines (155 loc) · 6.93 KB
/
memorydomain.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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"github.com/stmcginnis/gofish/common"
)
// MemoryDomain is used to represent Memory Domains.
type MemoryDomain struct {
common.Entity
// ODataContext is the odata context.
ODataContext string `json:"@odata.context"`
// ODataType is the odata type.
ODataType string `json:"@odata.type"`
// AllowsBlockProvisioning shall indicate if this Memory Domain supports the
// creation of Blocks of memory.
AllowsBlockProvisioning bool
// AllowsMemoryChunkCreation shall indicate if this Memory Domain supports
// the creation of Memory Chunks.
AllowsMemoryChunkCreation bool
// AllowsMirroring shall indicate if this Memory Domain supports the
// creation of Memory Chunks with mirroring enabled.
AllowsMirroring bool
// AllowsSparing shall indicate if this Memory Domain supports the creation
// of Memory Chunks with sparing enabled.
AllowsSparing bool
// Description provides a description of this resource.
Description string
// InterleavableMemorySets shall represent the interleave sets for the
// memory chunk.
InterleavableMemorySets []MemorySet
// MemoryChunkIncrementMiB shall contain the incremental size, from MemoryChunkIncrementMiB, allowed for a memory
// chunk within this domain in mebibytes (MiB).
MemoryChunkIncrementMiB int
// memoryChunks shall be a link to a collection of type MemoryChunkCollection.
memoryChunks string
// MemorySizeMiB shall contain the total size of the memory domain in mebibytes (MiB).
MemorySizeMiB int
// MinMemoryChunkSizeMiB shall contain the minimum size allowed for a memory chunk within this domain in mebibytes
// (MiB).
MinMemoryChunkSizeMiB int
// Status shall contain any status or health properties of the resource.
Status common.Status
cxlLogicalDevices []string
// CXLLogicalDevicesCount is the number of CXL logical devices that are associated with this memory domain.
CXLLogicalDevicesCount int
fabricAdapters []string
// FabricAdaptersCount is the number of fabric adapters that present this memory domain to a fabric.
FabricAdaptersCount int
mediaControllers []string
// MediaControllersCount is the number of media controllers for this memory domain.
// This property has been deprecated in favor of the FabricAdapters property.
MediaControllersCount int
pcieFunctions []string
// PCIeFunctionsCount is the number of PCIe functions representing this memory domain.
PCIeFunctionsCount int
}
// UnmarshalJSON unmarshals a MemoryDomain object from the raw JSON.
func (memorydomain *MemoryDomain) UnmarshalJSON(b []byte) error {
type temp MemoryDomain
type Links struct {
// CXLLogicalDevices shall contain an array of links to resources of type CXLLogicalDevice that represent the CXL
// logical devices that are associated with this memory domain.
CXLLogicalDevices common.Links
CXLLogicalDevicesCount int `json:"[email protected]"`
// FabricAdapters shall contain an array of links to resources of type FabricAdapter that represent the fabric
// adapters that present this memory domain to a fabric.
FabricAdapters common.Links
FabricAdaptersCount int `json:"[email protected]"`
// MediaControllers is array of links to the media controllers for this memory domain.
// This property has been deprecated in favor of the FabricAdapters property.
MediaControllers common.Links
MediaControllersCount int `json:"[email protected]"`
// PCIeFunctions shall contain an array of links to resources of type PCIeFunction that represent the PCIe
// functions representing this memory domain.
PCIeFunctions common.Links
PCIeFunctionsCount int `json:"[email protected]"`
}
var t struct {
temp
MemoryChunks common.Link
Links Links
}
err := json.Unmarshal(b, &t)
if err != nil {
return err
}
// Extract the links to other entities for later
*memorydomain = MemoryDomain(t.temp)
memorydomain.memoryChunks = t.MemoryChunks.String()
memorydomain.cxlLogicalDevices = t.Links.CXLLogicalDevices.ToStrings()
memorydomain.CXLLogicalDevicesCount = t.Links.CXLLogicalDevicesCount
memorydomain.fabricAdapters = t.Links.FabricAdapters.ToStrings()
memorydomain.FabricAdaptersCount = t.Links.FabricAdaptersCount
memorydomain.mediaControllers = t.Links.MediaControllers.ToStrings()
memorydomain.MediaControllersCount = t.Links.MediaControllersCount
memorydomain.pcieFunctions = t.Links.PCIeFunctions.ToStrings()
memorydomain.PCIeFunctionsCount = t.Links.PCIeFunctionsCount
return nil
}
// CXLLogicalDevices gets the CXLLogicalDevice that represent the CXL logical devices
// that are associated with this memory domain.
func (memorydomain *MemoryDomain) CXLLogicalDevices() ([]*CXLLogicalDevice, error) {
return common.GetObjects[CXLLogicalDevice](memorydomain.GetClient(), memorydomain.cxlLogicalDevices)
}
// FabricAdapters gets the fabric adapters that present this memory domain to a fabric.
func (memorydomain *MemoryDomain) FabricAdapters() ([]*FabricAdapter, error) {
return common.GetObjects[FabricAdapter](memorydomain.GetClient(), memorydomain.fabricAdapters)
}
// MediaControllers gets the media controllers for this memory domain.
// This property has been deprecated in favor of the FabricAdapters property.
func (memorydomain *MemoryDomain) MediaControllers() ([]*MediaController, error) {
return common.GetObjects[MediaController](memorydomain.GetClient(), memorydomain.mediaControllers)
}
// PCIeFunctions gets the PCIe functions representing this memory domain.
func (memorydomain *MemoryDomain) PCIeFunctions() ([]*PCIeFunction, error) {
return common.GetObjects[PCIeFunction](memorydomain.GetClient(), memorydomain.pcieFunctions)
}
// GetMemoryDomain will get a MemoryDomain instance from the service.
func GetMemoryDomain(c common.Client, uri string) (*MemoryDomain, error) {
return common.GetObject[MemoryDomain](c, uri)
}
// ListReferencedMemoryDomains gets the collection of MemoryDomain from
// a provided reference.
func ListReferencedMemoryDomains(c common.Client, link string) ([]*MemoryDomain, error) {
return common.GetCollectionObjects[MemoryDomain](c, link)
}
// MemorySet shall represent the interleave sets for a memory chunk.
type MemorySet struct {
// MemorySet shall be links to objects of type Memory.
memorySet []string
// MemorySetCount is the number of memory sets.
MemorySetCount int `json:"[email protected]"`
}
// UnmarshalJSON unmarshals a MemorySet object from the raw JSON.
func (memoryset *MemorySet) UnmarshalJSON(b []byte) error {
type temp MemorySet
var t struct {
temp
MemorySet common.Links
}
err := json.Unmarshal(b, &t)
if err != nil {
return err
}
// Extract the links to other entities for later
*memoryset = MemorySet(t.temp)
memoryset.memorySet = t.MemorySet.ToStrings()
return nil
}
// MemorySet gets the Memory objects that are part of this set.
func (memoryset *MemorySet) MemorySet(c common.Client) ([]*Memory, error) {
return common.GetObjects[Memory](c, memoryset.memorySet)
}