2727 regexPCIDevice = regexp .MustCompile (`^hostpci\d+$` )
2828 // regexVirtiofsShare is a regex pattern for matching virtiofs share names.
2929 regexVirtiofsShare = regexp .MustCompile (`^virtiofs\d+$` )
30+ // regexNetworkDevice is a regex pattern for matching network device names.
31+ regexNetworkDevice = regexp .MustCompile (`^net\d+$` )
32+ // regexIPConfig is a regex pattern for matching cloud-init IP config names.
33+ regexIPConfig = regexp .MustCompile (`^ipconfig\d+$` )
3034)
3135
3236// WaitForIPConfig specifies which IP address types to wait for when waiting for network interfaces.
@@ -229,38 +233,7 @@ type GetResponseData struct {
229233 HookScript * string `json:"hookscript,omitempty"`
230234 Hotplug * types.CustomCommaSeparatedList `json:"hotplug,omitempty"`
231235 Hugepages * string `json:"hugepages,omitempty"`
232- IPConfig0 * CustomCloudInitIPConfig `json:"ipconfig0,omitempty"`
233- IPConfig1 * CustomCloudInitIPConfig `json:"ipconfig1,omitempty"`
234- IPConfig2 * CustomCloudInitIPConfig `json:"ipconfig2,omitempty"`
235- IPConfig3 * CustomCloudInitIPConfig `json:"ipconfig3,omitempty"`
236- IPConfig4 * CustomCloudInitIPConfig `json:"ipconfig4,omitempty"`
237- IPConfig5 * CustomCloudInitIPConfig `json:"ipconfig5,omitempty"`
238- IPConfig6 * CustomCloudInitIPConfig `json:"ipconfig6,omitempty"`
239- IPConfig7 * CustomCloudInitIPConfig `json:"ipconfig7,omitempty"`
240- IPConfig8 * CustomCloudInitIPConfig `json:"ipconfig8,omitempty"`
241- IPConfig9 * CustomCloudInitIPConfig `json:"ipconfig9,omitempty"`
242- IPConfig10 * CustomCloudInitIPConfig `json:"ipconfig10,omitempty"`
243- IPConfig11 * CustomCloudInitIPConfig `json:"ipconfig11,omitempty"`
244- IPConfig12 * CustomCloudInitIPConfig `json:"ipconfig12,omitempty"`
245- IPConfig13 * CustomCloudInitIPConfig `json:"ipconfig13,omitempty"`
246- IPConfig14 * CustomCloudInitIPConfig `json:"ipconfig14,omitempty"`
247- IPConfig15 * CustomCloudInitIPConfig `json:"ipconfig15,omitempty"`
248- IPConfig16 * CustomCloudInitIPConfig `json:"ipconfig16,omitempty"`
249- IPConfig17 * CustomCloudInitIPConfig `json:"ipconfig17,omitempty"`
250- IPConfig18 * CustomCloudInitIPConfig `json:"ipconfig18,omitempty"`
251- IPConfig19 * CustomCloudInitIPConfig `json:"ipconfig19,omitempty"`
252- IPConfig20 * CustomCloudInitIPConfig `json:"ipconfig20,omitempty"`
253- IPConfig21 * CustomCloudInitIPConfig `json:"ipconfig21,omitempty"`
254- IPConfig22 * CustomCloudInitIPConfig `json:"ipconfig22,omitempty"`
255- IPConfig23 * CustomCloudInitIPConfig `json:"ipconfig23,omitempty"`
256- IPConfig24 * CustomCloudInitIPConfig `json:"ipconfig24,omitempty"`
257- IPConfig25 * CustomCloudInitIPConfig `json:"ipconfig25,omitempty"`
258- IPConfig26 * CustomCloudInitIPConfig `json:"ipconfig26,omitempty"`
259- IPConfig27 * CustomCloudInitIPConfig `json:"ipconfig27,omitempty"`
260- IPConfig28 * CustomCloudInitIPConfig `json:"ipconfig28,omitempty"`
261- IPConfig29 * CustomCloudInitIPConfig `json:"ipconfig29,omitempty"`
262- IPConfig30 * CustomCloudInitIPConfig `json:"ipconfig30,omitempty"`
263- IPConfig31 * CustomCloudInitIPConfig `json:"ipconfig31,omitempty"`
236+ IPConfigs CustomCloudInitIPConfigMap `json:"-"`
264237 KeepHugepages * types.CustomBool `json:"keephugepages,omitempty"`
265238 KeyboardLayout * string `json:"keyboard,omitempty"`
266239 KVMArguments * string `json:"args,omitempty"`
@@ -271,38 +244,7 @@ type GetResponseData struct {
271244 MigrateDowntime * float64 `json:"migrate_downtime,omitempty"`
272245 MigrateSpeed * int `json:"migrate_speed,omitempty"`
273246 Name * string `json:"name,omitempty"`
274- NetworkDevice0 * CustomNetworkDevice `json:"net0,omitempty"`
275- NetworkDevice1 * CustomNetworkDevice `json:"net1,omitempty"`
276- NetworkDevice2 * CustomNetworkDevice `json:"net2,omitempty"`
277- NetworkDevice3 * CustomNetworkDevice `json:"net3,omitempty"`
278- NetworkDevice4 * CustomNetworkDevice `json:"net4,omitempty"`
279- NetworkDevice5 * CustomNetworkDevice `json:"net5,omitempty"`
280- NetworkDevice6 * CustomNetworkDevice `json:"net6,omitempty"`
281- NetworkDevice7 * CustomNetworkDevice `json:"net7,omitempty"`
282- NetworkDevice8 * CustomNetworkDevice `json:"net8,omitempty"`
283- NetworkDevice9 * CustomNetworkDevice `json:"net9,omitempty"`
284- NetworkDevice10 * CustomNetworkDevice `json:"net10,omitempty"`
285- NetworkDevice11 * CustomNetworkDevice `json:"net11,omitempty"`
286- NetworkDevice12 * CustomNetworkDevice `json:"net12,omitempty"`
287- NetworkDevice13 * CustomNetworkDevice `json:"net13,omitempty"`
288- NetworkDevice14 * CustomNetworkDevice `json:"net14,omitempty"`
289- NetworkDevice15 * CustomNetworkDevice `json:"net15,omitempty"`
290- NetworkDevice16 * CustomNetworkDevice `json:"net16,omitempty"`
291- NetworkDevice17 * CustomNetworkDevice `json:"net17,omitempty"`
292- NetworkDevice18 * CustomNetworkDevice `json:"net18,omitempty"`
293- NetworkDevice19 * CustomNetworkDevice `json:"net19,omitempty"`
294- NetworkDevice20 * CustomNetworkDevice `json:"net20,omitempty"`
295- NetworkDevice21 * CustomNetworkDevice `json:"net21,omitempty"`
296- NetworkDevice22 * CustomNetworkDevice `json:"net22,omitempty"`
297- NetworkDevice23 * CustomNetworkDevice `json:"net23,omitempty"`
298- NetworkDevice24 * CustomNetworkDevice `json:"net24,omitempty"`
299- NetworkDevice25 * CustomNetworkDevice `json:"net25,omitempty"`
300- NetworkDevice26 * CustomNetworkDevice `json:"net26,omitempty"`
301- NetworkDevice27 * CustomNetworkDevice `json:"net27,omitempty"`
302- NetworkDevice28 * CustomNetworkDevice `json:"net28,omitempty"`
303- NetworkDevice29 * CustomNetworkDevice `json:"net29,omitempty"`
304- NetworkDevice30 * CustomNetworkDevice `json:"net30,omitempty"`
305- NetworkDevice31 * CustomNetworkDevice `json:"net31,omitempty"`
247+ NetworkDevices CustomNetworkDeviceMap `json:"-"`
306248 NUMAEnabled * types.CustomBool `json:"numa,omitempty"`
307249 NUMADevices0 * CustomNUMADevice `json:"numa0,omitempty"`
308250 NUMADevices1 * CustomNUMADevice `json:"numa1,omitempty"`
@@ -496,6 +438,8 @@ func (d *GetResponseData) UnmarshalJSON(b []byte) error {
496438 data .StorageDevices = make (CustomStorageDevices )
497439 data .PCIDevices = make (CustomPCIDevices )
498440 data .VirtiofsShares = make (CustomVirtiofsShares )
441+ data .NetworkDevices = make (CustomNetworkDeviceMap )
442+ data .IPConfigs = make (CustomCloudInitIPConfigMap )
499443
500444 for key , value := range byAttr {
501445 for _ , prefix := range StorageInterfaces {
@@ -528,6 +472,24 @@ func (d *GetResponseData) UnmarshalJSON(b []byte) error {
528472
529473 data .VirtiofsShares [key ] = & share
530474 }
475+
476+ if regexNetworkDevice .MatchString (key ) {
477+ var device CustomNetworkDevice
478+ if err := json .Unmarshal ([]byte (`"` + value .(string )+ `"` ), & device ); err != nil {
479+ return fmt .Errorf ("failed to unmarshal %s: %w" , key , err )
480+ }
481+
482+ data .NetworkDevices [key ] = & device
483+ }
484+
485+ if regexIPConfig .MatchString (key ) {
486+ var ipConfig CustomCloudInitIPConfig
487+ if err := json .Unmarshal ([]byte (`"` + value .(string )+ `"` ), & ipConfig ); err != nil {
488+ return fmt .Errorf ("failed to unmarshal %s: %w" , key , err )
489+ }
490+
491+ data .IPConfigs [key ] = & ipConfig
492+ }
531493 }
532494
533495 * d = GetResponseData (data )
0 commit comments