cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [18/20] git commit: updated refs/heads/hotfix/scp-exception to 7de94c9
Date Mon, 15 Dec 2014 08:43:46 GMT
CLOUDSTACK-8070: Upgrade router.ram.size using encryption util

Upgrade fails if value is set using plain text encoding, the value needs to
be encrypted (if a key was provided during db was setup).

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 6321a29e4336de9ffe96e27968f896ec5a8bf37d)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1a66b3b5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1a66b3b5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1a66b3b5

Branch: refs/heads/hotfix/scp-exception
Commit: 1a66b3b5c6b88e9180377e1b5e1206fe2f892c46
Parents: dd145a3
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Sat Dec 13 00:15:40 2014 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Sat Dec 13 00:18:05 2014 +0530

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade442to450.java  | 25 ++++++++++++++++++++
 setup/db/db/schema-442to450.sql                 |  2 --
 2 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a66b3b5/engine/schema/src/com/cloud/upgrade/dao/Upgrade442to450.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade442to450.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade442to450.java
index 9fe1319..86c2439 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade442to450.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade442to450.java
@@ -18,6 +18,7 @@
 package com.cloud.upgrade.dao;
 
 import java.io.File;
+import java.io.UnsupportedEncodingException;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -30,6 +31,7 @@ import java.util.Map;
 import java.util.Set;
 
 import com.cloud.hypervisor.Hypervisor;
+import com.cloud.utils.crypt.DBEncryptionUtil;
 import org.apache.log4j.Logger;
 
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -68,10 +70,33 @@ public class Upgrade442to450 implements DbUpgrade {
         updateSystemVmTemplates(conn);
         dropInvalidKeyFromStoragePoolTable(conn);
         dropDuplicatedForeignKeyFromAsyncJobTable(conn);
+        updateMaxRouterSizeConfig(conn);
         upgradeMemoryOfVirtualRoutervmOffering(conn);
         upgradeMemoryOfInternalLoadBalancervmOffering(conn);
     }
 
+    private void updateMaxRouterSizeConfig(Connection conn) {
+        PreparedStatement updatePstmt = null;
+        try {
+            String encryptedValue = DBEncryptionUtil.encrypt("256");
+            updatePstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value=?
WHERE name='router.ram.size' AND category='Hidden'");
+            updatePstmt.setBytes(1, encryptedValue.getBytes("UTF-8"));
+            updatePstmt.executeUpdate();
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("Unable to upgrade max ram size of router in
config.", e);
+        } catch (UnsupportedEncodingException e) {
+            throw new CloudRuntimeException("Unable encrypt configuration values ", e);
+        } finally {
+            try {
+                if (updatePstmt != null) {
+                    updatePstmt.close();
+                }
+            } catch (SQLException e) {
+            }
+        }
+        s_logger.debug("Done updating router.ram.size config to 256");
+    }
+
     private void upgradeMemoryOfVirtualRoutervmOffering(Connection conn) {
         PreparedStatement updatePstmt = null;
         PreparedStatement selectPstmt = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1a66b3b5/setup/db/db/schema-442to450.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-442to450.sql b/setup/db/db/schema-442to450.sql
index 3131842..872e0de 100644
--- a/setup/db/db/schema-442to450.sql
+++ b/setup/db/db/schema-442to450.sql
@@ -448,8 +448,6 @@ UPDATE configuration SET value='KVM,XenServer,VMware,BareMetal,Ovm,LXC,Hyperv'
W
 UPDATE `cloud`.`configuration` SET description="If set to true, will set guest VM's name
as it appears on the hypervisor, to its hostname. The flag is supported for VMware hypervisor
only" WHERE name='vm.instancename.flag';
 INSERT IGNORE INTO `cloud`.`configuration`(category, instance, component, name, value, description,
default_value) VALUES ('Advanced', 'DEFAULT', 'management-server', 'implicit.host.tags', 'GPU',
'Tag hosts at the time of host disovery based on the host properties/capabilities ', 'GPU');
 
-UPDATE `cloud`.`configuration` SET value='256' WHERE name='router.ram.size';
-
 DROP VIEW IF EXISTS `cloud`.`domain_router_view`;
 CREATE VIEW `cloud`.`domain_router_view` AS
     select


Mime
View raw message