Skip to content

Commit db29a56

Browse files
author
Abhinandan Prateek
committed
bug 10313: marking default system offering as default so that they should not be deleted
status 10313: resolved fixed
1 parent 287274c commit db29a56

15 files changed

Lines changed: 54 additions & 21 deletions

File tree

api/src/com/cloud/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public class ApiConstants {
113113
public static final String NUM_RETRIES = "numretries";
114114
public static final String OFFER_HA = "offerha";
115115
public static final String IS_SYSTEM_OFFERING = "issystem";
116+
public static final String IS_DEFAULT_USE = "defaultuse";
116117
public static final String OP = "op";
117118
public static final String OS_CATEGORY_ID = "oscategoryid";
118119
public static final String OS_TYPE_ID = "ostypeid";

api/src/com/cloud/api/response/ServiceOfferingResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public class ServiceOfferingResponse extends BaseResponse {
6969
@SerializedName(ApiConstants.IS_SYSTEM_OFFERING) @Param(description="is this a system vm offering")
7070
private Boolean isSystem;
7171

72+
@SerializedName(ApiConstants.IS_DEFAULT_USE) @Param(description="is this a default system vm offering")
73+
private Boolean defaultUse;
74+
7275

7376
public Long getId() {
7477
return id;
@@ -95,6 +98,15 @@ public void setIsSystemOffering(Boolean isSystem) {
9598
}
9699

97100

101+
public Boolean getDefaultUse() {
102+
return defaultUse;
103+
}
104+
105+
public void setDefaultUse(Boolean defaultUse) {
106+
this.defaultUse = defaultUse;
107+
}
108+
109+
98110
public String getDisplayText() {
99111
return displayText;
100112
}

api/src/com/cloud/offering/ServiceOffering.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,6 @@ public interface ServiceOffering {
8989
* @return tag that should be present on the host needed, optional parameter
9090
*/
9191
String getHostTag();
92+
93+
boolean getDefaultUse();
9294
}

server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,14 @@ private long calcHostAllocatedCpuMemoryCapacity(long hostId, short capacityType)
261261
}
262262
so = _offeringDao.findById(userVm.getServiceOfferingId());
263263
} else if (vm.getType() == VirtualMachine.Type.ConsoleProxy) {
264-
so = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, false, true, null, true);
264+
so = new ServiceOfferingVO("Fake Offering For DomP", 1, _proxyRamSize, 0, 0, 0, false, null, false, true, null, true, false);
265265
} else if (vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
266-
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, false, true, null, true);
266+
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, false, true, null, true, false);
267267
} else if (vm.getType() == VirtualMachine.Type.DomainRouter) {
268-
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, true, null, false, true, null, true);
268+
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, true, null, false, true, null, true, false);
269269
} else {
270270
assert (false) : "Unsupported system vm type";
271-
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, false, true, null, true);
271+
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, false, true, null, true, false);
272272
}
273273

274274
if (capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {

server/src/com/cloud/api/ApiResponseHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ public ServiceOfferingResponse createServiceOfferingResponse(ServiceOffering off
426426
offeringResponse.setId(offering.getId());
427427
offeringResponse.setName(offering.getName());
428428
offeringResponse.setIsSystemOffering(offering.getSystemUse());
429+
offeringResponse.setDefaultUse(offering.getDefaultUse());
429430
offeringResponse.setDisplayText(offering.getDisplayText());
430431
offeringResponse.setCpuNumber(offering.getCpu());
431432
offeringResponse.setCpuSpeed(offering.getSpeed());

server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
12451245
_itMgr.registerGuru(VirtualMachine.Type.ConsoleProxy, this);
12461246

12471247
boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
1248-
_serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, _proxyCpuMHz, 0, 0, false, null, useLocalStorage, true, null, true);
1248+
_serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, _proxyCpuMHz, 0, 0, false, null, useLocalStorage, true, null, true, true);
12491249
_serviceOffering.setUniqueName("Cloud.com-ConsoleProxy");
12501250
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
12511251

server/src/com/cloud/migration/ServiceOffering21VO.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,10 @@ public void setHostTag(String hostTag) {
165165

166166
public String getHostTag() {
167167
return hostTag;
168-
}
168+
}
169+
170+
@Override
171+
public boolean getDefaultUse() {
172+
return false;
173+
}
169174
}

server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ public boolean configure(final String name, final Map<String, Object> params) th
569569
_itMgr.registerGuru(VirtualMachine.Type.DomainRouter, this);
570570

571571
boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
572-
_offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, _routerCpuMHz, null, null, true, null, useLocalStorage, true, null, true);
572+
_offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, _routerCpuMHz, null, null, true, null, useLocalStorage, true, null, true, true);
573573
_offering.setUniqueName("Cloud.Com-SoftwareRouter");
574574
_offering = _serviceOfferingDao.persistSystemServiceOffering(_offering);
575575

server/src/com/cloud/server/ConfigurationServerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ private DiskOfferingVO createDiskOffering(Long domainId, String name, String des
805805

806806
private ServiceOfferingVO createServiceOffering(long userId, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired, boolean offerHA, String tags) {
807807
tags = cleanupTags(tags);
808-
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, offerHA, displayText, localStorageRequired, false, tags, false);
808+
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, offerHA, displayText, localStorageRequired, false, tags, false, false);
809809

810810
if ((offering = _serviceOfferingDao.persist(offering)) != null) {
811811
return offering;

server/src/com/cloud/service/ServiceOfferingVO.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,24 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
5656

5757
@Column(name="host_tag")
5858
private String hostTag;
59+
60+
@Column(name="default_use")
61+
private boolean default_use;
5962

6063
protected ServiceOfferingVO() {
6164
super();
6265
}
6366

64-
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) {
67+
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) {
6568
super(name, displayText, false, tags, recreatable, useLocalStorage, systemUse, true);
6669
this.cpu = cpu;
6770
this.ramSize = ramSize;
6871
this.speed = speed;
6972
this.rateMbps = rateMbps;
7073
this.multicastRateMbps = multicastRateMbps;
7174
this.offerHA = offerHA;
72-
this.limitCpuUse = false;
75+
this.limitCpuUse = false;
76+
this.default_use = defaultUse;
7377
}
7478

7579
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 ServiceOfferingVO(String name, int cpu, int ramSize, int speed, Integer r
8084
this.rateMbps = rateMbps;
8185
this.multicastRateMbps = multicastRateMbps;
8286
this.offerHA = offerHA;
83-
this.limitCpuUse = limitCpuUse;
87+
this.limitCpuUse = limitCpuUse;
88+
this.default_use = false;
8489
}
8590

8691
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 boolean getLimitCpuUse() {
105110
public void setLimitResourceUse(boolean limitCpuUse) {
106111
this.limitCpuUse = limitCpuUse;
107112
}
113+
114+
@Override
115+
public boolean getDefaultUse() {
116+
return default_use;
117+
}
108118

109119
@Override
110120
@Transient

0 commit comments

Comments
 (0)