mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-2590: we should only search for active user templates when
deleting an image store.
This commit is contained in:
parent
2af36aa87b
commit
cb0659ab33
|
|
@ -39,4 +39,6 @@ public interface TemplateJoinDao extends GenericDao<TemplateJoinVO, Long> {
|
|||
|
||||
List<TemplateJoinVO> searchByIds(Long... ids);
|
||||
|
||||
List<TemplateJoinVO> listActiveTemplates(long storeId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
|
|||
|
||||
private final SearchBuilder<TemplateJoinVO> tmpltZoneSearch;
|
||||
|
||||
private final SearchBuilder<TemplateJoinVO> activeTmpltSearch;
|
||||
|
||||
|
||||
protected TemplateJoinDaoImpl() {
|
||||
|
||||
|
|
@ -92,6 +94,11 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
|
|||
tmpltZoneSearch.and("downloadState", tmpltZoneSearch.entity().getDownloadState(), SearchCriteria.Op.EQ);
|
||||
tmpltZoneSearch.done();
|
||||
|
||||
activeTmpltSearch = createSearchBuilder();
|
||||
activeTmpltSearch.and("store_id", activeTmpltSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ);
|
||||
activeTmpltSearch.and("type", activeTmpltSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
||||
activeTmpltSearch.done();
|
||||
|
||||
// select distinct pair (template_id, zone_id)
|
||||
this._count = "select count(distinct id) from template_view WHERE ";
|
||||
}
|
||||
|
|
@ -438,4 +445,15 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
|
|||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<TemplateJoinVO> listActiveTemplates(long storeId) {
|
||||
SearchCriteria<TemplateJoinVO> sc = activeTmpltSearch.create();
|
||||
sc.setParameters("store_id", storeId);
|
||||
sc.setParameters("type", TemplateType.USER);
|
||||
return searchIncludingRemoved(sc, null, null, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,6 +179,9 @@ public class TemplateJoinVO extends BaseViewVO implements ControlledViewEntity {
|
|||
@Column(name="data_center_name")
|
||||
private String dataCenterName;
|
||||
|
||||
@Column(name="store_id")
|
||||
private Long dataStoreId; // this can be null for baremetal templates
|
||||
|
||||
@Column (name="download_state")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Status downloadState;
|
||||
|
|
@ -1003,4 +1006,16 @@ public class TemplateJoinVO extends BaseViewVO implements ControlledViewEntity {
|
|||
|
||||
|
||||
|
||||
public Long getDataStoreId() {
|
||||
return dataStoreId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setDataStoreId(Long dataStoreId) {
|
||||
this.dataStoreId = dataStoreId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -177,7 +177,7 @@ CREATE TABLE `cloud`.`snapshot_store_ref` (
|
|||
`parent_snapshot_id` bigint unsigned DEFAULT 0,
|
||||
`install_path` varchar(255),
|
||||
`state` varchar(255) NOT NULL,
|
||||
`removed` datetime COMMENT 'date removed if not null',
|
||||
-- `removed` datetime COMMENT 'date removed if not null',
|
||||
`update_count` bigint unsigned,
|
||||
`updated` datetime,
|
||||
PRIMARY KEY (`id`),
|
||||
|
|
@ -1752,6 +1752,7 @@ CREATE VIEW `cloud`.`template_view` AS
|
|||
data_center.uuid data_center_uuid,
|
||||
data_center.name data_center_name,
|
||||
launch_permission.account_id lp_account_id,
|
||||
template_store_ref.store_id,
|
||||
template_store_ref.download_state,
|
||||
template_store_ref.download_pct,
|
||||
template_store_ref.error_str,
|
||||
|
|
|
|||
Loading…
Reference in New Issue