bug 10313: marking default system offering as default so that they should not be deleted

status 10313: resolved fixed
This commit is contained in:
Abhinandan Prateek 2011-06-19 12:16:06 +05:30
parent 287274ccea
commit db29a56eaf
15 changed files with 54 additions and 21 deletions

View File

@ -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";

View File

@ -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;
}

View File

@ -89,4 +89,6 @@ public interface ServiceOffering {
* @return tag that should be present on the host needed, optional parameter
*/
String getHostTag();
boolean getDefaultUse();
}

View File

@ -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) {

View File

@ -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());

View File

@ -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);

View File

@ -165,5 +165,10 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe
public String getHostTag() {
return hostTag;
}
}
@Override
public boolean getDefaultUse() {
return false;
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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`;