Skip to content

Commit e6d1680

Browse files
Henrique Satohsato03
authored andcommitted
Add disk offering Hypervisor default cache mode
1 parent 98f5663 commit e6d1680

File tree

10 files changed

+28
-10
lines changed

10 files changed

+28
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ enum State {
3737
State getState();
3838

3939
enum DiskCacheMode {
40-
NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough");
40+
HYPERVISOR_DEFAULT("hypervisor_default"), NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough");
4141

4242
private final String _diskCacheMode;
4343

core/src/main/java/org/apache/cloudstack/storage/to/VolumeObjectTO.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.apache.cloudstack.storage.to;
2121

2222
import com.cloud.agent.api.LogLevel;
23+
import com.cloud.offering.DiskOffering;
2324
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
2425

2526
import com.cloud.agent.api.to.DataObjectType;
@@ -112,8 +113,8 @@ public VolumeObjectTO(VolumeInfo volume) {
112113
iopsWriteRate = volume.getIopsWriteRate();
113114
iopsWriteRateMax = volume.getIopsWriteRateMax();
114115
iopsWriteRateMaxLength = volume.getIopsWriteRateMaxLength();
115-
cacheMode = volume.getCacheMode();
116116
hypervisorType = volume.getHypervisorType();
117+
setCacheMode(volume.getCacheMode());
117118
setDeviceId(volume.getDeviceId());
118119
this.migrationOptions = volume.getMigrationOptions();
119120
this.directDownload = volume.isDirectDownload();
@@ -337,6 +338,10 @@ public void setDeviceId(Long deviceId) {
337338
}
338339

339340
public void setCacheMode(DiskCacheMode cacheMode) {
341+
if (DiskCacheMode.HYPERVISOR_DEFAULT.equals(cacheMode) && !Hypervisor.HypervisorType.KVM.equals(hypervisorType)) {
342+
this.cacheMode = DiskOffering.DiskCacheMode.NONE;
343+
return;
344+
}
340345
this.cacheMode = cacheMode;
341346
}
342347

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ SELECT uuid(), role_id, 'quotaCreditsList', permission, sort_order
3131
FROM `cloud`.`role_permissions` rp
3232
WHERE rp.rule = 'quotaStatement'
3333
AND NOT EXISTS(SELECT 1 FROM cloud.role_permissions rp_ WHERE rp.role_id = rp_.role_id AND rp_.rule = 'quotaCreditsList');
34+
35+
-- Increase the cache_mode column size from cloud.disk_offering table
36+
CALL `cloud`.`IDEMPOTENT_CHANGE_COLUMN`('cloud.disk_offering', 'cache_mode', 'cache_mode', 'varchar(18) DEFAULT "none" COMMENT "The disk cache mode to use for disks created with this offering"');

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ public String toString() {
706706
}
707707

708708
public enum DiskCacheMode {
709-
NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough");
709+
HYPERVISOR_DEFAULT("default"), NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough");
710710
String _diskCacheMode;
711711

712712
DiskCacheMode(String cacheMode) {

plugins/storage/volume/adaptive/src/main/java/org/apache/cloudstack/storage/datastore/adapter/ProviderAdapterDiskOffering.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public ProviderAdapterDiskOffering(DiskOffering hiddenDiskOffering) {
3434
this.type = ProvisioningType.getProvisioningType(hiddenDiskOffering.getProvisioningType().toString());
3535
}
3636
if (hiddenDiskOffering.getCacheMode() != null) {
37-
this.diskCacheMode = DiskCacheMode.getDiskCasehMode(hiddenDiskOffering.getCacheMode().toString());
37+
this.diskCacheMode = DiskCacheMode.getDiskCacheMode(hiddenDiskOffering.getCacheMode().toString());
3838
}
3939
if (hiddenDiskOffering.getState() != null) {
4040
this.state = State.valueOf(hiddenDiskOffering.getState().toString());
@@ -166,7 +166,7 @@ enum State {
166166
}
167167

168168
enum DiskCacheMode {
169-
NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough");
169+
HYPERVISOR_DEFAULT("hypervisor_default"), NONE("none"), WRITEBACK("writeback"), WRITETHROUGH("writethrough");
170170

171171
private final String _diskCacheMode;
172172

@@ -179,13 +179,15 @@ public String toString() {
179179
return _diskCacheMode;
180180
}
181181

182-
public static DiskCacheMode getDiskCasehMode(String cacheMode) {
182+
public static DiskCacheMode getDiskCacheMode(String cacheMode) {
183183
if (cacheMode.equals(NONE._diskCacheMode)) {
184184
return NONE;
185185
} else if (cacheMode.equals(WRITEBACK._diskCacheMode)) {
186186
return WRITEBACK;
187187
} else if (cacheMode.equals(WRITETHROUGH._diskCacheMode)) {
188188
return WRITETHROUGH;
189+
} else if (cacheMode.equals(HYPERVISOR_DEFAULT._diskCacheMode)) {
190+
return HYPERVISOR_DEFAULT;
189191
} else {
190192
throw new NotImplementedException("Invalid cache mode specified: " + cacheMode);
191193
}

server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8061,7 +8061,7 @@ protected void validateCacheMode(String cacheMode){
80618061
!Enums.getIfPresent(DiskOffering.DiskCacheMode.class,
80628062
cacheMode.toUpperCase()).isPresent()) {
80638063
throw new InvalidParameterValueException(String.format("Invalid cache mode (%s). Please specify one of the following " +
8064-
"valid cache mode parameters: none, writeback or writethrough", cacheMode));
8064+
"valid cache mode parameters: none, writeback, writethrough or hypervisor_default.", cacheMode));
80658065
}
80668066
}
80678067

ui/public/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,7 @@
11011101
"label.hourly": "Hourly",
11021102
"label.hypervisor": "Hypervisor",
11031103
"label.hypervisor.capabilities": "Hypervisor capabilities",
1104+
"label.hypervisor.default": "Hypervisor default",
11041105
"label.hypervisor.type": "Hypervisor type",
11051106
"label.hypervisors": "Hypervisors",
11061107
"label.hypervisorsnapshotreserve": "Hypervisor Snapshot reserve",
@@ -2596,7 +2597,7 @@
25962597
"label.windows": "Windows",
25972598
"label.with.snapshotid": "with Snapshot ID",
25982599
"label.write": "Write",
2599-
"label.writeback": "Write-back disk caching",
2600+
"label.writeback": "Write-back",
26002601
"label.writecachetype": "Write-cache Type",
26012602
"label.writeio": "Write (IO)",
26022603
"label.writethrough": "Write-through",

ui/public/locales/pt_BR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@
770770
"label.hourly": "A cada hora",
771771
"label.hypervisor": "Virtualizador",
772772
"label.hypervisor.capabilities": "Recursos do virtualizador",
773+
"label.hypervisor.default": "Padr\u00e3o do virtualizador",
773774
"label.hypervisor.type": "Tipo do virtualizador",
774775
"label.hypervisors": "Virtualizadores",
775776
"label.hypervisorsnapshotreserve": "Reserva de snapshot do virtualizador",
@@ -1812,7 +1813,7 @@
18121813
"label.windows": "Windows",
18131814
"label.with.snapshotid": "com o ID da snapshot",
18141815
"label.write": "Escreva",
1815-
"label.writeback": "Cache de disco write-back",
1816+
"label.writeback": "Write-back",
18161817
"label.writecachetype": "Tipo do cache de escrita",
18171818
"label.writeio": "Escrita (IO)",
18181819
"label.writethrough": "Write-through",

ui/src/views/offering/AddComputeOffering.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@
409409
<a-radio-button value="writethrough">
410410
{{ $t('label.writethrough') }}
411411
</a-radio-button>
412+
<a-radio-button value="hypervisor_default">
413+
{{ $t('label.hypervisor.default') }}
414+
</a-radio-button>
412415
</a-radio-group>
413416
</a-form-item>
414417
<a-form-item :label="$t('label.qostype')" name="qostype" ref="qostype">

ui/src/views/offering/AddDiskOffering.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@
211211
<a-radio-button value="writethrough">
212212
{{ $t('label.writethrough') }}
213213
</a-radio-button>
214+
<a-radio-button value="hypervisor_default">
215+
{{ $t('label.hypervisor.default') }}
216+
</a-radio-button>
214217
</a-radio-group>
215218
</a-form-item>
216219
<a-form-item v-if="isAdmin() || isDomainAdminAllowedToInformTags" name="tags" ref="tags">
@@ -601,7 +604,7 @@ export default {
601604
width: 80vw;
602605
603606
@media (min-width: 800px) {
604-
width: 430px;
607+
width: 480px;
605608
}
606609
}
607610
</style>

0 commit comments

Comments
 (0)