CLOUDSTACK-5530 attempt to add secondary storage with the same name is ignored

This commit is contained in:
Bharat Kumar 2013-12-26 15:30:30 +05:30 committed by Min Chen
parent 35ba14d88d
commit 69fb1d4ed0
1 changed files with 9 additions and 0 deletions

View File

@ -1689,6 +1689,15 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
scopeType = ScopeType.REGION;
}
String name = cmd.getName();
if (name == null) {
name = cmd.getUrl();
}
ImageStoreVO imageStore = _imageStoreDao.findByName(name);
if (imageStore != null) {
throw new InvalidParameterValueException("The image store with name " + name + " already exists, try creating with another name");
}
// check if scope is supported by store provider
if (!((ImageStoreProvider) storeProvider).isScopeSupported(scopeType)) {
throw new InvalidParameterValueException("Image store provider " + providerName + " does not support scope " + scopeType);