|
111 | 111 | import org.apache.cloudstack.framework.config.ConfigKey; |
112 | 112 | import org.apache.cloudstack.framework.config.Configurable; |
113 | 113 | import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
| 114 | +import org.apache.cloudstack.jsinterpreter.JsInterpreterHelper; |
114 | 115 | import org.apache.cloudstack.managed.context.ManagedContextRunnable; |
115 | 116 | import org.apache.cloudstack.management.ManagementServerHost; |
116 | 117 | import org.apache.cloudstack.resourcedetail.dao.DiskOfferingDetailsDao; |
@@ -417,6 +418,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C |
417 | 418 | StorageManager storageManager; |
418 | 419 | @Inject |
419 | 420 | ManagementService managementService; |
| 421 | + @Inject |
| 422 | + JsInterpreterHelper jsInterpreterHelper; |
420 | 423 |
|
421 | 424 | protected List<StoragePoolDiscoverer> _discoverers; |
422 | 425 |
|
@@ -962,6 +965,8 @@ protected void checkNFSMountOptionsForUpdate(Map<String, String> details, Storag |
962 | 965 |
|
963 | 966 | @Override |
964 | 967 | public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException, IllegalArgumentException, UnknownHostException, ResourceUnavailableException { |
| 968 | + jsInterpreterHelper.ensureInterpreterEnabledIfParameterProvided(ApiConstants.IS_TAG_A_RULE, Boolean.TRUE.equals(cmd.isTagARule())); |
| 969 | + |
965 | 970 | String providerName = cmd.getStorageProviderName(); |
966 | 971 | Map<String,String> uriParams = extractUriParamsAsMap(cmd.getUrl()); |
967 | 972 | boolean isFileScheme = "file".equals(uriParams.get("scheme")); |
@@ -1034,9 +1039,6 @@ public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws Resource |
1034 | 1039 | throw new PermissionDeniedException(String.format("Cannot perform this operation, Zone is currently disabled: %s", zone)); |
1035 | 1040 | } |
1036 | 1041 |
|
1037 | | - managementService.checkJsInterpretationAllowedIfNeededForParameterValue(ApiConstants.IS_TAG_A_RULE, |
1038 | | - Boolean.TRUE.equals(cmd.isTagARule())); |
1039 | | - |
1040 | 1042 | Map<String, Object> params = new HashMap<>(); |
1041 | 1043 | params.put("zoneId", zone.getId()); |
1042 | 1044 | params.put("clusterId", clusterId); |
@@ -1218,11 +1220,9 @@ public StoragePool enablePrimaryStoragePool(Long id) { |
1218 | 1220 | @ActionEvent(eventType = EventTypes.EVENT_UPDATE_PRIMARY_STORAGE, eventDescription = "update storage pool") |
1219 | 1221 | public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException { |
1220 | 1222 | // Input validation |
1221 | | - Long id = cmd.getId(); |
1222 | | - |
1223 | | - managementService.checkJsInterpretationAllowedIfNeededForParameterValue(ApiConstants.IS_TAG_A_RULE, |
1224 | | - Boolean.TRUE.equals(cmd.isTagARule())); |
| 1223 | + jsInterpreterHelper.ensureInterpreterEnabledIfParameterProvided(ApiConstants.IS_TAG_A_RULE, Boolean.TRUE.equals(cmd.isTagARule())); |
1225 | 1224 |
|
| 1225 | + Long id = cmd.getId(); |
1226 | 1226 | StoragePoolVO pool = _storagePoolDao.findById(id); |
1227 | 1227 | if (pool == null) { |
1228 | 1228 | throw new IllegalArgumentException("Unable to find storage pool with ID: " + id); |
@@ -2751,6 +2751,7 @@ protected void validateHeuristicRule(String heuristicRule) { |
2751 | 2751 | if (StringUtils.isBlank(heuristicRule)) { |
2752 | 2752 | throw new IllegalArgumentException("Unable to create a new secondary storage selector as the given heuristic rule is blank."); |
2753 | 2753 | } |
| 2754 | + jsInterpreterHelper.ensureInterpreterEnabledIfParameterProvided(ApiConstants.HEURISTIC_RULE, true); |
2754 | 2755 | } |
2755 | 2756 |
|
2756 | 2757 | public void syncDatastoreClusterStoragePool(long datastoreClusterPoolId, List<ModifyStoragePoolAnswer> childDatastoreAnswerList, long hostId) { |
|
0 commit comments