Skip to content

Commit f15cab1

Browse files
server: Decouple service (compute) offering and disk offering (#5008)
Currently, our compute offerings and disk offerings are tightly coupled with respect to many aspects. For example, if a compute offering is created, a corresponding disk offering entry is also created with the same ID as the reference. Also creating compute offering takes few disk-related parameters which anyway goes to the corresponding disk offering only. I think this design was initially made to address compute offering for the root volume created from a template. Also changing the offering of a volume is tightly coupled with storage tags and has to be done in different APIs either migrateVolume or resizeVolume. Changing of disk offering should be seamless and should consider new storage tags, new size and place the volume in appropriate state as defined in disk offering. more details are mentioned here https://cwiki.apache.org/confluence/display/CLOUDSTACK/Compute+offering+and+disk+offering+refactoring * Schema changes and disk offering column change from "type" to "compute_only" * Few more changes * Decoupled service offering and disk offering * Remove diskofferingid from vminstance VO * Decouple service offering and disk offering states * diskoffering getsize() is only for strict disk offerings * Fix deployVM flow * Added new API params to compute offering creation * Add diskofferingstrictness to serviceoffering vo under quota * Added overrideDiskOfferingId parameter in deploy VM API which will override disk offering for the root disk both in template and ISO case Added diskSizeStrictness parameter in create Disk offering API which will decide whether to restrict resize or disk offering change of a volume * Fix User vm response to show proper service offering and disk offerings * Added disk size strictness in disk offering response * Added disk offering strictness to the service offering response * Remove comments * Added UI changes for Disk offering strictness in add compute offering form and Disk size strictness in add disk offering form * Added diskoffering details to the service offering response * Added UI changes in deployvm wizard to accept override disk offering id * Fix delete compute offering * Fix VM deployment from custom service offering * Move uselocalstorage column access from service offering to disk offering * UI: Separated compute and disk releated parameters in add compute offering wizard, also added association to disk offering * Fixed diskoffering automatic selection on add compute offering wizard * UI: move compute only toggle button outside the box in add compute offering wizard * Added volumeId parameter to listDiskOfferings API and the disksizestrictness flag of the current disk offering is honored while list disk offerings * Added configuration parameter to decide whether to check volume tags on the destination storagepool during migration * Added disk offering change checks during resize volume operation * Added new API changeofferingforVolume API and corresponding changes * Add UI form for changeOfferingForVolume API * Fix UI conflicts * Fix service offering usage as disk offering * Fix unit test failures * fix user_vm_view * Addressed review comments * Fixed service_offering_view * Fix service offering edit flow * Fix service offering constructor to address custom offering * Fix domain_router_view to get proper service offering id * Removed unused import * Addressed review comments and fixed update service offering flow with storage tags * Added marvin test cases for checking disk offering strictness * review comments addressed * Remove system_use column from disk offering join * update volume_view to update system_use column from service offering and not disk offering * Fix changeOfferingForVolume API for custom disk offering * Fix global setting implementation * Fix list volumes, after changing system_use column from disk offering to service offering in volume_view * Changes for override root disk offering in deployvm wizard in case of custom offering * Fix a unit test case * Fixed recent unit test cases with new serviceofferingvo constructor * Fix unit test in VolumeApiServiceImpl * Added storage id for the list disk offering API and corresponding UI changes in migrateVolume and changeOfferingForVolume flow * Rename global configuration parameter from storage.pool.tags.disk.offering.strictness to match.storage.pool.tags.with.disk.offering * Fix smoke test failures * Added tool tip for migrate volume UI form * Address review comments and fix UI form of deploy VM in case of ISO. * Fixed resize volume UI form for data disk * UI changes to disable override root disk size when override root disk offering is enabled * UI fix in deploy vm wizard * Fix listdiskoffering after rebasing with main * Fixed UI in migrate and changeofferingfor volume to handle empty disk offering list Removed the volume's current disk offering from listDiskOffering response list * Added custom Iops to resize volume form and removed the current disk offering during change offering for volume UI form * Fix false response on updateDiskOffering API * Added search field for changeofferingforvolume UI form * Fix resize volume and migrate volume to update volume path if DRS is applied on volume in datastore cluster * Removed DB changes from 4.16 upgrade file * Resolving merge conflicts with main 4.17 * Added support for auto migration and auto resize of the root volume upon changing the service offering for VM. * UI: Added automigrate checkbox in scale VM form * Addes since attributes to new API params * Added shrinkOK parameter to changeofferingforvolume API * Added shrinkOk param to UI in changeOfferingforVolume form * Added shrinkOk flag to scaleVM and changeServiceForVirtualMachines and UI form * Removed old foreign key constraint on IDs of service offering and disk offering * Allow resize and automigrate of root volume if required in all cases of service offering change * Allow only resize to higher disk size from UI * Fixing vue syntax error * Make UI changes to provide root disk size box when the linked disk offering is of custom * Converted from check box to toggle in scale VM, changeoffering, resize and migrate volume forms * Fix resize volume operation to update the VM settings * Fix migratevolume form to pick selected storage pool id in list diskofferings API
1 parent b9905c7 commit f15cab1

File tree

102 files changed

+3726
-1021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+3726
-1021
lines changed

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ public class EventTypes {
258258
public static final String EVENT_VOLUME_UPDATE = "VOLUME.UPDATE";
259259
public static final String EVENT_VOLUME_DESTROY = "VOLUME.DESTROY";
260260
public static final String EVENT_VOLUME_RECOVER = "VOLUME.RECOVER";
261+
public static final String EVENT_VOLUME_CHANGE_DISK_OFFERING = "VOLUME.CHANGE.DISK.OFFERING";
261262

262263
// Domains
263264
public static final String EVENT_DOMAIN_CREATE = "DOMAIN.CREATE";
@@ -768,6 +769,7 @@ public class EventTypes {
768769
entityEventDetails.put(EVENT_VOLUME_RESIZE, Volume.class);
769770
entityEventDetails.put(EVENT_VOLUME_DESTROY, Volume.class);
770771
entityEventDetails.put(EVENT_VOLUME_RECOVER, Volume.class);
772+
entityEventDetails.put(EVENT_VOLUME_CHANGE_DISK_OFFERING, Volume.class);
771773

772774
// Domains
773775
entityEventDetails.put(EVENT_DOMAIN_CREATE, Domain.class);

api/src/main/java/com/cloud/offering/DiskOffering.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ enum State {
3434
Inactive, Active,
3535
}
3636

37-
enum Type {
38-
Disk, Service
39-
};
40-
4137
State getState();
4238

4339
enum DiskCacheMode {
@@ -61,8 +57,6 @@ public String toString() {
6157

6258
String getName();
6359

64-
boolean isSystemUse();
65-
6660
String getDisplayText();
6761

6862
ProvisioningType getProvisioningType();
@@ -152,5 +146,7 @@ public String toString() {
152146

153147
void setCacheMode(DiskCacheMode cacheMode);
154148

155-
Type getType();
149+
boolean isComputeOnly();
150+
151+
boolean getDiskSizeStrictness();
156152
}

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

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,34 @@
2525
/**
2626
* offered.
2727
*/
28-
public interface ServiceOffering extends DiskOffering, InfrastructureEntity, InternalIdentity, Identity {
29-
public static final String consoleProxyDefaultOffUniqueName = "Cloud.com-ConsoleProxy";
30-
public static final String ssvmDefaultOffUniqueName = "Cloud.com-SecondaryStorage";
31-
public static final String routerDefaultOffUniqueName = "Cloud.Com-SoftwareRouter";
32-
public static final String elbVmDefaultOffUniqueName = "Cloud.Com-ElasticLBVm";
33-
public static final String internalLbVmDefaultOffUniqueName = "Cloud.Com-InternalLBVm";
28+
public interface ServiceOffering extends InfrastructureEntity, InternalIdentity, Identity {
29+
static final String consoleProxyDefaultOffUniqueName = "Cloud.com-ConsoleProxy";
30+
static final String ssvmDefaultOffUniqueName = "Cloud.com-SecondaryStorage";
31+
static final String routerDefaultOffUniqueName = "Cloud.Com-SoftwareRouter";
32+
static final String elbVmDefaultOffUniqueName = "Cloud.Com-ElasticLBVm";
33+
static final String internalLbVmDefaultOffUniqueName = "Cloud.Com-InternalLBVm";
3434
// leaving cloud.com references as these are identifyers and no real world addresses (check against DB)
3535

36-
public enum StorageType {
36+
enum State {
37+
Inactive, Active,
38+
}
39+
40+
enum StorageType {
3741
local, shared
3842
}
3943

40-
@Override
4144
String getDisplayText();
4245

43-
@Override
4446
Date getCreated();
4547

46-
@Override
47-
String getTags();
48-
4948
/**
5049
* @return user readable description
5150
*/
52-
@Override
5351
String getName();
5452

5553
/**
5654
* @return is this a system service offering
5755
*/
58-
@Override
5956
boolean isSystemUse();
6057

6158
/**
@@ -98,12 +95,6 @@ public enum StorageType {
9895
*/
9996
Integer getMulticastRateMbps();
10097

101-
/**
102-
* @return whether or not the service offering requires local storage
103-
*/
104-
@Override
105-
boolean isUseLocalStorage();
106-
10798
/**
10899
* @return tag that should be present on the host needed, optional parameter
109100
*/
@@ -117,5 +108,35 @@ public enum StorageType {
117108

118109
boolean isDynamic();
119110

111+
void setState(ServiceOffering.State state);
112+
113+
ServiceOffering.State getState();
114+
115+
void setName(String name);
116+
117+
String getUniqueName();
118+
119+
void setUniqueName(String uniqueName);
120+
121+
void setDisplayText(String displayText);
122+
123+
boolean isCustomized();
124+
125+
void setCustomized(boolean customized);
126+
127+
Date getRemoved();
128+
129+
void setRemoved(Date removed);
130+
131+
void setSortKey(int key);
132+
133+
int getSortKey();
134+
135+
Long getDiskOfferingId();
136+
120137
boolean isDynamicScalingEnabled();
138+
139+
Boolean getDiskOfferingStrictness();
140+
141+
void setDiskOfferingStrictness(boolean diskOfferingStrictness);
121142
}

api/src/main/java/com/cloud/server/ManagementService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,17 @@ public interface ManagementService {
394394

395395
/**
396396
* List storage pools for live migrating of a volume. The API returns list of all pools in the cluster to which the
397-
* volume can be migrated. Current pool is not included in the list.
397+
* volume can be migrated. Current pool is not included in the list. In case of vSphere datastore cluster storage pools,
398+
* this method removes the child storage pools and adds the corresponding parent datastore cluster for API response listing
398399
*
399400
* @param Long volumeId
400401
* @return Pair<List<? extends StoragePool>, List<? extends StoragePool>> List of storage pools in cluster and list
401402
* of pools with enough capacity.
402403
*/
403404
Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolume(Long volumeId);
404405

406+
Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolumeInternal(Long volumeId, Long newDiskOfferingId, Long newSize, Long newMinIops, Long newMaxIops, boolean keepSourceStoragePool);
407+
405408
String[] listEventTypes();
406409

407410
Pair<List<? extends HypervisorCapabilities>, Integer> listHypervisorCapabilities(Long id, HypervisorType hypervisorType, String keyword, Long startIndex,

api/src/main/java/com/cloud/storage/VolumeApiService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Map;
2323

2424
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
25+
import org.apache.cloudstack.api.command.user.volume.ChangeOfferingForVolumeCmd;
2526
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
2627
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
2728
import org.apache.cloudstack.api.command.user.volume.ExtractVolumeCmd;
@@ -152,4 +153,6 @@ Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account acc
152153
Volume destroyVolume(long volumeId, Account caller, boolean expunge, boolean forceExpunge);
153154

154155
Volume recoverVolume(long volumeId);
156+
157+
Volume changeDiskOfferingForVolume(ChangeOfferingForVolumeCmd cmd) throws ResourceAllocationException;
155158
}

api/src/main/java/com/cloud/vm/DiskProfile.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public class DiskProfile {
4242
private Long iopsReadRate;
4343
private Long iopsWriteRate;
4444
private String cacheMode;
45+
private Long minIops;
46+
private Long maxIops;
4547

4648
private HypervisorType hyperType;
4749

@@ -227,4 +229,22 @@ public void setCacheMode(String cacheMode) {
227229
public String getCacheMode() {
228230
return cacheMode;
229231
}
232+
233+
234+
public Long getMinIops() {
235+
return minIops;
236+
}
237+
238+
public void setMinIops(Long minIops) {
239+
this.minIops = minIops;
240+
}
241+
242+
public Long getMaxIops() {
243+
return maxIops;
244+
}
245+
246+
public void setMaxIops(Long maxIops) {
247+
this.maxIops = maxIops;
248+
}
249+
230250
}

api/src/main/java/com/cloud/vm/UserVmService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ UserVm createBasicSecurityGroupVirtualMachine(DataCenter zone, ServiceOffering s
218218
String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIp, Boolean displayVm, String keyboard,
219219
List<Long> affinityGroupIdList, Map<String, String> customParameter, String customId, Map<String, Map<Integer, String>> dhcpOptionMap,
220220
Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
221-
Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled) throws InsufficientCapacityException,
221+
Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled, Long overrideDiskOfferingId) throws InsufficientCapacityException,
222222
ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
223223

224224
/**
@@ -300,7 +300,7 @@ UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, ServiceOfferin
300300
HTTPMethod httpmethod, String userData, String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard,
301301
List<Long> affinityGroupIdList, Map<String, String> customParameters, String customId, Map<String, Map<Integer, String>> dhcpOptionMap,
302302
Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
303-
Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled) throws InsufficientCapacityException,
303+
Map<String, String> userVmOVFProperties, boolean dynamicScalingEnabled, Long overrideDiskOfferingId) throws InsufficientCapacityException,
304304
ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
305305

306306
/**
@@ -379,7 +379,7 @@ UserVm createAdvancedVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
379379
String hostName, String displayName, Long diskOfferingId, Long diskSize, String group, HypervisorType hypervisor, HTTPMethod httpmethod, String userData,
380380
String sshKeyPair, Map<Long, IpAddresses> requestedIps, IpAddresses defaultIps, Boolean displayVm, String keyboard, List<Long> affinityGroupIdList,
381381
Map<String, String> customParameters, String customId, Map<String, Map<Integer, String>> dhcpOptionMap, Map<Long, DiskOffering> dataDiskTemplateToDiskOfferingMap,
382-
Map<String, String> templateOvfPropertiesMap, boolean dynamicScalingEnabled, String type)
382+
Map<String, String> templateOvfPropertiesMap, boolean dynamicScalingEnabled, String type, Long overrideDiskOfferingId)
383383

384384
throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, StorageUnavailableException, ResourceAllocationException;
385385

api/src/main/java/com/cloud/vm/VirtualMachine.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,6 @@ public boolean isUsedBySystem() {
323323

324324
long getServiceOfferingId();
325325

326-
Long getDiskOfferingId();
327-
328326
Long getBackupOfferingId();
329327

330328
String getBackupExternalId();

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,15 @@ public class ApiConstants {
112112
public static final String DISK = "disk";
113113
public static final String DISK_OFFERING_ID = "diskofferingid";
114114
public static final String NEW_DISK_OFFERING_ID = "newdiskofferingid";
115+
public static final String OVERRIDE_DISK_OFFERING_ID = "overridediskofferingid";
115116
public static final String DISK_KBS_READ = "diskkbsread";
116117
public static final String DISK_KBS_WRITE = "diskkbswrite";
117118
public static final String DISK_IO_READ = "diskioread";
118119
public static final String DISK_IO_WRITE = "diskiowrite";
119120
public static final String DISK_IO_PSTOTAL = "diskiopstotal";
120121
public static final String DISK_SIZE = "disksize";
122+
public static final String DISK_SIZE_STRICTNESS = "disksizestrictness";
123+
public static final String DISK_OFFERING_STRICTNESS = "diskofferingstrictness";
121124
public static final String DOWNLOAD_DETAILS = "downloaddetails";
122125
public static final String UTILIZATION = "utilization";
123126
public static final String DRIVER = "driver";
@@ -589,6 +592,7 @@ public class ApiConstants {
589592
public static final String LIVE_MIGRATE = "livemigrate";
590593
public static final String MIGRATE_ALLOWED = "migrateallowed";
591594
public static final String MIGRATE_TO = "migrateto";
595+
public static final String AUTO_MIGRATE = "automigrate";
592596
public static final String GUID = "guid";
593597
public static final String VSWITCH_TYPE_GUEST_TRAFFIC = "guestvswitchtype";
594598
public static final String VSWITCH_TYPE_PUBLIC_TRAFFIC = "publicvswitchtype";

api/src/main/java/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ public class CreateDiskOfferingCmd extends BaseCmd {
159159
@Parameter(name = ApiConstants.STORAGE_POLICY, type = CommandType.UUID, entityType = VsphereStoragePoliciesResponse.class,required = false, description = "Name of the storage policy defined at vCenter, this is applicable only for VMware", since = "4.15")
160160
private Long storagePolicy;
161161

162+
@Parameter(name = ApiConstants.DISK_SIZE_STRICTNESS, type = CommandType.BOOLEAN, description = "To allow or disallow the resize operation on the disks created from this disk offering, if the flag is true then resize is not allowed", since = "4.17")
163+
private Boolean diskSizeStrictness;
164+
162165
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "details to specify disk offering parameters", since = "4.16")
163166
private Map details;
164167

@@ -301,6 +304,11 @@ public Map<String, String> getDetails() {
301304
public Long getStoragePolicy() {
302305
return storagePolicy;
303306
}
307+
308+
public boolean getDiskSizeStrictness() {
309+
return diskSizeStrictness != null ? diskSizeStrictness : false;
310+
}
311+
304312
/////////////////////////////////////////////////////
305313
/////////////// API Implementation///////////////////
306314
/////////////////////////////////////////////////////

0 commit comments

Comments
 (0)