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

Method GetNextID

pkg/api/guest_create.go:41–58  ·  view source on GitHub ↗

GetNextID returns the next free VMID, optionally validating a requested one.

(requested int)

Source from the content-addressed store, hash-verified

39
40// GetNextID returns the next free VMID, optionally validating a requested one.
41func (c *Client) GetNextID(requested int) (int, error) {
42 path := "/cluster/nextid"
43 if requested > 0 {
44 path += "?vmid=" + strconv.Itoa(requested)
45 }
46
47 var res map[string]interface{}
48 if err := c.Get(path, &res); err != nil {
49 return 0, fmt.Errorf("failed to get next VMID: %w", err)
50 }
51
52 nextID := getInt(res, "data")
53 if nextID <= 0 {
54 return 0, fmt.Errorf("invalid nextid response format")
55 }
56
57 return nextID, nil
58}
59
60// CreateVM creates a QEMU VM and returns the queued task UPID.
61func (c *Client) CreateVM(nodeName string, options VMCreateOptions) (string, error) {

Callers 3

runGuestsCreateVMFunction · 0.45
runGuestsCreateLXCFunction · 0.45

Calls 2

GetMethod · 0.95
getIntFunction · 0.85

Tested by

no test coverage detected