MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / UpdateVMConfig

Method UpdateVMConfig

pkg/api/vm_config.go:75–94  ·  view source on GitHub ↗

UpdateVMConfig updates the configuration for a VM or container. For LXC: uses PUT (synchronous, no task ID) For QEMU: uses POST (asynchronous, returns task ID).

(vm *VM, config *VMConfig)

Source from the content-addressed store, hash-verified

73// For LXC: uses PUT (synchronous, no task ID)
74// For QEMU: uses POST (asynchronous, returns task ID).
75func (c *Client) UpdateVMConfig(vm *VM, config *VMConfig) error {
76 endpoint := fmt.Sprintf("/nodes/%s/%s/%d/config", vm.Node, vm.Type, vm.ID)
77 data := buildConfigPayload(vm.Type, config)
78
79 if vm.Type == VMTypeLXC {
80 err := c.httpClient.Put(context.Background(), endpoint, data, nil)
81 if err != nil {
82 c.logger.Error("Failed to update LXC config for %s %d with payload %+v: %v", vm.Type, vm.ID, data, err)
83 }
84 return err
85 } else if vm.Type == VMTypeQemu {
86 err := c.httpClient.Post(context.Background(), endpoint, data, nil)
87 if err != nil {
88 c.logger.Error("Failed to update QEMU config for %s %d with payload %+v: %v", vm.Type, vm.ID, data, err)
89 }
90 return err
91 }
92
93 return fmt.Errorf("unsupported VM type: %s", vm.Type)
94}
95
96// ResizeVMStorage resizes a disk for a VM or container.
97func (c *Client) ResizeVMStorage(vm *VM, disk string, size string) error {

Callers 1

ShowVMContextMenuMethod · 0.45

Calls 4

buildConfigPayloadFunction · 0.85
PutMethod · 0.80
ErrorMethod · 0.65
PostMethod · 0.45

Tested by

no test coverage detected