diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index 334e374aea7..da98df61b4e 100644 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -367,6 +367,19 @@ public class ConfigurationServerImpl implements ConfigurationServer { // now insert the user insertSql = "INSERT INTO `cloud`.`user` (id, username, password, account_id, firstname, lastname, created) " + "VALUES (" + id + ",'" + username + "','" + sb.toString() + "', 2, '" + firstname + "','" + lastname + "',now())"; + + + txn = Transaction.currentTxn(); + try { + PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql); + stmt.executeUpdate(); + } catch (SQLException ex) { + } + + //save default security group + insertSql = "INSERT INTO `cloud`.`security_group` (name, description, account_id, domain_id, account_name) " + + "VALUES ('default', 'Default Security Group', 2, 1, 'admin')"; + txn = Transaction.currentTxn(); try { @@ -864,5 +877,5 @@ public class ConfigurationServerImpl implements ConfigurationServer { } return networks.get(0).getId(); } - + } diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index aab024f00fb..275b2b5dcc8 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -1282,6 +1282,7 @@ CREATE TABLE `cloud`.`security_group` ( `domain_id` bigint unsigned NOT NULL, `account_id` bigint unsigned NOT NULL, `account_name` varchar(100) NOT NULL, + UNIQUE (`name`, `account_id`), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;