|
53 | 53 | public class KVMStoragePoolManager { |
54 | 54 | protected Logger logger = LogManager.getLogger(getClass()); |
55 | 55 |
|
56 | | - private class StoragePoolInformation { |
57 | | - String name; |
58 | | - String host; |
59 | | - int port; |
60 | | - String path; |
61 | | - String userInfo; |
62 | | - boolean type; |
63 | | - StoragePoolType poolType; |
64 | | - Map<String, String> details; |
65 | | - |
66 | | - public StoragePoolInformation(String name, String host, int port, String path, String userInfo, StoragePoolType poolType, Map<String, String> details, boolean type) { |
67 | | - this.name = name; |
68 | | - this.host = host; |
69 | | - this.port = port; |
70 | | - this.path = path; |
71 | | - this.userInfo = userInfo; |
72 | | - this.type = type; |
73 | | - this.poolType = poolType; |
74 | | - this.details = details; |
75 | | - } |
76 | | - } |
77 | | - |
78 | 56 | private KVMHAMonitor _haMonitor; |
79 | 57 | private final Map<String, StoragePoolInformation> _storagePools = new ConcurrentHashMap<String, StoragePoolInformation>(); |
80 | 58 | private final Map<String, StorageAdaptor> _storageMapper = new HashMap<String, StorageAdaptor>(); |
@@ -303,14 +281,33 @@ public KVMStoragePool getStoragePool(StoragePoolType type, String uuid, boolean |
303 | 281 | } catch (Exception e) { |
304 | 282 | StoragePoolInformation info = _storagePools.get(uuid); |
305 | 283 | if (info != null) { |
306 | | - pool = createStoragePool(info.name, info.host, info.port, info.path, info.userInfo, info.poolType, info.details, info.type); |
| 284 | + pool = createStoragePool(info.getName(), info.getHost(), info.getPort(), info.getPath(), info.getUserInfo(), info.getPoolType(), info.getDetails(), info.isType()); |
307 | 285 | } else { |
308 | 286 | throw new CloudRuntimeException("Could not fetch storage pool " + uuid + " from libvirt due to " + e.getMessage()); |
309 | 287 | } |
310 | 288 | } |
| 289 | + |
| 290 | + if (pool instanceof LibvirtStoragePool) { |
| 291 | + addPoolDetails(uuid, (LibvirtStoragePool) pool); |
| 292 | + } |
| 293 | + |
311 | 294 | return pool; |
312 | 295 | } |
313 | 296 |
|
| 297 | + /** |
| 298 | + * As the class {@link LibvirtStoragePool} is constrained to the {@link org.libvirt.StoragePool} class, there is no way of saving a generic parameter such as the details, hence, |
| 299 | + * this method was created to always make available the details of libvirt primary storages for when they are needed. |
| 300 | + */ |
| 301 | + private void addPoolDetails(String uuid, LibvirtStoragePool pool) { |
| 302 | + StoragePoolInformation storagePoolInformation = _storagePools.get(uuid); |
| 303 | + Map<String, String> details = storagePoolInformation.getDetails(); |
| 304 | + |
| 305 | + if (MapUtils.isNotEmpty(details)) { |
| 306 | + logger.trace("Adding the details {} to the pool with UUID {}.", details, uuid); |
| 307 | + pool.setDetails(details); |
| 308 | + } |
| 309 | + } |
| 310 | + |
314 | 311 | public KVMStoragePool getStoragePoolByURI(String uri) { |
315 | 312 | URI storageUri = null; |
316 | 313 |
|
|
0 commit comments