Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins/hypervisors/xenserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,10 @@
<artifactId>xen-api</artifactId>
<version>${cs.xapi.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.6.3</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import javax.persistence.EntityExistsException;

import org.apache.cloudstack.hypervisor.xenserver.XenserverConfigs;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.apache.xmlrpc.XmlRpcException;

import com.cloud.agent.AgentManager;
Expand Down Expand Up @@ -122,6 +124,16 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
private String xenServerIsoName = TemplateManager.XS_TOOLS_ISO;
private String xenServerIsoDisplayText = "XenServer Tools Installer ISO (xen-pv-drv-iso)";

public final static String MIN_UEFI_SUPPORTED_VERSION = "8.2";

public static boolean isUefiSupported(String hostProductVersion) {
if (StringUtils.isEmpty(hostProductVersion)) {
return false;
}
ComparableVersion version = new ComparableVersion(hostProductVersion);
return version.compareTo(new ComparableVersion(MIN_UEFI_SUPPORTED_VERSION)) >= 0;
}

protected XcpServerDiscoverer() {
}

Expand Down Expand Up @@ -309,6 +321,9 @@ protected boolean poolHasHotFix(Connection conn, String hostIp, String hotFixUui
details.put("username", username);
params.put("username", username);
details.put("password", password);
if (isUefiSupported(prodVersion)) {
details.put(com.cloud.host.Host.HOST_UEFI_ENABLE, Boolean.TRUE.toString());
}
params.put("password", password);
params.put("zone", Long.toString(dcId));
params.put("guid", record.uuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.
package com.cloud.hypervisor.xenserver.resource;

import static com.cloud.hypervisor.xenserver.discoverer.XcpServerDiscoverer.isUefiSupported;
import static com.cloud.utils.NumbersUtil.toHumanReadableSize;

import java.io.BufferedReader;
Expand Down Expand Up @@ -51,6 +52,7 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.diagnostics.CopyToSecondaryStorageAnswer;
import org.apache.cloudstack.diagnostics.CopyToSecondaryStorageCommand;
import org.apache.cloudstack.diagnostics.DiagnosticsService;
Expand Down Expand Up @@ -1438,6 +1440,11 @@ public VM createVmFromTemplate(final Connection conn, final VirtualMachineTO vmS
} catch (final Exception e) {
throw new CloudRuntimeException("Unable to finalize VM MetaData: " + vmSpec);
}
try {
setVmBootDetails(vm, conn, vmSpec.getBootType(), vmSpec.getBootMode());
} catch (final XenAPIException | XmlRpcException e) {
throw new CloudRuntimeException(String.format("Unable to handle VM boot options: %s", vmSpec), e);
}
return vm;
}

Expand Down Expand Up @@ -1784,6 +1791,9 @@ protected void fillHostInfo(final Connection conn, final StartupRoutingCommand c
}
details.put("product_brand", productBrand);
details.put("product_version", _host.getProductVersion());
if (isUefiSupported(_host.getProductVersion())) {
details.put(com.cloud.host.Host.HOST_UEFI_ENABLE, Boolean.TRUE.toString());
}
if (hr.softwareVersion.get("product_version_text_short") != null) {
details.put("product_version_text_short", hr.softwareVersion.get("product_version_text_short"));
cmd.setHypervisorVersion(hr.softwareVersion.get("product_version_text_short"));
Expand Down Expand Up @@ -1942,6 +1952,20 @@ protected void finalizeVmMetaData(final VM vm, final VM.Record vmr, final Connec
}
}

protected void setVmBootDetails(final VM vm, final Connection conn, String bootType, String bootMode) throws XenAPIException, XmlRpcException {
if (!ApiConstants.BootType.UEFI.toString().equals(bootType)) {
bootType = ApiConstants.BootType.BIOS.toString();
}
Boolean isSecure = bootType.equals(ApiConstants.BootType.UEFI.toString()) &&
ApiConstants.BootMode.SECURE.toString().equals(bootMode);
final Map<String, String> bootParams = vm.getHVMBootParams(conn);
bootParams.replace("firmware", bootType.toLowerCase());
vm.setHVMBootParams(conn, bootParams);
final Map<String, String> platform = vm.getPlatform(conn);
platform.put("secureboot", isSecure.toString());
vm.setPlatform(conn, platform);
}

/**
* This method just creates a XenServer network following the tunnel network
* naming convention
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.cloud.hypervisor.xenserver.discoverer;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InOrder;
Expand Down Expand Up @@ -70,4 +71,25 @@ public void createXenServerToolsIsoEntryInDatabaseTestEntryAlreadyExist() {
inOrder.verify(vmTemplateVOMock).setDisplayText("XenServer Tools Installer ISO (xen-pv-drv-iso)");
inOrder.verify(vmTemplateDao).update(1L, vmTemplateVOMock);
}

@Test
public void uefiSupportedVersionTest() {
Assert.assertTrue(XcpServerDiscoverer.isUefiSupported("8.2"));
Assert.assertTrue(XcpServerDiscoverer.isUefiSupported("8.2.0"));
Assert.assertTrue(XcpServerDiscoverer.isUefiSupported("8.2.1"));
Assert.assertTrue(XcpServerDiscoverer.isUefiSupported("9"));
Assert.assertTrue(XcpServerDiscoverer.isUefiSupported("9.1"));
Assert.assertTrue(XcpServerDiscoverer.isUefiSupported("9.1.0"));
Assert.assertTrue(XcpServerDiscoverer.isUefiSupported("10"));
Assert.assertTrue(XcpServerDiscoverer.isUefiSupported("10.1"));
Assert.assertTrue(XcpServerDiscoverer.isUefiSupported("10.1.0"));
Assert.assertFalse(XcpServerDiscoverer.isUefiSupported(null));
Assert.assertFalse(XcpServerDiscoverer.isUefiSupported(""));
Assert.assertFalse(XcpServerDiscoverer.isUefiSupported("abc"));
Assert.assertFalse(XcpServerDiscoverer.isUefiSupported("0"));
Assert.assertFalse(XcpServerDiscoverer.isUefiSupported("7.4"));
Assert.assertFalse(XcpServerDiscoverer.isUefiSupported("8"));
Assert.assertFalse(XcpServerDiscoverer.isUefiSupported("8.1"));
Assert.assertFalse(XcpServerDiscoverer.isUefiSupported("8.1.0"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public List<Host> allocateTo(VirtualMachineProfile vmProfile, DeploymentPlan pla
isVMDeployedWithUefi = true;
}
}
s_logger.info(" Guest VM is requested with Cusotm[UEFI] Boot Type "+ isVMDeployedWithUefi);
s_logger.info(" Guest VM is requested with Custom[UEFI] Boot Type "+ isVMDeployedWithUefi);


if (type == Host.Type.Storage) {
Expand Down
3 changes: 1 addition & 2 deletions ui/src/views/compute/DeployVM.vue
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,9 @@
</span>
<div style="margin-top: 15px" v-show="this.showDetails">
<div
v-if="vm.templateid && ['KVM', 'VMware'].includes(hypervisor) && !template.deployasis">
v-if="vm.templateid && ['KVM', 'VMware', 'XenServer'].includes(hypervisor) && !template.deployasis">
<a-form-item :label="$t('label.boottype')">
<a-select
:autoFocus="vm.templateid && ['KVM', 'VMware'].includes(hypervisor) && !template.deployasis"
v-decorator="['boottype']"
@change="fetchBootModes"
>
Expand Down