[GH-ISSUE #114] Can't set VM's net config (and some other option) #21

Closed
opened 2026-03-03 15:29:38 +03:00 by kerem · 3 comments
Owner

Originally created by @Jlan45 on GitHub (Feb 8, 2024).
Original GitHub issue: https://github.com/luthermonson/go-proxmox/issues/114

Originally created by @Jlan45 on GitHub (Feb 8, 2024). Original GitHub issue: https://github.com/luthermonson/go-proxmox/issues/114
kerem closed this issue 2026-03-03 15:29:39 +03:00
Author
Owner

@Jlan45 commented on GitHub (Feb 8, 2024):

截屏2024-02-09 00 56 12 As you see in this picture, the net params should be requested with list in http, but the VirtualMachineOption didn't give us options like "list" , so the Config action will fail and return bad request: 400 Parameter verification failed. - {"net[0]":"property is not defined in schema and the schema does not allow additional properties"} (This may be caused by URL encoding.) But I think it may be a good solution to directly use parameters similar to those in VirtualMachineConfig and process them in functions.
<!-- gh-comment-id:1934557840 --> @Jlan45 commented on GitHub (Feb 8, 2024): <img width="299" alt="截屏2024-02-09 00 56 12" src="https://github.com/luthermonson/go-proxmox/assets/49506020/c11361ba-a92a-45a2-a20e-f42a4150295f"> As you see in this picture, the net params should be requested with list in http, but the VirtualMachineOption didn't give us options like "list" , so the Config action will fail and return bad request: 400 Parameter verification failed. - {"net[0]":"property is not defined in schema and the schema does not allow additional properties"} (This may be caused by URL encoding.) But I think it may be a good solution to directly use parameters similar to those in VirtualMachineConfig and process them in functions.
Author
Owner

@jqueuniet commented on GitHub (Feb 8, 2024):

The config key is net0, not net[0].

ie:

vifopt := proxmox.VirtualMachineOption{
    Name:  fmt.Sprintf("net%d", vif.Index),
    Value: "virtio,bridge=" + vnet.GetInterfaceName(),
}

And there are already parameters for network interfaces in the VirtualMachineConfig, with the same helpers as other similar indexed devices like disks.

type VirtualMachineConfig struct {
        // [...]
        
	// Network devices
	Nets map[string]string `json:"-"`
	Net0 string            `json:"net0,omitempty"`
	Net1 string            `json:"net1,omitempty"`
	Net2 string            `json:"net2,omitempty"`
	Net3 string            `json:"net3,omitempty"`
	Net4 string            `json:"net4,omitempty"`
	Net5 string            `json:"net5,omitempty"`
	Net6 string            `json:"net6,omitempty"`
	Net7 string            `json:"net7,omitempty"`
	Net8 string            `json:"net8,omitempty"`
	Net9 string            `json:"net9,omitempty"`
	
        // [...]
}
<!-- gh-comment-id:1934591207 --> @jqueuniet commented on GitHub (Feb 8, 2024): The config key is `net0`, not `net[0]`. ie: ```go vifopt := proxmox.VirtualMachineOption{ Name: fmt.Sprintf("net%d", vif.Index), Value: "virtio,bridge=" + vnet.GetInterfaceName(), } ``` And there are already parameters for network interfaces in the `VirtualMachineConfig`, with the same helpers as other similar indexed devices like disks. ```go type VirtualMachineConfig struct { // [...] // Network devices Nets map[string]string `json:"-"` Net0 string `json:"net0,omitempty"` Net1 string `json:"net1,omitempty"` Net2 string `json:"net2,omitempty"` Net3 string `json:"net3,omitempty"` Net4 string `json:"net4,omitempty"` Net5 string `json:"net5,omitempty"` Net6 string `json:"net6,omitempty"` Net7 string `json:"net7,omitempty"` Net8 string `json:"net8,omitempty"` Net9 string `json:"net9,omitempty"` // [...] } ```
Author
Owner

@Jlan45 commented on GitHub (Feb 8, 2024):

Thanks, my problem has been solved.

<!-- gh-comment-id:1935111031 --> @Jlan45 commented on GitHub (Feb 8, 2024): Thanks, my problem has been solved.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/go-proxmox#21
No description provided.