mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
CLOUDSTACK-3110: [VMWARE]NPE while adding primary storage(scope=cluster) with Invalid hostname
Description:
When retrieving primary datastore, handle case for non-existing datastores/hosts.
Throw exception and handle the exception in datastore mgmt layer and pass onward
to create storage pool API.
This commit is contained in:
parent
141fbc7ef7
commit
6bad34c509
@ -40,12 +40,16 @@ public class DataStoreManagerImpl implements DataStoreManager {
|
||||
|
||||
@Override
|
||||
public DataStore getDataStore(long storeId, DataStoreRole role) {
|
||||
if (role == DataStoreRole.Primary) {
|
||||
return primaryStoreMgr.getPrimaryDataStore(storeId);
|
||||
} else if (role == DataStoreRole.Image) {
|
||||
return imageDataStoreMgr.getImageStore(storeId);
|
||||
} else if (role == DataStoreRole.ImageCache) {
|
||||
return imageDataStoreMgr.getImageStore(storeId);
|
||||
try {
|
||||
if (role == DataStoreRole.Primary) {
|
||||
return primaryStoreMgr.getPrimaryDataStore(storeId);
|
||||
} else if (role == DataStoreRole.Image) {
|
||||
return imageDataStoreMgr.getImageStore(storeId);
|
||||
} else if (role == DataStoreRole.ImageCache) {
|
||||
return imageDataStoreMgr.getImageStore(storeId);
|
||||
}
|
||||
} catch (CloudRuntimeException e) {
|
||||
throw e;
|
||||
}
|
||||
throw new CloudRuntimeException("un recognized type" + role);
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Component
|
||||
public class PrimaryDataStoreProviderManagerImpl implements PrimaryDataStoreProviderManager {
|
||||
@ -55,6 +56,9 @@ public class PrimaryDataStoreProviderManagerImpl implements PrimaryDataStoreProv
|
||||
@Override
|
||||
public PrimaryDataStore getPrimaryDataStore(long dataStoreId) {
|
||||
StoragePoolVO dataStoreVO = dataStoreDao.findById(dataStoreId);
|
||||
if (dataStoreVO == null) {
|
||||
throw new CloudRuntimeException("Unable to locate datastore with id " + dataStoreId);
|
||||
}
|
||||
String providerName = dataStoreVO.getStorageProviderName();
|
||||
DataStoreProvider provider = providerManager.getDataStoreProvider(providerName);
|
||||
PrimaryDataStoreImpl dataStore = PrimaryDataStoreImpl.createDataStore(dataStoreVO,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user