bug 6088: track template physical size in template_host_ref table

add migration from 21 to 22
after migration , SSVM needs to stop/start

status 6088: resolved fixed
This commit is contained in:
anthony 2010-11-24 20:02:41 -08:00
parent bdb1f31dc4
commit 30fa6530f9
14 changed files with 166 additions and 120 deletions

View File

@ -147,8 +147,8 @@ import com.cloud.agent.api.storage.CreateCommand;
import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
import com.cloud.agent.api.storage.CreatePrivateTemplateCommand;
import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.DownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
import com.cloud.agent.api.to.NicTO;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.agent.api.to.VirtualMachineTO;
@ -1765,7 +1765,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
return sp;
}
}
protected Answer execute(final PrimaryStorageDownloadCommand cmd) {
protected PrimaryStorageDownloadAnswer execute(final PrimaryStorageDownloadCommand cmd) {
String tmplturl = cmd.getUrl();
int index = tmplturl.lastIndexOf("/");
String mountpoint = tmplturl.substring(0, index);
@ -1781,7 +1781,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
try {
secondaryPool = getNfsSPbyURI(_conn, new URI(mountpoint));
if (secondaryPool == null) {
return new Answer(cmd, false, " Failed to create storage pool");
return new PrimaryStorageDownloadAnswer(" Failed to create storage pool");
}
if (tmpltname == null) {
/*Hack: server just pass the directory of system vm template, need to scan the folder */
@ -1790,7 +1790,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
}
String[] volumes = secondaryPool.listVolumes();
if (volumes == null) {
return new Answer(cmd, false, "Failed to get volumes from pool: " + secondaryPool.getName());
return new PrimaryStorageDownloadAnswer("Failed to get volumes from pool: " + secondaryPool.getName());
}
for (String volumeName : volumes) {
if (volumeName.endsWith("qcow2")) {
@ -1799,40 +1799,32 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
}
}
if (tmpltname == null) {
return new Answer(cmd, false, "Failed to get template from pool: " + secondaryPool.getName());
return new PrimaryStorageDownloadAnswer("Failed to get template from pool: " + secondaryPool.getName());
}
}
tmplVol = getVolume(secondaryPool, getPathOfStoragePool(secondaryPool) + tmpltname);
if (tmplVol == null) {
return new Answer(cmd, false, " Can't find volume");
return new PrimaryStorageDownloadAnswer(" Can't find volume");
}
primaryPool = _conn.storagePoolLookupByUUIDString(cmd.getPoolUuid());
if (primaryPool == null) {
return new Answer(cmd, false, " Can't find primary storage pool");
return new PrimaryStorageDownloadAnswer(" Can't find primary storage pool");
}
LibvirtStorageVolumeDef vol = new LibvirtStorageVolumeDef(UUID.randomUUID().toString(), tmplVol.getInfo().capacity, volFormat.QCOW2, null, null);
s_logger.debug(vol.toString());
primaryVol = copyVolume(primaryPool, vol, tmplVol);
if (primaryVol == null) {
return new Answer(cmd, false, " Can't create storage volume on storage pool");
return new PrimaryStorageDownloadAnswer(" Can't create storage volume on storage pool");
}
StorageVolInfo priVolInfo = primaryVol.getInfo();
DownloadAnswer answer = new DownloadAnswer(null,
100,
cmd,
com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED,
primaryVol.getKey(),
primaryVol.getKey());
answer.setTemplateSize(priVolInfo.allocation);
return answer;
return new PrimaryStorageDownloadAnswer(primaryVol.getKey(), priVolInfo.allocation);
} catch (LibvirtException e) {
result = "Failed to download template: " + e.toString();
s_logger.debug(result);
return new Answer(cmd, false, result);
return new PrimaryStorageDownloadAnswer(result);
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
return new Answer(cmd, false, e.toString());
return new PrimaryStorageDownloadAnswer(e.toString());
} finally {
try {
if (primaryVol != null) {

View File

@ -31,7 +31,8 @@ public class DownloadAnswer extends Answer {
private VMTemplateHostVO.Status downloadStatus;
private String downloadPath;
private String installPath;
public Long templateSize = 0L;
private long templateSize = 0L;
private long templatePhySicalSize = 0L;
public int getDownloadPct() {
return downloadPct;
@ -62,8 +63,15 @@ public class DownloadAnswer extends Answer {
this.jobId = jobId;
}
public DownloadAnswer(String errorString, Status status) {
super();
this.downloadPct = 0;
this.errorString = errorString;
this.downloadStatus = status;
}
public DownloadAnswer(String jobId, int downloadPct, String errorString,
Status downloadStatus, String fileSystemPath, String installPath, long templateSize) {
Status downloadStatus, String fileSystemPath, String installPath, long templateSize, long templatePhySicalSize ) {
super();
this.jobId = jobId;
this.downloadPct = downloadPct;
@ -72,6 +80,7 @@ public class DownloadAnswer extends Answer {
this.downloadPath = fileSystemPath;
this.installPath = fixPath(installPath);
this.templateSize = templateSize;
this.templatePhySicalSize = templatePhySicalSize;
}
public DownloadAnswer(String jobId, int downloadPct, Command command,
@ -114,5 +123,11 @@ public class DownloadAnswer extends Answer {
public Long getTemplateSize() {
return templateSize;
}
public void setTemplatePhySicalSize(long templatePhySicalSize) {
this.templatePhySicalSize = templatePhySicalSize;
}
public long getTemplatePhySicalSize() {
return templatePhySicalSize;
}
}

View File

@ -0,0 +1,55 @@
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.agent.api.storage;
import com.cloud.agent.api.Answer;
public class PrimaryStorageDownloadAnswer extends Answer {
private String installPath;
private long templateSize = 0L;
protected PrimaryStorageDownloadAnswer() {
}
public PrimaryStorageDownloadAnswer(String detail) {
super(null, false, detail);
}
public PrimaryStorageDownloadAnswer(String installPath, long templateSize ) {
super(null);
this.installPath = installPath;
this.templateSize = templateSize;
}
public String getInstallPath() {
return installPath;
}
public void setInstallPath(String installPath) {
this.installPath = installPath;
}
public void setTemplateSize(long templateSize) {
this.templateSize = templateSize;
}
public Long getTemplateSize() {
return templateSize;
}
}

View File

@ -142,8 +142,8 @@ import com.cloud.agent.api.storage.CreateAnswer;
import com.cloud.agent.api.storage.CreateCommand;
import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.DownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
import com.cloud.agent.api.storage.ShareAnswer;
import com.cloud.agent.api.storage.ShareCommand;
import com.cloud.agent.api.to.NicTO;
@ -2066,7 +2066,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
}
@Override
public DownloadAnswer execute(final PrimaryStorageDownloadCommand cmd) {
public PrimaryStorageDownloadAnswer execute(final PrimaryStorageDownloadCommand cmd) {
SR tmpltsr = null;
String tmplturl = cmd.getUrl();
int index = tmplturl.lastIndexOf("/");
@ -2082,7 +2082,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
if (srs.size() != 1) {
String msg = "There are " + srs.size() + " SRs with same name: " + pUuid;
s_logger.warn(msg);
return new DownloadAnswer(null, 0, msg, com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR, "", "", 0);
return new PrimaryStorageDownloadAnswer(msg);
} else {
poolsr = srs.iterator().next();
}
@ -2119,7 +2119,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
if (tmpltvdi == null) {
String msg = "Unable to find template vdi on secondary storage" + "host:" + _host.uuid + "pool: " + tmplturl;
s_logger.warn(msg);
return new DownloadAnswer(null, 0, msg, com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR, "", "", 0);
return new PrimaryStorageDownloadAnswer(msg);
}
vmtmpltvdi = cloudVDIcopy(tmpltvdi, poolsr);
snapshotvdi = vmtmpltvdi.snapshot(conn, new HashMap<String, String>());
@ -2138,20 +2138,16 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
// Determine the size of the template
long phySize = vmtmpltvdi.getPhysicalUtilisation(conn);
DownloadAnswer answer = new DownloadAnswer(null, 100, cmd, com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED, uuid, uuid);
answer.setTemplateSize(phySize);
return answer;
return new PrimaryStorageDownloadAnswer(uuid, phySize);
} catch (XenAPIException e) {
String msg = "XenAPIException:" + e.toString() + "host:" + _host.uuid + "pool: " + tmplturl;
s_logger.warn(msg, e);
return new DownloadAnswer(null, 0, msg, com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR, "", "", 0);
return new PrimaryStorageDownloadAnswer(msg);
} catch (Exception e) {
String msg = "XenAPIException:" + e.getMessage() + "host:" + _host.uuid + "pool: " + tmplturl;
s_logger.warn(msg, e);
return new DownloadAnswer(null, 0, msg, com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR, "", "", 0);
return new PrimaryStorageDownloadAnswer(msg);
} finally {
removeSR(tmpltsr);
}
@ -3901,7 +3897,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
VDI pvISO = vids.iterator().next();
String uuid = pvISO.getUuid(conn);
Map<String, TemplateInfo> pvISOtmlt = new HashMap<String, TemplateInfo>();
TemplateInfo tmplt = new TemplateInfo("xs-tools.iso", uuid, pvISO.getVirtualSize(conn), true, false);
TemplateInfo tmplt = new TemplateInfo("xs-tools.iso", uuid, pvISO.getVirtualSize(conn), pvISO.getVirtualSize(conn), true, false);
pvISOtmlt.put("xs-tools", tmplt);
sscmd.setTemplateInfo(pvISOtmlt);
} catch (XenAPIException e) {

View File

@ -62,7 +62,10 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc {
private int downloadPercent;
@Column (name="size")
private long size;
private long size;
@Column (name="physicalSize")
private long physicalSize;
@Column (name="download_state")
@Enumerated(EnumType.STRING)
@ -240,6 +243,14 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc {
}
public void setPhysicalSize(long physicalSize) {
this.physicalSize = physicalSize;
}
public long getPhysicalSize() {
return physicalSize;
}
public void setDestroyed(boolean destroyed) {
this.destroyed = destroyed;
}

View File

@ -23,14 +23,14 @@ import com.cloud.agent.api.storage.CopyVolumeCommand;
import com.cloud.agent.api.storage.CreateAnswer;
import com.cloud.agent.api.storage.CreateCommand;
import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.DownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
import com.cloud.agent.api.storage.ShareAnswer;
import com.cloud.agent.api.storage.ShareCommand;
public interface StoragePoolResource {
// FIXME: Should have a PrimaryStorageDownloadAnswer
DownloadAnswer execute(PrimaryStorageDownloadCommand cmd);
PrimaryStorageDownloadAnswer execute(PrimaryStorageDownloadCommand cmd);
// FIXME: Should have an DestroyAnswer
Answer execute(DestroyCommand cmd);

View File

@ -58,6 +58,7 @@ import com.cloud.utils.component.ComponentLocator.ComponentInfo;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.OutputInterpreter;
import com.cloud.utils.script.Script;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
/**
* @author chiradeep
@ -94,6 +95,7 @@ public class DownloadManagerImpl implements DownloadManager {
private Long accountId;
private String installPathPrefix;
private long templatesize;
private long templatePhysicalSize;
private long id;
public DownloadJob(TemplateDownloader td, String jobId, long id, String tmpltName, ImageFormat format, boolean hvm, Long accountId, String descr, String cksum, String installPathPrefix) {
@ -192,6 +194,14 @@ public class DownloadManagerImpl implements DownloadManager {
public long getTemplatesize() {
return templatesize;
}
public void setTemplatePhysicalSize(long templatePhysicalSize) {
this.templatePhysicalSize = templatePhysicalSize;
}
public long getTemplatePhysicalSize() {
return templatePhysicalSize;
}
}
public static final Logger s_logger = Logger.getLogger(DownloadManagerImpl.class);
@ -348,6 +358,7 @@ public class DownloadManagerImpl implements DownloadManager {
if (info != null) {
loc.addFormat(info);
dnld.setTemplatesize(info.virtualSize);
dnld.setTemplatePhysicalSize(info.size);
break;
}
}
@ -448,6 +459,14 @@ public class DownloadManagerImpl implements DownloadManager {
}
return 0;
}
public long getDownloadTemplatePhysicalSize(String jobId) {
DownloadJob dj = jobs.get(jobId);
if (dj != null) {
return dj.getTemplatePhysicalSize();
}
return 0;
}
// @Override
public String getDownloadLocalPath(String jobId) {
@ -502,11 +521,11 @@ public class DownloadManagerImpl implements DownloadManager {
}
if (cmd.getUrl() == null) {
return new DownloadAnswer(null, 0, "Template is corrupted on storage due to an invalid url , cannot download", com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR, "", "", 0);
return new DownloadAnswer("Template is corrupted on storage due to an invalid url , cannot download", VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR);
}
if (cmd.getName() == null) {
return new DownloadAnswer(null, 0, "Invalid Name", com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR, "", "", 0);
return new DownloadAnswer("Invalid Name", VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR);
}
String installPathPrefix = null;
@ -523,10 +542,10 @@ public class DownloadManagerImpl implements DownloadManager {
String jobId = downloadPublicTemplate(cmd.getId(), cmd.getUrl(), cmd.getName(), cmd.getFormat(), cmd.isHvm(), cmd.getAccountId(), cmd.getDescription(), cmd.getChecksum(), installPathPrefix, user, password, maxDownloadSizeInBytes);
sleep();
if (jobId == null) {
return new DownloadAnswer(null, 0, "Internal Error", com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR, "", "", 0);
return new DownloadAnswer("Internal Error", VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR);
}
return new DownloadAnswer(jobId, getDownloadPct(jobId), getDownloadError(jobId), getDownloadStatus2(jobId), getDownloadLocalPath(jobId), getInstallPath(jobId),
getDownloadTemplateSize(jobId));
getDownloadTemplateSize(jobId), getDownloadTemplateSize(jobId));
}
private void sleep() {
@ -548,7 +567,7 @@ public class DownloadManagerImpl implements DownloadManager {
DownloadCommand dcmd = new DownloadCommand(cmd);
return handleDownloadCommand(dcmd);
} else {
return new DownloadAnswer(null, 0, "Cannot find job", com.cloud.storage.VMTemplateHostVO.Status.UNKNOWN, "", "", 0);
return new DownloadAnswer("Cannot find job", VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR.UNKNOWN);
}
}
TemplateDownloader td = dj.getTemplateDownloader();
@ -566,14 +585,15 @@ public class DownloadManagerImpl implements DownloadManager {
break;
case PURGE:
td.stopDownload();
answer = new DownloadAnswer(jobId, getDownloadPct(jobId), getDownloadError(jobId), getDownloadStatus2(jobId), getDownloadLocalPath(jobId), getInstallPath(jobId), getDownloadTemplateSize(jobId));
answer = new DownloadAnswer(jobId, getDownloadPct(jobId), getDownloadError(jobId), getDownloadStatus2(jobId), getDownloadLocalPath(jobId),
getInstallPath(jobId), getDownloadTemplateSize(jobId), getDownloadTemplatePhysicalSize(jobId));
jobs.remove(jobId);
return answer;
default:
break; // TODO
}
return new DownloadAnswer(jobId, getDownloadPct(jobId), getDownloadError(jobId), getDownloadStatus2(jobId), getDownloadLocalPath(jobId), getInstallPath(jobId),
getDownloadTemplateSize(jobId));
return new DownloadAnswer(jobId, getDownloadPct(jobId), getDownloadError(jobId), getDownloadStatus2(jobId), getDownloadLocalPath(jobId),
getInstallPath(jobId), getDownloadTemplateSize(jobId), getDownloadTemplatePhysicalSize(jobId));
}
private String getInstallPath(String jobId) {

View File

@ -23,6 +23,7 @@ public class TemplateInfo {
String templateName;
String installPath;
long size;
long physicalSize;
long id;
boolean isPublic;
boolean isCorrupted;
@ -31,16 +32,17 @@ public class TemplateInfo {
}
public TemplateInfo(String templateName, String installPath, long size, boolean isPublic, boolean isCorrupted) {
public TemplateInfo(String templateName, String installPath, long size, long physicalSize, boolean isPublic, boolean isCorrupted) {
this.templateName = templateName;
this.installPath = installPath;
this.size = size;
this.physicalSize = physicalSize;
this.isPublic = isPublic;
this.isCorrupted = isCorrupted;
}
public TemplateInfo(String templateName, String installPath, boolean isPublic, boolean isCorrupted) {
this(templateName, installPath, 0, isPublic, isCorrupted);
this(templateName, installPath, 0, 0, isPublic, isCorrupted);
}
public long getId() {
@ -71,6 +73,10 @@ public class TemplateInfo {
return size;
}
public long getPhysicalSize() {
return physicalSize;
}
public void setSize(long size) {
this.size = size;
}

View File

@ -106,8 +106,8 @@ public class TemplateLocation {
continue;
}
info.size = NumbersUtil.parseLong(_props.getProperty(format.getFileExtension() + ".size"), -1);
_props.setProperty("physicalSize", Long.toString(info.size));
info.virtualSize = NumbersUtil.parseLong(_props.getProperty(format.getFileExtension() + ".virtualsize"), -1);
_formats.add(info);
if (!checkFormatValidity(info)) {
@ -145,14 +145,12 @@ public class TemplateLocation {
} catch (IOException e) {
}
}
}
}
return true;
}
public TemplateInfo getTemplateInfo() {
TemplateInfo tmplInfo = new TemplateInfo();
TemplateInfo tmplInfo = new TemplateInfo();
tmplInfo.id = Long.parseLong(_props.getProperty("id"));
tmplInfo.installPath = _templatePath + File.separator + _props.getProperty("filename");
tmplInfo.installPath = tmplInfo.installPath.substring(tmplInfo.installPath.indexOf("template"));
@ -160,6 +158,7 @@ public class TemplateLocation {
tmplInfo.isPublic = Boolean.parseBoolean(_props.getProperty("public"));
tmplInfo.templateName = _props.getProperty("uniquename");
tmplInfo.size = Long.parseLong(_props.getProperty("virtualsize"));
tmplInfo.physicalSize = Long.parseLong(_props.getProperty("physicalSize"));
return tmplInfo;
}

View File

@ -187,16 +187,13 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
for (VMTemplateStoragePoolVO templatePoolVO : templatePoolVOs) {
VMTemplateVO templateInPool = _templateDao.findById(templatePoolVO.getTemplateId());
int templateSizeMultiplier = pool.getPoolType() == StoragePoolType.NetworkFilesystem ? 1 : 2;
if ((template != null) && !tmpinstalled && (templateInPool.getId() == template.getId())) {
tmpinstalled = true;
}
s_logger.debug("For template: " + templateInPool.getName() + ", using template size multiplier: " + templateSizeMultiplier);
long templateSize = templatePoolVO.getTemplateSize();
totalAllocatedSize += templateSizeMultiplier * (templateSize + _extraBytesPerVolume);
totalAllocatedSize += templateSize + _extraBytesPerVolume;
}
if ((template != null) && !tmpinstalled) {
@ -212,7 +209,8 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
} else {
s_logger.debug("For template: " + template.getName() + ", using template size multiplier: " + 2);
long templateSize = templateHostVO.getSize();
totalAllocatedSize += 2 * (templateSize + _extraBytesPerVolume);
long templatePhysicalSize = templateHostVO.getPhysicalSize();
totalAllocatedSize += (templateSize + _extraBytesPerVolume) + (templatePhysicalSize + _extraBytesPerVolume);
}
}
}

View File

@ -474,12 +474,14 @@ public class DownloadMonitorImpl implements DownloadMonitor {
tmpltHost.setDownloadState(Status.DOWNLOADED);
tmpltHost.setInstallPath(tmpltInfo.getInstallPath());
tmpltHost.setSize(tmpltInfo.getSize());
tmpltHost.setPhysicalSize(tmpltInfo.getPhysicalSize());
tmpltHost.setLastUpdated(new Date());
}
_vmTemplateHostDao.update(tmpltHost.getId(), tmpltHost);
} else {
tmpltHost = new VMTemplateHostVO(sserverId, tmplt.getId(), new Date(), 100, Status.DOWNLOADED, null, null, null, tmpltInfo.getInstallPath(), tmplt.getUrl());
tmpltHost.setSize(tmpltInfo.getSize());
tmpltHost.setPhysicalSize(tmpltInfo.getPhysicalSize());
_vmTemplateHostDao.persist(tmpltHost);
}

View File

@ -35,6 +35,7 @@ import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.DownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.api.BaseCmd;
import com.cloud.api.ServerApiException;
@ -687,11 +688,11 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
}
dcmd.setLocalPath(vo.getLocalPath());
// set 120 min timeout for this command
DownloadAnswer answer = (DownloadAnswer)_agentMgr.easySend(vo.getHostId(), dcmd, 120*60*1000);
if (answer != null) {
templateStoragePoolRef.setDownloadPercent(templateStoragePoolRef.getDownloadPercent());
templateStoragePoolRef.setDownloadState(answer.getDownloadStatus());
templateStoragePoolRef.setLocalDownloadPath(answer.getDownloadPath());
PrimaryStorageDownloadAnswer answer = (PrimaryStorageDownloadAnswer)_agentMgr.easySend(vo.getHostId(), dcmd, 120*60*1000);
if (answer != null && answer.getResult() ) {
templateStoragePoolRef.setDownloadPercent(100);
templateStoragePoolRef.setDownloadState(Status.DOWNLOADED);
templateStoragePoolRef.setLocalDownloadPath(answer.getInstallPath());
templateStoragePoolRef.setInstallPath(answer.getInstallPath());
templateStoragePoolRef.setTemplateSize(answer.getTemplateSize());
_tmpltPoolDao.update(templateStoragePoolRef.getId(), templateStoragePoolRef);
@ -699,6 +700,9 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
s_logger.debug("Template " + templateId + " is downloaded via " + vo.getHostId());
}
return templateStoragePoolRef;
} else {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Template " + templateId + " download to pool " + vo.getPoolId() + " failed due to " + (answer!=null?answer.getDetails():"return null")); }
}
}
} finally {

View File

@ -683,6 +683,7 @@ CREATE TABLE `cloud`.`template_host_ref` (
`job_id` varchar(255),
`download_pct` int(10) unsigned,
`size` bigint unsigned,
`physicalSize` bigint unsigned DEFAULT 0,
`download_state` varchar(255),
`error_str` varchar(255),
`local_path` varchar(255),

View File

@ -1,59 +1,6 @@
--
-- Schema upgrade from 2.1 to 2.2
--
CREATE TABLE `cloud`.`instance_group` (
`id` bigint unsigned NOT NULL UNIQUE auto_increment,
`account_id` bigint unsigned NOT NULL COMMENT 'owner. foreign key to account table',
`name` varchar(255) NOT NULL,
`removed` datetime COMMENT 'date the group was removed',
`created` datetime COMMENT 'date the group was created',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`instance_group_vm_map` (
`id` bigint unsigned NOT NULL auto_increment,
`group_id` bigint unsigned NOT NULL,
`instance_id` bigint unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`certificate` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`certificate` text COMMENT 'the actual custom certificate being stored in the db',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`remote_access_vpn` (
`id` bigint unsigned NOT NULL auto_increment,
`account_id` bigint unsigned NOT NULL,
`zone_id` bigint unsigned NOT NULL,
`vpn_server_addr` varchar(15) UNIQUE NOT NULL,
`local_ip` varchar(15) NOT NULL,
`ip_range` varchar(32) NOT NULL,
`ipsec_psk` varchar(256) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`vpn_users` (
`id` bigint unsigned NOT NULL auto_increment,
`account_id` bigint unsigned NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `cloud`.`data_center` MODIFY COLUMN `guest_network_cidr` varchar(18); -- modify column width to 18 from 15
ALTER TABLE `cloud`.`resource_count` ADD COLUMN `domain_id` bigint unsigned; -- add the new column
ALTER TABLE `cloud`.`resource_count` MODIFY COLUMN `account_id` bigint unsigned; -- modify the column to allow NULL values
ALTER TABLE `cloud`.`storage_pool` add COLUMN STATUS varchar(32) not null; -- new status column for maintenance mode support for primary storage
ALTER TABLE `cloud`.`volumes` ADD COLUMN `source_id` bigint unsigned; -- id for the source
ALTER TABLE `cloud`.`volumes` ADD COLUMN `source_type` varchar(32); --source from which the volume is created i.e. snapshot, diskoffering, template, blank
ALTER TABLE `cloud`.`volumes` ADD COLUMN 'attached' datetime; --date and time the volume was attached
ALTER TABLE `cloud`.`disk_offering` ADD COLUMN `customized` tinyint(1) unsigned NOT NULL DEFAULT 0;-- 0 implies not customized by default
ALTER TABLE `cloud`.`user_ip_address` ADD COLUMN `one_to_one_nat` int(1) unsigned NOT NULL default '0'; -- new column for NAT ip
SET foreign_key_checks = 0;
--
-- Schema upgrade from 2.1 to 2.2
--
ALTER TABLE `cloud`.`template_host_ref` ADD COLUMN `physicalSize` bigint unsigned NOT NULL DEFAULT 0;