CLOUDSTACK-10197: Rename xentools iso for XenServer 7.0+ (#2365)

The xentools iso has been renamed from xs-tools to guest-tools
starting from XenServer 7.0.
This commit is contained in:
Khosrow Moossavi 2018-01-07 05:30:39 -05:00 committed by Rohit Yadav
parent 92a6bc27ff
commit 25d7d741a7
2 changed files with 23 additions and 5 deletions

View File

@ -536,7 +536,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
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 Tools Installer ISO (xen-pv-drv-iso)", false, 1, false, HypervisorType.XenServer);
_tmpltDao.persist(template);
} else {
id = tmplt.getId();

View File

@ -2592,9 +2592,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
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();
@ -2630,6 +2631,22 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
}
}
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");
@ -3882,9 +3899,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
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) {