mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-15 18:12:35 +01:00
Remove state from vm_template table, we should use template_store_ref
state column to represent the state of a template in each zone.
This commit is contained in:
parent
c5083a385f
commit
bb85a564da
@ -764,7 +764,6 @@
|
|||||||
<bean id="iSCSI" class="org.apache.cloudstack.storage.datastore.type.ISCSI" />
|
<bean id="iSCSI" class="org.apache.cloudstack.storage.datastore.type.ISCSI" />
|
||||||
<bean id="ISO" class="org.apache.cloudstack.storage.image.format.ISO" />
|
<bean id="ISO" class="org.apache.cloudstack.storage.image.format.ISO" />
|
||||||
<bean id="templateDataFactoryImpl" class="org.apache.cloudstack.storage.image.TemplateDataFactoryImpl" />
|
<bean id="templateDataFactoryImpl" class="org.apache.cloudstack.storage.image.TemplateDataFactoryImpl" />
|
||||||
<bean id="imageDataManagerImpl" class="org.apache.cloudstack.storage.image.manager.ImageDataManagerImpl" />
|
|
||||||
<bean id="imageStoreHelper" class="org.apache.cloudstack.storage.image.datastore.ImageStoreHelper" />
|
<bean id="imageStoreHelper" class="org.apache.cloudstack.storage.image.datastore.ImageStoreHelper" />
|
||||||
<bean id="imageFormatHelper" class="org.apache.cloudstack.storage.image.format.ImageFormatHelper" />
|
<bean id="imageFormatHelper" class="org.apache.cloudstack.storage.image.format.ImageFormatHelper" />
|
||||||
<bean id="templateServiceImpl" class="org.apache.cloudstack.storage.image.TemplateServiceImpl" />
|
<bean id="templateServiceImpl" class="org.apache.cloudstack.storage.image.TemplateServiceImpl" />
|
||||||
|
|||||||
@ -42,7 +42,7 @@ import com.cloud.utils.fsm.StateObject;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "vm_template")
|
@Table(name = "vm_template")
|
||||||
public class VMTemplateVO implements VirtualMachineTemplate, StateObject<TemplateState> {
|
public class VMTemplateVO implements VirtualMachineTemplate {
|
||||||
@Id
|
@Id
|
||||||
@TableGenerator(name = "vm_template_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value",
|
@TableGenerator(name = "vm_template_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value",
|
||||||
pkColumnValue = "vm_template_seq", allocationSize = 1)
|
pkColumnValue = "vm_template_seq", allocationSize = 1)
|
||||||
@ -133,9 +133,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
|
|||||||
@Column(name = "size")
|
@Column(name = "size")
|
||||||
private Long size;
|
private Long size;
|
||||||
|
|
||||||
@Column(name = "state")
|
|
||||||
private TemplateState state;
|
|
||||||
|
|
||||||
@Column(name = "update_count", updatable = true)
|
@Column(name = "update_count", updatable = true)
|
||||||
protected long updatedCount;
|
protected long updatedCount;
|
||||||
|
|
||||||
@ -157,7 +154,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
|
|||||||
|
|
||||||
public VMTemplateVO() {
|
public VMTemplateVO() {
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.state = TemplateState.Allocated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,7 +167,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
|
|||||||
null, requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType,
|
null, requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType,
|
||||||
details);
|
details);
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.state = TemplateState.Allocated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured,
|
public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured,
|
||||||
@ -182,7 +177,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
|
|||||||
displayText, enablePassword, guestOSId, bootable, hyperType, details);
|
displayText, enablePassword, guestOSId, bootable, hyperType, details);
|
||||||
this.templateTag = templateTag;
|
this.templateTag = templateTag;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.state = TemplateState.Allocated;
|
|
||||||
this.enableSshKey = sshKeyEnabled;
|
this.enableSshKey = sshKeyEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +186,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
|
|||||||
boolean bootable, HypervisorType hyperType) {
|
boolean bootable, HypervisorType hyperType) {
|
||||||
VMTemplateVO template = new VMTemplateVO(id, uniqueName, name, format, isPublic, featured, type, url, created,
|
VMTemplateVO template = new VMTemplateVO(id, uniqueName, name, format, isPublic, featured, type, url, created,
|
||||||
requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType);
|
requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType);
|
||||||
template.state = TemplateState.Ready;
|
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +212,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
|
|||||||
this.bootable = bootable;
|
this.bootable = bootable;
|
||||||
this.hypervisorType = hyperType;
|
this.hypervisorType = hyperType;
|
||||||
this.uuid = UUID.randomUUID().toString();
|
this.uuid = UUID.randomUUID().toString();
|
||||||
this.state = TemplateState.Allocated;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has an extra attribute - isExtractable
|
// Has an extra attribute - isExtractable
|
||||||
@ -532,10 +524,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
|
|||||||
return this.size;
|
return this.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TemplateState getState() {
|
|
||||||
return this.state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getUpdatedCount() {
|
public long getUpdatedCount() {
|
||||||
return this.updatedCount;
|
return this.updatedCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,8 +30,7 @@ import com.cloud.utils.fsm.StateDao;
|
|||||||
/*
|
/*
|
||||||
* Data Access Object for vm_templates table
|
* Data Access Object for vm_templates table
|
||||||
*/
|
*/
|
||||||
public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long>,
|
public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long> {
|
||||||
StateDao<TemplateState, TemplateEvent, VMTemplateVO> {
|
|
||||||
|
|
||||||
public List<VMTemplateVO> listByPublic();
|
public List<VMTemplateVO> listByPublic();
|
||||||
|
|
||||||
|
|||||||
@ -102,7 +102,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
private SearchBuilder<VMTemplateVO> PublicIsoSearch;
|
private SearchBuilder<VMTemplateVO> PublicIsoSearch;
|
||||||
private SearchBuilder<VMTemplateVO> UserIsoSearch;
|
private SearchBuilder<VMTemplateVO> UserIsoSearch;
|
||||||
private GenericSearchBuilder<VMTemplateVO, Long> CountTemplatesByAccount;
|
private GenericSearchBuilder<VMTemplateVO, Long> CountTemplatesByAccount;
|
||||||
private SearchBuilder<VMTemplateVO> updateStateSearch;
|
// private SearchBuilder<VMTemplateVO> updateStateSearch;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ResourceTagDao _tagsDao;
|
ResourceTagDao _tagsDao;
|
||||||
@ -369,11 +369,11 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
CountTemplatesByAccount.and("removed", CountTemplatesByAccount.entity().getRemoved(), SearchCriteria.Op.NULL);
|
CountTemplatesByAccount.and("removed", CountTemplatesByAccount.entity().getRemoved(), SearchCriteria.Op.NULL);
|
||||||
CountTemplatesByAccount.done();
|
CountTemplatesByAccount.done();
|
||||||
|
|
||||||
updateStateSearch = this.createSearchBuilder();
|
// updateStateSearch = this.createSearchBuilder();
|
||||||
updateStateSearch.and("id", updateStateSearch.entity().getId(), Op.EQ);
|
// updateStateSearch.and("id", updateStateSearch.entity().getId(), Op.EQ);
|
||||||
updateStateSearch.and("state", updateStateSearch.entity().getState(), Op.EQ);
|
// updateStateSearch.and("state", updateStateSearch.entity().getState(), Op.EQ);
|
||||||
updateStateSearch.and("updatedCount", updateStateSearch.entity().getUpdatedCount(), Op.EQ);
|
// updateStateSearch.and("updatedCount", updateStateSearch.entity().getUpdatedCount(), Op.EQ);
|
||||||
updateStateSearch.done();
|
// updateStateSearch.done();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -390,25 +390,25 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* pageSize, Long startIndex, Long zoneId, HypervisorType hyperType, boolean
|
* pageSize, Long startIndex, Long zoneId, HypervisorType hyperType, boolean
|
||||||
* onlyReady, boolean showDomr, List<Account> permittedAccounts, Account
|
* onlyReady, boolean showDomr, List<Account> permittedAccounts, Account
|
||||||
* caller, Map<String, String> tags) {
|
* caller, Map<String, String> tags) {
|
||||||
*
|
*
|
||||||
* StringBuilder builder = new StringBuilder(); if
|
* StringBuilder builder = new StringBuilder(); if
|
||||||
* (!permittedAccounts.isEmpty()) { for (Account permittedAccount :
|
* (!permittedAccounts.isEmpty()) { for (Account permittedAccount :
|
||||||
* permittedAccounts) { builder.append(permittedAccount.getAccountId() +
|
* permittedAccounts) { builder.append(permittedAccount.getAccountId() +
|
||||||
* ","); } }
|
* ","); } }
|
||||||
*
|
*
|
||||||
* String permittedAccountsStr = builder.toString();
|
* String permittedAccountsStr = builder.toString();
|
||||||
*
|
*
|
||||||
* if (permittedAccountsStr.length() > 0) { // chop the "," off
|
* if (permittedAccountsStr.length() > 0) { // chop the "," off
|
||||||
* permittedAccountsStr = permittedAccountsStr.substring(0,
|
* permittedAccountsStr = permittedAccountsStr.substring(0,
|
||||||
* permittedAccountsStr.length() - 1); }
|
* permittedAccountsStr.length() - 1); }
|
||||||
*
|
*
|
||||||
* Transaction txn = Transaction.currentTxn(); txn.start();
|
* Transaction txn = Transaction.currentTxn(); txn.start();
|
||||||
*
|
*
|
||||||
* Set<Pair<Long, Long>> templateZonePairList = new HashSet<Pair<Long,
|
* Set<Pair<Long, Long>> templateZonePairList = new HashSet<Pair<Long,
|
||||||
* Long>>(); PreparedStatement pstmt = null; ResultSet rs = null; String sql
|
* Long>>(); PreparedStatement pstmt = null; ResultSet rs = null; String sql
|
||||||
* = SELECT_TEMPLATE_SWIFT_REF; try { String joinClause = ""; String
|
* = SELECT_TEMPLATE_SWIFT_REF; try { String joinClause = ""; String
|
||||||
* whereClause = " WHERE t.removed IS NULL";
|
* whereClause = " WHERE t.removed IS NULL";
|
||||||
*
|
*
|
||||||
* if (isIso) { whereClause += " AND t.format = 'ISO'"; if
|
* if (isIso) { whereClause += " AND t.format = 'ISO'"; if
|
||||||
* (!hyperType.equals(HypervisorType.None)) { joinClause =
|
* (!hyperType.equals(HypervisorType.None)) { joinClause =
|
||||||
* " INNER JOIN guest_os guestOS on (guestOS.id = t.guest_os_id) INNER JOIN guest_os_hypervisor goh on ( goh.guest_os_id = guestOS.id) "
|
* " INNER JOIN guest_os guestOS on (guestOS.id = t.guest_os_id) INNER JOIN guest_os_hypervisor goh on ( goh.guest_os_id = guestOS.id) "
|
||||||
@ -424,12 +424,12 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* (keyword != null) { whereClause += " AND t.name LIKE \"%" + keyword +
|
* (keyword != null) { whereClause += " AND t.name LIKE \"%" + keyword +
|
||||||
* "%\""; } else if (name != null) { whereClause += " AND t.name LIKE \"%" +
|
* "%\""; } else if (name != null) { whereClause += " AND t.name LIKE \"%" +
|
||||||
* name + "%\""; }
|
* name + "%\""; }
|
||||||
*
|
*
|
||||||
* if (bootable != null) { whereClause += " AND t.bootable = " + bootable; }
|
* if (bootable != null) { whereClause += " AND t.bootable = " + bootable; }
|
||||||
*
|
*
|
||||||
* if (!showDomr) { whereClause += " AND t.type != '" +
|
* if (!showDomr) { whereClause += " AND t.type != '" +
|
||||||
* Storage.TemplateType.SYSTEM.toString() + "'"; }
|
* Storage.TemplateType.SYSTEM.toString() + "'"; }
|
||||||
*
|
*
|
||||||
* if (templateFilter == TemplateFilter.featured) { whereClause +=
|
* if (templateFilter == TemplateFilter.featured) { whereClause +=
|
||||||
* " AND t.public = 1 AND t.featured = 1"; } else if ((templateFilter ==
|
* " AND t.public = 1 AND t.featured = 1"; } else if ((templateFilter ==
|
||||||
* TemplateFilter.self || templateFilter == TemplateFilter.selfexecutable)
|
* TemplateFilter.self || templateFilter == TemplateFilter.selfexecutable)
|
||||||
@ -455,20 +455,20 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* TemplateFilter.all && caller.getType() == Account.ACCOUNT_TYPE_ADMIN) { }
|
* TemplateFilter.all && caller.getType() == Account.ACCOUNT_TYPE_ADMIN) { }
|
||||||
* else if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) { return
|
* else if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) { return
|
||||||
* templateZonePairList; }
|
* templateZonePairList; }
|
||||||
*
|
*
|
||||||
* sql += joinClause + whereClause + getOrderByLimit(pageSize, startIndex);
|
* sql += joinClause + whereClause + getOrderByLimit(pageSize, startIndex);
|
||||||
* pstmt = txn.prepareStatement(sql); rs = pstmt.executeQuery(); while
|
* pstmt = txn.prepareStatement(sql); rs = pstmt.executeQuery(); while
|
||||||
* (rs.next()) { Pair<Long, Long> templateZonePair = new Pair<Long,
|
* (rs.next()) { Pair<Long, Long> templateZonePair = new Pair<Long,
|
||||||
* Long>(rs.getLong(1), -1L); templateZonePairList.add(templateZonePair); }
|
* Long>(rs.getLong(1), -1L); templateZonePairList.add(templateZonePair); }
|
||||||
*
|
*
|
||||||
* } catch (Exception e) { s_logger.warn("Error listing templates", e); }
|
* } catch (Exception e) { s_logger.warn("Error listing templates", e); }
|
||||||
* finally { try { if (rs != null) { rs.close(); } if (pstmt != null) {
|
* finally { try { if (rs != null) { rs.close(); } if (pstmt != null) {
|
||||||
* pstmt.close(); } txn.commit(); } catch (SQLException sqle) {
|
* pstmt.close(); } txn.commit(); } catch (SQLException sqle) {
|
||||||
* s_logger.warn("Error in cleaning up", sqle); } }
|
* s_logger.warn("Error in cleaning up", sqle); } }
|
||||||
*
|
*
|
||||||
* return templateZonePairList; }
|
* return templateZonePairList; }
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @Override public Set<Pair<Long, Long>> searchTemplates(String name,
|
* @Override public Set<Pair<Long, Long>> searchTemplates(String name,
|
||||||
* String keyword, TemplateFilter templateFilter, boolean isIso,
|
* String keyword, TemplateFilter templateFilter, boolean isIso,
|
||||||
* List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long
|
* List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long
|
||||||
@ -479,15 +479,15 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* StringBuilder(); if (!permittedAccounts.isEmpty()) { for (Account
|
* StringBuilder(); if (!permittedAccounts.isEmpty()) { for (Account
|
||||||
* permittedAccount : permittedAccounts) {
|
* permittedAccount : permittedAccounts) {
|
||||||
* builder.append(permittedAccount.getAccountId() + ","); } }
|
* builder.append(permittedAccount.getAccountId() + ","); } }
|
||||||
*
|
*
|
||||||
* String permittedAccountsStr = builder.toString();
|
* String permittedAccountsStr = builder.toString();
|
||||||
*
|
*
|
||||||
* if (permittedAccountsStr.length() > 0) { //chop the "," off
|
* if (permittedAccountsStr.length() > 0) { //chop the "," off
|
||||||
* permittedAccountsStr = permittedAccountsStr.substring(0,
|
* permittedAccountsStr = permittedAccountsStr.substring(0,
|
||||||
* permittedAccountsStr.length()-1); }
|
* permittedAccountsStr.length()-1); }
|
||||||
*
|
*
|
||||||
* Transaction txn = Transaction.currentTxn(); txn.start();
|
* Transaction txn = Transaction.currentTxn(); txn.start();
|
||||||
*
|
*
|
||||||
* // Use LinkedHashSet here to guarantee iteration order Set<Pair<Long,
|
* // Use LinkedHashSet here to guarantee iteration order Set<Pair<Long,
|
||||||
* Long>> templateZonePairList = new LinkedHashSet<Pair<Long, Long>>();
|
* Long>> templateZonePairList = new LinkedHashSet<Pair<Long, Long>>();
|
||||||
* PreparedStatement pstmt = null; ResultSet rs = null; StringBuilder
|
* PreparedStatement pstmt = null; ResultSet rs = null; StringBuilder
|
||||||
@ -496,7 +496,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* accountType; //String accountId = null; String guestOSJoin = "";
|
* accountType; //String accountId = null; String guestOSJoin = "";
|
||||||
* StringBuilder templateHostRefJoin = new StringBuilder(); String
|
* StringBuilder templateHostRefJoin = new StringBuilder(); String
|
||||||
* dataCenterJoin = "", lpjoin = ""; String tagsJoin = "";
|
* dataCenterJoin = "", lpjoin = ""; String tagsJoin = "";
|
||||||
*
|
*
|
||||||
* if (isIso && !hyperType.equals(HypervisorType.None)) { guestOSJoin =
|
* if (isIso && !hyperType.equals(HypervisorType.None)) { guestOSJoin =
|
||||||
* " INNER JOIN guest_os guestOS on (guestOS.id = t.guest_os_id) INNER JOIN guest_os_hypervisor goh on ( goh.guest_os_id = guestOS.id) "
|
* " INNER JOIN guest_os guestOS on (guestOS.id = t.guest_os_id) INNER JOIN guest_os_hypervisor goh on ( goh.guest_os_id = guestOS.id) "
|
||||||
* ; } if (onlyReady){ templateHostRefJoin.append(
|
* ; } if (onlyReady){ templateHostRefJoin.append(
|
||||||
@ -506,22 +506,22 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* TemplateFilter.featured) || (templateFilter == TemplateFilter.community))
|
* TemplateFilter.featured) || (templateFilter == TemplateFilter.community))
|
||||||
* { dataCenterJoin =
|
* { dataCenterJoin =
|
||||||
* " INNER JOIN data_center dc on (h.data_center_id = dc.id)"; }
|
* " INNER JOIN data_center dc on (h.data_center_id = dc.id)"; }
|
||||||
*
|
*
|
||||||
* if (zoneType != null) { dataCenterJoin =
|
* if (zoneType != null) { dataCenterJoin =
|
||||||
* " INNER JOIN template_host_ref thr on (t.id = thr.template_id) INNER JOIN host h on (thr.host_id = h.id)"
|
* " INNER JOIN template_host_ref thr on (t.id = thr.template_id) INNER JOIN host h on (thr.host_id = h.id)"
|
||||||
* ; dataCenterJoin +=
|
* ; dataCenterJoin +=
|
||||||
* " INNER JOIN data_center dc on (h.data_center_id = dc.id)"; }
|
* " INNER JOIN data_center dc on (h.data_center_id = dc.id)"; }
|
||||||
*
|
*
|
||||||
* if (templateFilter == TemplateFilter.sharedexecutable || templateFilter
|
* if (templateFilter == TemplateFilter.sharedexecutable || templateFilter
|
||||||
* == TemplateFilter.shared ){ lpjoin =
|
* == TemplateFilter.shared ){ lpjoin =
|
||||||
* " INNER JOIN launch_permission lp ON t.id = lp.template_id "; }
|
* " INNER JOIN launch_permission lp ON t.id = lp.template_id "; }
|
||||||
*
|
*
|
||||||
* if (tags != null && !tags.isEmpty()) { tagsJoin =
|
* if (tags != null && !tags.isEmpty()) { tagsJoin =
|
||||||
* " INNER JOIN resource_tags r ON t.id = r.resource_id "; }
|
* " INNER JOIN resource_tags r ON t.id = r.resource_id "; }
|
||||||
*
|
*
|
||||||
* sql += guestOSJoin + templateHostRefJoin + dataCenterJoin + lpjoin +
|
* sql += guestOSJoin + templateHostRefJoin + dataCenterJoin + lpjoin +
|
||||||
* tagsJoin; String whereClause = "";
|
* tagsJoin; String whereClause = "";
|
||||||
*
|
*
|
||||||
* //All joins have to be made before we start setting the condition
|
* //All joins have to be made before we start setting the condition
|
||||||
* settings if ((listProjectResourcesCriteria ==
|
* settings if ((listProjectResourcesCriteria ==
|
||||||
* ListProjectResourcesCriteria.SkipProjectResources ||
|
* ListProjectResourcesCriteria.SkipProjectResources ||
|
||||||
@ -541,19 +541,19 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* (listProjectResourcesCriteria ==
|
* (listProjectResourcesCriteria ==
|
||||||
* ListProjectResourcesCriteria.SkipProjectResources) { whereClause +=
|
* ListProjectResourcesCriteria.SkipProjectResources) { whereClause +=
|
||||||
* " WHERE a.type != " + Account.ACCOUNT_TYPE_PROJECT; } }
|
* " WHERE a.type != " + Account.ACCOUNT_TYPE_PROJECT; } }
|
||||||
*
|
*
|
||||||
* if (!permittedAccounts.isEmpty()) { for (Account account :
|
* if (!permittedAccounts.isEmpty()) { for (Account account :
|
||||||
* permittedAccounts) { //accountType = account.getType(); //accountId =
|
* permittedAccounts) { //accountType = account.getType(); //accountId =
|
||||||
* Long.toString(account.getId()); DomainVO accountDomain =
|
* Long.toString(account.getId()); DomainVO accountDomain =
|
||||||
* _domainDao.findById(account.getDomainId());
|
* _domainDao.findById(account.getDomainId());
|
||||||
*
|
*
|
||||||
* // get all parent domain ID's all the way till root domain DomainVO
|
* // get all parent domain ID's all the way till root domain DomainVO
|
||||||
* domainTreeNode = accountDomain; while (true) {
|
* domainTreeNode = accountDomain; while (true) {
|
||||||
* relatedDomainIds.append(domainTreeNode.getId());
|
* relatedDomainIds.append(domainTreeNode.getId());
|
||||||
* relatedDomainIds.append(","); if (domainTreeNode.getParent() != null) {
|
* relatedDomainIds.append(","); if (domainTreeNode.getParent() != null) {
|
||||||
* domainTreeNode = _domainDao.findById(domainTreeNode.getParent()); } else
|
* domainTreeNode = _domainDao.findById(domainTreeNode.getParent()); } else
|
||||||
* { break; } }
|
* { break; } }
|
||||||
*
|
*
|
||||||
* // get all child domain ID's if (isAdmin(account.getType()) ) {
|
* // get all child domain ID's if (isAdmin(account.getType()) ) {
|
||||||
* List<DomainVO> allChildDomains =
|
* List<DomainVO> allChildDomains =
|
||||||
* _domainDao.findAllChildren(accountDomain.getPath(),
|
* _domainDao.findAllChildren(accountDomain.getPath(),
|
||||||
@ -561,10 +561,10 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* relatedDomainIds.append(childDomain.getId());
|
* relatedDomainIds.append(childDomain.getId());
|
||||||
* relatedDomainIds.append(","); } }
|
* relatedDomainIds.append(","); } }
|
||||||
* relatedDomainIds.setLength(relatedDomainIds.length()-1); } }
|
* relatedDomainIds.setLength(relatedDomainIds.length()-1); } }
|
||||||
*
|
*
|
||||||
* String attr = " AND "; if (whereClause.endsWith(" WHERE ")) { attr +=
|
* String attr = " AND "; if (whereClause.endsWith(" WHERE ")) { attr +=
|
||||||
* " WHERE "; }
|
* " WHERE "; }
|
||||||
*
|
*
|
||||||
* if (!isIso) { if ( hypers.isEmpty() ) { return templateZonePairList; }
|
* if (!isIso) { if ( hypers.isEmpty() ) { return templateZonePairList; }
|
||||||
* else { StringBuilder relatedHypers = new StringBuilder(); for
|
* else { StringBuilder relatedHypers = new StringBuilder(); for
|
||||||
* (HypervisorType hyper : hypers ) { relatedHypers.append("'");
|
* (HypervisorType hyper : hypers ) { relatedHypers.append("'");
|
||||||
@ -572,14 +572,14 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* relatedHypers.append(","); }
|
* relatedHypers.append(","); }
|
||||||
* relatedHypers.setLength(relatedHypers.length()-1); whereClause += attr +
|
* relatedHypers.setLength(relatedHypers.length()-1); whereClause += attr +
|
||||||
* " t.hypervisor_type IN (" + relatedHypers + ")"; } }
|
* " t.hypervisor_type IN (" + relatedHypers + ")"; } }
|
||||||
*
|
*
|
||||||
* if (!permittedAccounts.isEmpty() && !(templateFilter ==
|
* if (!permittedAccounts.isEmpty() && !(templateFilter ==
|
||||||
* TemplateFilter.featured || templateFilter == TemplateFilter.community ||
|
* TemplateFilter.featured || templateFilter == TemplateFilter.community ||
|
||||||
* templateFilter == TemplateFilter.executable || templateFilter ==
|
* templateFilter == TemplateFilter.executable || templateFilter ==
|
||||||
* TemplateFilter.shared || templateFilter ==
|
* TemplateFilter.shared || templateFilter ==
|
||||||
* TemplateFilter.sharedexecutable) && !isAdmin(caller.getType()) ) {
|
* TemplateFilter.sharedexecutable) && !isAdmin(caller.getType()) ) {
|
||||||
* whereClause += attr + "t.account_id IN (" + permittedAccountsStr + ")"; }
|
* whereClause += attr + "t.account_id IN (" + permittedAccountsStr + ")"; }
|
||||||
*
|
*
|
||||||
* if (templateFilter == TemplateFilter.featured) { whereClause += attr +
|
* if (templateFilter == TemplateFilter.featured) { whereClause += attr +
|
||||||
* "t.public = 1 AND t.featured = 1"; if (!permittedAccounts.isEmpty()) {
|
* "t.public = 1 AND t.featured = 1"; if (!permittedAccounts.isEmpty()) {
|
||||||
* whereClause += attr + "(dc.domain_id IN (" + relatedDomainIds +
|
* whereClause += attr + "(dc.domain_id IN (" + relatedDomainIds +
|
||||||
@ -599,22 +599,22 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* "(dc.domain_id IN (" + relatedDomainIds + ") OR dc.domain_id is NULL)"; }
|
* "(dc.domain_id IN (" + relatedDomainIds + ") OR dc.domain_id is NULL)"; }
|
||||||
* } else if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && !isIso) {
|
* } else if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && !isIso) {
|
||||||
* return templateZonePairList; }
|
* return templateZonePairList; }
|
||||||
*
|
*
|
||||||
* if (tags != null && !tags.isEmpty()) { whereClause += " AND ("; boolean
|
* if (tags != null && !tags.isEmpty()) { whereClause += " AND ("; boolean
|
||||||
* first = true; for (String key : tags.keySet()) { if (!first) {
|
* first = true; for (String key : tags.keySet()) { if (!first) {
|
||||||
* whereClause += " OR "; } whereClause += "(r.key=\"" + key +
|
* whereClause += " OR "; } whereClause += "(r.key=\"" + key +
|
||||||
* "\" and r.value=\"" + tags.get(key) + "\")"; first = false; } whereClause
|
* "\" and r.value=\"" + tags.get(key) + "\")"; first = false; } whereClause
|
||||||
* += ")"; }
|
* += ")"; }
|
||||||
*
|
*
|
||||||
* if (whereClause.equals("")) { whereClause += " WHERE "; } else if
|
* if (whereClause.equals("")) { whereClause += " WHERE "; } else if
|
||||||
* (!whereClause.equals(" WHERE ")) { whereClause += " AND "; }
|
* (!whereClause.equals(" WHERE ")) { whereClause += " AND "; }
|
||||||
*
|
*
|
||||||
* sql += whereClause + getExtrasWhere(templateFilter, name, keyword, isIso,
|
* sql += whereClause + getExtrasWhere(templateFilter, name, keyword, isIso,
|
||||||
* bootable, hyperType, zoneId, onlyReady, showDomr, zoneType) +
|
* bootable, hyperType, zoneId, onlyReady, showDomr, zoneType) +
|
||||||
* groupByClause + getOrderByLimit(pageSize, startIndex);
|
* groupByClause + getOrderByLimit(pageSize, startIndex);
|
||||||
*
|
*
|
||||||
* pstmt = txn.prepareStatement(sql); rs = pstmt.executeQuery();
|
* pstmt = txn.prepareStatement(sql); rs = pstmt.executeQuery();
|
||||||
*
|
*
|
||||||
* while (rs.next()) { Pair<Long, Long> templateZonePair = new Pair<Long,
|
* while (rs.next()) { Pair<Long, Long> templateZonePair = new Pair<Long,
|
||||||
* Long>(rs.getLong(1), rs.getLong(2));
|
* Long>(rs.getLong(1), rs.getLong(2));
|
||||||
* templateZonePairList.add(templateZonePair); } //for now, defaulting
|
* templateZonePairList.add(templateZonePair); } //for now, defaulting
|
||||||
@ -623,18 +623,18 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* templateFilter != TemplateFilter.community && !(templateFilter ==
|
* templateFilter != TemplateFilter.community && !(templateFilter ==
|
||||||
* TemplateFilter.self && !BaseCmd.isRootAdmin(caller.getType())) ){
|
* TemplateFilter.self && !BaseCmd.isRootAdmin(caller.getType())) ){
|
||||||
* //evaluates to true If root admin and filter=self
|
* //evaluates to true If root admin and filter=self
|
||||||
*
|
*
|
||||||
* List<VMTemplateVO> publicIsos = publicIsoSearch(bootable, false, tags);
|
* List<VMTemplateVO> publicIsos = publicIsoSearch(bootable, false, tags);
|
||||||
* List<VMTemplateVO> userIsos = userIsoSearch(false);
|
* List<VMTemplateVO> userIsos = userIsoSearch(false);
|
||||||
*
|
*
|
||||||
* //Listing the ISOs according to the page size.Restricting the total no.
|
* //Listing the ISOs according to the page size.Restricting the total no.
|
||||||
* of ISOs on a page //to be less than or equal to the pageSize parameter
|
* of ISOs on a page //to be less than or equal to the pageSize parameter
|
||||||
*
|
*
|
||||||
* int i=0;
|
* int i=0;
|
||||||
*
|
*
|
||||||
* if (startIndex > userIsos.size()) { i=(int) (startIndex -
|
* if (startIndex > userIsos.size()) { i=(int) (startIndex -
|
||||||
* userIsos.size()); }
|
* userIsos.size()); }
|
||||||
*
|
*
|
||||||
* for (; i < publicIsos.size(); i++) { if(templateZonePairList.size() >=
|
* for (; i < publicIsos.size(); i++) { if(templateZonePairList.size() >=
|
||||||
* pageSize){ break; } else { if (keyword != null &&
|
* pageSize){ break; } else { if (keyword != null &&
|
||||||
* publicIsos.get(i).getName().contains(keyword)) {
|
* publicIsos.get(i).getName().contains(keyword)) {
|
||||||
@ -649,7 +649,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* null) { rs.close(); } if (pstmt != null) { pstmt.close(); } txn.commit();
|
* null) { rs.close(); } if (pstmt != null) { pstmt.close(); } txn.commit();
|
||||||
* } catch( SQLException sqle) { s_logger.warn("Error in cleaning up",
|
* } catch( SQLException sqle) { s_logger.warn("Error in cleaning up",
|
||||||
* sqle); } }
|
* sqle); } }
|
||||||
*
|
*
|
||||||
* return templateZonePairList; }
|
* return templateZonePairList; }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -660,39 +660,39 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* zoneType) { String sql = ""; if (keyword != null) { sql +=
|
* zoneType) { String sql = ""; if (keyword != null) { sql +=
|
||||||
* " t.name LIKE \"%" + keyword + "%\" AND"; } else if (name != null) { sql
|
* " t.name LIKE \"%" + keyword + "%\" AND"; } else if (name != null) { sql
|
||||||
* += " t.name LIKE \"%" + name + "%\" AND"; }
|
* += " t.name LIKE \"%" + name + "%\" AND"; }
|
||||||
*
|
*
|
||||||
* if (isIso) { sql += " t.format = 'ISO'"; if
|
* if (isIso) { sql += " t.format = 'ISO'"; if
|
||||||
* (!hyperType.equals(HypervisorType.None)) { sql +=
|
* (!hyperType.equals(HypervisorType.None)) { sql +=
|
||||||
* " AND goh.hypervisor_type = '" + hyperType.toString() + "'"; } } else {
|
* " AND goh.hypervisor_type = '" + hyperType.toString() + "'"; } } else {
|
||||||
* sql += " t.format <> 'ISO'"; if (!hyperType.equals(HypervisorType.None))
|
* sql += " t.format <> 'ISO'"; if (!hyperType.equals(HypervisorType.None))
|
||||||
* { sql += " AND t.hypervisor_type = '" + hyperType.toString() + "'"; } }
|
* { sql += " AND t.hypervisor_type = '" + hyperType.toString() + "'"; } }
|
||||||
*
|
*
|
||||||
* if (bootable != null) { sql += " AND t.bootable = " + bootable; }
|
* if (bootable != null) { sql += " AND t.bootable = " + bootable; }
|
||||||
*
|
*
|
||||||
* if (onlyReady){ sql += " AND thr.download_state = '"
|
* if (onlyReady){ sql += " AND thr.download_state = '"
|
||||||
* +Status.DOWNLOADED.toString() + "'" + " AND thr.destroyed=0 "; if (zoneId
|
* +Status.DOWNLOADED.toString() + "'" + " AND thr.destroyed=0 "; if (zoneId
|
||||||
* != null){ sql += " AND h.data_center_id = " +zoneId; } }else if (zoneId
|
* != null){ sql += " AND h.data_center_id = " +zoneId; } }else if (zoneId
|
||||||
* != null){ sql += " AND tzr.zone_id = " +zoneId+
|
* != null){ sql += " AND tzr.zone_id = " +zoneId+
|
||||||
* " AND tzr.removed is null" ; }else{ sql += " AND tzr.removed is null "; }
|
* " AND tzr.removed is null" ; }else{ sql += " AND tzr.removed is null "; }
|
||||||
*
|
*
|
||||||
* if (zoneType != null){ sql += " AND dc.networktype = '" + zoneType + "'";
|
* if (zoneType != null){ sql += " AND dc.networktype = '" + zoneType + "'";
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (!showDomr){ sql += " AND t.type != '"
|
* if (!showDomr){ sql += " AND t.type != '"
|
||||||
* +Storage.TemplateType.SYSTEM.toString() + "'"; }
|
* +Storage.TemplateType.SYSTEM.toString() + "'"; }
|
||||||
*
|
*
|
||||||
* sql += " AND t.removed IS NULL";
|
* sql += " AND t.removed IS NULL";
|
||||||
*
|
*
|
||||||
* return sql; }
|
* return sql; }
|
||||||
*
|
*
|
||||||
* private String getOrderByLimit(Long pageSize, Long startIndex) { Boolean
|
* private String getOrderByLimit(Long pageSize, Long startIndex) { Boolean
|
||||||
* isAscending =
|
* isAscending =
|
||||||
* Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm"));
|
* Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm"));
|
||||||
* isAscending = (isAscending == null ? true : isAscending);
|
* isAscending = (isAscending == null ? true : isAscending);
|
||||||
*
|
*
|
||||||
* String sql; if (isAscending) { sql = " ORDER BY t.sort_key ASC"; } else {
|
* String sql; if (isAscending) { sql = " ORDER BY t.sort_key ASC"; } else {
|
||||||
* sql = " ORDER BY t.sort_key DESC"; }
|
* sql = " ORDER BY t.sort_key DESC"; }
|
||||||
*
|
*
|
||||||
* if ((pageSize != null) && (startIndex != null)) { sql += " LIMIT " +
|
* if ((pageSize != null) && (startIndex != null)) { sql += " LIMIT " +
|
||||||
* startIndex.toString() + "," + pageSize.toString(); } return sql; }
|
* startIndex.toString() + "," + pageSize.toString(); } return sql; }
|
||||||
*/
|
*/
|
||||||
@ -849,17 +849,17 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* Long zoneId, final HypervisorType hyperType, final boolean onlyReady,
|
* Long zoneId, final HypervisorType hyperType, final boolean onlyReady,
|
||||||
* final boolean showDomr, final List<Account> permittedAccounts, final
|
* final boolean showDomr, final List<Account> permittedAccounts, final
|
||||||
* Account caller, final Map<String, String> tags) {
|
* Account caller, final Map<String, String> tags) {
|
||||||
*
|
*
|
||||||
* final String permittedAccountsStr = join(",", permittedAccounts);
|
* final String permittedAccountsStr = join(",", permittedAccounts);
|
||||||
*
|
*
|
||||||
* final Transaction txn = Transaction.currentTxn(); txn.start();
|
* final Transaction txn = Transaction.currentTxn(); txn.start();
|
||||||
*
|
*
|
||||||
* Set<Pair<Long, Long>> templateZonePairList = new HashSet<Pair<Long,
|
* Set<Pair<Long, Long>> templateZonePairList = new HashSet<Pair<Long,
|
||||||
* Long>>(); PreparedStatement pstmt = null; ResultSet rs = null; try {
|
* Long>>(); PreparedStatement pstmt = null; ResultSet rs = null; try {
|
||||||
*
|
*
|
||||||
* final StringBuilder joinClause = new StringBuilder(); final StringBuilder
|
* final StringBuilder joinClause = new StringBuilder(); final StringBuilder
|
||||||
* whereClause = new StringBuilder(" WHERE t.removed IS NULL");
|
* whereClause = new StringBuilder(" WHERE t.removed IS NULL");
|
||||||
*
|
*
|
||||||
* if (isIso) { whereClause.append(" AND t.format = 'ISO'"); if
|
* if (isIso) { whereClause.append(" AND t.format = 'ISO'"); if
|
||||||
* (!hyperType.equals(HypervisorType.None)) { joinClause.append(
|
* (!hyperType.equals(HypervisorType.None)) { joinClause.append(
|
||||||
* " INNER JOIN guest_os guestOS on (guestOS.id = t.guest_os_id) INNER JOIN guest_os_hypervisor goh on ( goh.guest_os_id = guestOS.id) "
|
* " INNER JOIN guest_os guestOS on (guestOS.id = t.guest_os_id) INNER JOIN guest_os_hypervisor goh on ( goh.guest_os_id = guestOS.id) "
|
||||||
@ -873,20 +873,20 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* relatedHypers.setLength(relatedHypers.length() - 1);
|
* relatedHypers.setLength(relatedHypers.length() - 1);
|
||||||
* whereClause.append(" AND t.hypervisor_type IN (");
|
* whereClause.append(" AND t.hypervisor_type IN (");
|
||||||
* whereClause.append(relatedHypers); whereClause.append(")"); } }
|
* whereClause.append(relatedHypers); whereClause.append(")"); } }
|
||||||
*
|
*
|
||||||
* joinClause.append(
|
* joinClause.append(
|
||||||
* " INNER JOIN template_s3_ref tsr on (t.id = tsr.template_id)");
|
* " INNER JOIN template_s3_ref tsr on (t.id = tsr.template_id)");
|
||||||
*
|
*
|
||||||
* whereClause.append("AND t.name LIKE \"%"); whereClause.append(keyword ==
|
* whereClause.append("AND t.name LIKE \"%"); whereClause.append(keyword ==
|
||||||
* null ? keyword : name); whereClause.append("%\"");
|
* null ? keyword : name); whereClause.append("%\"");
|
||||||
*
|
*
|
||||||
* if (bootable != null) { whereClause.append(" AND t.bootable = ");
|
* if (bootable != null) { whereClause.append(" AND t.bootable = ");
|
||||||
* whereClause.append(bootable); }
|
* whereClause.append(bootable); }
|
||||||
*
|
*
|
||||||
* if (!showDomr) { whereClause.append(" AND t.type != '");
|
* if (!showDomr) { whereClause.append(" AND t.type != '");
|
||||||
* whereClause.append(Storage.TemplateType.SYSTEM); whereClause.append("'");
|
* whereClause.append(Storage.TemplateType.SYSTEM); whereClause.append("'");
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* if (templateFilter == TemplateFilter.featured) {
|
* if (templateFilter == TemplateFilter.featured) {
|
||||||
* whereClause.append(" AND t.public = 1 AND t.featured = 1"); } else if
|
* whereClause.append(" AND t.public = 1 AND t.featured = 1"); } else if
|
||||||
* ((templateFilter == TemplateFilter.self || templateFilter ==
|
* ((templateFilter == TemplateFilter.self || templateFilter ==
|
||||||
@ -916,11 +916,11 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* (templateFilter == TemplateFilter.all && caller.getType() ==
|
* (templateFilter == TemplateFilter.all && caller.getType() ==
|
||||||
* Account.ACCOUNT_TYPE_ADMIN) { } else if (caller.getType() !=
|
* Account.ACCOUNT_TYPE_ADMIN) { } else if (caller.getType() !=
|
||||||
* Account.ACCOUNT_TYPE_ADMIN) { return templateZonePairList; }
|
* Account.ACCOUNT_TYPE_ADMIN) { return templateZonePairList; }
|
||||||
*
|
*
|
||||||
* final StringBuilder sql = new StringBuilder(SELECT_TEMPLATE_S3_REF);
|
* final StringBuilder sql = new StringBuilder(SELECT_TEMPLATE_S3_REF);
|
||||||
* sql.append(joinClause); sql.append(whereClause);
|
* sql.append(joinClause); sql.append(whereClause);
|
||||||
* sql.append(getOrderByLimit(pageSize, startIndex));
|
* sql.append(getOrderByLimit(pageSize, startIndex));
|
||||||
*
|
*
|
||||||
* pstmt = txn.prepareStatement(sql.toString()); rs = pstmt.executeQuery();
|
* pstmt = txn.prepareStatement(sql.toString()); rs = pstmt.executeQuery();
|
||||||
* while (rs.next()) { final Pair<Long, Long> templateZonePair = new
|
* while (rs.next()) { final Pair<Long, Long> templateZonePair = new
|
||||||
* Pair<Long, Long>( rs.getLong(1), -1L);
|
* Pair<Long, Long>( rs.getLong(1), -1L);
|
||||||
@ -928,46 +928,9 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
|||||||
* (Exception e) { s_logger.warn("Error listing S3 templates", e); if (txn
|
* (Exception e) { s_logger.warn("Error listing S3 templates", e); if (txn
|
||||||
* != null) { txn.rollback(); } } finally { closeResources(pstmt, rs); if
|
* != null) { txn.rollback(); } } finally { closeResources(pstmt, rs); if
|
||||||
* (txn != null) { txn.close(); } }
|
* (txn != null) { txn.close(); } }
|
||||||
*
|
*
|
||||||
* return templateZonePairList; }
|
* return templateZonePairList; }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean updateState(TemplateState currentState, TemplateEvent event, TemplateState nextState,
|
|
||||||
VMTemplateVO vo, Object data) {
|
|
||||||
Long oldUpdated = vo.getUpdatedCount();
|
|
||||||
Date oldUpdatedTime = vo.getUpdated();
|
|
||||||
|
|
||||||
SearchCriteria<VMTemplateVO> sc = updateStateSearch.create();
|
|
||||||
sc.setParameters("id", vo.getId());
|
|
||||||
sc.setParameters("state", currentState);
|
|
||||||
sc.setParameters("updatedCount", vo.getUpdatedCount());
|
|
||||||
|
|
||||||
vo.incrUpdatedCount();
|
|
||||||
|
|
||||||
UpdateBuilder builder = getUpdateBuilder(vo);
|
|
||||||
builder.set(vo, "state", nextState);
|
|
||||||
builder.set(vo, "updated", new Date());
|
|
||||||
|
|
||||||
int rows = update((VMTemplateVO) vo, sc);
|
|
||||||
if (rows == 0 && s_logger.isDebugEnabled()) {
|
|
||||||
VMTemplateVO dbVol = findByIdIncludingRemoved(vo.getId());
|
|
||||||
if (dbVol != null) {
|
|
||||||
StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
|
|
||||||
str.append(": DB Data={id=").append(dbVol.getId()).append("; state=").append(dbVol.getState())
|
|
||||||
.append("; updatecount=").append(dbVol.getUpdatedCount()).append(";updatedTime=")
|
|
||||||
.append(dbVol.getUpdated());
|
|
||||||
str.append(": New Data={id=").append(vo.getId()).append("; state=").append(nextState)
|
|
||||||
.append("; event=").append(event).append("; updatecount=").append(vo.getUpdatedCount())
|
|
||||||
.append("; updatedTime=").append(vo.getUpdated());
|
|
||||||
str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState)
|
|
||||||
.append("; event=").append(event).append("; updatecount=").append(oldUpdated)
|
|
||||||
.append("; updatedTime=").append(oldUpdatedTime);
|
|
||||||
} else {
|
|
||||||
s_logger.debug("Unable to update objectIndatastore: id=" + vo.getId()
|
|
||||||
+ ", as there is no such object exists in the database anymore");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rows > 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,6 @@ import org.apache.cloudstack.storage.datastore.DataObjectManager;
|
|||||||
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
||||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||||
import org.apache.cloudstack.storage.image.manager.ImageDataManager;
|
|
||||||
import org.apache.cloudstack.storage.image.store.TemplateObject;
|
import org.apache.cloudstack.storage.image.store.TemplateObject;
|
||||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
@ -121,8 +120,6 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
@Inject
|
@Inject
|
||||||
EndPointSelector _epSelector;
|
EndPointSelector _epSelector;
|
||||||
@Inject
|
@Inject
|
||||||
ImageDataManager imageMgr;
|
|
||||||
@Inject
|
|
||||||
TemplateManager _tmpltMgr;
|
TemplateManager _tmpltMgr;
|
||||||
|
|
||||||
class TemplateOpContext<T> extends AsyncRpcConext<T> {
|
class TemplateOpContext<T> extends AsyncRpcConext<T> {
|
||||||
@ -324,19 +321,6 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
VMTemplateVO tmlpt = _templateDao.findById(tmplt.getId());
|
VMTemplateVO tmlpt = _templateDao.findById(tmplt.getId());
|
||||||
tmlpt.setSize(tmpltInfo.getSize());
|
tmlpt.setSize(tmpltInfo.getSize());
|
||||||
_templateDao.update(tmplt.getId(), tmlpt);
|
_templateDao.update(tmplt.getId(), tmlpt);
|
||||||
// set template to ready state
|
|
||||||
if (tmplt.getState() != TemplateState.Ready) {
|
|
||||||
try {
|
|
||||||
imageMgr.getStateMachine().transitTo(tmplt, TemplateEvent.CreateRequested, null,
|
|
||||||
_templateDao);
|
|
||||||
imageMgr.getStateMachine().transitTo(tmplt, TemplateEvent.OperationSucceeded, null,
|
|
||||||
_templateDao);
|
|
||||||
} catch (NoTransitionException e) {
|
|
||||||
// non fatal though
|
|
||||||
s_logger.debug(
|
|
||||||
"failed to update template " + tmplt.getUniqueName() + " state to Ready", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tmpltInfo.getSize() > 0 && tmplt.getUrl() != null) {
|
if (tmpltInfo.getSize() > 0 && tmplt.getUrl() != null) {
|
||||||
long accountId = tmplt.getAccountId();
|
long accountId = tmplt.getAccountId();
|
||||||
@ -370,18 +354,7 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
_templateDao.update(tmplt.getId(), tmlpt);
|
_templateDao.update(tmplt.getId(), tmlpt);
|
||||||
associateTemplateToZone(tmplt.getId(), zoneId);
|
associateTemplateToZone(tmplt.getId(), zoneId);
|
||||||
|
|
||||||
// set template to ready state
|
|
||||||
if (tmplt.getState() != TemplateState.Ready) {
|
|
||||||
try {
|
|
||||||
imageMgr.getStateMachine().transitTo(tmplt, TemplateEvent.CreateRequested, null,
|
|
||||||
_templateDao);
|
|
||||||
imageMgr.getStateMachine().transitTo(tmplt, TemplateEvent.OperationSucceeded, null,
|
|
||||||
_templateDao);
|
|
||||||
} catch (NoTransitionException e) {
|
|
||||||
// non fatal though
|
|
||||||
s_logger.debug("failed to update template " + tmplt.getUniqueName() + " state to Ready", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (tmpltStore != null) {
|
if (tmpltStore != null) {
|
||||||
@ -623,16 +596,6 @@ public class TemplateServiceImpl implements TemplateService {
|
|||||||
long storeId = store.getId();
|
long storeId = store.getId();
|
||||||
List<VMTemplateVO> rtngTmplts = _templateDao.listAllSystemVMTemplates();
|
List<VMTemplateVO> rtngTmplts = _templateDao.listAllSystemVMTemplates();
|
||||||
for (VMTemplateVO tmplt : rtngTmplts) {
|
for (VMTemplateVO tmplt : rtngTmplts) {
|
||||||
// set template ready state
|
|
||||||
if (tmplt.getState() != TemplateState.Ready) {
|
|
||||||
try {
|
|
||||||
imageMgr.getStateMachine().transitTo(tmplt, TemplateEvent.CreateRequested, null, _templateDao);
|
|
||||||
imageMgr.getStateMachine().transitTo(tmplt, TemplateEvent.OperationSucceeded, null, _templateDao);
|
|
||||||
} catch (NoTransitionException e) {
|
|
||||||
// non fatal though
|
|
||||||
s_logger.debug("failed to update system vm template state to Ready", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TemplateDataStoreVO tmpltStore = _vmTemplateStoreDao.findByStoreTemplate(storeId, tmplt.getId());
|
TemplateDataStoreVO tmpltStore = _vmTemplateStoreDao.findByStoreTemplate(storeId, tmplt.getId());
|
||||||
if (tmpltStore == null) {
|
if (tmpltStore == null) {
|
||||||
tmpltStore = new TemplateDataStoreVO(storeId, tmplt.getId(), new Date(), 100, Status.DOWNLOADED, null,
|
tmpltStore = new TemplateDataStoreVO(storeId, tmplt.getId(), new Date(), 100, Status.DOWNLOADED, null,
|
||||||
|
|||||||
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.apache.cloudstack.storage.image.manager;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
|
||||||
|
|
||||||
import com.cloud.storage.VMTemplateVO;
|
|
||||||
import com.cloud.utils.fsm.StateMachine2;
|
|
||||||
|
|
||||||
public interface ImageDataManager {
|
|
||||||
StateMachine2<TemplateState, TemplateEvent, VMTemplateVO> getStateMachine();
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.apache.cloudstack.storage.image.manager;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.storage.VMTemplateVO;
|
|
||||||
import com.cloud.utils.fsm.StateMachine2;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class ImageDataManagerImpl implements ImageDataManager {
|
|
||||||
private final StateMachine2<TemplateState, TemplateEvent, VMTemplateVO> stateMachine = new StateMachine2<TemplateState, TemplateEvent, VMTemplateVO>();
|
|
||||||
|
|
||||||
public ImageDataManagerImpl() {
|
|
||||||
stateMachine.addTransition(TemplateState.Allocated, TemplateEvent.CreateRequested, TemplateState.Creating);
|
|
||||||
stateMachine.addTransition(TemplateState.Creating, TemplateEvent.CreateRequested, TemplateState.Creating);
|
|
||||||
stateMachine.addTransition(TemplateState.Creating, TemplateEvent.OperationSucceeded, TemplateState.Ready);
|
|
||||||
stateMachine.addTransition(TemplateState.Creating, TemplateEvent.OperationFailed, TemplateState.Allocated);
|
|
||||||
stateMachine.addTransition(TemplateState.Creating, TemplateEvent.DestroyRequested, TemplateState.Destroying);
|
|
||||||
stateMachine.addTransition(TemplateState.Ready, TemplateEvent.DestroyRequested, TemplateState.Destroying);
|
|
||||||
stateMachine.addTransition(TemplateState.Allocated, TemplateEvent.DestroyRequested, TemplateState.Destroying);
|
|
||||||
stateMachine.addTransition(TemplateState.Destroying, TemplateEvent.DestroyRequested, TemplateState.Destroying);
|
|
||||||
stateMachine.addTransition(TemplateState.Destroying, TemplateEvent.OperationFailed, TemplateState.Destroying);
|
|
||||||
stateMachine.addTransition(TemplateState.Destroying, TemplateEvent.OperationSucceeded, TemplateState.Destroyed);
|
|
||||||
// TODO: this should not be needed, but it happened during testing where
|
|
||||||
// multiple success event is sent to callback
|
|
||||||
stateMachine.addTransition(TemplateState.Ready, TemplateEvent.OperationSucceeded, TemplateState.Ready);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StateMachine2<TemplateState, TemplateEvent, VMTemplateVO> getStateMachine() {
|
|
||||||
return stateMachine;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -33,7 +33,6 @@ import org.apache.cloudstack.storage.command.CopyCmdAnswer;
|
|||||||
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
|
||||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||||
import org.apache.cloudstack.storage.image.manager.ImageDataManager;
|
|
||||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
@ -58,8 +57,6 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
private VMTemplateVO imageVO;
|
private VMTemplateVO imageVO;
|
||||||
private DataStore dataStore;
|
private DataStore dataStore;
|
||||||
@Inject
|
@Inject
|
||||||
ImageDataManager imageMgr;
|
|
||||||
@Inject
|
|
||||||
VMTemplateDao imageDao;
|
VMTemplateDao imageDao;
|
||||||
@Inject
|
@Inject
|
||||||
ObjectInDataStoreManager objectInStoreMgr;
|
ObjectInDataStoreManager objectInStoreMgr;
|
||||||
@ -155,12 +152,12 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
return this.imageVO.getFormat();
|
return this.imageVO.getFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean stateTransit(TemplateEvent e) throws NoTransitionException {
|
// public boolean stateTransit(TemplateEvent e) throws NoTransitionException {
|
||||||
this.imageVO = imageDao.findById(this.imageVO.getId());
|
// this.imageVO = imageDao.findById(this.imageVO.getId());
|
||||||
boolean result = imageMgr.getStateMachine().transitTo(this.imageVO, e, null, imageDao);
|
// boolean result = imageMgr.getStateMachine().transitTo(this.imageVO, e, null, imageDao);
|
||||||
this.imageVO = imageDao.findById(this.imageVO.getId());
|
// this.imageVO = imageDao.findById(this.imageVO.getId());
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processEvent(Event event) {
|
public void processEvent(Event event) {
|
||||||
@ -178,9 +175,9 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
templEvent = TemplateEvent.OperationFailed;
|
templEvent = TemplateEvent.OperationFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (templEvent != null && this.getDataStore().getRole() == DataStoreRole.Image) {
|
// if (templEvent != null && this.getDataStore().getRole() == DataStoreRole.Image) {
|
||||||
this.stateTransit(templEvent);
|
// this.stateTransit(templEvent);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
objectInStoreMgr.update(this, event);
|
objectInStoreMgr.update(this, event);
|
||||||
@ -241,9 +238,9 @@ public class TemplateObject implements TemplateInfo {
|
|||||||
templEvent = TemplateEvent.OperationFailed;
|
templEvent = TemplateEvent.OperationFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (templEvent != null && this.getDataStore().getRole() == DataStoreRole.Image) {
|
// if (templEvent != null && this.getDataStore().getRole() == DataStoreRole.Image) {
|
||||||
this.stateTransit(templEvent);
|
// this.stateTransit(templEvent);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
objectInStoreMgr.update(this, event);
|
objectInStoreMgr.update(this, event);
|
||||||
} catch (NoTransitionException e) {
|
} catch (NoTransitionException e) {
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import javax.inject.Inject;
|
|||||||
import org.apache.cloudstack.api.BaseCmd;
|
import org.apache.cloudstack.api.BaseCmd;
|
||||||
import org.apache.cloudstack.api.response.TemplateResponse;
|
import org.apache.cloudstack.api.response.TemplateResponse;
|
||||||
import org.apache.cloudstack.api.response.TemplateZoneResponse;
|
import org.apache.cloudstack.api.response.TemplateZoneResponse;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -103,7 +104,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
|
|||||||
templateResponse.setDisplayText(template.getDisplayText());
|
templateResponse.setDisplayText(template.getDisplayText());
|
||||||
templateResponse.setPublic(template.isPublicTemplate());
|
templateResponse.setPublic(template.isPublicTemplate());
|
||||||
templateResponse.setCreated(template.getCreatedOnStore());
|
templateResponse.setCreated(template.getCreatedOnStore());
|
||||||
templateResponse.setReady(template.getState() == TemplateState.Ready);
|
templateResponse.setReady(template.getState() == ObjectInDataStoreStateMachine.State.Ready);
|
||||||
templateResponse.setFeatured(template.isFeatured());
|
templateResponse.setFeatured(template.isFeatured());
|
||||||
templateResponse.setExtractable(template.isExtractable() && !(template.getTemplateType() == TemplateType.SYSTEM));
|
templateResponse.setExtractable(template.isExtractable() && !(template.getTemplateType() == TemplateType.SYSTEM));
|
||||||
templateResponse.setPasswordEnabled(template.isEnablePassword());
|
templateResponse.setPasswordEnabled(template.isEnablePassword());
|
||||||
@ -293,7 +294,13 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
|
|||||||
isoResponse.setPublic(iso.isPublicTemplate());
|
isoResponse.setPublic(iso.isPublicTemplate());
|
||||||
isoResponse.setExtractable(iso.isExtractable() && !(iso.getTemplateType() == TemplateType.PERHOST));
|
isoResponse.setExtractable(iso.isExtractable() && !(iso.getTemplateType() == TemplateType.PERHOST));
|
||||||
isoResponse.setCreated(iso.getCreatedOnStore());
|
isoResponse.setCreated(iso.getCreatedOnStore());
|
||||||
isoResponse.setReady(iso.getState() == TemplateState.Ready);
|
if ( iso.getTemplateType() == TemplateType.PERHOST ){
|
||||||
|
// for xs-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);
|
||||||
|
}
|
||||||
isoResponse.setBootable(iso.isBootable());
|
isoResponse.setBootable(iso.isBootable());
|
||||||
isoResponse.setFeatured(iso.isFeatured());
|
isoResponse.setFeatured(iso.isFeatured());
|
||||||
isoResponse.setCrossZones(iso.isCrossZones());
|
isoResponse.setCrossZones(iso.isCrossZones());
|
||||||
|
|||||||
@ -26,17 +26,12 @@ import javax.persistence.Table;
|
|||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.Identity;
|
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
|
||||||
import org.apache.cloudstack.api.InternalIdentity;
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
|
|
||||||
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
import com.cloud.storage.Storage;
|
import com.cloud.storage.Storage;
|
||||||
import com.cloud.storage.Volume;
|
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
import com.cloud.vm.VirtualMachine;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="template_view")
|
@Table(name="template_view")
|
||||||
@ -240,9 +235,9 @@ public class TemplateJoinVO extends BaseViewVO implements ControlledViewEntity {
|
|||||||
@Column(name="tag_customer")
|
@Column(name="tag_customer")
|
||||||
private String tagCustomer;
|
private String tagCustomer;
|
||||||
|
|
||||||
@Column(name="state")
|
@Column(name = "state")
|
||||||
@Enumerated(value=EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private TemplateState state;
|
ObjectInDataStoreStateMachine.State state;
|
||||||
|
|
||||||
public TemplateJoinVO() {
|
public TemplateJoinVO() {
|
||||||
}
|
}
|
||||||
@ -1021,16 +1016,15 @@ public class TemplateJoinVO extends BaseViewVO implements ControlledViewEntity {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public TemplateState getState() {
|
public ObjectInDataStoreStateMachine.State getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setState(TemplateState state) {
|
public void setState(ObjectInDataStoreStateMachine.State state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1830,7 +1830,7 @@ CREATE VIEW `cloud`.`template_view` AS
|
|||||||
vm_template.display_text,
|
vm_template.display_text,
|
||||||
vm_template.enable_password,
|
vm_template.enable_password,
|
||||||
vm_template.guest_os_id,
|
vm_template.guest_os_id,
|
||||||
vm_template.state,
|
-- vm_template.state,
|
||||||
guest_os.uuid guest_os_uuid,
|
guest_os.uuid guest_os_uuid,
|
||||||
guest_os.display_name guest_os_name,
|
guest_os.display_name guest_os_name,
|
||||||
vm_template.bootable,
|
vm_template.bootable,
|
||||||
@ -1860,6 +1860,7 @@ CREATE VIEW `cloud`.`template_view` AS
|
|||||||
data_center.name data_center_name,
|
data_center.name data_center_name,
|
||||||
launch_permission.account_id lp_account_id,
|
launch_permission.account_id lp_account_id,
|
||||||
template_store_ref.store_id,
|
template_store_ref.store_id,
|
||||||
|
template_store_ref.state,
|
||||||
template_store_ref.download_state,
|
template_store_ref.download_state,
|
||||||
template_store_ref.download_pct,
|
template_store_ref.download_pct,
|
||||||
template_store_ref.error_str,
|
template_store_ref.error_str,
|
||||||
@ -1898,7 +1899,7 @@ CREATE VIEW `cloud`.`template_view` AS
|
|||||||
left join
|
left join
|
||||||
`cloud`.`data_center` ON template_zone_ref.zone_id = data_center.id
|
`cloud`.`data_center` ON template_zone_ref.zone_id = data_center.id
|
||||||
left join
|
left join
|
||||||
`cloud`.`image_store` ON image_store.data_center_id = data_center.id OR image_store.scope = 'REGION'
|
`cloud`.`image_store` ON image_store.removed is NULL AND (image_store.data_center_id = data_center.id OR image_store.scope = 'REGION')
|
||||||
left join
|
left join
|
||||||
`cloud`.`template_store_ref` ON template_store_ref.template_id = vm_template.id AND template_store_ref.store_id = image_store.id
|
`cloud`.`template_store_ref` ON template_store_ref.template_id = vm_template.id AND template_store_ref.store_id = image_store.id
|
||||||
left join
|
left join
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user