Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -914,15 +914,26 @@ public Pair<Configuration, String> resetConfiguration(final ResetCfgCmd cmd) thr
final Long accountId = cmd.getAccountId();
final Long domainId = cmd.getDomainId();
final Long imageStoreId = cmd.getImageStoreId();
ConfigKey<?> configKey = null;
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;
String category;
String configScope;
final ConfigurationVO config = _configDao.findByName(name);
if (config == null) {
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");
}
defaultValue = configKey.defaultValue();
category = configKey.category();
configScope = configKey.scope().toString();
} else {
defaultValue = config.getDefaultValue();
category = config.getCategory();
configScope = config.getScope();
}
String defaultValue = configKey.defaultValue();
String category = configKey.category();
String configScope = configKey.scope().toString();

String scope = "";
Map<String, Long> scopeMap = new LinkedHashMap<>();
Expand Down Expand Up @@ -958,7 +969,7 @@ public Pair<Configuration, String> resetConfiguration(final ResetCfgCmd cmd) thr
throw new InvalidParameterValueException("unable to find zone by id " + id);
}
_dcDetailsDao.removeDetail(id, name);
optionalValue = Optional.ofNullable(configKey.valueIn(id));
optionalValue = Optional.ofNullable(configKey != null ? configKey.valueIn(id): config.getValue());
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
break;

Expand All @@ -968,13 +979,13 @@ public Pair<Configuration, String> resetConfiguration(final ResetCfgCmd cmd) thr
throw new InvalidParameterValueException("unable to find cluster by id " + id);
}
ClusterDetailsVO clusterDetailsVO = _clusterDetailsDao.findDetail(id, name);
newValue = configKey.value().toString();
newValue = configKey != null ? configKey.value().toString() : config.getValue();
if (name.equalsIgnoreCase("cpu.overprovisioning.factor") || name.equalsIgnoreCase("mem.overprovisioning.factor")) {
_clusterDetailsDao.persist(id, name, newValue);
} else if (clusterDetailsVO != null) {
_clusterDetailsDao.remove(clusterDetailsVO.getId());
}
optionalValue = Optional.ofNullable(configKey.valueIn(id));
optionalValue = Optional.ofNullable(configKey != null ? configKey.valueIn(id): config.getValue());
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
break;

Expand All @@ -984,7 +995,7 @@ public Pair<Configuration, String> resetConfiguration(final ResetCfgCmd cmd) thr
throw new InvalidParameterValueException("unable to find storage pool by id " + id);
}
_storagePoolDetailsDao.removeDetail(id, name);
optionalValue = Optional.ofNullable(configKey.valueIn(id));
optionalValue = Optional.ofNullable(configKey != null ? configKey.valueIn(id) : config.getValue());
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
break;

Expand All @@ -997,7 +1008,7 @@ public Pair<Configuration, String> resetConfiguration(final ResetCfgCmd cmd) thr
if (domainDetailVO != null) {
_domainDetailsDao.remove(domainDetailVO.getId());
}
optionalValue = Optional.ofNullable(configKey.valueIn(id));
optionalValue = Optional.ofNullable(configKey != null ? configKey.valueIn(id) : config.getValue());
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
break;

Expand All @@ -1010,7 +1021,7 @@ public Pair<Configuration, String> resetConfiguration(final ResetCfgCmd cmd) thr
if (accountDetailVO != null) {
_accountDetailsDao.remove(accountDetailVO.getId());
}
optionalValue = Optional.ofNullable(configKey.valueIn(id));
optionalValue = Optional.ofNullable(configKey != null ? configKey.valueIn(id) : config.getValue());
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
break;

Expand All @@ -1023,7 +1034,7 @@ public Pair<Configuration, String> resetConfiguration(final ResetCfgCmd cmd) thr
if (imageStoreDetailVO != null) {
_imageStoreDetailsDao.remove(imageStoreDetailVO.getId());
}
optionalValue = Optional.ofNullable(configKey.valueIn(id));
optionalValue = Optional.ofNullable(configKey != null ? configKey.valueIn(id) : config.getValue());
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
break;

Expand All @@ -1032,7 +1043,7 @@ public Pair<Configuration, String> resetConfiguration(final ResetCfgCmd cmd) thr
s_logger.error("Failed to reset configuration option, name: " + name + ", defaultValue:" + defaultValue);
throw new CloudRuntimeException("Failed to reset configuration value. Please contact Cloud Support.");
}
optionalValue = Optional.ofNullable(configKey.value());
optionalValue = Optional.ofNullable(configKey != null ? configKey.value() : config.getValue());
newValue = optionalValue.isPresent() ? optionalValue.get().toString() : defaultValue;
}

Expand Down