fix: CloudInit regenerate calls PUT endpoint instead of GET dump

RegenerateCloudInitImage was calling GET /cloudinit/dump?type=user
which returns the cloud-init YAML content, not a task UPID. The
cmdlet then passed this YAML string to WaitForTask, causing a 501
error trying to poll a URI like "GET nodes/.../tasks/%23cloud-config..."

Fixed to call PUT /nodes/{node}/qemu/{vmid}/cloudinit which is the
correct regeneration endpoint that returns a UPID.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Clint Branham
2026-03-25 14:06:28 -05:00
parent f5c950f7fa
commit 2e126b96a3
2 changed files with 6 additions and 15 deletions
@@ -105,13 +105,10 @@ namespace PSProxmoxVE.Core.Services
}
/// <summary>
/// Triggers regeneration of the Cloud-Init ISO drive attached to the VM.
/// This is done by calling the cloudinit dump endpoint, then touching the config to
/// force PVE to rebuild the CD-ROM image on next start.
/// Regenerates the Cloud-Init ISO drive attached to the VM
/// (PUT /nodes/{node}/qemu/{vmid}/cloudinit).
/// </summary>
/// <returns>
/// The raw Cloud-Init dump (user-data) string as reported by the PVE API.
/// </returns>
/// <returns>The UPID of the regeneration task.</returns>
public string RegenerateCloudInitImage(PveSession session, string node, int vmid)
{
if (session == null) throw new ArgumentNullException(nameof(session));
@@ -120,10 +117,9 @@ namespace PSProxmoxVE.Core.Services
IPveHttpClient client = _injectedClient ?? new PveHttpClient(session);
try
{
// Request a Cloud-Init dump (user-data section) — this causes PVE to rebuild the image
var dumpResponse = client.GetAsync($"nodes/{Uri.EscapeDataString(node)}/qemu/{vmid}/cloudinit/dump?type=user")
var response = client.PutAsync($"nodes/{Uri.EscapeDataString(node)}/qemu/{vmid}/cloudinit", null)
.GetAwaiter().GetResult();
var data = JObject.Parse(dumpResponse)["data"];
var data = JObject.Parse(response)["data"];
return data?.ToString() ?? string.Empty;
}
finally
@@ -42,12 +42,7 @@ namespace PSProxmoxVE.Cmdlets.CloudInit
var service = new CloudInitService();
var upid = service.RegenerateCloudInitImage(session, Node, VmId);
var task = new PveTask
{
Node = Node,
Status = "stopped",
ExitStatus = "OK"
};
var task = new PveTask { Upid = upid, Node = Node, Status = "running" };
if (Wait.IsPresent && !string.IsNullOrEmpty(upid))
{