Java Example of Configuring the Boot Options of a Virtual Machine

This example is based on the code in the
BootConfiguration.java
sample file.
For a complete and up-to-date version of the Java sample code, see the
vsphere-automation-sdk-java
VMware repository at GitHub.
... private String vmName; private String vmId; private BootTypes.Info originalBootInfo; private Boot bootService; ... this.bootService = vapiAuthHelper.getStubFactory().createStub(Boot.class, this.sessionStubConfig); System.out.println("\n\n#### Setup: Get the virtual machine id"); this.vmId = VmHelper.getVM(vapiAuthHelper.getStubFactory(), sessionStubConfig, vmName); // Print the current boot configuration System.out.println("\n\n#### Print the original Boot Info"); BootTypes.Info bootInfo = this.bootService.get(this.vmId); System.out.println(bootInfo); // Save the current boot info to verify that we have cleaned up properly this.originalBootInfo = bootInfo; System.out.println( "\n\n#### Example: Update firmware to EFI for boot configuration."); BootTypes.UpdateSpec bootUpdateSpec = new BootTypes.UpdateSpec.Builder() .setType(BootTypes.Type.EFI) .build(); this.bootService.update(this.vmId, bootUpdateSpec); System.out.println(bootUpdateSpec); bootInfo = this.bootService.get(this.vmId); System.out.println(bootInfo); System.out.println( "\n\n#### Example: Update boot firmware to tell it to enter setup" + " mode on next boot."); bootUpdateSpec = new BootTypes.UpdateSpec.Builder() .setEnterSetupMode(true) .build(); this.bootService.update(this.vmId, bootUpdateSpec); System.out.println(bootUpdateSpec); bootInfo = this.bootService.get(this.vmId); System.out.println(bootInfo); System.out.println( "\n\n#### Example: Update firmware to introduce a delay in boot " + "process and automatically reboot after a failure to boot, " + "retry delay = 30000 ms."); bootUpdateSpec = new BootTypes.UpdateSpec.Builder() .setDelay(10000l) .setRetry(true) .setRetryDelay(30000l) .build(); this.bootService.update(this.vmId, bootUpdateSpec); bootInfo = this.bootService.get(this.vmId); System.out.println(bootInfo); ...