diff --git a/api/src/com/cloud/api/ApiConstants.java b/api/src/com/cloud/api/ApiConstants.java index 7353384100b..37e26e9a6e3 100755 --- a/api/src/com/cloud/api/ApiConstants.java +++ b/api/src/com/cloud/api/ApiConstants.java @@ -113,6 +113,7 @@ public class ApiConstants { public static final String NUM_RETRIES = "numretries"; public static final String OFFER_HA = "offerha"; public static final String IS_SYSTEM_OFFERING = "issystem"; + public static final String IS_DEFAULT_USE = "defaultuse"; public static final String OP = "op"; public static final String OS_CATEGORY_ID = "oscategoryid"; public static final String OS_TYPE_ID = "ostypeid"; diff --git a/api/src/com/cloud/api/response/ServiceOfferingResponse.java b/api/src/com/cloud/api/response/ServiceOfferingResponse.java index 6090d9da4a9..87ac80d8ee1 100644 --- a/api/src/com/cloud/api/response/ServiceOfferingResponse.java +++ b/api/src/com/cloud/api/response/ServiceOfferingResponse.java @@ -69,6 +69,9 @@ public class ServiceOfferingResponse extends BaseResponse { @SerializedName(ApiConstants.IS_SYSTEM_OFFERING) @Param(description="is this a system vm offering") private Boolean isSystem; + @SerializedName(ApiConstants.IS_DEFAULT_USE) @Param(description="is this a default system vm offering") + private Boolean defaultUse; + public Long getId() { return id; @@ -95,6 +98,15 @@ public class ServiceOfferingResponse extends BaseResponse { } + public Boolean getDefaultUse() { + return defaultUse; + } + + public void setDefaultUse(Boolean defaultUse) { + this.defaultUse = defaultUse; + } + + public String getDisplayText() { return displayText; } diff --git a/api/src/com/cloud/offering/ServiceOffering.java b/api/src/com/cloud/offering/ServiceOffering.java index 6c93981623e..26807c1fe35 100755 --- a/api/src/com/cloud/offering/ServiceOffering.java +++ b/api/src/com/cloud/offering/ServiceOffering.java @@ -89,4 +89,6 @@ public interface ServiceOffering { * @return tag that should be present on the host needed, optional parameter */ String getHostTag(); + + boolean getDefaultUse(); } 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 108a9f1f1e9..980c0e20e20 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); + so = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, false, true, null, true, 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); + so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, false, true, null, true, 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); + so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, true, null, false, true, null, true, 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); + so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, false, true, null, true, 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 a9d851fc12e..ad9db36261a 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -426,6 +426,7 @@ public class ApiResponseHelper implements ResponseGenerator { offeringResponse.setId(offering.getId()); offeringResponse.setName(offering.getName()); offeringResponse.setIsSystemOffering(offering.getSystemUse()); + offeringResponse.setDefaultUse(offering.getDefaultUse()); offeringResponse.setDisplayText(offering.getDisplayText()); offeringResponse.setCpuNumber(offering.getCpu()); offeringResponse.setCpuSpeed(offering.getSpeed()); diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index da36c16645f..55b44a2a5f5 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); + _serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, _proxyCpuMHz, 0, 0, false, null, useLocalStorage, true, null, true, 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 829f7c08c68..4ab382411e7 100644 --- a/server/src/com/cloud/migration/ServiceOffering21VO.java +++ b/server/src/com/cloud/migration/ServiceOffering21VO.java @@ -165,5 +165,10 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe public String getHostTag() { return hostTag; - } + } + + @Override + public boolean getDefaultUse() { + return false; + } } diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index af62f92f6d8..ea840c961a3 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); + _offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, _routerCpuMHz, null, null, true, null, useLocalStorage, true, null, true, 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 841adc08710..b9c0262bacc 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); + ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, offerHA, displayText, localStorageRequired, false, tags, false, false); if ((offering = _serviceOfferingDao.persist(offering)) != null) { return offering; diff --git a/server/src/com/cloud/service/ServiceOfferingVO.java b/server/src/com/cloud/service/ServiceOfferingVO.java index e7faffc6b4b..00994620730 100644 --- a/server/src/com/cloud/service/ServiceOfferingVO.java +++ b/server/src/com/cloud/service/ServiceOfferingVO.java @@ -56,12 +56,15 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering @Column(name="host_tag") private String hostTag; + + @Column(name="default_use") + private boolean default_use; 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) { + 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) { super(name, displayText, false, tags, recreatable, useLocalStorage, systemUse, true); this.cpu = cpu; this.ramSize = ramSize; @@ -69,7 +72,8 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering this.rateMbps = rateMbps; this.multicastRateMbps = multicastRateMbps; this.offerHA = offerHA; - this.limitCpuUse = false; + this.limitCpuUse = false; + this.default_use = defaultUse; } 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) { @@ -80,7 +84,8 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering this.rateMbps = rateMbps; this.multicastRateMbps = multicastRateMbps; this.offerHA = offerHA; - this.limitCpuUse = limitCpuUse; + this.limitCpuUse = limitCpuUse; + this.default_use = false; } 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) { @@ -105,6 +110,11 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering public void setLimitResourceUse(boolean limitCpuUse) { this.limitCpuUse = limitCpuUse; } + + @Override + public boolean getDefaultUse() { + return default_use; + } @Override @Transient diff --git a/server/src/com/cloud/storage/allocator/LocalStoragePoolAllocator.java b/server/src/com/cloud/storage/allocator/LocalStoragePoolAllocator.java index 2267f26fda0..a5f6b5e886d 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); + so = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, false, true, null, true, 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); + so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, false, true, null, true, 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); + so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, true, null, false, true, null, true, 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); + so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, false, true, null, false, 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); + so = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, false, true, null, true, 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); + so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, false, true, null, true, 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); + so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, true, null, false, true, null, true, 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); + so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, false, true, null, false, 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 1d80a1f8cef..c569a1299bf 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); + _serviceOffering = new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, _secStorageVmRamSize, _secStorageVmCpuMHz, null, null, false, null, _useLocalStorage, true, null, true, 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 ee13615107b..7a099f355ab 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); + ServiceOfferingVO serviceOffering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, ha, displayText, useLocalStorage, false, null, false, 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 56133da9a29..993b2b67948 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -1149,6 +1149,7 @@ CREATE TABLE `cloud`.`service_offering` ( `ha_enabled` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Enable HA', `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', 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 b70cdc6a190..6229f1cedfd 100644 --- a/setup/db/db/schema-226to227.sql +++ b/setup/db/db/schema-226to227.sql @@ -6,6 +6,7 @@ ALTER TABLE `cloud`.`mshost` ADD COLUMN `runid` bigint NOT NULL DEFAULT 0 COMMEN ALTER TABLE `cloud`.`mshost` ADD COLUMN `state` varchar(10) NOT NULL default 'Down'; 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`.`storage_pool` MODIFY `host_address` varchar(255) NOT NULL; DROP TABLE IF EXISTS `cloud`.`certificate`;