@@ -4,12 +4,10 @@ import (
44 "fmt"
55
66 "github.com/pkg/errors"
7- "k8s.io/klog/v2"
87
8+ infrav1 "github.com/sp-yduck/cluster-api-provider-proxmox/api/v1beta1"
99 "github.com/sp-yduck/cluster-api-provider-proxmox/cloud/cloudinit"
1010 "github.com/sp-yduck/cluster-api-provider-proxmox/cloud/scope"
11-
12- infrav1 "github.com/sp-yduck/cluster-api-provider-proxmox/api/v1beta1"
1311)
1412
1513// reconcileCloudInit
@@ -18,18 +16,10 @@ func reconcileCloudInit(s *Service, vmid int, bootstrap string) error {
1816 storageName := s .scope .GetStorage ().Name
1917 cloudInit := s .scope .GetCloudInit ()
2018
21- klog .Info (cloudInit )
22-
2319 // user
24- if err := reconcileCloudInitUser (vmid , vmName , storageName , bootstrap , cloudInit .User , s .remote ); err != nil {
25- return err
26- }
27-
28- // meta & network
29- if err := reconcileCloudInitConfig (vmid , vmName , storageName , cloudInit , s .remote ); err != nil {
20+ if err := reconcileCloudInitUser (vmid , vmName , storageName , bootstrap , * cloudInit .User , s .remote ); err != nil {
3021 return err
3122 }
32-
3323 return nil
3424}
3525
@@ -59,25 +49,21 @@ func reconcileCloudInitUser(vmid int, vmName, storageName, bootstrap string, con
5949 return errors .Errorf ("ssh command error : %s : %v" , out , err )
6050 }
6151
62- if err := ApplyCICustom (vmid , vmName , storageName , "user" , ssh ); err != nil {
63- return err
64- }
6552 return nil
6653}
6754
55+ // DEPRECATED : network can be configured via API with ipconfig params
6856func reconcileCloudInitConfig (vmid int , vmName , storageName string , cloudInit infrav1.CloudInit , ssh scope.SSHClient ) error {
69- klog .Info (cloudInit .Network )
7057
71- networkYaml , err := cloudinit .GenerateNetworkYaml (cloudInit .Network )
72- if err != nil {
73- return err
74- }
75- out , err := ssh .RunWithStdin (fmt .Sprintf ("tee /var/lib/vz/%s/snippets/%s-network.yml" , storageName , vmName ), networkYaml )
76- if err != nil {
77- return errors .Errorf ("ssh command error : %s : %v" , out , err )
78- }
79- if err := ApplyCICustom (vmid , vmName , storageName , "network" , ssh ); err != nil {
80- return err
58+ if cloudInit .Network != nil {
59+ networkYaml , err := cloudinit .GenerateNetworkYaml (* cloudInit .Network )
60+ if err != nil {
61+ return err
62+ }
63+ out , err := ssh .RunWithStdin (fmt .Sprintf ("tee /var/lib/vz/%s/snippets/%s-network.yml" , storageName , vmName ), networkYaml )
64+ if err != nil {
65+ return errors .Errorf ("ssh command error : %s : %v" , out , err )
66+ }
8167 }
8268
8369 // if meta != nil {
@@ -89,14 +75,12 @@ func reconcileCloudInitConfig(vmid int, vmName, storageName string, cloudInit in
8975 // if err != nil {
9076 // return errors.Errorf("ssh command error : %s : %v", out, err)
9177 // }
92- // if err := ApplyCICustom(vmid, vmName, storageName, "meta", ssh); err != nil {
93- // return err
94- // }
9578 // }
9679
9780 return nil
9881}
9982
83+ // DEPRECATED : cicustom should be set via API
10084func ApplyCICustom (vmid int , vmName , storageName , ciType string , ssh scope.SSHClient ) error {
10185 if ! cloudinit .IsValidType (ciType ) {
10286 return errors .Errorf ("invalid cloud init type: %s" , ciType )
0 commit comments