diff --git a/api/src/com/cloud/api/commands/CreateServiceOfferingCmd.java b/api/src/com/cloud/api/commands/CreateServiceOfferingCmd.java index d80baac80e2..40ae8b99ed3 100644 --- a/api/src/com/cloud/api/commands/CreateServiceOfferingCmd.java +++ b/api/src/com/cloud/api/commands/CreateServiceOfferingCmd.java @@ -25,6 +25,7 @@ import com.cloud.api.BaseCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; +import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.ServiceOfferingResponse; import com.cloud.offering.ServiceOffering; import com.cloud.user.Account; @@ -74,6 +75,8 @@ public class CreateServiceOfferingCmd extends BaseCmd { @Parameter(name=ApiConstants.IS_SYSTEM_OFFERING, type=CommandType.BOOLEAN, description="is this a system vm offering") private Boolean isSystem; + @Parameter(name=ApiConstants.SYSTEM_VM_TYPE, type=CommandType.STRING, description="the system VM type. Possible types are \"consoleproxy\" and \"secondarystoragevm\".") + private String systemVmType; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -127,6 +130,10 @@ public class CreateServiceOfferingCmd extends BaseCmd { return isSystem == null ? false : isSystem; } + public String getSystemVmType() { + return systemVmType; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/com/cloud/api/commands/ListServiceOfferingsCmd.java b/api/src/com/cloud/api/commands/ListServiceOfferingsCmd.java index 69d5c9a5931..0387ed835da 100644 --- a/api/src/com/cloud/api/commands/ListServiceOfferingsCmd.java +++ b/api/src/com/cloud/api/commands/ListServiceOfferingsCmd.java @@ -26,6 +26,7 @@ import com.cloud.api.ApiConstants; import com.cloud.api.BaseListCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; +import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.ListResponse; import com.cloud.api.response.ServiceOfferingResponse; import com.cloud.offering.ServiceOffering; @@ -52,10 +53,12 @@ public class ListServiceOfferingsCmd extends BaseListCmd { @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the domain associated with the service offering") private Long domainId; - @Parameter(name=ApiConstants.IS_SYSTEM_OFFERING, type=CommandType.BOOLEAN, description="is this a system vm offering") private Boolean isSystem; + @Parameter(name=ApiConstants.SYSTEM_VM_TYPE, type=CommandType.STRING, description="the system VM type. Possible types are \"consoleproxy\", \"secondarystoragevm\" or \"domainrouter\".") + private String systemVmType; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -80,6 +83,10 @@ public class ListServiceOfferingsCmd extends BaseListCmd { public Boolean getIsSystem() { return isSystem == null ? false : isSystem; } + + public String getSystemVmType(){ + return systemVmType; + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// diff --git a/api/src/com/cloud/api/response/ServiceOfferingResponse.java b/api/src/com/cloud/api/response/ServiceOfferingResponse.java index 87ac80d8ee1..d97bc756ae5 100644 --- a/api/src/com/cloud/api/response/ServiceOfferingResponse.java +++ b/api/src/com/cloud/api/response/ServiceOfferingResponse.java @@ -72,6 +72,9 @@ public class ServiceOfferingResponse extends BaseResponse { @SerializedName(ApiConstants.IS_DEFAULT_USE) @Param(description="is this a default system vm offering") private Boolean defaultUse; + @SerializedName(ApiConstants.SYSTEM_VM_TYPE) @Param(description="is this a the systemvm type for system vm offering") + private String vm_type; + public Long getId() { return id; @@ -105,6 +108,15 @@ public class ServiceOfferingResponse extends BaseResponse { public void setDefaultUse(Boolean defaultUse) { this.defaultUse = defaultUse; } + + + public String getSystemVmType() { + return vm_type; + } + + public void setSystemVmType(String vmtype) { + this.vm_type = vmtype; + } public String getDisplayText() { diff --git a/api/src/com/cloud/offering/ServiceOffering.java b/api/src/com/cloud/offering/ServiceOffering.java index 26807c1fe35..7a0c9816ecb 100755 --- a/api/src/com/cloud/offering/ServiceOffering.java +++ b/api/src/com/cloud/offering/ServiceOffering.java @@ -91,4 +91,6 @@ public interface ServiceOffering { String getHostTag(); boolean getDefaultUse(); + + String getSystemVmType(); } diff --git a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java index 980c0e20e20..730439638ed 100755 --- a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java @@ -261,14 +261,14 @@ public class UserConcentratedAllocator implements PodAllocator { } so = _offeringDao.findById(userVm.getServiceOfferingId()); } else if (vm.getType() == VirtualMachine.Type.ConsoleProxy) { - so = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, false, true, null, true, false); + so = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, false, true, null, true, VirtualMachine.Type.ConsoleProxy, false); } else if (vm.getType() == VirtualMachine.Type.SecondaryStorageVm) { - so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, false, true, null, true, false); + so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, false, true, null, true, VirtualMachine.Type.SecondaryStorageVm, false); } else if (vm.getType() == VirtualMachine.Type.DomainRouter) { - so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, true, null, false, true, null, true, false); + so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, true, null, false, true, null, true, VirtualMachine.Type.DomainRouter, false); } else { assert (false) : "Unsupported system vm type"; - so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, false, true, null, true, false); + so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, false, true, null, true, null, false); } if (capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) { diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index ad9db36261a..08b6bef110a 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -427,6 +427,7 @@ public class ApiResponseHelper implements ResponseGenerator { offeringResponse.setName(offering.getName()); offeringResponse.setIsSystemOffering(offering.getSystemUse()); offeringResponse.setDefaultUse(offering.getDefaultUse()); + offeringResponse.setSystemVmType(offering.getSystemVmType()); offeringResponse.setDisplayText(offering.getDisplayText()); offeringResponse.setCpuNumber(offering.getCpu()); offeringResponse.setCpuSpeed(offering.getSpeed()); diff --git a/server/src/com/cloud/configuration/ConfigurationManager.java b/server/src/com/cloud/configuration/ConfigurationManager.java index 562c8b4e363..a18635db698 100644 --- a/server/src/com/cloud/configuration/ConfigurationManager.java +++ b/server/src/com/cloud/configuration/ConfigurationManager.java @@ -40,6 +40,7 @@ import com.cloud.service.ServiceOfferingVO; import com.cloud.storage.DiskOfferingVO; import com.cloud.user.Account; import com.cloud.utils.component.Manager; +import com.cloud.vm.VirtualMachine; /** * ConfigurationManager handles adding pods/zones, changing IP ranges, enabling external firewalls, and editing configuration values @@ -70,7 +71,7 @@ public interface ConfigurationManager extends ConfigurationService, Manager { * @param hostTag * @return ID */ - ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean limitResourceUse, String tags, Long domainId, String hostTag); + ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_typeType, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean limitResourceUse, String tags, Long domainId, String hostTag); /** * Creates a new disk offering diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index bccc83a9d1c..b4868dcb010 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1496,17 +1496,33 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura if (limitCpuUse == null) { limitCpuUse = false; } - - return createServiceOffering(userId, cmd.getIsSystem(), cmd.getServiceOfferingName(), cpuNumber.intValue(), memory.intValue(), cpuSpeed.intValue(), cmd.getDisplayText(), localStorageRequired, offerHA, + String vm_type_string = cmd.getSystemVmType(); + VirtualMachine.Type vm_type = null; + if (cmd.getIsSystem() && vm_type_string == null){ + vm_type = VirtualMachine.Type.DomainRouter; + } + else { + if (VirtualMachine.Type.ConsoleProxy.toString().toLowerCase().equals(vm_type_string)){ + vm_type = VirtualMachine.Type.ConsoleProxy; + } + else if (VirtualMachine.Type.SecondaryStorageVm.toString().toLowerCase().equals(vm_type_string)){ + vm_type = VirtualMachine.Type.SecondaryStorageVm; + } + else if (VirtualMachine.Type.DomainRouter.toString().toLowerCase().equals(vm_type_string)){ + vm_type = VirtualMachine.Type.DomainRouter; + } + } + + return createServiceOffering(userId, cmd.getIsSystem(), vm_type, cmd.getServiceOfferingName(), cpuNumber.intValue(), memory.intValue(), cpuSpeed.intValue(), cmd.getDisplayText(), localStorageRequired, offerHA, limitCpuUse, cmd.getTags(), cmd.getDomainId(), cmd.getHostTag()); } @Override @ActionEvent(eventType = EventTypes.EVENT_SERVICE_OFFERING_CREATE, eventDescription = "creating service offering") - public ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, boolean limitResourceUse, String tags, - Long domainId, String hostTag) { + public ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_type, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, + boolean offerHA, boolean limitResourceUse, String tags, Long domainId, String hostTag) { tags = cleanupTags(tags); - ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, offerHA, limitResourceUse, displayText, localStorageRequired, false, tags, isSystem, domainId, hostTag); + ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, offerHA, limitResourceUse, displayText, localStorageRequired, false, tags, isSystem, vm_type, domainId, hostTag); if ((offering = _serviceOfferingDao.persist(offering)) != null) { UserContext.current().setEventDetails("Service offering id=" + offering.getId()); diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index 55b44a2a5f5..6910d8c2037 100644 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -1245,7 +1245,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx _itMgr.registerGuru(VirtualMachine.Type.ConsoleProxy, this); boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key())); - _serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, _proxyCpuMHz, 0, 0, false, null, useLocalStorage, true, null, true, true); + _serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, _proxyCpuMHz, 0, 0, false, null, useLocalStorage, true, null, true, VirtualMachine.Type.ConsoleProxy, true); _serviceOffering.setUniqueName("Cloud.com-ConsoleProxy"); _serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering); diff --git a/server/src/com/cloud/migration/ServiceOffering21VO.java b/server/src/com/cloud/migration/ServiceOffering21VO.java index 4ab382411e7..37b34fc0c60 100644 --- a/server/src/com/cloud/migration/ServiceOffering21VO.java +++ b/server/src/com/cloud/migration/ServiceOffering21VO.java @@ -170,5 +170,10 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe @Override public boolean getDefaultUse() { return false; - } + } + + @Override + public String getSystemVmType() { + return null; + } } diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index ea840c961a3..3e2bcb8271b 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -569,7 +569,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian _itMgr.registerGuru(VirtualMachine.Type.DomainRouter, this); boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key())); - _offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, _routerCpuMHz, null, null, true, null, useLocalStorage, true, null, true, true); + _offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, _routerCpuMHz, null, null, true, null, useLocalStorage, true, null, true, VirtualMachine.Type.DomainRouter, true); _offering.setUniqueName("Cloud.Com-SoftwareRouter"); _offering = _serviceOfferingDao.persistSystemServiceOffering(_offering); diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index b9c0262bacc..be6d7d2c51d 100644 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -805,7 +805,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { private ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, String tags) { tags = cleanupTags(tags); - ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, offerHA, displayText, localStorageRequired, false, tags, false, false); + ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, offerHA, displayText, localStorageRequired, false, tags, false, null, false); if ((offering = _serviceOfferingDao.persist(offering)) != null) { return offering; diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index ea9043461a4..0a899762b38 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -1007,6 +1007,7 @@ public class ManagementServerImpl implements ManagementServer { Long vmId = cmd.getVirtualMachineId(); Long domainId = cmd.getDomainId(); Boolean issystem = cmd.getIsSystem(); + String vm_type_str = cmd.getSystemVmType(); // Keeping this logic consistent with domain specific zones // if a domainId is provided, we just return the so associated with this domain @@ -1015,7 +1016,7 @@ public class ManagementServerImpl implements ManagementServer { if (account.getDomainId() != 1 && issystem){ //NON ROOT admin throw new InvalidParameterValueException("Non ROOT admins cannot access system's offering"); } - return _offeringsDao.findServiceOfferingByDomainIdAndIsSystem(domainId, issystem);// no perm check + return _offeringsDao.findSystemOffering(domainId, issystem, vm_type_str);// no perm check } else { if (issystem){ throw new InvalidParameterValueException("Non root users cannot access system's offering"); @@ -1023,7 +1024,7 @@ public class ManagementServerImpl implements ManagementServer { // check if the user's domain == so's domain || user's domain is a child of so's domain if (isPermissible(account.getDomainId(), domainId)) { // perm check succeeded - return _offeringsDao.findServiceOfferingByDomainIdAndIsSystem(domainId, false); + return _offeringsDao.findSystemOffering(domainId, false, vm_type_str); } else { throw new PermissionDeniedException("The account:" + account.getAccountName() + " does not fall in the same domain hierarchy as the service offering"); } @@ -1067,7 +1068,6 @@ public class ManagementServerImpl implements ManagementServer { // sc.addAnd("guestIpType", SearchCriteria.Op.EQ, offering.getGuestIpType()); sc.addAnd("useLocalStorage", SearchCriteria.Op.EQ, offering.getUseLocalStorage()); } - if (id != null) { sc.addAnd("id", SearchCriteria.Op.EQ, id); } @@ -1075,8 +1075,10 @@ public class ManagementServerImpl implements ManagementServer { if (name != null) { sc.addAnd("name", SearchCriteria.Op.LIKE, "%" + name + "%"); } + if (vm_type_str != null){ + sc.addAnd("vm_type", SearchCriteria.Op.EQ, vm_type_str); + } sc.addAnd("systemUse", SearchCriteria.Op.EQ, issystem); - return _offeringsDao.search(sc, searchFilter); } diff --git a/server/src/com/cloud/service/ServiceOfferingVO.java b/server/src/com/cloud/service/ServiceOfferingVO.java index 00994620730..1a37ceb36b8 100644 --- a/server/src/com/cloud/service/ServiceOfferingVO.java +++ b/server/src/com/cloud/service/ServiceOfferingVO.java @@ -27,6 +27,7 @@ import javax.persistence.Transient; import com.cloud.offering.ServiceOffering; import com.cloud.storage.DiskOfferingVO; +import com.cloud.vm.VirtualMachine; @Entity @Table(name="service_offering") @@ -59,12 +60,15 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering @Column(name="default_use") private boolean default_use; + + @Column(name="vm_type") + private String vm_type; protected ServiceOfferingVO() { super(); } - public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, boolean defaultUse) { + public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, String displayText, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vm_type, boolean defaultUse) { super(name, displayText, false, tags, recreatable, useLocalStorage, systemUse, true); this.cpu = cpu; this.ramSize = ramSize; @@ -73,10 +77,11 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering this.multicastRateMbps = multicastRateMbps; this.offerHA = offerHA; this.limitCpuUse = false; - this.default_use = defaultUse; + this.default_use = defaultUse; + this.vm_type = vm_type == null ? null : vm_type.toString().toLowerCase(); } - public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, boolean limitCpuUse, String displayText, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, Long domainId) { + public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, boolean limitCpuUse, String displayText, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vm_type, Long domainId) { super(name, displayText, false, tags, recreatable, useLocalStorage, systemUse, true, domainId); this.cpu = cpu; this.ramSize = ramSize; @@ -85,11 +90,11 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering this.multicastRateMbps = multicastRateMbps; this.offerHA = offerHA; this.limitCpuUse = limitCpuUse; - this.default_use = false; + this.vm_type = vm_type == null ? null : vm_type.toString().toLowerCase(); } - public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, boolean limitResourceUse, String displayText, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, Long domainId, String hostTag) { - this(name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, limitResourceUse, displayText, useLocalStorage, recreatable, tags, systemUse, domainId); + public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, Integer rateMbps, Integer multicastRateMbps, boolean offerHA, boolean limitResourceUse, String displayText, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, VirtualMachine.Type vm_type, Long domainId, String hostTag) { + this(name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, limitResourceUse, displayText, useLocalStorage, recreatable, tags, systemUse, vm_type, domainId); this.hostTag = hostTag; } @@ -178,5 +183,10 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering public String getHostTag() { return hostTag; - } + } + + public String getSystemVmType(){ + return vm_type; + } + } diff --git a/server/src/com/cloud/service/dao/ServiceOfferingDao.java b/server/src/com/cloud/service/dao/ServiceOfferingDao.java index 316c39094b4..6db9f2d1599 100644 --- a/server/src/com/cloud/service/dao/ServiceOfferingDao.java +++ b/server/src/com/cloud/service/dao/ServiceOfferingDao.java @@ -31,5 +31,5 @@ public interface ServiceOfferingDao extends GenericDao ServiceOfferingVO persistSystemServiceOffering(ServiceOfferingVO vo); List findPublicServiceOfferings(); List findServiceOfferingByDomainId(Long domainId); - List findServiceOfferingByDomainIdAndIsSystem(Long domainId, Boolean isSystem); + List findSystemOffering(Long domainId, Boolean isSystem, String vm_type); } diff --git a/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java b/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java index 3bdc7da385e..6fcf6e5d899 100644 --- a/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java +++ b/server/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java @@ -37,7 +37,7 @@ public class ServiceOfferingDaoImpl extends GenericDaoBase UniqueNameSearch; protected final SearchBuilder ServiceOfferingsByDomainIdSearch; - protected final SearchBuilder ServiceOfferingsByDomainIdAndUseSystemSearch; + protected final SearchBuilder SystemServiceOffering; protected final SearchBuilder ServiceOfferingsByKeywordSearch; protected final SearchBuilder PublicServiceOfferingSearch; @@ -53,10 +53,11 @@ public class ServiceOfferingDaoImpl extends GenericDaoBase findServiceOfferingByDomainIdAndIsSystem(Long domainId, Boolean isSystem){ - SearchCriteria sc = ServiceOfferingsByDomainIdAndUseSystemSearch.create(); + public List findSystemOffering(Long domainId, Boolean isSystem, String vm_type){ + SearchCriteria sc = SystemServiceOffering.create(); sc.setParameters("domainId", domainId); sc.setParameters("system", isSystem); + sc.setParameters("vm_type", vm_type); return listBy(sc); } diff --git a/server/src/com/cloud/storage/allocator/LocalStoragePoolAllocator.java b/server/src/com/cloud/storage/allocator/LocalStoragePoolAllocator.java index a5f6b5e886d..25afbf07bbb 100644 --- a/server/src/com/cloud/storage/allocator/LocalStoragePoolAllocator.java +++ b/server/src/com/cloud/storage/allocator/LocalStoragePoolAllocator.java @@ -143,14 +143,14 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator { } } else if (vm.getType() == VirtualMachine.Type.ConsoleProxy) { - so = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, false, true, null, true, false); + so = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, false, true, null, true, VirtualMachine.Type.ConsoleProxy, false); } else if (vm.getType() == VirtualMachine.Type.SecondaryStorageVm) { - so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, false, true, null, true, false); + so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, false, true, null, true, VirtualMachine.Type.SecondaryStorageVm, false); } else if (vm.getType() == VirtualMachine.Type.DomainRouter) { - so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, true, null, false, true, null, true, false); + so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, true, null, false, true, null, true, VirtualMachine.Type.DomainRouter, false); } else { assert (false) : "Unsupported system vm type"; - so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, false, true, null, false, false); + so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, false, true, null, false, null, false); } long usedMemory = calcHostAllocatedCpuMemoryCapacity(vmOnHost, CapacityVO.CAPACITY_TYPE_MEMORY); @@ -247,14 +247,14 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator { } so = _offeringDao.findById(userVm.getServiceOfferingId()); } else if (vm.getType() == VirtualMachine.Type.ConsoleProxy) { - so = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, false, true, null, true, false); + so = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, false, true, null, true, VirtualMachine.Type.ConsoleProxy, false); } else if (vm.getType() == VirtualMachine.Type.SecondaryStorageVm) { - so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, false, true, null, true, false); + so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, false, true, null, true, VirtualMachine.Type.SecondaryStorageVm, false); } else if (vm.getType() == VirtualMachine.Type.DomainRouter) { - so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, true, null, false, true, null, true, false); + so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, true, null, false, true, null, true, VirtualMachine.Type.DomainRouter, false); } else { assert (false) : "Unsupported system vm type"; - so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, false, true, null, false, false); + so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, false, true, null, false, null, false); } if (capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) { diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index c569a1299bf..707c3275c69 100644 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -781,7 +781,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V _itMgr.registerGuru(VirtualMachine.Type.SecondaryStorageVm, this); _useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key())); - _serviceOffering = new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, _secStorageVmRamSize, _secStorageVmCpuMHz, null, null, false, null, _useLocalStorage, true, null, true, true); + _serviceOffering = new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, _secStorageVmRamSize, _secStorageVmCpuMHz, null, null, false, null, _useLocalStorage, true, null, true, VirtualMachine.Type.SecondaryStorageVm, true); _serviceOffering.setUniqueName("Cloud.com-SecondaryStorage"); _serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering); diff --git a/server/src/com/cloud/test/DatabaseConfig.java b/server/src/com/cloud/test/DatabaseConfig.java index 7a099f355ab..8458d49302f 100755 --- a/server/src/com/cloud/test/DatabaseConfig.java +++ b/server/src/com/cloud/test/DatabaseConfig.java @@ -805,7 +805,7 @@ public class DatabaseConfig { useLocalStorage = false; } - ServiceOfferingVO serviceOffering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, ha, displayText, useLocalStorage, false, null, false, false); + ServiceOfferingVO serviceOffering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, ha, displayText, useLocalStorage, false, null, false, null, false); ServiceOfferingDaoImpl dao = ComponentLocator.inject(ServiceOfferingDaoImpl.class); try { dao.persist(serviceOffering); diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 993b2b67948..f91887a73da 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -1150,6 +1150,7 @@ CREATE TABLE `cloud`.`service_offering` ( `limit_cpu_use` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Limit the CPU usage to service offering', `host_tag` varchar(255) COMMENT 'host tag specified by the service_offering', `default_use` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'is this offering a default system offering', + `vm_type` varchar(32) COMMENT 'type of offering specified for system offerings', PRIMARY KEY (`id`), CONSTRAINT `fk_service_offering__id` FOREIGN KEY (`id`) REFERENCES `disk_offering`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/setup/db/db/schema-226to227.sql b/setup/db/db/schema-226to227.sql index 6229f1cedfd..632297e2ee5 100644 --- a/setup/db/db/schema-226to227.sql +++ b/setup/db/db/schema-226to227.sql @@ -7,6 +7,7 @@ ALTER TABLE `cloud`.`mshost` ADD COLUMN `state` varchar(10) NOT NULL default 'Do ALTER TABLE `cloud`.`vm_instance` ADD COLUMN `limit_cpu_use` tinyint(1) NOT NULL DEFAULT 0 ; ALTER TABLE `cloud`.`service_offering` ADD COLUMN `limit_cpu_use` tinyint(1) NOT NULL DEFAULT 0 ; ALTER TABLE `cloud`.`service_offering` ADD COLUMN `default_use` tinyint(1) NOT NULL DEFAULT 0 ; +ALTER TABLE `cloud`.`service_offering` ADD COLUMN `vm_type` varchar(32) COMMENT 'type of offering specified for system offerings'; ALTER TABLE `cloud`.`storage_pool` MODIFY `host_address` varchar(255) NOT NULL; DROP TABLE IF EXISTS `cloud`.`certificate`;