sureshanaparti commented on code in PR #6812:
URL: https://github.com/apache/cloudstack/pull/6812#discussion_r994034404


##########
engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41710to41800.java:
##########
@@ -83,4 +92,55 @@ public void updateSystemVmTemplates(Connection conn) {
             throw new CloudRuntimeException("Failed to find / register 
SystemVM template(s)");
         }
     }
+
+    protected void decryptGlobalConfigurationValues(Connection conn) {
+        LOG.info("Decrypting global configuration values from the following 
tables: account_details and domain_details.");
+
+        Map<Long, String> accountsMap = selectValuesWithCustomConfigs(conn, 
ACCOUNT_DETAILS);
+        executeUpdateOnConfigValues(conn, accountsMap, ACCOUNT_DETAILS);
+        LOG.info("Successfully decrypted configurations from account_details 
table.");
+
+        Map<Long, String> domainsMap = selectValuesWithCustomConfigs(conn, 
DOMAIN_DETAILS);
+        executeUpdateOnConfigValues(conn, domainsMap, DOMAIN_DETAILS);
+        LOG.info("Successfully decrypted configurations from domain_details 
table.");
+    }
+
+    protected Map<Long, String> selectValuesWithCustomConfigs(Connection conn, 
String table) {
+        Map<Long, String> accountValuesToBeUpdated = new HashMap<>();
+        String selectDetails = String.format("SELECT details.id, details.value 
from cloud.%s details, cloud.configuration c " +
+                "WHERE details.name = c.name AND c.category NOT IN ('Hidden', 
'Secure') ORDER BY details.id;", table);
+
+        try (PreparedStatement pstmt = conn.prepareStatement(selectDetails)) {
+            try (ResultSet result = pstmt.executeQuery()) {
+                while (result.next()) {
+                    accountValuesToBeUpdated.put(result.getLong("id"), 
result.getString("value"));
+                }
+            }
+            return accountValuesToBeUpdated;
+        } catch (SQLException e) {
+            String message = String.format("Unable to retrieve data from table 
[%s] due to [%s].", table, e.getMessage());
+            LOG.error(message, e);
+            throw new CloudRuntimeException(message, e);
+        }
+    }
+
+    protected void executeUpdateOnConfigValues(Connection conn, Map<Long, 
String> valuesMapToBeUpdated, String table) {

Review Comment:
   ```suggestion
       protected void executeUpdateOnConfigValues(Connection conn, Map<Long, 
String> configsToBeUpdated, String table) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to