use of org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO in project cloudstack by apache.
the class BareMetalTemplateAdapter method create.
@Override
public VMTemplateVO create(TemplateProfile profile) {
VMTemplateVO template = persistTemplate(profile, State.Active);
Long zoneId = profile.getZoneId();
// create an entry at template_store_ref with store_id = null to represent that this template is ready for use.
TemplateDataStoreVO vmTemplateHost = new TemplateDataStoreVO(null, template.getId(), new Date(), 100, Status.DOWNLOADED, null, null, null, null, template.getUrl());
this._tmpltStoreDao.persist(vmTemplateHost);
if (zoneId == null || zoneId == -1) {
List<DataCenterVO> dcs = _dcDao.listAllIncludingRemoved();
if (dcs != null && dcs.size() > 0) {
templateCreateUsage(template, dcs.get(0).getId());
}
} else {
templateCreateUsage(template, zoneId);
}
_resourceLimitMgr.incrementResourceCount(profile.getAccountId(), ResourceType.template);
return template;
}
Aggregations