Search in sources :

Example 16 with TemplateProfile

use of com.cloud.storage.TemplateProfile in project cloudstack by apache.

the class HypervisorTemplateAdapter method prepareDelete.

@Override
public TemplateProfile prepareDelete(DeleteTemplateCmd cmd) {
    TemplateProfile profile = super.prepareDelete(cmd);
    VMTemplateVO template = profile.getTemplate();
    Long zoneId = profile.getZoneId();
    if (template.getTemplateType() == TemplateType.SYSTEM) {
        throw new InvalidParameterValueException("The DomR template cannot be deleted.");
    }
    if (zoneId != null && (storeMgr.getImageStore(zoneId) == null)) {
        throw new InvalidParameterValueException("Failed to find a secondary storage in the specified zone.");
    }
    return profile;
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) VMTemplateVO(com.cloud.storage.VMTemplateVO) TemplateProfile(com.cloud.storage.TemplateProfile)

Aggregations

TemplateProfile (com.cloud.storage.TemplateProfile)16 VMTemplateVO (com.cloud.storage.VMTemplateVO)11 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)9 Account (com.cloud.user.Account)6 ActionEvent (com.cloud.event.ActionEvent)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 UserVO (com.cloud.user.UserVO)3 PermissionDeniedException (com.cloud.exception.PermissionDeniedException)2 TemplateDataStoreVO (org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO)2 DataCenterVO (com.cloud.dc.DataCenterVO)1 GuestOS (com.cloud.storage.GuestOS)1 ImageFormat (com.cloud.storage.Storage.ImageFormat)1 AccountVO (com.cloud.user.AccountVO)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 URL (java.net.URL)1 GetUploadParamsResponse (org.apache.cloudstack.api.response.GetUploadParamsResponse)1 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)1 EndPoint (org.apache.cloudstack.engine.subsystem.api.storage.EndPoint)1 TemplateInfo (org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo)1