Search in sources :

Example 1 with VirtualMachineBootOptions

use of com.vmware.vim25.VirtualMachineBootOptions in project cloudstack by apache.

the class VmwareResource method canSetEnableSetupConfig.

/**
 * set the boot into setup option if possible
 * @param vmMo vmware view on the vm
 * @param virtualMachine orchestration spec for the vm
 * @return true unless reboot into setup is requested and vmware is unable to comply
 */
private boolean canSetEnableSetupConfig(VirtualMachineMO vmMo, VirtualMachineTO virtualMachine) {
    if (virtualMachine.isEnterHardwareSetup()) {
        VirtualMachineBootOptions bootOptions = new VirtualMachineBootOptions();
        VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
        if (s_logger.isDebugEnabled()) {
            s_logger.debug(String.format("configuring VM '%s' to reboot into hardware setup menu.", virtualMachine.getName()));
        }
        bootOptions.setEnterBIOSSetup(virtualMachine.isEnterHardwareSetup());
        vmConfigSpec.setBootOptions(bootOptions);
        try {
            if (!vmMo.configureVm(vmConfigSpec)) {
                return false;
            }
        } catch (Exception e) {
            s_logger.error(String.format("failed to reconfigure VM '%s' to boot into hardware setup menu", virtualMachine.getName()), e);
            return false;
        }
    }
    return true;
}
Also used : VirtualMachineConfigSpec(com.vmware.vim25.VirtualMachineConfigSpec) VirtualMachineBootOptions(com.vmware.vim25.VirtualMachineBootOptions) ConnectException(java.net.ConnectException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) InternalErrorException(com.cloud.exception.InternalErrorException) CloudException(com.cloud.exception.CloudException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConfigurationException(javax.naming.ConfigurationException)

Aggregations

CloudException (com.cloud.exception.CloudException)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 VirtualMachineBootOptions (com.vmware.vim25.VirtualMachineBootOptions)1 VirtualMachineConfigSpec (com.vmware.vim25.VirtualMachineConfigSpec)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ConnectException (java.net.ConnectException)1 RemoteException (java.rmi.RemoteException)1 ConfigurationException (javax.naming.ConfigurationException)1