@@ -202,6 +202,15 @@ func fastDeploy(
202
202
})
203
203
logger .Info ("Got pool" , "pool" , pool .Reference ())
204
204
205
+ var host * object.HostSystem
206
+ if createArgs .HostMoID != "" {
207
+ host = object .NewHostSystem (vimClient , vimtypes.ManagedObjectReference {
208
+ Type : "HostSystem" ,
209
+ Value : createArgs .HostMoID ,
210
+ })
211
+ logger .Info ("Got host" , "host" , host .Reference ())
212
+ }
213
+
205
214
// Determine the type of fast deploy operation.
206
215
var fastDeployMode string
207
216
@@ -222,6 +231,7 @@ func fastDeploy(
222
231
vmCtx ,
223
232
folder ,
224
233
pool ,
234
+ host ,
225
235
createArgs .ConfigSpec ,
226
236
createArgs .Datastores [0 ].MoRef ,
227
237
disks ,
@@ -234,6 +244,7 @@ func fastDeploy(
234
244
datacenter ,
235
245
folder ,
236
246
pool ,
247
+ host ,
237
248
createArgs .ConfigSpec ,
238
249
diskSpecs ,
239
250
dstDiskFormat ,
@@ -245,6 +256,7 @@ func fastDeployLinked(
245
256
ctx context.Context ,
246
257
folder * object.Folder ,
247
258
pool * object.ResourcePool ,
259
+ host * object.HostSystem ,
248
260
configSpec vimtypes.VirtualMachineConfigSpec ,
249
261
datastoreRef vimtypes.ManagedObjectReference ,
250
262
disks []* vimtypes.VirtualDisk ,
@@ -290,14 +302,15 @@ func fastDeployLinked(
290
302
}
291
303
}
292
304
293
- return fastDeployCreateVM (ctx , logger , folder , pool , configSpec )
305
+ return fastDeployCreateVM (ctx , logger , folder , pool , host , configSpec )
294
306
}
295
307
296
308
func fastDeployDirect (
297
309
ctx context.Context ,
298
310
datacenter * object.Datacenter ,
299
311
folder * object.Folder ,
300
312
pool * object.ResourcePool ,
313
+ host * object.HostSystem ,
301
314
configSpec vimtypes.VirtualMachineConfigSpec ,
302
315
diskSpecs []* vimtypes.VirtualDeviceConfigSpec ,
303
316
diskFormat vimtypes.DatastoreSectorFormat ,
@@ -341,14 +354,15 @@ func fastDeployDirect(
341
354
}
342
355
}
343
356
344
- return fastDeployCreateVM (ctx , logger , folder , pool , configSpec )
357
+ return fastDeployCreateVM (ctx , logger , folder , pool , host , configSpec )
345
358
}
346
359
347
360
func fastDeployCreateVM (
348
361
ctx context.Context ,
349
362
logger logr.Logger ,
350
363
folder * object.Folder ,
351
364
pool * object.ResourcePool ,
365
+ host * object.HostSystem ,
352
366
configSpec vimtypes.VirtualMachineConfigSpec ) (* vimtypes.ManagedObjectReference , error ) {
353
367
354
368
logger .Info ("Creating VM" , "configSpec" , vimtypes .ToString (configSpec ))
@@ -357,7 +371,7 @@ func fastDeployCreateVM(
357
371
ctx ,
358
372
configSpec ,
359
373
pool ,
360
- nil )
374
+ host )
361
375
if err != nil {
362
376
return nil , fmt .Errorf ("failed to call create task: %w" , err )
363
377
}
0 commit comments