3333import com .cloud .utils .exception .CloudRuntimeException ;
3434
3535public class KVMStoragePoolManager {
36+ private class StoragePoolInformation {
37+ String name ;
38+ String host ;
39+ int port ;
40+ String path ;
41+ String userInfo ;
42+ boolean type ;
43+ StoragePoolType poolType ;
44+
45+
46+ public StoragePoolInformation (String name ,
47+ String host ,
48+ int port ,
49+ String path ,
50+ String userInfo ,
51+ StoragePoolType poolType ,
52+ boolean type ) {
53+ this .name = name ;
54+ this .host = host ;
55+ this .port = port ;
56+ this .path = path ;
57+ this .userInfo = userInfo ;
58+ this .type = type ;
59+ this .poolType = poolType ;
60+ }
61+ }
3662 private StorageAdaptor _storageAdaptor ;
3763 private KVMHAMonitor _haMonitor ;
38- private final Map <String , Object > _storagePools = new ConcurrentHashMap <String , Object >();
64+ private final Map <String , StoragePoolInformation > _storagePools = new ConcurrentHashMap <String , StoragePoolInformation >();
3965 private final Map <String , StorageAdaptor > _storageMapper = new HashMap <String , StorageAdaptor >();
4066
4167 private StorageAdaptor getStorageAdaptor (StoragePoolType type ) {
@@ -51,10 +77,10 @@ private StorageAdaptor getStorageAdaptor(StoragePoolType type) {
5177 return adaptor ;
5278 }
5379
54- private void addStoragePool (String uuid ) {
80+ private void addStoragePool (String uuid , StoragePoolInformation pool ) {
5581 synchronized (_storagePools ) {
5682 if (!_storagePools .containsKey (uuid )) {
57- _storagePools .put (uuid , new Object () );
83+ _storagePools .put (uuid , pool );
5884 }
5985 }
6086 }
@@ -69,7 +95,16 @@ public KVMStoragePoolManager(StorageLayer storagelayer, KVMHAMonitor monitor) {
6995
7096 public KVMStoragePool getStoragePool (StoragePoolType type , String uuid ) {
7197 StorageAdaptor adaptor = getStorageAdaptor (type );
72- return adaptor .getStoragePool (uuid );
98+ KVMStoragePool pool = null ;
99+ try {
100+ pool = adaptor .getStoragePool (uuid );
101+ } catch (Exception e ) {
102+ StoragePoolInformation info = _storagePools .get (uuid );
103+ if (info != null ) {
104+ pool = createStoragePool (info .name , info .host , info .port , info .path , info .userInfo , info .poolType , info .type );
105+ }
106+ }
107+ return pool ;
73108 }
74109
75110 public KVMStoragePool getStoragePoolByURI (String uri ) {
@@ -119,7 +154,8 @@ private KVMStoragePool createStoragePool( String name, String host, int port,
119154 PoolType .PrimaryStorage );
120155 _haMonitor .addStoragePool (nfspool );
121156 }
122- addStoragePool (pool .getUuid ());
157+ StoragePoolInformation info = new StoragePoolInformation (name , host , port , path , userInfo , type , primaryStorage );
158+ addStoragePool (pool .getUuid (), info );
123159 return pool ;
124160 }
125161
0 commit comments