Insert default security group to the network_group table when do 21x to 222 upgrade

This commit is contained in:
alena 2011-05-23 12:31:44 -07:00
parent eb753bcacd
commit 5ff3cb0a1f
1 changed files with 13 additions and 3 deletions

View File

@ -379,12 +379,22 @@ public class ConfigurationServerImpl implements ConfigurationServer {
try {
insertSql = "SELECT * FROM `cloud`.`security_group` where account_id=2 and name='default'";
String tableName = "security_group";
try {
String checkSql = "SELECT * from network_group";
PreparedStatement stmt = txn.prepareAutoCloseStatement(checkSql);
stmt.executeQuery();
tableName = "network_group";
} catch (Exception ex) {
// if network_groups table exists, create the default security group there
}
insertSql = "SELECT * FROM " + tableName + " where account_id=2 and name='default'";
PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql);
ResultSet rs = stmt.executeQuery();
if (!rs.next()) {
//save default security group
insertSql = "INSERT INTO `cloud`.`security_group` (name, description, account_id, domain_id, account_name) " +
insertSql = "INSERT INTO " + tableName + " (name, description, account_id, domain_id, account_name) " +
"VALUES ('default', 'Default Security Group', 2, 1, 'admin')";
@ -398,7 +408,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
}
rs.close();
} catch (Exception ex) {
s_logger.warn("Failed to create default security group for default admin account due to ", ex);
s_logger.warn("Failed to create default security group for admin account", ex);
}
}