diff --git a/src/PSProxmoxVE.Core/Services/CloudInitService.cs b/src/PSProxmoxVE.Core/Services/CloudInitService.cs index 2f5ef98..443b5df 100644 --- a/src/PSProxmoxVE.Core/Services/CloudInitService.cs +++ b/src/PSProxmoxVE.Core/Services/CloudInitService.cs @@ -105,13 +105,10 @@ namespace PSProxmoxVE.Core.Services } /// - /// 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). /// - /// - /// The raw Cloud-Init dump (user-data) string as reported by the PVE API. - /// + /// The UPID of the regeneration task. 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 diff --git a/src/PSProxmoxVE/Cmdlets/CloudInit/InvokePveCloudInitRegenerateCmdlet.cs b/src/PSProxmoxVE/Cmdlets/CloudInit/InvokePveCloudInitRegenerateCmdlet.cs index b862c78..c013e1a 100644 --- a/src/PSProxmoxVE/Cmdlets/CloudInit/InvokePveCloudInitRegenerateCmdlet.cs +++ b/src/PSProxmoxVE/Cmdlets/CloudInit/InvokePveCloudInitRegenerateCmdlet.cs @@ -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)) {