github.com/vmware/govmomi@v0.43.0/ovf/envelope.go (about) 1 /* 2 Copyright (c) 2015-2023 VMware, Inc. All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package ovf 18 19 import ( 20 "fmt" 21 ) 22 23 type Envelope struct { 24 References []File `xml:"References>File"` 25 26 // Package level meta-data 27 Annotation *AnnotationSection `xml:"AnnotationSection"` 28 Product *ProductSection `xml:"ProductSection"` 29 Network *NetworkSection `xml:"NetworkSection"` 30 Disk *DiskSection `xml:"DiskSection"` 31 OperatingSystem *OperatingSystemSection `xml:"OperatingSystemSection"` 32 Eula *EulaSection `xml:"EulaSection"` 33 VirtualHardware *VirtualHardwareSection `xml:"VirtualHardwareSection"` 34 ResourceAllocation *ResourceAllocationSection `xml:"ResourceAllocationSection"` 35 DeploymentOption *DeploymentOptionSection `xml:"DeploymentOptionSection"` 36 37 // Content: A VirtualSystem or a VirtualSystemCollection 38 VirtualSystem *VirtualSystem `xml:"VirtualSystem"` 39 } 40 41 type VirtualSystem struct { 42 Content 43 44 Annotation []AnnotationSection `xml:"AnnotationSection"` 45 Product []ProductSection `xml:"ProductSection"` 46 OperatingSystem []OperatingSystemSection `xml:"OperatingSystemSection"` 47 Eula []EulaSection `xml:"EulaSection"` 48 VirtualHardware []VirtualHardwareSection `xml:"VirtualHardwareSection"` 49 } 50 51 type File struct { 52 ID string `xml:"id,attr"` 53 Href string `xml:"href,attr"` 54 Size uint `xml:"size,attr"` 55 Compression *string `xml:"compression,attr"` 56 ChunkSize *int `xml:"chunkSize,attr"` 57 } 58 59 type Content struct { 60 ID string `xml:"id,attr"` 61 Info string `xml:"Info"` 62 Name *string `xml:"Name"` 63 } 64 65 type Section struct { 66 Required *bool `xml:"required,attr"` 67 Info string `xml:"Info"` 68 Category string `xml:"Category"` 69 } 70 71 type AnnotationSection struct { 72 Section 73 74 Annotation string `xml:"Annotation"` 75 } 76 77 type ProductSection struct { 78 Section 79 80 Class *string `xml:"class,attr"` 81 Instance *string `xml:"instance,attr"` 82 83 Product string `xml:"Product"` 84 Vendor string `xml:"Vendor"` 85 Version string `xml:"Version"` 86 FullVersion string `xml:"FullVersion"` 87 ProductURL string `xml:"ProductUrl"` 88 VendorURL string `xml:"VendorUrl"` 89 AppURL string `xml:"AppUrl"` 90 Property []Property `xml:"Property"` 91 } 92 93 func (p ProductSection) Key(prop Property) string { 94 // From OVF spec, section 9.5.1: 95 // key-value-env = [class-value "."] key-value-prod ["." instance-value] 96 97 k := prop.Key 98 if p.Class != nil { 99 k = fmt.Sprintf("%s.%s", *p.Class, k) 100 } 101 if p.Instance != nil { 102 k = fmt.Sprintf("%s.%s", k, *p.Instance) 103 } 104 return k 105 } 106 107 type Property struct { 108 Key string `xml:"key,attr"` 109 Type string `xml:"type,attr"` 110 Qualifiers *string `xml:"qualifiers,attr"` 111 UserConfigurable *bool `xml:"userConfigurable,attr"` 112 Default *string `xml:"value,attr"` 113 Password *bool `xml:"password,attr"` 114 115 Label *string `xml:"Label"` 116 Description *string `xml:"Description"` 117 118 Values []PropertyConfigurationValue `xml:"Value"` 119 } 120 121 type PropertyConfigurationValue struct { 122 Value string `xml:"value,attr"` 123 Configuration *string `xml:"configuration,attr"` 124 } 125 126 type NetworkSection struct { 127 Section 128 129 Networks []Network `xml:"Network"` 130 } 131 132 type Network struct { 133 Name string `xml:"name,attr"` 134 135 Description string `xml:"Description"` 136 } 137 138 type DiskSection struct { 139 Section 140 141 Disks []VirtualDiskDesc `xml:"Disk"` 142 } 143 144 type VirtualDiskDesc struct { 145 DiskID string `xml:"diskId,attr"` 146 FileRef *string `xml:"fileRef,attr"` 147 Capacity string `xml:"capacity,attr"` 148 CapacityAllocationUnits *string `xml:"capacityAllocationUnits,attr"` 149 Format *string `xml:"format,attr"` 150 PopulatedSize *int `xml:"populatedSize,attr"` 151 ParentRef *string `xml:"parentRef,attr"` 152 } 153 154 type OperatingSystemSection struct { 155 Section 156 157 ID int16 `xml:"id,attr"` 158 Version *string `xml:"version,attr"` 159 OSType *string `xml:"osType,attr"` 160 161 Description *string `xml:"Description"` 162 } 163 164 type EulaSection struct { 165 Section 166 167 License string `xml:"License"` 168 } 169 170 type Config struct { 171 Required *bool `xml:"required,attr"` 172 Key string `xml:"key,attr"` 173 Value string `xml:"value,attr"` 174 } 175 176 type VirtualHardwareSection struct { 177 Section 178 179 ID *string `xml:"id,attr"` 180 Transport *string `xml:"transport,attr"` 181 182 System *VirtualSystemSettingData `xml:"System"` 183 Item []ResourceAllocationSettingData `xml:"Item"` 184 StorageItem []StorageAllocationSettingData `xml:"StorageItem"` 185 Config []Config `xml:"Config"` 186 ExtraConfig []Config `xml:"ExtraConfig"` 187 } 188 189 type VirtualSystemSettingData struct { 190 CIMVirtualSystemSettingData 191 } 192 193 type ResourceAllocationSettingData struct { 194 CIMResourceAllocationSettingData 195 196 Required *bool `xml:"required,attr"` 197 Configuration *string `xml:"configuration,attr"` 198 Bound *string `xml:"bound,attr"` 199 } 200 201 type StorageAllocationSettingData struct { 202 CIMStorageAllocationSettingData 203 204 Required *bool `xml:"required,attr"` 205 Configuration *string `xml:"configuration,attr"` 206 Bound *string `xml:"bound,attr"` 207 } 208 209 type ResourceAllocationSection struct { 210 Section 211 212 Item []ResourceAllocationSettingData `xml:"Item"` 213 } 214 215 type DeploymentOptionSection struct { 216 Section 217 218 Configuration []DeploymentOptionConfiguration `xml:"Configuration"` 219 } 220 221 type DeploymentOptionConfiguration struct { 222 ID string `xml:"id,attr"` 223 Default *bool `xml:"default,attr"` 224 225 Label string `xml:"Label"` 226 Description string `xml:"Description"` 227 }