Skip to content

Commit 028c676

Browse files
committed
address reviews
1 parent e681012 commit 028c676

4 files changed

Lines changed: 3 additions & 115 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/command/user/backup/GetBackupReportCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
@APICommand(name = "getBackupReport",
4343
description = "Get the backup report for the given period",
44-
responseObject = BackupReportResponse.class, since = "4.24.0.0", authorized = {RoleType.Admin})
44+
responseObject = BackupReportResponse.class, since = "24.0.0", authorized = {RoleType.Admin})
4545
public class GetBackupReportCmd extends BaseCmd {
4646

4747
@Inject

engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42020to42030.java

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -25,95 +25,6 @@
2525
import com.cloud.utils.exception.CloudRuntimeException;
2626

2727
public class Upgrade42020to42030 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
28-
29-
private static String SELECT_TEMPLATE = "SELECT `name` FROM `cloud`.`email_template` WHERE `name`=\"backup_report_template\";";
30-
private static String INSERT_TEMPLATE = "INSERT INTO `cloud`.`email_template` (name, template) VALUES (\"backup_report_template\", \'<h1>Backup report</h1>\n" +
31-
"<p>Backup storage usage increase for the environment during the period is ${storageUsage} GiB.</p>\n" +
32-
"\n" +
33-
"<#list backupReportDomainResponseList as domain>\n" +
34-
"<hr>\n" +
35-
"<h2>Domain ${domain.domainName}</h2>\n" +
36-
"<p>Backup storage usage increase for the domain ${domain.domainName} is ${domain.storageUsage} GiB.</p>\n" +
37-
"\n" +
38-
" <#list domain.backupReportAccountResponseList as account>\n" +
39-
" <hr>\n" +
40-
" <#if account.accountName??>\n" +
41-
" <h3>Account ${account.accountName}</h3>\n" +
42-
" <p>Backup storage usage increase for the account ${account.accountName} is ${account.storageUsage} GiB.</p> \n" +
43-
" <#else>\n" +
44-
" <h3>Project ${account.projectName}</h3>\n" +
45-
" <p>Backup storage usage increase for the project ${account.projectName} is ${account.storageUsage} GiB.</p>\n" +
46-
" </#if>\n" +
47-
" \n" +
48-
"\n" +
49-
" <#list account.successfulBackups>\n" +
50-
" <p>Successfully created backups for the ${(account.accountName??)?then(\"project\",\"account\")}:</p>\n" +
51-
" <ul>\n" +
52-
" <#items as backup>\n" +
53-
" <li>Backup ${backup.name!\"without name\"} with ID ${backup.id} of VM ${backup.vmName} with ID ${backup.vmId} was created at ${backup.date?datetime};</li>\n" +
54-
" </#items>\n" +
55-
" </ul>\n" +
56-
" </#list>\n" +
57-
"\n" +
58-
" <#list account.failedBackups>\n" +
59-
" <p>Failed backups for the ${(account.accountName??)?then(\"project\",\"account\")}:</p>\n" +
60-
" <ul>\n" +
61-
"\n" +
62-
" <#items as backup>\n" +
63-
" <li>Backup ${backup.name!\"without name\"} with ID ${backup.id} of VM ${backup.vmName} with ID ${backup.vmId} failed at ${(backup.date?datetime)!\"unable to get date\"};\n" +
64-
"\n" +
65-
" <#if backup.failureReason?? || backup.logid??>\n" +
66-
" <ul> \n" +
67-
" <#if backup.failureReason??>\n" +
68-
" <li>Due to ${backup.failureReason}</li> \n" +
69-
" </#if> \n" +
70-
" <#if backup.logid??>\n" +
71-
" <li>With logid:${backup.logid}</li>\n" +
72-
" </#if>\n" +
73-
" </ul>\n" +
74-
" </#if>\n" +
75-
" </#items>\n" +
76-
"\n" +
77-
" </ul>\n" +
78-
" </#list>\n" +
79-
"\n" +
80-
" <#list account.deletedBackups>\n" +
81-
" <p>Removed backups for the ${(account.accountName??)?then(\"project\",\"account\")}:</p> \n" +
82-
" <ul>\n" +
83-
" <#items as backup>\n" +
84-
" <li>Backup ${backup.name} with ID ${backup.id} of VM ${backup.vmName} with ID ${backup.vmId} was created at ${(backup.date?datetime)!\"unable to get date\"} and deleted at ${backup.removed?datetime};</li>\n" +
85-
" </#items>\n" +
86-
" </ul> \n" +
87-
" </#list>\n" +
88-
" </#list>\n" +
89-
"</#list>\n" +
90-
"\n" +
91-
"<#list backupScheduleResponseList>\n" +
92-
"<hr>\n" +
93-
"<h1>Scheduled backups</h1>\n" +
94-
"\n" +
95-
"<table>\n" +
96-
"<thead>\n" +
97-
"<tr>\n" +
98-
"<th>VM</th>\n" +
99-
"<th>ID</th>\n" +
100-
"<th>Scheduled date</th>\n" +
101-
"<th>Schedule ID</th>\n" +
102-
"</tr>\n" +
103-
"</thead>\n" +
104-
"<tbody> \n" +
105-
" <#items as schedule>\n" +
106-
" <tr>\n" +
107-
" <td>${schedule.vmName}</td>\n" +
108-
" <td>${schedule.vmId}</td>\n" +
109-
" <td>${schedule.schedule}</td>\n" +
110-
" <td>${schedule.id}</td>\n" +
111-
" </tr>\n" +
112-
" </#items>\n" +
113-
"</tbody>\n" +
114-
"</table>\n" +
115-
"</#list>\n\')";
116-
11728
@Override
11829
public String[] getUpgradableVersionRange() {
11930
return new String[]{"4.20.2.0", "4.20.3.0"};
@@ -142,29 +53,6 @@ public InputStream[] getPrepareScripts() {
14253

14354
@Override
14455
public void performDataMigration(Connection conn) {
145-
insertBackupReportEmailTemplate(conn);
146-
}
147-
148-
private void insertBackupReportEmailTemplate(Connection conn) {
149-
try (PreparedStatement pstmt = conn.prepareStatement(SELECT_TEMPLATE)) {
150-
ResultSet result = pstmt.executeQuery();
151-
if (result.next()) {
152-
logger.debug("Email template for backup_report_template is already on the database.");
153-
return;
154-
}
155-
} catch (SQLException e) {
156-
String message = String.format("Unable to retrieve email templates due to [%s].", e.getMessage());
157-
logger.error(message, e);
158-
throw new CloudRuntimeException(message, e);
159-
}
160-
161-
try (PreparedStatement pstmt = conn.prepareStatement(INSERT_TEMPLATE)) {
162-
pstmt.executeUpdate();
163-
} catch (SQLException e) {
164-
String message = String.format("Unable to insert email template for backup_report_template due to [%s].", e.getMessage());
165-
logger.error(message, e);
166-
throw new CloudRuntimeException(message, e);
167-
}
16856
}
16957

17058
@Override

engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42210to42300.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
public class Upgrade42210to42300 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
3131

32-
// This must be moved to the new upgrade class when 4.23 is released
32+
// This must be moved to the new upgrade class when 4.23 is released and the class is actually created. Waiting for https://github.com/apache/cloudstack/pull/14033
3333
private static String SELECT_TEMPLATE = "SELECT `name` FROM `cloud`.`email_template` WHERE `name`=\"backup_report_template\";";
3434
private static String INSERT_TEMPLATE = "INSERT INTO `cloud`.`email_template` (name, template) VALUES (\"backup_report_template\", \'<h1>Backup report</h1>\n" +
3535
"<p>Backup storage usage increase for the environment during the period is ${storageUsage} GiB.</p>\n" +

server/src/main/java/org/apache/cloudstack/backup/BackupReportServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
168168

169169
protected void run() {
170170
ThreadContext.put(LOGCONTEXTID, UuidUtils.first(UUID.randomUUID().toString()));
171-
logger.info("Starting backup report task.");
171+
logger.debug("Starting backup report task.");
172172

173173
try {
174174
Transaction.execute(TransactionLegacy.CLOUD_DB, new TransactionCallbackNoReturn() {

0 commit comments

Comments
 (0)