|
17 | 17 |
|
18 | 18 | package com.cloud.upgrade.dao; |
19 | 19 |
|
20 | | -import com.cloud.utils.PropertiesUtil; |
21 | | -import com.cloud.utils.db.ScriptRunner; |
22 | | -import com.cloud.utils.exception.CloudRuntimeException; |
23 | | -import com.cloud.utils.script.Script; |
24 | | -import org.apache.cloudstack.acl.RoleType; |
25 | | -import org.apache.log4j.Logger; |
26 | | - |
27 | 20 | import java.io.File; |
28 | 21 | import java.io.FileReader; |
29 | 22 | import java.io.IOException; |
30 | 23 | import java.sql.Connection; |
31 | 24 | import java.sql.PreparedStatement; |
32 | 25 | import java.sql.ResultSet; |
33 | 26 | import java.sql.SQLException; |
34 | | -import java.util.Map; |
| 27 | + |
| 28 | +import org.apache.cloudstack.acl.RoleType; |
| 29 | +import org.apache.log4j.Logger; |
| 30 | + |
| 31 | +import com.cloud.utils.db.ScriptRunner; |
| 32 | +import com.cloud.utils.exception.CloudRuntimeException; |
| 33 | +import com.cloud.utils.script.Script; |
35 | 34 |
|
36 | 35 | public class Upgrade481to490 implements DbUpgrade { |
37 | 36 | final static Logger s_logger = Logger.getLogger(Upgrade481to490.class); |
@@ -115,23 +114,19 @@ private void setupRolesAndPermissionsForDynamicChecker(final Connection conn) { |
115 | 114 |
|
116 | 115 | migrateAccountsToDefaultRoles(conn); |
117 | 116 |
|
118 | | - final Map<String, String> apiMap = PropertiesUtil.processConfigFile(new String[] { PropertiesUtil.getDefaultApiCommandsFileName() }); |
119 | | - if (apiMap == null || apiMap.isEmpty()) { |
120 | | - if (s_logger.isDebugEnabled()) { |
121 | | - s_logger.debug("The commands.properties file and default role permissions were not found. " + |
122 | | - "Assuming new installation, configuring default role-api mappings."); |
123 | | - } |
124 | | - String script = Script.findScript("", "db/create-default-role-api-mappings.sql"); |
125 | | - if (script == null) { |
126 | | - s_logger.error("Unable to find default role-api mapping sql file, please configure api per role manually"); |
127 | | - return; |
128 | | - } |
129 | | - try(final FileReader reader = new FileReader(new File(script))) { |
130 | | - ScriptRunner runner = new ScriptRunner(conn, false, true); |
131 | | - runner.runScript(reader); |
132 | | - } catch (SQLException | IOException e) { |
133 | | - s_logger.error("Unable to insert default api-role mappings from file: " + script + ". Please configure api per role manually, giving up!", e); |
134 | | - } |
| 117 | + if (s_logger.isDebugEnabled()) { |
| 118 | + s_logger.debug("Configuring default role-api mappings, use migrate-dynamicroles.py instead if you want to migrate rules from an existing commands.properties file"); |
| 119 | + } |
| 120 | + String script = Script.findScript("", "db/create-default-role-api-mappings.sql"); |
| 121 | + if (script == null) { |
| 122 | + s_logger.error("Unable to find default role-api mapping sql file, please configure api per role manually"); |
| 123 | + return; |
| 124 | + } |
| 125 | + try(final FileReader reader = new FileReader(new File(script))) { |
| 126 | + ScriptRunner runner = new ScriptRunner(conn, false, true); |
| 127 | + runner.runScript(reader); |
| 128 | + } catch (SQLException | IOException e) { |
| 129 | + s_logger.error("Unable to insert default api-role mappings from file: " + script + ". Please configure api per role manually, giving up!", e); |
135 | 130 | } |
136 | 131 | } |
137 | 132 |
|
|
0 commit comments