Skip to content

Commit 6693498

Browse files
committed
quota: quota service implementation
squash merged from quota branch
1 parent ee66cd4 commit 6693498

File tree

86 files changed

+7312
-61
lines changed

Some content is hidden

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

86 files changed

+7312
-61
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ public class ApiConstants {
269269
public static final String VIRTUAL_MACHINE_IDS = "virtualmachineids";
270270
public static final String VIRTUAL_MACHINE_ID_IP = "vmidipmap";
271271
public static final String USAGE_ID = "usageid";
272+
public static final String USAGE_TYPE = "usagetype";
272273

273274
public static final String VLAN = "vlan";
274275
public static final String VLAN_RANGE = "vlanrange";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static enum HTTPMethod {
9797
GET, POST, PUT, DELETE
9898
}
9999
public static enum CommandType {
100-
BOOLEAN, DATE, FLOAT, INTEGER, SHORT, LIST, LONG, OBJECT, MAP, STRING, TZDATE, UUID
100+
BOOLEAN, DATE, FLOAT, DOUBLE, INTEGER, SHORT, LIST, LONG, OBJECT, MAP, STRING, TZDATE, UUID
101101
}
102102

103103
private Object _responseObject;

api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
@APICommand(name = "listUsageRecords", description = "Lists usage records for accounts", responseObject = UsageRecordResponse.class,
3939
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
4040
public class GetUsageRecordsCmd extends BaseListCmd {
41+
4142
public static final Logger s_logger = Logger.getLogger(GetUsageRecordsCmd.class.getName());
4243

4344
private static final String s_name = "listusagerecordsresponse";
@@ -111,6 +112,30 @@ public Long getProjectId() {
111112
public String getUsageId() {
112113
return usageId;
113114
}
115+
public void setAccountName(String accountName) {
116+
this.accountName = accountName;
117+
}
118+
119+
public void setDomainId(Long domainId) {
120+
this.domainId = domainId;
121+
}
122+
123+
public void setEndDate(Date endDate) {
124+
this.endDate = endDate;
125+
}
126+
127+
public void setStartDate(Date startDate) {
128+
this.startDate = startDate;
129+
}
130+
131+
public void setAccountId(Long accountId) {
132+
this.accountId = accountId;
133+
}
134+
135+
public void setUsageId(String usageId) {
136+
this.usageId = usageId;
137+
}
138+
114139

115140
/////////////////////////////////////////////////////
116141
/////////////// API Implementation///////////////////

api/src/org/apache/cloudstack/usage/UsageTypes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import org.apache.cloudstack.api.response.UsageTypeResponse;
2323

2424
public class UsageTypes {
25+
26+
/* Any changes here should also reflect in cloud_usage.quota_mapping table */
2527
public static final int RUNNING_VM = 1;
2628
public static final int ALLOCATED_VM = 2; // used for tracking how long storage has been allocated for a VM
2729
public static final int IP_ADDRESS = 3;

client/WEB-INF/classes/resources/messages.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,13 @@ label.show.advanced.settings=Show advanced settings
13551355
label.delete.OpenDaylight.device=Delete OpenDaylight Controller
13561356
label.polling.interval.sec=Polling Interval (in sec)
13571357
label.quiet.time.sec=Quiet Time (in sec)
1358+
label.usage.type=Usage Type
1359+
label.usage.unit=Unit
1360+
label.quota.value=Quota Value
1361+
label.quota.description=Quota Description
1362+
label.quota.configuration=Quota Configuration
1363+
label.quota.configure=Configure Quota
1364+
label.quota.remove=Remove Quota
13581365
label.destroy.vm.graceperiod=Destroy VM Grace Period
13591366
label.SNMP.community=SNMP Community
13601367
label.SNMP.port=SNMP Port

client/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@
246246
<artifactId>cloud-framework-ipc</artifactId>
247247
<version>${project.version}</version>
248248
</dependency>
249+
<dependency>
250+
<groupId>org.apache.cloudstack</groupId>
251+
<artifactId>cloud-framework-quota</artifactId>
252+
<version>${project.version}</version>
253+
</dependency>
249254
<dependency>
250255
<groupId>org.apache.cloudstack</groupId>
251256
<artifactId>cloud-framework-rest</artifactId>
@@ -356,6 +361,11 @@
356361
<artifactId>cloud-plugin-network-globodns</artifactId>
357362
<version>${project.version}</version>
358363
</dependency>
364+
<dependency>
365+
<groupId>org.apache.cloudstack</groupId>
366+
<artifactId>cloud-plugin-database-quota</artifactId>
367+
<version>${project.version}</version>
368+
</dependency>
359369
</dependencies>
360370
<build>
361371
<plugins>

client/tomcatconf/commands.properties.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,3 +782,14 @@ listOpenDaylightControllers=1
782782

783783
### GloboDNS commands
784784
addGloboDnsHost=1
785+
786+
### Quota Service
787+
quotaRefresh=1
788+
quotaStatement=15
789+
quotaBalance=15
790+
quotaTariffList=15
791+
quotaTariffUpdate=1
792+
quotaCredits=1
793+
quotaEmailTemplateList=1
794+
quotaEmailTemplateUpdate=1
795+

engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,5 @@ public ServiceOfferingVO getcomputeOffering(ServiceOfferingVO serviceOffering, M
238238

239239
return dummyoffering;
240240
}
241+
241242
}

engine/schema/src/com/cloud/usage/UsageVO.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ public class UsageVO implements Usage, InternalIdentity {
103103
@Temporal(value = TemporalType.TIMESTAMP)
104104
private Date endDate = null;
105105

106+
@Column(name = "quota_calculated")
107+
private Integer quotaCalculated = null;
108+
109+
public Integer getQuotaCalculated() {
110+
return quotaCalculated;
111+
}
112+
113+
public void setQuotaCalculated(Integer quotaCalculated) {
114+
this.quotaCalculated = quotaCalculated;
115+
}
116+
106117
public UsageVO() {
107118
}
108119

engine/schema/src/com/cloud/usage/dao/UsageDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,6 @@ public interface UsageDao extends GenericDao<UsageVO, Long> {
5353
void saveVmDiskStats(List<VmDiskStatisticsVO> vmDiskStats);
5454

5555
void saveUsageRecords(List<UsageVO> usageRecords);
56+
57+
Pair<List<? extends UsageVO>, Integer> getUsageRecordsPendingQuotaAggregation(long accountId, long domainId);
5658
}

0 commit comments

Comments
 (0)