Skip to content

Commit 4334991

Browse files
authored
Merge pull request #3 from simplysoft/fix-vm-from-uuid
fix early abort in VirtualMachineFromUUID
2 parents 832aa90 + 8f7fde8 commit 4334991

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

proxmox/qemu.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ func (s *Service) CreateVirtualMachine(ctx context.Context, node string, vmid in
6969
return s.VirtualMachine(ctx, vmid)
7070
}
7171

72+
// VirtualMachineFromUUID attempts to find virtual machine based on SMBIOS UUID. It will ignore any error that prevents
73+
// it from inspecting additional virtual machines (e.g. offline node, vm config not accessible, malformed uuids)
7274
func (s *Service) VirtualMachineFromUUID(ctx context.Context, uuid string) (*VirtualMachine, error) {
7375
nodes, err := s.Nodes(ctx)
7476
if err != nil {
@@ -77,16 +79,16 @@ func (s *Service) VirtualMachineFromUUID(ctx context.Context, uuid string) (*Vir
7779
for _, node := range nodes {
7880
vms, err := s.restclient.GetVirtualMachines(ctx, node.Node)
7981
if err != nil {
80-
return nil, err
82+
continue
8183
}
8284
for _, vm := range vms {
8385
config, err := s.restclient.GetVirtualMachineConfig(ctx, node.Node, vm.VMID)
8486
if err != nil {
85-
return nil, err
87+
continue
8688
}
8789
vmuuid, err := ConvertSMBiosToUUID(config.SMBios1)
8890
if err != nil {
89-
return nil, err
91+
continue
9092
}
9193
if vmuuid == uuid {
9294
return &VirtualMachine{service: s, restclient: s.restclient, VM: vm, Node: node.Node, config: config}, nil

0 commit comments

Comments
 (0)