cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aprat...@apache.org
Subject [1/2] git commit: updated refs/heads/4.3 to 12f3568
Date Thu, 09 Jan 2014 10:20:06 GMT
Updated Branches:
  refs/heads/4.3 7584cf906 -> 12f3568e9


CLOUDSTACK-5790: decrypted ldap hostname and port during upgrade as they are not encrypted
now.

Signed-off-by: Abhinandan Prateek <aprateek@apache.org>


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

Branch: refs/heads/4.3
Commit: 12f3568e97f27784568bed9dd61260d444b9ef14
Parents: dfabe23
Author: Rajani Karuturi <rajanikaruturi@gmail.com>
Authored: Wed Jan 8 18:12:55 2014 +0530
Committer: Abhinandan Prateek <aprateek@apache.org>
Committed: Thu Jan 9 15:43:21 2014 +0530

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade421to430.java  | 38 ++++++++++++++++++--
 setup/db/db/schema-421to430.sql                 |  3 --
 2 files changed, 36 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/12f3568e/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
index 471307a..268a27d 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
@@ -21,10 +21,11 @@ import java.io.File;
 import java.io.UnsupportedEncodingException;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
+import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.util.Properties;
+import java.sql.Types;
 
-import com.cloud.utils.db.DbProperties;
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 
 import com.cloud.utils.crypt.DBEncryptionUtil;
@@ -90,6 +91,39 @@ public class Upgrade421to430 implements DbUpgrade {
                 pstmt.setString(3, desc);
                 pstmt.executeUpdate();
             }
+
+            /**
+             * if encrypted, decrypt the ldap hostname and port and then update as they are
not encrypted now.
+             */
+            pstmt = conn.prepareStatement("SELECT conf.value FROM `cloud`.`configuration`
conf WHERE conf.name='ldap.hostname'");
+            ResultSet resultSet = pstmt.executeQuery();
+            String hostname = null;
+            String port;
+            int portNumber = 0;
+            if (resultSet.next()) {
+                hostname = DBEncryptionUtil.decrypt(resultSet.getString(1));
+            }
+
+            pstmt = conn.prepareStatement("SELECT conf.value FROM `cloud`.`configuration`
conf WHERE conf.name='ldap.port'");
+            resultSet = pstmt.executeQuery();
+            if (resultSet.next()) {
+                port = DBEncryptionUtil.decrypt(resultSet.getString(1));
+                if (StringUtils.isNotBlank(port)) {
+                    portNumber = Integer.valueOf(port);
+                }
+            }
+
+            if (StringUtils.isNotBlank(hostname)) {
+                pstmt = conn.prepareStatement("INSERT INTO `cloud`.`ldap_configuration`(hostname,
port) VALUES(?,?)");
+                pstmt.setString(1, hostname);
+                if (portNumber != 0) {
+                    pstmt.setInt(2, portNumber);
+                } else {
+                    pstmt.setNull(2, Types.INTEGER);
+                }
+                pstmt.executeUpdate();
+            }
+
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to insert ldap configuration values ",
e);
         } catch (UnsupportedEncodingException e) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/12f3568e/setup/db/db/schema-421to430.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql
index d1d8792..c1f9780 100644
--- a/setup/db/db/schema-421to430.sql
+++ b/setup/db/db/schema-421to430.sql
@@ -616,9 +616,6 @@ CREATE TABLE `cloud`.`ldap_configuration` (
   PRIMARY KEY  (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
-INSERT INTO `cloud`.`ldap_configuration`(hostname) SELECT conf.value FROM `cloud`.`configuration`
conf WHERE conf.name='ldap.hostname' ;
-UPDATE `cloud`.`ldap_configuration` SET port=(SELECT conf.value FROM `cloud`.`configuration`
conf WHERE conf.name='ldap.port') WHERE hostname = (SELECT conf.value FROM `cloud` .`configuration`
conf WHERE conf.name='ldap.hostname');
-
 UPDATE `cloud`.`volumes` SET display_volume=1 where id>0;
 
 create table `cloud`.`monitoring_services` (


Mime
View raw message