Search in sources :

Example 46 with TemplateDataStoreVO

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;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) VMTemplateVO(com.cloud.storage.VMTemplateVO) TemplateDataStoreVO(org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO) Date(java.util.Date)

Aggregations

TemplateDataStoreVO (org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO)46 VMTemplateVO (com.cloud.storage.VMTemplateVO)22 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)22 TemplateInfo (org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo)15 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)14 Date (java.util.Date)13 ZoneScope (org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope)8 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)7 PrimaryDataStore (org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore)7 TemplateApiResult (org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult)7 VolumeDataStoreVO (org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO)7 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)6 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)6 DB (com.cloud.utils.db.DB)6 ExecutionException (java.util.concurrent.ExecutionException)6 SnapshotDataStoreVO (org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO)6 StorageUnavailableException (com.cloud.exception.StorageUnavailableException)5 ConfigurationException (javax.naming.ConfigurationException)5 ImageStoreEntity (org.apache.cloudstack.storage.image.datastore.ImageStoreEntity)5 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)4