Updated Branches:
  refs/heads/4.1 186fb9ff5 -> 6d01ce565

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

Branch: refs/heads/4.1
Commit: 6d01ce565d4fe01c215eb6d6d894fa0d5555d6f3
Parents: 186fb9f
Author: Min Chen <min.c...@citrix.com>
Authored: Fri Mar 15 16:28:46 2013 -0700
Committer: Chip Childers <chip.child...@gmail.com>
Committed: Fri Mar 15 21:19:55 2013 -0400

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


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/6d01ce56/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);

Reply via email to