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 b53835c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
Expand Up @@ -393,6 +393,8 @@ protected void addSamePool(Connection conn, Map<CitrixResourceBase, Map<String,
}

protected CitrixResourceBase createServerResource(String prodBrand, String prodVersion, String prodVersionTextShort, String hotfix) {
determineToolsIsoName(prodBrand, prodVersion);

// Xen Cloud Platform group of hypervisors
if (prodBrand.equals("XCP") && (prodVersion.equals("1.0.0") || prodVersion.equals("1.1.0")
|| prodVersion.equals("5.6.100") || prodVersion.startsWith("1.4") || prodVersion.startsWith("1.6"))) {
Expand Down Expand Up @@ -439,7 +441,26 @@ else if (prodBrand.equals("XenServer") && prodVersion.equals("6.2.0")) {
throw new RuntimeException(msg);
}

private void determineToolsIsoName(String prodBrand, String prodVersion) {
final String[] items = prodVersion.split("\\.");
String isoToRemove;

// should keep guest-tools.iso for XenServer 7.x+
if (prodBrand.equals("XenServer") && Integer.parseInt(items[0]) >= 7) {
isoToRemove = "xs-tools.iso";
}

// should keep xs-tools.iso for every other versions of XenServer
else {
isoToRemove = "guest-tools.iso";
}

VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoToRemove);

if (tmplt != null) {
_tmpltDao.remove(tmplt.getId());
}
}

protected CitrixResourceBase createServerResource(long dcId, Long podId, Host.Record record, String hotfix) {
String prodBrand = record.softwareVersion.get("product_brand");
Expand Down Expand Up @@ -529,13 +550,18 @@ public boolean processCommands(long agentId, long seq, Command[] commands) {
}

private void createXsToolsISO() {
String isoName = "xs-tools.iso";
VMTemplateVO tmplt = _tmpltDao.findByTemplateName(isoName);
// register both iso name now and the correct version (based on version of XenServer) will be removed later on
createXsToolsISO("xs-tools.iso");
createXsToolsISO("guest-tools.iso");
}

private void createXsToolsISO(String toolsIsoName) {
VMTemplateVO tmplt = _tmpltDao.findByTemplateName(toolsIsoName);
Long id;
if (tmplt == null) {
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,
VMTemplateVO.createPreHostIso(id, toolsIsoName, toolsIsoName, ImageFormat.ISO, true, true, TemplateType.PERHOST, null, null, true, 64, Account.ACCOUNT_ID_SYSTEM,
null, "xen-pv-drv-iso", false, 1, false, HypervisorType.XenServer);
_tmpltDao.persist(template);
} else {
Expand Down
Expand Up @@ -2590,7 +2590,9 @@ public SR getISOSRbyVmName(final Connection conn, final String vmName) {
public VDI getIsoVDIByURL(final Connection conn, final String vmName, final String isoURL) {
SR isoSR = null;
String mountpoint = null;
if (isoURL.startsWith("xs-tools")) {
// XenServer 7.0+ => guest-tools.iso
// XenServer [other] => xs-tools.iso
if (isoURL.startsWith("xs-tools") || isoURL.startsWith("guest-tools")) {
try {
final Set<VDI> vdis = VDI.getByNameLabel(conn, isoURL);
if (vdis.isEmpty()) {
Expand Down Expand Up @@ -3880,7 +3882,9 @@ protected VDI mount(final Connection conn, final String vmName, final DiskTO vol

// corer case, xenserver pv driver iso
final String templateName = iso.getName();
if (templateName.startsWith("xs-tools")) {
// XenServer 7.0+ => guest-tools.iso
// XenServer [other] => xs-tools.iso
if (templateName.startsWith("xs-tools") || templateName.startsWith("guest-tools")) {
try {
final Set<VDI> vdis = VDI.getByNameLabel(conn, templateName);
if (vdis.isEmpty()) {
Expand Down
2 changes: 1 addition & 1 deletion server/src/com/cloud/api/query/QueryManagerImpl.java
Expand Up @@ -3342,7 +3342,7 @@ else if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYP
SearchCriteria<TemplateJoinVO> zoneSc = _templateJoinDao.createSearchCriteria();
zoneSc.addOr("dataCenterId", SearchCriteria.Op.EQ, zoneId);
zoneSc.addOr("dataStoreScope", SearchCriteria.Op.EQ, ScopeType.REGION);
// handle the case where xs-tools.iso and vmware-tools.iso do not
// handle the case where xs-tools.iso, guest-tools.iso and vmware-tools.iso do not
// have data_center information in template_view
SearchCriteria<TemplateJoinVO> isoPerhostSc = _templateJoinDao.createSearchCriteria();
isoPerhostSc.addAnd("format", SearchCriteria.Op.EQ, ImageFormat.ISO);
Expand Down
Expand Up @@ -278,7 +278,7 @@ public TemplateResponse newIsoResponse(TemplateJoinVO iso) {
isoResponse.setCreated(iso.getCreatedOnStore());
isoResponse.setDynamicallyScalable(iso.isDynamicallyScalable());
if (iso.getTemplateType() == TemplateType.PERHOST) {
// for xs-tools.iso and vmware-tools.iso, we didn't download, but is ready to use.
// for xs-tools.iso, guest-tools.iso and vmware-tools.iso, we didn't download, but is ready to use.
isoResponse.setReady(true);
} else {
isoResponse.setReady(iso.getState() == ObjectInDataStoreStateMachine.State.Ready);
Expand Down

0 comments on commit b53835c

Please sign in to comment.