cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject git commit: refs/heads/master - CLOUDSTACK-1690: Remove region_id from sql insert statement for inserting "system" and "admin" account and user in MS startup due to recent region feature change.
Date Mon, 18 Mar 2013 18:44:18 GMT
Updated Branches:
  refs/heads/master 6ba0ef1a1 -> 2b05f546b


CLOUDSTACK-1690: Remove region_id from sql insert statement for inserting "system" and "admin"
account and user in MS startup due to recent region feature change.


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

Branch: refs/heads/master
Commit: 2b05f546b7b882e61d54a653a8c5069be22b1be2
Parents: 6ba0ef1
Author: Min Chen <min.chen@citrix.com>
Authored: Fri Mar 15 16:28:46 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Mon Mar 18 11:21:15 2013 -0700

----------------------------------------------------------------------
 .../com/cloud/server/ConfigurationServerImpl.java  |   30 +++++---------
 1 files changed, 11 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2b05f546/server/src/com/cloud/server/ConfigurationServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java
index 8c665ad..3b0ec0f 100755
--- a/server/src/com/cloud/server/ConfigurationServerImpl.java
+++ b/server/src/com/cloud/server/ConfigurationServerImpl.java
@@ -106,10 +106,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.net.NetUtils;
 import com.cloud.utils.script.Script;
 import com.cloud.uuididentity.dao.IdentityDao;
-import org.apache.cloudstack.region.RegionVO;
-import org.apache.cloudstack.region.dao.RegionDao;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.log4j.Logger;
+
 
 @Component
 public class ConfigurationServerImpl extends ManagerBase implements ConfigurationServer {
@@ -152,7 +149,7 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
     public void persistDefaultValues() throws InternalErrorException {
 
     	fixupScriptFileAttribute();
-    	
+
         // Create system user and admin user
         saveUser();
 
@@ -337,23 +334,20 @@ public class ConfigurationServerImpl extends ManagerBase implements
Configuratio
 
     @DB
     protected void saveUser() {
-        int region_id = _configDao.getRegionId();
         // insert system account
-        String insertSql = "INSERT INTO `cloud`.`account` (id, uuid, account_name, type,
domain_id, region_id) VALUES (1, UUID(), 'system', '1', '1', ?)";
+        String insertSql = "INSERT INTO `cloud`.`account` (id, uuid, account_name, type,
domain_id) VALUES (1, UUID(), 'system', '1', '1')";
         Transaction txn = Transaction.currentTxn();
         try {
             PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
-            stmt.setInt(1, region_id);
             stmt.executeUpdate();
         } catch (SQLException ex) {
         }
         // insert system user
-        insertSql = "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id,
firstname, lastname, created, region_id)" +
-                " VALUES (1, UUID(), 'system', RAND(), 1, 'system', 'cloud', now(), ?)";
+        insertSql = "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id,
firstname, lastname, created)" +
+                " VALUES (1, UUID(), 'system', RAND(), 1, 'system', 'cloud', now())";
         txn = Transaction.currentTxn();
         try {
             PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
-            stmt.setInt(1, region_id);
             stmt.executeUpdate();
         } catch (SQLException ex) {
         }
@@ -366,23 +360,21 @@ public class ConfigurationServerImpl extends ManagerBase implements
Configuratio
         String lastname = "cloud";
 
         // create an account for the admin user first
-        insertSql = "INSERT INTO `cloud`.`account` (id, uuid, account_name, type, domain_id,
region_id) VALUES (" + id + ", UUID(), '" + username + "', '1', '1', ?)";
+        insertSql = "INSERT INTO `cloud`.`account` (id, uuid, account_name, type, domain_id)
VALUES (" + id + ", UUID(), '" + username + "', '1', '1')";
         txn = Transaction.currentTxn();
         try {
             PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
-            stmt.setInt(1, region_id);
             stmt.executeUpdate();
         } catch (SQLException ex) {
         }
 
         // now insert the user
-        insertSql = "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id,
firstname, lastname, created, state, region_id) " +
-                "VALUES (" + id + ", UUID(), '" + username + "', RAND(), 2, '" + firstname
+ "','" + lastname + "',now(), 'disabled', ?)";
+        insertSql = "INSERT INTO `cloud`.`user` (id, uuid, username, password, account_id,
firstname, lastname, created, state) " +
+                "VALUES (" + id + ", UUID(), '" + username + "', RAND(), 2, '" + firstname
+ "','" + lastname + "',now(), 'disabled')";
 
         txn = Transaction.currentTxn();
         try {
             PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
-            stmt.setInt(1, region_id);
             stmt.executeUpdate();
         } catch (SQLException ex) {
         }
@@ -708,15 +700,15 @@ public class ConfigurationServerImpl extends ManagerBase implements
Configuratio
         }
 
     }
-    
+
 	private void fixupScriptFileAttribute() {
-		// TODO : this is a hacking fix to workaround that executable bit is not preserved in WAR
package 
+		// TODO : this is a hacking fix to workaround that executable bit is not preserved in WAR
package
         String scriptPath = Script.findScript("", "scripts/vm/systemvm/injectkeys.sh");
         if(scriptPath != null) {
         	File file = new File(scriptPath);
         	if(!file.canExecute()) {
         		s_logger.info("Some of the shell script files may not have executable bit set.
Fixup...");
-        		
+
         		String cmd = "chmod ugo+x " + scriptPath;
         		s_logger.info("Executing " + cmd);
                 String result = Script.runSimpleBashScript(cmd);


Mime
View raw message