@@ -127,19 +127,19 @@ func (s *Service) CreateInstance(ctx context.Context, bootstrap string) (*vm.Vir
127127 return nil , err
128128 }
129129
130- if err := applyCICustom (vmid , s .scope .Name (), s .scope .GetStorage ().Name , s .remote ); err != nil {
130+ if err := ApplyCICustom (vmid , s .scope .Name (), s .scope .GetStorage ().Name , s .remote ); err != nil {
131131 return nil , err
132132 }
133133
134- if err := setCloudImage (ctx , vmid , s .scope .GetStorage ().Name , s .remote ); err != nil {
134+ if err := SetCloudImage (ctx , vmid , s .scope .GetStorage ().Name , s .remote ); err != nil {
135135 return nil , err
136136 }
137137
138138 if err := vm .ResizeVolume ("scsi0" , "+30G" ); err != nil {
139139 return nil , err
140140 }
141141
142- if err := ensureRunning (* vm ); err != nil {
142+ if err := EnsureRunning (* vm ); err != nil {
143143 return nil , err
144144 }
145145 return vm , nil
@@ -184,7 +184,7 @@ func (s *Service) Delete(ctx context.Context) error {
184184 return instance .Delete ()
185185}
186186
187- func setCloudImage (ctx context.Context , vmid int , storageName string , ssh scope.SSHClient ) error {
187+ func SetCloudImage (ctx context.Context , vmid int , storageName string , ssh scope.SSHClient ) error {
188188 log := log .FromContext (ctx )
189189 log .Info ("setting cloud image" )
190190
@@ -229,7 +229,7 @@ func setCloudConfig(ctx context.Context, vmName, storageName, bootstrap string,
229229 return nil
230230}
231231
232- func applyCICustom (vmid int , vmName , storageName string , ssh scope.SSHClient ) error {
232+ func ApplyCICustom (vmid int , vmName , storageName string , ssh scope.SSHClient ) error {
233233 cicustom := fmt .Sprintf ("user=%s:snippets/%s.yml" , storageName , vmName )
234234 out , err := ssh .RunCommand (fmt .Sprintf ("qm set %d --cicustom '%s'" , vmid , cicustom ))
235235 if err != nil {
@@ -241,19 +241,19 @@ func applyCICustom(vmid int, vmName, storageName string, ssh scope.SSHClient) er
241241
242242func generateVMOptions (vmName , storageName string ) vm.VirtualMachineCreateOptions {
243243 vmoptions := vm.VirtualMachineCreateOptions {
244- Agent : "enabled=1" ,
245- Cores : 2 ,
246- Memory : 1024 * 4 ,
247- Name : vmName ,
248- Boot : "order=scsi0" ,
249- Ide : vm.Ide {Ide2 : fmt .Sprintf ("file=%s:cloudinit,media=cdrom" , storageName )},
250- IPConfig : vm.IPConfig {IPConfig0 : "ip=dhcp" },
251- OSType : vm .L26 ,
252- Net : vm.Net {Net0 : "model=virtio,bridge=vmbr0,firewall=1" },
253- Scsi : vm.Scsi {Scsi0 : fmt .Sprintf ("file=%s:16 " , storageName )},
254- ScsiHw : vm .VirtioScsiPci ,
255- Serial : vm.Serial {Serial0 : "socket" },
256- VGA : "serial0" ,
244+ Agent : "enabled=1" ,
245+ Cores : 2 ,
246+ Memory : 1024 * 4 ,
247+ Name : vmName ,
248+ Boot : "order=scsi0" ,
249+ Ide : vm.Ide {Ide2 : fmt .Sprintf ("file=%s:cloudinit,media=cdrom" , storageName )},
250+ // IPConfig: vm.IPConfig{IPConfig0: "ip=dhcp"},
251+ OSType : vm .L26 ,
252+ Net : vm.Net {Net0 : "model=virtio,bridge=vmbr0,firewall=1" },
253+ Scsi : vm.Scsi {Scsi0 : fmt .Sprintf ("file=%s:8 " , storageName )},
254+ ScsiHw : vm .VirtioScsiPci ,
255+ Serial : vm.Serial {Serial0 : "socket" },
256+ VGA : "serial0" ,
257257 }
258258 return vmoptions
259259}
@@ -267,7 +267,7 @@ func sshKeyUrlEncode(keys string) (encodedKeys string) {
267267 return
268268}
269269
270- func ensureRunning (instance vm.VirtualMachine ) error {
270+ func EnsureRunning (instance vm.VirtualMachine ) error {
271271 // ensure instance is running
272272 switch instance .Status {
273273 case vm .ProcessStatusRunning :
@@ -286,6 +286,6 @@ func ensureRunning(instance vm.VirtualMachine) error {
286286 return nil
287287}
288288
289- // func ensureStopped (instance vm.VirtualMachine) error {
289+ // func EnsureStopped (instance vm.VirtualMachine) error {
290290// return nil
291291// }
0 commit comments