44 "context"
55 "fmt"
66 "regexp"
7- "strconv"
87 "strings"
98
109 "github.com/pkg/errors"
@@ -37,7 +36,9 @@ func (s *Service) Reconcile(ctx context.Context) error {
3736 }
3837
3938 log .Info (fmt .Sprintf ("Reconciled instance: bios-uuid=%s" , * uuid ))
40- s .scope .SetProviderID (* uuid )
39+ if err := s .scope .SetProviderID (* uuid ); err != nil {
40+ return err
41+ }
4142 s .scope .SetInstanceStatus (infrav1 .InstanceStatus (instance .Status ))
4243 // s.scope.SetAddresses()
4344 return nil
@@ -127,7 +128,7 @@ func getBiosUUID(vm *vm.VirtualMachine) (*string, error) {
127128 if err != nil {
128129 return nil , err
129130 }
130- return pointer .StringPtr (uuid ), nil
131+ return pointer .String (uuid ), nil
131132}
132133
133134func convertSMBiosToUUID (smbios string ) (string , error ) {
@@ -140,29 +141,6 @@ func convertSMBiosToUUID(smbios string) (string, error) {
140141 return strings .Split (match , "=" )[1 ], nil
141142}
142143
143- // will be abolished
144- func (s * Service ) getInstanceFromInstanceID (instanceID string ) (* vm.VirtualMachine , error ) {
145- vmid , err := strconv .Atoi (instanceID )
146- if err != nil {
147- return nil , err
148- }
149- nodes , err := s .client .Nodes ()
150- if err != nil {
151- return nil , err
152- }
153- if len (nodes ) == 0 {
154- return nil , errors .New ("proxmox nodes not found" )
155- }
156- for _ , node := range nodes {
157- vm , err := node .VirtualMachine (vmid )
158- if err != nil {
159- continue
160- }
161- return vm , nil
162- }
163- return nil , api .ErrNotFound
164- }
165-
166144func (s * Service ) getInstanceFromBiosUUID (uuid string ) (* vm.VirtualMachine , error ) {
167145 nodes , err := s .client .Nodes ()
168146 if err != nil {
0 commit comments