Skip to content

Commit

Permalink
CLOUDSTACK-10197: Rename xentools iso for XenServer 7.0+
Browse files Browse the repository at this point in the history
The xentools iso has been renamed from xs-tools to guest-tools
starting from XenServer 7.0.
  • Loading branch information
khos2ow committed Jan 3, 2018
1 parent 044636c commit 5ff7a1d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Expand Up @@ -536,7 +536,7 @@ private void createXsToolsISO() {
id = _tmpltDao.getNextInSequence(Long.class, "id");
VMTemplateVO template =
VMTemplateVO.createPreHostIso(id, isoName, isoName, ImageFormat.ISO, true, true, TemplateType.PERHOST, null, null, true, 64, Account.ACCOUNT_ID_SYSTEM,
null, "xen-pv-drv-iso", false, 1, false, HypervisorType.XenServer);
null, "XenServer Installer ISO (xen-pv-drv-iso)", false, 1, false, HypervisorType.XenServer);
_tmpltDao.persist(template);
} else {
id = tmplt.getId();
Expand Down
Expand Up @@ -2592,9 +2592,10 @@ public VDI getIsoVDIByURL(final Connection conn, final String vmName, final Stri
String mountpoint = null;
if (isoURL.startsWith("xs-tools")) {
try {
final Set<VDI> vdis = VDI.getByNameLabel(conn, isoURL);
final String actualIsoURL = actualIsoTemplate(conn);
final Set<VDI> vdis = VDI.getByNameLabel(conn, actualIsoURL);
if (vdis.isEmpty()) {
throw new CloudRuntimeException("Could not find ISO with URL: " + isoURL);
throw new CloudRuntimeException("Could not find ISO with URL: " + actualIsoURL);
}
return vdis.iterator().next();

Expand Down Expand Up @@ -2630,6 +2631,22 @@ public VDI getIsoVDIByURL(final Connection conn, final String vmName, final Stri
}
}

private String actualIsoTemplate(final Connection conn) throws BadServerResponse, XenAPIException, XmlRpcException {
final Host host = Host.getByUuid(conn, _host.getUuid());
final Host.Record record = host.getRecord(conn);
final String xenBrand = record.softwareVersion.get("product_brand");
final String xenVersion = record.softwareVersion.get("product_version");
final String[] items = xenVersion.split("\\.");

// guest-tools.iso for XenServer version 7.0+
if (xenBrand.equals("XenServer") && Integer.parseInt(items[0]) >= 7) {
return "guest-tools.iso";
}

// xs-tools.iso for older XenServer versions
return "xs-tools.iso";
}

public String getLabel() {
final Connection conn = getConnection();
final String result = callHostPlugin(conn, "ovstunnel", "getLabel");
Expand Down Expand Up @@ -3882,9 +3899,10 @@ protected VDI mount(final Connection conn, final String vmName, final DiskTO vol
final String templateName = iso.getName();
if (templateName.startsWith("xs-tools")) {
try {
final Set<VDI> vdis = VDI.getByNameLabel(conn, templateName);
final String actualTemplateName = actualIsoTemplate(conn);
final Set<VDI> vdis = VDI.getByNameLabel(conn, actualTemplateName);
if (vdis.isEmpty()) {
throw new CloudRuntimeException("Could not find ISO with URL: " + templateName);
throw new CloudRuntimeException("Could not find ISO with URL: " + actualTemplateName);
}
return vdis.iterator().next();
} catch (final XenAPIException e) {
Expand Down

0 comments on commit 5ff7a1d

Please sign in to comment.