mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
bug 9345: Remove pool_id from template_host_ref. Its not needed anymore. Also removed the unwarranted code.
status 9345: resolved fixed
This commit is contained in:
parent
dfd0d7730e
commit
a3cb6d9a09
@ -78,10 +78,7 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc {
|
||||
private String errorString;
|
||||
|
||||
@Column (name="job_id")
|
||||
private String jobId;
|
||||
|
||||
@Column (name="pool_id")
|
||||
private Long poolId;
|
||||
private String jobId;
|
||||
|
||||
@Column (name="install_path")
|
||||
private String installPath;
|
||||
@ -222,17 +219,9 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof VMTemplateHostVO) {
|
||||
VMTemplateHostVO other = (VMTemplateHostVO)obj;
|
||||
if (poolId == null && other.getPoolId() == null) {
|
||||
return (this.templateId==other.getTemplateId() && this.hostId==other.getHostId());
|
||||
} else if (poolId == null && other.getPoolId() != null) {
|
||||
return false;
|
||||
} else if (poolId != null && other.getPoolId() == null) {
|
||||
return false;
|
||||
} else {
|
||||
return (this.templateId==other.getTemplateId() && this.hostId==other.getHostId() && poolId.longValue() == other.getPoolId().longValue());
|
||||
}
|
||||
if (obj instanceof VMTemplateHostVO) {
|
||||
VMTemplateHostVO other = (VMTemplateHostVO)obj;
|
||||
return (this.templateId==other.getTemplateId() && this.hostId==other.getHostId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -241,15 +230,7 @@ public class VMTemplateHostVO implements VMTemplateStorageResourceAssoc {
|
||||
public int hashCode() {
|
||||
Long tid = new Long(templateId);
|
||||
Long hid = new Long(hostId);
|
||||
return tid.hashCode()+hid.hashCode() + ((poolId != null)?poolId.hashCode():0);
|
||||
}
|
||||
|
||||
public void setPoolId(Long poolId) {
|
||||
this.poolId = poolId;
|
||||
}
|
||||
|
||||
public Long getPoolId() {
|
||||
return poolId;
|
||||
return tid.hashCode()+hid.hashCode();
|
||||
}
|
||||
|
||||
public void setSize(long size) {
|
||||
|
||||
@ -38,10 +38,6 @@ public interface VMTemplateHostDao extends GenericDao<VMTemplateHostVO, Long> {
|
||||
|
||||
List<VMTemplateHostVO> listByHostTemplate(long hostId, long templateId);
|
||||
|
||||
VMTemplateHostVO findByHostTemplatePool(long hostId, long templateId, long poolId);
|
||||
|
||||
List<VMTemplateHostVO> listByTemplatePool(long templateId, long poolId);
|
||||
|
||||
void update(VMTemplateHostVO instance);
|
||||
|
||||
List<VMTemplateHostVO> listByTemplateStatus(long templateId, VMTemplateHostVO.Status downloadState);
|
||||
|
||||
@ -55,8 +55,6 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long
|
||||
protected final SearchBuilder<VMTemplateHostVO> HostTemplateSearch;
|
||||
protected final SearchBuilder<VMTemplateHostVO> HostTemplateStateSearch;
|
||||
protected final SearchBuilder<VMTemplateHostVO> HostDestroyedSearch;
|
||||
protected final SearchBuilder<VMTemplateHostVO> PoolTemplateSearch;
|
||||
protected final SearchBuilder<VMTemplateHostVO> HostTemplatePoolSearch;
|
||||
protected final SearchBuilder<VMTemplateHostVO> TemplateStatusSearch;
|
||||
protected final SearchBuilder<VMTemplateHostVO> TemplateStatesSearch;
|
||||
protected SearchBuilder<VMTemplateHostVO> ZONE_TEMPLATE_SEARCH;
|
||||
@ -101,13 +99,7 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long
|
||||
HostDestroyedSearch = createSearchBuilder();
|
||||
HostDestroyedSearch.and("host_id", HostDestroyedSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostDestroyedSearch.and("destroyed", HostDestroyedSearch.entity().getDestroyed(), SearchCriteria.Op.EQ);
|
||||
HostDestroyedSearch.done();
|
||||
|
||||
HostTemplatePoolSearch = createSearchBuilder();
|
||||
HostTemplatePoolSearch.and("host_id", HostTemplatePoolSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostTemplatePoolSearch.and("template_id", HostTemplatePoolSearch.entity().getTemplateId(), SearchCriteria.Op.EQ);
|
||||
HostTemplatePoolSearch.and("pool_id", HostTemplatePoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||
HostTemplatePoolSearch.done();
|
||||
HostDestroyedSearch.done();
|
||||
|
||||
TemplateStatusSearch = createSearchBuilder();
|
||||
TemplateStatusSearch.and("template_id", TemplateStatusSearch.entity().getTemplateId(), SearchCriteria.Op.EQ);
|
||||
@ -124,11 +116,7 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long
|
||||
HostTemplateStateSearch.and("host_id", HostTemplateStateSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
HostTemplateStateSearch.and("states", HostTemplateStateSearch.entity().getDownloadState(), SearchCriteria.Op.IN);
|
||||
HostTemplateStateSearch.done();
|
||||
|
||||
PoolTemplateSearch = createSearchBuilder();
|
||||
PoolTemplateSearch.and("pool_id", PoolTemplateSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||
PoolTemplateSearch.and("template_id", PoolTemplateSearch.entity().getTemplateId(), SearchCriteria.Op.EQ);
|
||||
PoolTemplateSearch.done();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -301,15 +289,6 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long
|
||||
return search(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMTemplateHostVO findByHostTemplatePool(long hostId, long templateId, long poolId) {
|
||||
SearchCriteria<VMTemplateHostVO> sc = HostTemplatePoolSearch.create();
|
||||
sc.setParameters("host_id", hostId);
|
||||
sc.setParameters("template_id", templateId);
|
||||
sc.setParameters("pool_id", poolId);
|
||||
return findOneIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMTemplateHostVO> listByHostTemplate(long hostId, long templateId) {
|
||||
SearchCriteria<VMTemplateHostVO> sc = HostTemplateSearch.create();
|
||||
@ -328,15 +307,7 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long
|
||||
}
|
||||
return listBy(sc);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMTemplateHostVO> listByTemplatePool(long templateId, long poolId) {
|
||||
SearchCriteria<VMTemplateHostVO> sc = PoolTemplateSearch.create();
|
||||
sc.setParameters("pool_id", poolId);
|
||||
sc.setParameters("template_id", templateId);
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMTemplateHostVO> listDestroyed(long hostId) {
|
||||
|
||||
@ -78,6 +78,7 @@ import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.SecondaryStorageVm;
|
||||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
@ -220,7 +221,7 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
||||
String url = generateCopyUrl(sourceServer, srcTmpltHost);
|
||||
if (url == null) {
|
||||
s_logger.warn("Unable to start/resume copy of template " + template.getUniqueName() + " to " + destServer.getName() + ", no secondary storage vm in running state in source zone");
|
||||
throw new StorageUnavailableException("No secondary VM in running state in zone " + sourceServer.getDataCenterId(), srcTmpltHost.getPoolId());
|
||||
throw new CloudRuntimeException("No secondary VM in running state in zone " + sourceServer.getDataCenterId());
|
||||
}
|
||||
destTmpltHost = _vmTemplateHostDao.findByHostTemplate(destServer.getId(), template.getId());
|
||||
if (destTmpltHost == null) {
|
||||
@ -401,38 +402,7 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
||||
VMTemplateHostVO vmTemplateHost = _vmTemplateHostDao.findByHostTemplate(host.getId(), template.getId());
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
if (vmTemplateHost != null) {
|
||||
Long poolId = vmTemplateHost.getPoolId();
|
||||
if (poolId != null) {
|
||||
VMTemplateStoragePoolVO vmTemplatePool = _vmTemplatePoolDao.findByPoolTemplate(poolId, template.getId());
|
||||
StoragePoolHostVO poolHost = _poolHostDao.findByPoolHost(poolId, host.getId());
|
||||
if (vmTemplatePool != null && poolHost != null) {
|
||||
vmTemplatePool.setDownloadPercent(vmTemplateHost.getDownloadPercent());
|
||||
vmTemplatePool.setDownloadState(vmTemplateHost.getDownloadState());
|
||||
vmTemplatePool.setErrorString(vmTemplateHost.getErrorString());
|
||||
String localPath = poolHost.getLocalPath();
|
||||
String installPath = vmTemplateHost.getInstallPath();
|
||||
if (installPath != null) {
|
||||
if (!installPath.startsWith("/")) {
|
||||
installPath = "/" + installPath;
|
||||
}
|
||||
if (!(localPath == null) && !installPath.startsWith(localPath)) {
|
||||
localPath = localPath.replaceAll("/\\p{Alnum}+/*$", ""); //remove instance if necessary
|
||||
}
|
||||
if (!(localPath == null) && installPath.startsWith(localPath)) {
|
||||
installPath = installPath.substring(localPath.length());
|
||||
}
|
||||
}
|
||||
vmTemplatePool.setInstallPath(installPath);
|
||||
vmTemplatePool.setLastUpdated(vmTemplateHost.getLastUpdated());
|
||||
vmTemplatePool.setJobId(vmTemplateHost.getJobId());
|
||||
vmTemplatePool.setLocalDownloadPath(vmTemplateHost.getLocalDownloadPath());
|
||||
_vmTemplatePoolDao.update(vmTemplatePool.getId(),vmTemplatePool);
|
||||
}
|
||||
}
|
||||
}
|
||||
txn.start();
|
||||
|
||||
if (dnldStatus == Status.DOWNLOADED) {
|
||||
long size = -1;
|
||||
|
||||
@ -955,7 +955,6 @@ CREATE TABLE `cloud`.`upload` (
|
||||
CREATE TABLE `cloud`.`template_host_ref` (
|
||||
`id` bigint unsigned NOT NULL auto_increment,
|
||||
`host_id` bigint unsigned NOT NULL,
|
||||
`pool_id` bigint unsigned,
|
||||
`template_id` bigint unsigned NOT NULL,
|
||||
`created` DATETIME NOT NULL,
|
||||
`last_updated` DATETIME,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user