Skip to content

Commit 455ecf1

Browse files
committed
[CLOUDSTACK-10039] Adding IOPS/GB offering
1 parent 189b0e4 commit 455ecf1

18 files changed

Lines changed: 1259 additions & 113 deletions

File tree

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
// under the License.
1717
package com.cloud.offering;
1818

19-
import java.util.Date;
20-
19+
import com.cloud.storage.Storage.ProvisioningType;
2120
import org.apache.cloudstack.acl.InfrastructureEntity;
2221
import org.apache.cloudstack.api.Identity;
2322
import org.apache.cloudstack.api.InternalIdentity;
2423

25-
import com.cloud.storage.Storage.ProvisioningType;
24+
import java.util.Date;
2625

2726
/**
2827
* Represents a disk offering that specifies what the end user needs in
@@ -111,6 +110,22 @@ public String toString() {
111110

112111
Long getIopsWriteRate();
113112

113+
Long getMinIopsPerGb();
114+
115+
void setMinIopsPerGb(Long minIopsPerGB);
116+
117+
Long getMaxIopsPerGb();
118+
119+
void setMaxIopsPerGb(Long maxIopsPerGB);
120+
121+
Long getHighestMinIops();
122+
123+
void setHighestMinIops(Long highestMinIops);
124+
125+
Long getHighestMaxIops();
126+
127+
void setHighestMaxIops(Long highestMaxIops);
128+
114129
void setHypervisorSnapshotReserve(Integer hypervisorSnapshotReserve);
115130

116131
Integer getHypervisorSnapshotReserve();

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,10 @@ public class ApiConstants {
669669
public static final String VIRTUAL_SIZE = "virtualsize";
670670
public static final String NETSCALER_CONTROLCENTER_ID = "netscalercontrolcenterid";
671671
public static final String NETSCALER_SERVICEPACKAGE_ID = "netscalerservicepackageid";
672+
public static final String MIN_IOPS_PER_GB = "miniopspergb";
673+
public static final String MAX_IOPS_PER_GB = "maxiopspergb";
674+
public static final String HIGHEST_MIN_IOPS = "highestminiops";
675+
public static final String HIGHEST_MAX_IOPS = "highestmaxiops";
672676

673677
public static final String ZONE_ID_LIST = "zoneids";
674678
public static final String DESTINATION_ZONE_ID_LIST = "destzoneids";

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ public class CreateDiskOfferingCmd extends BaseCmd {
9898
@Parameter(name = ApiConstants.MAX_IOPS, type = CommandType.LONG, required = false, description = "max iops of the disk offering")
9999
private Long maxIops;
100100

101+
@Parameter(name = ApiConstants.MIN_IOPS_PER_GB, type = CommandType.LONG, required = false, description = "IOPS/GB rate for min IOPS. miniops = size * miniopspergb")
102+
private Long minIopsPerGb;
103+
104+
@Parameter(name = ApiConstants.MAX_IOPS_PER_GB, type = CommandType.LONG, required = false, description = "IOPS/GB rate for max IOPS. maxiops = size * maxiopspergb")
105+
private Long maxIopsPerGb;
106+
107+
@Parameter(name = ApiConstants.HIGHEST_MIN_IOPS, type = CommandType.LONG, required = false, description = "Highest Min IOPS value that is allowed for this offering")
108+
private Long highestMinIops;
109+
110+
@Parameter(name = ApiConstants.HIGHEST_MAX_IOPS, type = CommandType.LONG, required = false, description = "Highest Max IOPS value that is allowed for this offering")
111+
private Long highestMaxIops;
112+
101113
@Parameter(name = ApiConstants.HYPERVISOR_SNAPSHOT_RESERVE,
102114
type = CommandType.INTEGER,
103115
required = false,
@@ -176,6 +188,21 @@ public Integer getHypervisorSnapshotReserve() {
176188
return hypervisorSnapshotReserve;
177189
}
178190

191+
public Long getMinIopsPerGb() {
192+
return minIopsPerGb;
193+
}
194+
195+
public Long getMaxIopsPerGb() {
196+
return maxIopsPerGb;
197+
}
198+
199+
public Long getHighestMinIops() {
200+
return highestMinIops;
201+
}
202+
203+
public Long getHighestMaxIops() {
204+
return highestMaxIops;
205+
}
179206
/////////////////////////////////////////////////////
180207
/////////////// API Implementation///////////////////
181208
/////////////////////////////////////////////////////

api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.response;
1818

19-
import java.util.Date;
20-
19+
import com.cloud.offering.DiskOffering;
20+
import com.cloud.serializer.Param;
2121
import com.google.gson.annotations.SerializedName;
22-
2322
import org.apache.cloudstack.api.ApiConstants;
2423
import org.apache.cloudstack.api.BaseResponse;
2524
import org.apache.cloudstack.api.EntityReference;
2625

27-
import com.cloud.offering.DiskOffering;
28-
import com.cloud.serializer.Param;
26+
import java.util.Date;
2927

3028
@EntityReference(value = DiskOffering.class)
3129
public class DiskOfferingResponse extends BaseResponse {
@@ -112,6 +110,21 @@ public class DiskOfferingResponse extends BaseResponse {
112110
@Param(description = "whether to display the offering to the end user or not.")
113111
private Boolean displayOffering;
114112

113+
@SerializedName(ApiConstants.MIN_IOPS_PER_GB)
114+
@Param(description = "IOPS/GB rate for min IOPS. miniops = size * miniopspergb")
115+
private Long minIopsPerGb;
116+
@SerializedName(ApiConstants.MAX_IOPS_PER_GB)
117+
@Param(description = "IOPS/GB rate for max IOPS. miniops = size * miniopspergb")
118+
private Long maxIopsPerGb;
119+
120+
@SerializedName(ApiConstants.HIGHEST_MIN_IOPS)
121+
@Param(description = "Highest Min IOPS value that is allowed for this offering")
122+
private Long highestMinIops;
123+
124+
@SerializedName(ApiConstants.HIGHEST_MAX_IOPS)
125+
@Param(description = "Highest Max IOPS value that is allowed for this offering")
126+
private Long highestMaxIops;
127+
115128
public Boolean getDisplayOffering() {
116129
return displayOffering;
117130
}
@@ -221,6 +234,38 @@ public Integer getHypervisorSnapshotReserve() {
221234
return hypervisorSnapshotReserve;
222235
}
223236

237+
public Long getMinIopsPerGb() {
238+
return minIopsPerGb;
239+
}
240+
241+
public void setMinIopsPerGb(Long minIopsPerGb) {
242+
this.minIopsPerGb = minIopsPerGb;
243+
}
244+
245+
public Long getMaxIopsPerGb() {
246+
return maxIopsPerGb;
247+
}
248+
249+
public void setMaxIopsPerGb(Long maxIopsPerGb) {
250+
this.maxIopsPerGb = maxIopsPerGb;
251+
}
252+
253+
public Long getHighestMinIops() {
254+
return highestMinIops;
255+
}
256+
257+
public void setHighestMinIops(Long highestMinIops) {
258+
this.highestMinIops = highestMinIops;
259+
}
260+
261+
public Long getHighestMaxIops() {
262+
return highestMaxIops;
263+
}
264+
265+
public void setHighestMaxIops(Long highestMaxIops) {
266+
this.highestMaxIops = highestMaxIops;
267+
}
268+
224269
public void setHypervisorSnapshotReserve(Integer hypervisorSnapshotReserve) {
225270
this.hypervisorSnapshotReserve = hypervisorSnapshotReserve;
226271
}
@@ -264,4 +309,5 @@ public void setIopsReadRate(Long iopsReadRate) {
264309
public void setIopsWriteRate(Long iopsWriteRate) {
265310
this.iopsWriteRate = iopsWriteRate;
266311
}
312+
267313
}

engine/schema/src/com/cloud/storage/DiskOfferingVO.java

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
// under the License.
1717
package com.cloud.storage;
1818

19-
import java.util.Date;
20-
import java.util.List;
21-
import java.util.UUID;
19+
import com.cloud.offering.DiskOffering;
20+
import com.cloud.utils.db.GenericDao;
2221

2322
import javax.persistence.Column;
2423
import javax.persistence.DiscriminatorColumn;
@@ -35,9 +34,9 @@
3534
import javax.persistence.Temporal;
3635
import javax.persistence.TemporalType;
3736
import javax.persistence.Transient;
38-
39-
import com.cloud.offering.DiskOffering;
40-
import com.cloud.utils.db.GenericDao;
37+
import java.util.Date;
38+
import java.util.List;
39+
import java.util.UUID;
4140

4241
@Entity
4342
@Table(name = "disk_offering")
@@ -117,6 +116,18 @@ public class DiskOfferingVO implements DiskOffering {
117116
@Column(name = "iops_write_rate")
118117
Long iopsWriteRate;
119118

119+
@Column(name = "min_iops_per_gb")
120+
Long minIopsPerGb;
121+
122+
@Column(name = "max_iops_per_gb")
123+
Long maxIopsPerGb;
124+
125+
@Column(name = "highest_min_iops")
126+
Long highestMinIops;
127+
128+
@Column(name = "highest_max_iops")
129+
Long highestMaxIops;
130+
120131
@Column(name = "cache_mode", updatable = true, nullable = false)
121132
@Enumerated(value = EnumType.STRING)
122133
private DiskCacheMode cacheMode;
@@ -465,7 +476,7 @@ public void setDisplayOffering(boolean displayOffering) {
465476
this.displayOffering = displayOffering;
466477
}
467478

468-
@Override
479+
@Override
469480
public void setBytesReadRate(Long bytesReadRate) {
470481
this.bytesReadRate = bytesReadRate;
471482
}
@@ -505,6 +516,46 @@ public Long getIopsWriteRate() {
505516
return iopsWriteRate;
506517
}
507518

519+
@Override
520+
public Long getMinIopsPerGb() {
521+
return this.minIopsPerGb;
522+
}
523+
524+
@Override
525+
public void setMinIopsPerGb(Long minIopsPerGb) {
526+
this.minIopsPerGb = minIopsPerGb;
527+
}
528+
529+
@Override
530+
public Long getMaxIopsPerGb() {
531+
return maxIopsPerGb;
532+
}
533+
534+
@Override
535+
public void setMaxIopsPerGb(Long maxIopsPerGb) {
536+
this.maxIopsPerGb = maxIopsPerGb;
537+
}
538+
539+
@Override
540+
public Long getHighestMinIops() {
541+
return this.highestMinIops;
542+
}
543+
544+
@Override
545+
public void setHighestMinIops(Long highestMinIops) {
546+
this.highestMinIops = highestMinIops;
547+
}
548+
549+
@Override
550+
public Long getHighestMaxIops() {
551+
return this.highestMaxIops;
552+
}
553+
554+
@Override
555+
public void setHighestMaxIops(Long highestMaxIops) {
556+
this.highestMaxIops = highestMaxIops;
557+
}
558+
508559
@Override
509560
public void setHypervisorSnapshotReserve(Integer hypervisorSnapshotReserve) {
510561
this.hypervisorSnapshotReserve = hypervisorSnapshotReserve;

framework/db/src/com/cloud/utils/db/ScriptRunner.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
package com.cloud.utils.db;
2222

23+
import org.apache.log4j.Logger;
24+
2325
import java.io.IOException;
2426
import java.io.LineNumberReader;
2527
import java.io.Reader;
@@ -29,15 +31,14 @@
2931
import java.sql.SQLException;
3032
import java.sql.Statement;
3133

32-
import org.apache.log4j.Logger;
33-
3434
/**
3535
* Tool to run database scripts
3636
*/
3737
public class ScriptRunner {
3838
private static Logger s_logger = Logger.getLogger(ScriptRunner.class);
3939

4040
private static final String DEFAULT_DELIMITER = ";";
41+
private static final String CHANGE_DELIMITER_STMT = "DELIMITER ";
4142

4243
private Connection connection;
4344

@@ -128,6 +129,12 @@ private void runScript(Connection conn, Reader reader) throws IOException, SQLEx
128129
// Do nothing
129130
} else if (trimmedLine.length() < 1 || trimmedLine.startsWith("#")) {
130131
// Do nothing
132+
} else if (trimmedLine.startsWith(CHANGE_DELIMITER_STMT)) {
133+
String[] res = trimmedLine.split(CHANGE_DELIMITER_STMT, 2);
134+
if (res.length == 2) {
135+
String newDelimiter = res[1];
136+
setDelimiter(newDelimiter, fullLineDelimiter);
137+
}
131138
} else if (!fullLineDelimiter && trimmedLine.endsWith(getDelimiter()) || fullLineDelimiter && trimmedLine.equals(getDelimiter())) {
132139
command.append(line.substring(0, line.lastIndexOf(getDelimiter())));
133140
command.append(" ");

server/src/com/cloud/api/query/dao/DiskOfferingJoinDaoImpl.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,18 @@
1616
// under the License.
1717
package com.cloud.api.query.dao;
1818

19-
import java.util.List;
20-
21-
22-
import org.apache.log4j.Logger;
23-
import org.springframework.stereotype.Component;
24-
25-
import org.apache.cloudstack.api.response.DiskOfferingResponse;
26-
2719
import com.cloud.api.query.vo.DiskOfferingJoinVO;
2820
import com.cloud.offering.DiskOffering;
2921
import com.cloud.offering.ServiceOffering;
3022
import com.cloud.utils.db.Attribute;
3123
import com.cloud.utils.db.GenericDaoBase;
3224
import com.cloud.utils.db.SearchBuilder;
3325
import com.cloud.utils.db.SearchCriteria;
26+
import org.apache.cloudstack.api.response.DiskOfferingResponse;
27+
import org.apache.log4j.Logger;
28+
import org.springframework.stereotype.Component;
29+
30+
import java.util.List;
3431

3532
@Component
3633
public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO, Long> implements DiskOfferingJoinDao {
@@ -62,6 +59,10 @@ public DiskOfferingResponse newDiskOfferingResponse(DiskOfferingJoinVO offering)
6259
diskOfferingResponse.setDiskSize(offering.getDiskSize() / (1024 * 1024 * 1024));
6360
diskOfferingResponse.setMinIops(offering.getMinIops());
6461
diskOfferingResponse.setMaxIops(offering.getMaxIops());
62+
diskOfferingResponse.setMinIopsPerGb(offering.getMinIopsPerGb());
63+
diskOfferingResponse.setMaxIopsPerGb(offering.getMaxIopsPerGb());
64+
diskOfferingResponse.setHighestMinIops(offering.getHighestMinIops());
65+
diskOfferingResponse.setHighestMaxIops(offering.getHighestMaxIops());
6566

6667
diskOfferingResponse.setDomain(offering.getDomainName());
6768
diskOfferingResponse.setDomainId(offering.getDomainUuid());

0 commit comments

Comments
 (0)