ravening commented on a change in pull request #4230:
URL: https://github.com/apache/cloudstack/pull/4230#discussion_r464419774
##########
File path:
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java
##########
@@ -814,6 +824,163 @@ public Configuration updateConfiguration(final
UpdateCfgCmd cmd) throws InvalidP
}
}
+ @Override
+ @ActionEvent(eventType = EventTypes.EVENT_CONFIGURATION_VALUE_EDIT,
eventDescription = "resetting configuration")
+ public Pair<Configuration, String> resetConfiguration(final ResetCfgCmd
cmd) throws InvalidParameterValueException {
+ final Long userId = CallContext.current().getCallingUserId();
+ final String name = cmd.getCfgName();
+ final Long zoneId = cmd.getZoneId();
+ final Long clusterId = cmd.getClusterId();
+ final Long storagepoolId = cmd.getStoragepoolId();
+ final Long accountId = cmd.getAccountId();
+ final Long domainId = cmd.getDomainId();
+ final Long imageStoreId = cmd.getImageStoreId();
+ Optional optionalValue;
+ final ConfigKey<?> configKey = _configDepot.get(name);
+ if (configKey == null) {
+ s_logger.warn("Probably the component manager where configuration
variable " + name + " is defined needs to implement Configurable interface");
+ throw new InvalidParameterValueException("Config parameter with
name " + name + " doesn't exist");
+ }
+ String defaultValue = configKey.defaultValue();
+ String category = configKey.category();
+ String configScope = configKey.scope().toString();
+
+ String scope = ConfigKey.Scope.Global.toString();
+
+ Long id = null;
+ int paramCountCheck = 0;
+
+ if (zoneId != null) {
+ scope = ConfigKey.Scope.Zone.toString();
+ id = zoneId;
+ paramCountCheck++;
+ }
+ if (clusterId != null) {
+ scope = ConfigKey.Scope.Cluster.toString();
+ id = clusterId;
+ paramCountCheck++;
+ }
+ if (domainId != null) {
+ scope = ConfigKey.Scope.Domain.toString();
+ id = domainId;
+ paramCountCheck++;
+ }
+ if (accountId != null) {
+ scope = ConfigKey.Scope.Account.toString();
+ id = accountId;
+ paramCountCheck++;
+ }
+ if (storagepoolId != null) {
+ scope = ConfigKey.Scope.StoragePool.toString();
+ id = storagepoolId;
+ paramCountCheck++;
+ }
+ if (imageStoreId != null) {
+ scope = ConfigKey.Scope.ImageStore.toString();
+ id = imageStoreId;
+ paramCountCheck++;
+ }
+
+ if (paramCountCheck > 1) {
+ throw new InvalidParameterValueException("cannot handle multiple
IDs, provide only one ID corresponding to the scope");
+ }
+
+ if (scope != null && !scope.equals(ConfigKey.Scope.Global.toString()))
{
+ if (!configScope.contains(scope) &&
!(configScope.contains(ConfigKey.Scope.Account.toString()) &&
scope.equals(ConfigKey.Scope.Domain.toString()))) {
Review comment:
@DaanHoogland this was the extra check which got added because of
https://github.com/apache/cloudstack/pull/4215
I have removed it now but still this pr depends on the above one
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]