MCPcopy Create free account
hub / github.com/linuxkit/linuxkit / addISO

Function addISO

src/cmd/linuxkit/run_vcenter.go:311–335  ·  view source on GitHub ↗
(ctx context.Context, newVM vmConfig, vm *object.VirtualMachine, dss *object.Datastore)

Source from the content-addressed store, hash-verified

309}
310
311func addISO(ctx context.Context, newVM vmConfig, vm *object.VirtualMachine, dss *object.Datastore) {
312 devices, err := vm.Device(ctx)
313 if err != nil {
314 log.Fatalf("Unable to read devices from VM configuration\n%v", err)
315 }
316
317 ide, err := devices.FindIDEController("")
318 if err != nil {
319 log.Fatalf("Unable to find IDE device from VM configuration\n%v", err)
320 }
321
322 cdrom, err := devices.CreateCdrom(ide)
323 if err != nil {
324 log.Fatalf("Unable to create new CDROM device\n%v", err)
325 }
326
327 var add []types.BaseVirtualDevice
328 add = append(add, devices.InsertIso(cdrom, dss.Path(fmt.Sprintf("%s/%s", *newVM.vmFolder, path.Base(*newVM.path)))))
329
330 log.Infof("Adding ISO to the Virtual Machine")
331
332 if err := vm.AddDevice(ctx, add...); err != nil {
333 log.Fatalf("Unable to add new CD-ROM device to VM configuration\n%v", err)
334 }
335}

Callers 1

runVCenterCmdFunction · 0.85

Calls 1

PathMethod · 0.65

Tested by

no test coverage detected