This is an automated email from the ASF dual-hosted git repository.
nvazquez pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.20 by this push:
new aba3285c3c8 [Usage] Include accounts uuid on the cloud_usage accounts
initial saving (#12420)
aba3285c3c8 is described below
commit aba3285c3c86250224ab6afd774e84c4f8a6fa2a
Author: Nicolas Vazquez <[email protected]>
AuthorDate: Thu Jan 15 06:50:35 2026 -0300
[Usage] Include accounts uuid on the cloud_usage accounts initial saving
(#12420)
---
.../src/main/java/com/cloud/usage/dao/UsageDaoImpl.java | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/engine/schema/src/main/java/com/cloud/usage/dao/UsageDaoImpl.java
b/engine/schema/src/main/java/com/cloud/usage/dao/UsageDaoImpl.java
index d863aacfd44..34e7843bfc4 100644
--- a/engine/schema/src/main/java/com/cloud/usage/dao/UsageDaoImpl.java
+++ b/engine/schema/src/main/java/com/cloud/usage/dao/UsageDaoImpl.java
@@ -52,7 +52,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO,
Long> implements Usage
private static final String DELETE_ALL = "DELETE FROM cloud_usage";
private static final String DELETE_ALL_BY_ACCOUNTID = "DELETE FROM
cloud_usage WHERE account_id = ?";
private static final String DELETE_ALL_BY_INTERVAL = "DELETE FROM
cloud_usage WHERE end_date < DATE_SUB(CURRENT_DATE(), INTERVAL ? DAY)";
- private static final String INSERT_ACCOUNT = "INSERT INTO
cloud_usage.account (id, account_name, type, role_id, domain_id, removed,
cleanup_needed) VALUES (?,?,?,?,?,?,?)";
+ private static final String INSERT_ACCOUNT = "INSERT INTO
cloud_usage.account (id, account_name, uuid, type, role_id, domain_id, removed,
cleanup_needed) VALUES (?,?,?,?,?,?,?,?)";
private static final String INSERT_USER_STATS = "INSERT INTO
cloud_usage.user_statistics (id, data_center_id, account_id, public_ip_address,
device_id, device_type, network_id, net_bytes_received,"
+ " net_bytes_sent, current_bytes_received, current_bytes_sent,
agg_bytes_received, agg_bytes_sent) VALUES (?,?,?,?,?,?,?,?,?,?, ?, ?, ?)";
@@ -129,25 +129,26 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO,
Long> implements Usage
for (AccountVO acct : accounts) {
pstmt.setLong(1, acct.getId());
pstmt.setString(2, acct.getAccountName());
- pstmt.setInt(3, acct.getType().ordinal());
+ pstmt.setString(3, acct.getUuid());
+ pstmt.setInt(4, acct.getType().ordinal());
//prevent autoboxing NPE by defaulting to User role
if(acct.getRoleId() == null){
- pstmt.setLong(4, RoleType.User.getId());
+ pstmt.setLong(5, RoleType.User.getId());
}else{
- pstmt.setLong(4, acct.getRoleId());
+ pstmt.setLong(5, acct.getRoleId());
}
- pstmt.setLong(5, acct.getDomainId());
+ pstmt.setLong(6, acct.getDomainId());
Date removed = acct.getRemoved();
if (removed == null) {
- pstmt.setString(6, null);
+ pstmt.setString(7, null);
} else {
- pstmt.setString(6,
DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), acct.getRemoved()));
+ pstmt.setString(7,
DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), acct.getRemoved()));
}
- pstmt.setBoolean(7, acct.getNeedsCleanup());
+ pstmt.setBoolean(8, acct.getNeedsCleanup());
pstmt.addBatch();
}