mirror of https://github.com/apache/cloudstack.git
Merge 2dffcda882 into bce3e54a7e
This commit is contained in:
commit
740b167984
|
|
@ -246,4 +246,9 @@ public abstract class ResourceDetailsDaoBase<R extends ResourceDetail> extends G
|
|||
}
|
||||
return resourceDetail.getValue();
|
||||
}
|
||||
|
||||
public boolean doesKeyValuePairExist(String key, String value) {
|
||||
List<R> details = findDetails(key, value, null);
|
||||
return CollectionUtils.isNotEmpty(details);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -277,4 +277,10 @@ public class ConfigKey<T> {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean hasValueInScope(String value) {
|
||||
if (value != null && s_depot != null) {
|
||||
return s_depot.doesConfigKeyAndValueExistInScope(_name, value, _scope);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,4 +31,10 @@ public interface ScopedConfigStorage {
|
|||
default String getConfigValue(long id, ConfigKey<?> key) {
|
||||
return getConfigValue(id, key.key());
|
||||
}
|
||||
|
||||
boolean doesKeyValuePairExist(String key, String value);
|
||||
|
||||
default boolean doesConfigKeyAndValueExist(String key, String value) {
|
||||
return doesKeyValuePairExist(key, value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,6 +296,27 @@ public class ConfigDepotImpl implements ConfigDepot, ConfigDepotAdmin {
|
|||
return null;
|
||||
}
|
||||
|
||||
public boolean doesConfigKeyAndValueExistInScope(String key, String value, ConfigKey.Scope scope) {
|
||||
if (!ConfigKey.Scope.Global.equals(scope)) {
|
||||
ScopedConfigStorage scopedConfigStorage = null;
|
||||
for (ScopedConfigStorage storage : _scopedStorages) {
|
||||
if (storage.getScope() == scope) {
|
||||
scopedConfigStorage = storage;
|
||||
}
|
||||
}
|
||||
if (scopedConfigStorage == null) {
|
||||
logger.warn("Unable to check existence of config key {} and value {} in scope: {}, couldn't find config storage for this scope", key, value, scope);
|
||||
return false;
|
||||
}
|
||||
return scopedConfigStorage.doesConfigKeyAndValueExist(key, value);
|
||||
}
|
||||
ConfigurationVO configurationVO = _configDao.findByName(key);
|
||||
if (configurationVO != null) {
|
||||
return configurationVO.getValue().equalsIgnoreCase(value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected Ternary<String, ConfigKey.Scope, Long> getConfigCacheKey(String key, ConfigKey.Scope scope, Long scopeId) {
|
||||
return new Ternary<>(key, scope, scopeId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -947,7 +947,7 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
|
|||
}
|
||||
|
||||
public boolean isDisabled(final Long zoneId) {
|
||||
return !(BackupFrameworkEnabled.value() && BackupFrameworkEnabled.valueIn(zoneId));
|
||||
return !(BackupFrameworkEnabled.valueIn(zoneId));
|
||||
}
|
||||
|
||||
private void validateForZone(final Long zoneId) {
|
||||
|
|
@ -980,7 +980,7 @@ public class BackupManagerImpl extends ManagerBase implements BackupManager {
|
|||
@Override
|
||||
public List<Class<?>> getCommands() {
|
||||
final List<Class<?>> cmdList = new ArrayList<Class<?>>();
|
||||
if (!BackupFrameworkEnabled.value()) {
|
||||
if (!BackupFrameworkEnabled.value() && !BackupFrameworkEnabled.hasValueInScope(Boolean.TRUE.toString())) {
|
||||
return cmdList;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue