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

Function buildConfigPayload

pkg/api/vm_config.go:280–364  ·  view source on GitHub ↗

buildConfigPayload builds the payload for updating VM/LXC config.

(vmType string, config *VMConfig)

Source from the content-addressed store, hash-verified

278
279// buildConfigPayload builds the payload for updating VM/LXC config.
280func buildConfigPayload(vmType string, config *VMConfig) map[string]interface{} {
281 data := map[string]interface{}{}
282 if vmType == VMTypeQemu && config.Name != "" {
283 data["name"] = config.Name
284 }
285 if config.Hostname != "" {
286 data["hostname"] = config.Hostname
287 }
288 if config.Cores > 0 {
289 data["cores"] = config.Cores
290 }
291
292 if config.Sockets > 0 {
293 data["sockets"] = config.Sockets
294 }
295
296 if config.Memory > 0 {
297 data["memory"] = config.Memory / 1024 / 1024 // MB
298 }
299
300 if config.Description != "" {
301 data["description"] = config.Description
302 }
303
304 if config.OnBoot != nil {
305 if *config.OnBoot {
306 data["onboot"] = 1
307 } else {
308 data["onboot"] = 0
309 }
310 }
311
312 if config.TagsExplicit {
313 data["tags"] = config.Tags
314 }
315
316 if vmType == VMTypeQemu {
317 if config.CPUType != "" {
318 data["cpu"] = config.CPUType
319 }
320
321 if config.MaxMem > 0 {
322 data["maxmem"] = config.MaxMem
323 }
324
325 if config.BootOrder != "" {
326 data["boot"] = config.BootOrder
327 }
328
329 if config.Agent != nil {
330 if *config.Agent {
331 data["agent"] = 1
332 } else {
333 data["agent"] = 0
334 }
335 }
336 }
337

Calls

no outgoing calls