sureshanaparti commented on a change in pull request #4871:
URL: https://github.com/apache/cloudstack/pull/4871#discussion_r602027118
##########
File path: server/src/main/java/com/cloud/storage/StorageManagerImpl.java
##########
@@ -1633,6 +1640,223 @@ public PrimaryDataStoreInfo
cancelPrimaryStorageForMaintenance(CancelPrimaryStor
return
(PrimaryDataStoreInfo)_dataStoreMgr.getDataStore(primaryStorage.getId(),
DataStoreRole.Primary);
}
+ @Override
+ @ActionEvent(eventType = EventTypes.EVENT_SYNC_STORAGE_POOL,
eventDescription = "synchronising storage pool with management server", async =
true)
+ public StoragePool syncStoragePool(SyncStoragePoolCmd cmd) {
+ Long poolId = cmd.getPoolId();
+ StoragePoolVO pool = _storagePoolDao.findById(poolId);
+
+ if (pool == null) {
+ String msg = "Unable to obtain lock on the storage pool record
while syncing storage pool with management server";
+ s_logger.error(msg);
+ throw new InvalidParameterValueException(msg);
+ }
+
+ if (!pool.getPoolType().equals(StoragePoolType.DatastoreCluster)) {
+ throw new
InvalidParameterValueException(String.format("SyncStoragePool API is currently
supported only for storage type of datastore cluster"));
+ }
+
+ if (!pool.getStatus().equals(StoragePoolStatus.Up)) {
+ throw new InvalidParameterValueException(String.format("Primary
storage with id %s is not ready for syncing, as the status is %s",
pool.getUuid(), pool.getStatus().toString()));
+ }
+
+ // find the host
+ List<Long> poolIds = new ArrayList<>();
+ poolIds.add(poolId);
+ List<Long> hosts =
_storagePoolHostDao.findHostsConnectedToPools(poolIds);
+ if (hosts.size() > 0) {
Review comment:
what in case of no hosts found ? can you log appropriate warn msg?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]