mirror of https://github.com/apache/cloudstack.git
registerIso - remove hardcoding of GuestosId when its None. Retrieve it from DB.
This commit is contained in:
parent
b625bb1d27
commit
197dc6cf6e
|
|
@ -94,6 +94,7 @@ public class ApiConstants {
|
|||
public static final String IS_RECURSIVE = "isrecursive";
|
||||
public static final String IS_SHARED = "isshared";
|
||||
public static final String ISO_FILTER = "isofilter";
|
||||
public static final String ISO_GUEST_OS_NONE = "None";
|
||||
public static final String JOB_ID = "jobid";
|
||||
public static final String JOB_STATUS = "jobstatus";
|
||||
public static final String LASTNAME = "lastname";
|
||||
|
|
|
|||
|
|
@ -355,6 +355,10 @@ public class ApiDBUtils {
|
|||
return _guestOSDao.findByIdIncludingRemoved(id);
|
||||
}
|
||||
|
||||
public static GuestOS findGuestOSByDisplayName(String displayName) {
|
||||
return _guestOSDao.listByDisplayName(displayName);
|
||||
}
|
||||
|
||||
public static HostVO findHostById(Long hostId) {
|
||||
return _hostDao.findByIdIncludingRemoved(hostId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,5 +21,7 @@ import com.cloud.storage.GuestOSVO;
|
|||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface GuestOSDao extends GenericDao<GuestOSVO, Long> {
|
||||
|
||||
GuestOSVO listByDisplayName(String displayName);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,16 +17,33 @@
|
|||
*/
|
||||
package com.cloud.storage.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.VMTemplateHostVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Local (value={GuestOSDao.class})
|
||||
public class GuestOSDaoImpl extends GenericDaoBase<GuestOSVO, Long> implements GuestOSDao {
|
||||
|
||||
|
||||
protected final SearchBuilder<GuestOSVO> Search;
|
||||
|
||||
protected GuestOSDaoImpl() {
|
||||
|
||||
Search = createSearchBuilder();
|
||||
Search.and("display_name", Search.entity().getDisplayName(), SearchCriteria.Op.EQ);
|
||||
Search.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuestOSVO listByDisplayName(String displayName) {
|
||||
SearchCriteria<GuestOSVO> sc = Search.create();
|
||||
sc.setParameters("display_name", displayName);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import javax.naming.ConfigurationException;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.commands.DeleteIsoCmd;
|
||||
import com.cloud.api.commands.DeleteTemplateCmd;
|
||||
import com.cloud.api.commands.RegisterIsoCmd;
|
||||
|
|
@ -23,6 +25,7 @@ import com.cloud.exception.ResourceAllocationException;
|
|||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.storage.GuestOS;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
|
|
@ -105,12 +108,12 @@ public abstract class TemplateAdapterBase implements TemplateAdapter {
|
|||
if (bootable == null) {
|
||||
bootable = Boolean.TRUE;
|
||||
}
|
||||
|
||||
if ((guestOSId == null || guestOSId == 138L) && bootable == true){
|
||||
GuestOS noneGuestOs = ApiDBUtils.findGuestOSByDisplayName(ApiConstants.ISO_GUEST_OS_NONE);
|
||||
if ((guestOSId == null || guestOSId == noneGuestOs.getId()) && bootable == true){
|
||||
throw new InvalidParameterValueException("Please pass a valid GuestOS Id");
|
||||
}
|
||||
if (bootable == false){
|
||||
guestOSId = 138L; //Guest os id of None.
|
||||
guestOSId = noneGuestOs.getId(); //Guest os id of None.
|
||||
}
|
||||
} else {
|
||||
if (bits == null) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue