-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #255 from Tinyblargon/Overhaul-Qemu-Disks-Merge
Overhaul qemu disks merge
- Loading branch information
Showing
13 changed files
with
9,989 additions
and
617 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package proxmox | ||
|
||
import ( | ||
"strconv" | ||
) | ||
|
||
// All code LXC and Qemu have in common should be placed here. | ||
|
||
// Check if there are any pending changes that require a reboot to be applied. | ||
func GuestHasPendingChanges(vmr *VmRef, client *Client) (bool, error) { | ||
params, err := pendingGuestConfigFromApi(vmr, client) | ||
if err != nil { | ||
return false, err | ||
} | ||
return keyExists(params, "pending"), nil | ||
} | ||
|
||
// Reboot the specified guest | ||
func GuestReboot(vmr *VmRef, client *Client) (err error) { | ||
_, err = client.ShutdownVm(vmr) | ||
if err != nil { | ||
return | ||
} | ||
_, err = client.StartVm(vmr) | ||
return | ||
} | ||
|
||
func pendingGuestConfigFromApi(vmr *VmRef, client *Client) ([]interface{}, error) { | ||
err := vmr.nilCheck() | ||
if err != nil { | ||
return nil, err | ||
} | ||
if err = client.CheckVmRef(vmr); err != nil { | ||
return nil, err | ||
} | ||
return client.GetItemConfigInterfaceArray("/nodes/"+vmr.node+"/"+vmr.vmType+"/"+strconv.Itoa(vmr.vmId)+"/pending", "Guest", "PENDING CONFIG") | ||
} |
Oops, something went wrong.