Skip to content

Commit d05ab01

Browse files
committed
Add missing SQL scripts and injections
1 parent f5c8d84 commit d05ab01

File tree

7 files changed

+49
-24
lines changed

7 files changed

+49
-24
lines changed

engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,13 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.vpc_offerings','conserve_mode', 'tin
117117

118118
--- Disable/enable NICs
119119
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.nics','enabled', 'TINYINT(1) NOT NULL DEFAULT 1 COMMENT ''Indicates whether the NIC is enabled or not'' ');
120+
121+
--- Quota usage details
122+
CREATE TABLE IF NOT EXISTS `cloud_usage`.`quota_usage_details` (
123+
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
124+
`tariff_id` bigint(20) unsigned NOT NULL COMMENT 'ID of the tariff of the Quota usage detail calculated, foreign key to quota_tariff table',
125+
`quota_usage_id` bigint(20) unsigned NOT NULL COMMENT 'ID of the aggregation of Quota usage details, foreign key to quota_usage table',
126+
`quota_used` decimal(20,8) NOT NULL COMMENT 'Amount of quota used',
127+
PRIMARY KEY (`id`),
128+
CONSTRAINT `fk_quota_usage_detail__tariff_id` FOREIGN KEY (`tariff_id`) REFERENCES `cloud_usage`.`quota_tariff` (`id`),
129+
CONSTRAINT `fk_quota_usage_detail__quota_usage_id` FOREIGN KEY (`quota_usage_id`) REFERENCES `cloud_usage`.`quota_usage` (`id`));
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
-- VIEW `cloud_usage`.`quota_usage_view`;
19+
20+
DROP VIEW IF EXISTS `cloud_usage`.`quota_usage_view`;
21+
CREATE VIEW `cloud_usage`.`quota_usage_view` AS
22+
SELECT qu.id,
23+
qu.usage_item_id,
24+
qu.zone_id,
25+
qu.account_id,
26+
qu.domain_id,
27+
qu.usage_type,
28+
qu.quota_used,
29+
qu.start_date,
30+
qu.end_date,
31+
cu.usage_id AS resource_id,
32+
cu.network_id as network_id,
33+
cu.offering_id as offering_id
34+
FROM `cloud_usage`.`quota_usage` qu
35+
INNER JOIN `cloud_usage`.`cloud_usage` cu ON (cu.id = qu.usage_item_id);

framework/quota/src/main/java/org/apache/cloudstack/quota/vo/QuotaUsageDetailVO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.apache.commons.lang3.builder.ToStringStyle;
2828

2929
@Entity
30-
@Table(name = "quota_usage_detail")
30+
@Table(name = "quota_usage_details")
3131
public class QuotaUsageDetailVO implements InternalIdentity {
3232
@Id
3333
@Column(name = "id")

framework/quota/src/main/resources/META-INF/cloudstack/quota/spring-framework-quota-context.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<bean id="QuotaEmailTemplatesDao"
2727
class="org.apache.cloudstack.quota.dao.QuotaEmailTemplatesDaoImpl" />
2828
<bean id="QuotaUsageDao" class="org.apache.cloudstack.quota.dao.QuotaUsageDaoImpl" />
29+
<bean id="QuotaUsageDetailDao" class="org.apache.cloudstack.quota.dao.QuotaUsageDetailDaoImpl" />
30+
<bean id="QuotaUsageJoinDao" class="org.apache.cloudstack.quota.dao.QuotaUsageJoinDaoImpl"/>
2931
<bean id="UserVmDetailsDao" class="org.apache.cloudstack.quota.dao.VMInstanceDetailsDaoImpl" />
3032

3133
<bean id="QuotaManager" class="org.apache.cloudstack.quota.QuotaManagerImpl" />

plugins/database/quota/src/main/java/org/apache/cloudstack/api/command/QuotaStatementCmd.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public class QuotaStatementCmd extends BaseCmd {
6767

6868
@ACL
6969
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class,
70-
description = "ID of the Project for which the Quota statement will be generated. Can not be specified with accountid.", , since = "4.23.0")
70+
description = "ID of the Project for which the Quota statement will be generated. Can not be specified with accountid.", since = "4.23.0")
7171
private Long projectId;
7272

7373
@Parameter(name = ApiConstants.SHOW_RESOURCES, type = CommandType.BOOLEAN, description = "List the resources of each Quota type in the period.", since = "4.23.0")
@@ -152,5 +152,4 @@ public void execute() {
152152
response.setResponseName(getCommandName());
153153
setResponseObject(response);
154154
}
155-
156155
}

plugins/database/quota/src/main/java/org/apache/cloudstack/api/response/QuotaResponseBuilder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
3333
import org.apache.cloudstack.quota.vo.QuotaEmailConfigurationVO;
3434
import org.apache.cloudstack.quota.vo.QuotaTariffVO;
35-
import org.apache.cloudstack.quota.vo.QuotaUsageJoinVO;
3635

3736
import java.util.Date;
3837
import java.util.List;

plugins/database/quota/src/main/java/org/apache/cloudstack/quota/QuotaServiceImpl.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -219,26 +219,6 @@ public List<QuotaBalanceVO> findQuotaBalanceVO(Long accountId, String accountNam
219219

220220
@Override
221221
public List<QuotaUsageJoinVO> getQuotaUsage(Long accountId, String accountName, Long domainId, Integer usageType, Date startDate, Date endDate) {
222-
// if accountId is not specified, use accountName and domainId
223-
if ((accountId == null) && (accountName != null) && (domainId != null)) {
224-
Account userAccount = null;
225-
Account caller = CallContext.current().getCallingAccount();
226-
if (_domainDao.isChildDomain(caller.getDomainId(), domainId)) {
227-
Filter filter = new Filter(AccountVO.class, "id", Boolean.FALSE, null, null);
228-
List<AccountVO> accounts = _accountDao.listAccounts(accountName, domainId, filter);
229-
if (!accounts.isEmpty()) {
230-
userAccount = accounts.get(0);
231-
}
232-
if (userAccount != null) {
233-
accountId = userAccount.getId();
234-
} else {
235-
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
236-
}
237-
} else {
238-
throw new PermissionDeniedException("Invalid Domain Id or Account");
239-
}
240-
}
241-
242222
if (startDate.after(endDate)) {
243223
throw new InvalidParameterValueException("Incorrect Date Range. Start date: " + startDate + " is after end date:" + endDate);
244224
}

0 commit comments

Comments
 (0)