Skip to content

Commit

Permalink
api: Support OVF ResourceType enum
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
akutz committed Dec 5, 2024
1 parent 42bf813 commit e9f9eb0
Showing 1 changed file with 51 additions and 6 deletions.
57 changes: 51 additions & 6 deletions ovf/cim.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,51 @@ import (
"github.com/vmware/govmomi/vim25/types"
)

/*
Source:
- https://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.24.0/CIM_ResourceAllocationSettingData.xsd
- https://schemas.dmtf.org/wbem/cim-html/2/CIM_ResourceAllocationSettingData.html
*/
type CIMResourceType uint16

// Please note, the iota pattern is not used to ensure these constants remain
// affixed to an explicit value.
const (
Other CIMResourceType = 1
ComputerSystem CIMResourceType = 2
Processor CIMResourceType = 3
Memory CIMResourceType = 4
IdeController CIMResourceType = 5
ParallelScsiHba CIMResourceType = 6
FcHba CIMResourceType = 7
IScsiHba CIMResourceType = 8
IbHba CIMResourceType = 9
EthernetAdapter CIMResourceType = 10
OtherNetwork CIMResourceType = 11
IoSlot CIMResourceType = 12
IoDevice CIMResourceType = 13
FloppyDrive CIMResourceType = 14
CdDrive CIMResourceType = 15
DvdDrive CIMResourceType = 16
DiskDrive CIMResourceType = 17
TapeDrive CIMResourceType = 18
StorageExtent CIMResourceType = 19
OtherStorage CIMResourceType = 20
SerialPort CIMResourceType = 21
ParallelPort CIMResourceType = 22
UsbController CIMResourceType = 23
Graphics CIMResourceType = 24
Ieee1394 CIMResourceType = 25
PartitionableUnit CIMResourceType = 26
BasePartitionable CIMResourceType = 27
PowerSupply CIMResourceType = 28
CoolingDevice CIMResourceType = 29
EthernetSwitchPort CIMResourceType = 30
LogicalDisk CIMResourceType = 31
StorageVolume CIMResourceType = 32
EthernetConnection CIMResourceType = 33
)

/*
Source: http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.24.0/CIM_VirtualSystemSettingData.xsd
*/
Expand Down Expand Up @@ -57,9 +102,9 @@ type CIMResourceAllocationSettingData struct {
ElementName string `xml:"ElementName"`
InstanceID string `xml:"InstanceID"`

ResourceType *uint16 `xml:"ResourceType"`
OtherResourceType *string `xml:"OtherResourceType"`
ResourceSubType *string `xml:"ResourceSubType"`
ResourceType *CIMResourceType `xml:"ResourceType"`
OtherResourceType *string `xml:"OtherResourceType"`
ResourceSubType *string `xml:"ResourceSubType"`

AddressOnParent *string `xml:"AddressOnParent"`
Address *string `xml:"Address"`
Expand Down Expand Up @@ -88,9 +133,9 @@ type CIMStorageAllocationSettingData struct {
ElementName string `xml:"ElementName"`
InstanceID string `xml:"InstanceID"`

ResourceType *uint16 `xml:"ResourceType"`
OtherResourceType *string `xml:"OtherResourceType"`
ResourceSubType *string `xml:"ResourceSubType"`
ResourceType *CIMResourceType `xml:"ResourceType"`
OtherResourceType *string `xml:"OtherResourceType"`
ResourceSubType *string `xml:"ResourceSubType"`

Access *uint16 `xml:"Access"`
Address *string `xml:"Address"`
Expand Down

0 comments on commit e9f9eb0

Please sign in to comment.