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/master to f741d99
Date Thu, 09 Jan 2014 10:28:10 GMT
Updated Branches:
  refs/heads/master 7dc4c5cb5 -> f741d99c8


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

Conflicts:
	engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java

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/f741d99c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/f741d99c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/f741d99c

Branch: refs/heads/master
Commit: f741d99c80b3a2ad26b41d4131c930646086ce3c
Parents: 001e67a
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:50:53 2014 +0530

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


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f741d99c/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 6df44ec..268a27d 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade421to430.java
@@ -21,8 +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.sql.Types;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 
 import com.cloud.utils.crypt.DBEncryptionUtil;
@@ -88,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/f741d99c/setup/db/db/schema-421to430.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql
index b26166a..24e8223 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