From ca96cfc9233b056c71bd186f6f1321488a7fc538 Mon Sep 17 00:00:00 2001 From: Deli Qiao Date: Tue, 3 Mar 2026 19:03:22 +0800 Subject: [PATCH] Fix getVMByName to include projectID parameter When VMs are deployed in a CloudStack project, the getVMByName function fails to find them because it doesn't include the projectID parameter in the ListVirtualMachines API call. This fix adds the projectID parameter to getVMByName, making it consistent with GetVMByID which already correctly handles project-scoped VMs. --- pkg/cloud/vms.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/cloud/vms.go b/pkg/cloud/vms.go index 2df3c7f..4a45106 100644 --- a/pkg/cloud/vms.go +++ b/pkg/cloud/vms.go @@ -59,8 +59,12 @@ func (c *client) getVMByName(ctx context.Context, name string) (*VM, error) { logger := klog.FromContext(ctx) p := c.VirtualMachine.NewListVirtualMachinesParams() p.SetName(name) + if c.projectID != "" { + p.SetProjectid(c.projectID) + } logger.V(2).Info("CloudStack API call", "command", "ListVirtualMachines", "params", map[string]string{ - "name": name, + "name": name, + "projectID": c.projectID, }) l, err := c.VirtualMachine.ListVirtualMachines(p) if err != nil {