Skip to content

Commit e9f9eb0

Browse files
committedDec 5, 2024
api: Support OVF ResourceType enum
This patch adds support to the OVF parser for an enum used to define the CIM ResourceType. BREAKING: Users of the `ovf` package may need to cast ResourceType to a uint16 depending on how they have used the value. Signed-off-by: akutz <akutz@vmware.com>
1 parent 42bf813 commit e9f9eb0

File tree

1 file changed

+51
-6
lines changed

1 file changed

+51
-6
lines changed
 

‎ovf/cim.go

+51-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,51 @@ import (
2020
"github.com/vmware/govmomi/vim25/types"
2121
)
2222

23+
/*
24+
Source:
25+
- https://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.24.0/CIM_ResourceAllocationSettingData.xsd
26+
- https://schemas.dmtf.org/wbem/cim-html/2/CIM_ResourceAllocationSettingData.html
27+
*/
28+
type CIMResourceType uint16
29+
30+
// Please note, the iota pattern is not used to ensure these constants remain
31+
// affixed to an explicit value.
32+
const (
33+
Other CIMResourceType = 1
34+
ComputerSystem CIMResourceType = 2
35+
Processor CIMResourceType = 3
36+
Memory CIMResourceType = 4
37+
IdeController CIMResourceType = 5
38+
ParallelScsiHba CIMResourceType = 6
39+
FcHba CIMResourceType = 7
40+
IScsiHba CIMResourceType = 8
41+
IbHba CIMResourceType = 9
42+
EthernetAdapter CIMResourceType = 10
43+
OtherNetwork CIMResourceType = 11
44+
IoSlot CIMResourceType = 12
45+
IoDevice CIMResourceType = 13
46+
FloppyDrive CIMResourceType = 14
47+
CdDrive CIMResourceType = 15
48+
DvdDrive CIMResourceType = 16
49+
DiskDrive CIMResourceType = 17
50+
TapeDrive CIMResourceType = 18
51+
StorageExtent CIMResourceType = 19
52+
OtherStorage CIMResourceType = 20
53+
SerialPort CIMResourceType = 21
54+
ParallelPort CIMResourceType = 22
55+
UsbController CIMResourceType = 23
56+
Graphics CIMResourceType = 24
57+
Ieee1394 CIMResourceType = 25
58+
PartitionableUnit CIMResourceType = 26
59+
BasePartitionable CIMResourceType = 27
60+
PowerSupply CIMResourceType = 28
61+
CoolingDevice CIMResourceType = 29
62+
EthernetSwitchPort CIMResourceType = 30
63+
LogicalDisk CIMResourceType = 31
64+
StorageVolume CIMResourceType = 32
65+
EthernetConnection CIMResourceType = 33
66+
)
67+
2368
/*
2469
Source: http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.24.0/CIM_VirtualSystemSettingData.xsd
2570
*/
@@ -57,9 +102,9 @@ type CIMResourceAllocationSettingData struct {
57102
ElementName string `xml:"ElementName"`
58103
InstanceID string `xml:"InstanceID"`
59104

60-
ResourceType *uint16 `xml:"ResourceType"`
61-
OtherResourceType *string `xml:"OtherResourceType"`
62-
ResourceSubType *string `xml:"ResourceSubType"`
105+
ResourceType *CIMResourceType `xml:"ResourceType"`
106+
OtherResourceType *string `xml:"OtherResourceType"`
107+
ResourceSubType *string `xml:"ResourceSubType"`
63108

64109
AddressOnParent *string `xml:"AddressOnParent"`
65110
Address *string `xml:"Address"`
@@ -88,9 +133,9 @@ type CIMStorageAllocationSettingData struct {
88133
ElementName string `xml:"ElementName"`
89134
InstanceID string `xml:"InstanceID"`
90135

91-
ResourceType *uint16 `xml:"ResourceType"`
92-
OtherResourceType *string `xml:"OtherResourceType"`
93-
ResourceSubType *string `xml:"ResourceSubType"`
136+
ResourceType *CIMResourceType `xml:"ResourceType"`
137+
OtherResourceType *string `xml:"OtherResourceType"`
138+
ResourceSubType *string `xml:"ResourceSubType"`
94139

95140
Access *uint16 `xml:"Access"`
96141
Address *string `xml:"Address"`

0 commit comments

Comments
 (0)
Please sign in to comment.