[Simulator] Fix NPE in SolidFireHostListener (#5955)

* [Simulator] Fix NPE in SolidFireHostListener

* address comments

* Update plugins/storage/volume/solidfire/src/main/java/org/apache/cloudstack/storage/datastore/provider/SolidFireSharedHostListener.java

Co-authored-by: sureshanaparti <12028987+sureshanaparti@users.noreply.github.com>

Co-authored-by: sureshanaparti <12028987+sureshanaparti@users.noreply.github.com>
This commit is contained in:
Pearl Dsilva 2022-02-12 17:02:19 +05:30 committed by GitHub
parent 7aa9d3cd51
commit 9f23fbe7b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -73,13 +73,18 @@ public class SolidFireHostListener implements HypervisorHostListener {
HostVO host = hostDao.findById(hostId);
if (host == null) {
LOGGER.error("Failed to add host by SolidFireHostListener as host was not found with id = " + hostId);
LOGGER.error(String.format("Failed to add host by SolidFireHostListener as host was not found with id = %s ", hostId));
return false;
}
if (host.getClusterId() == null) {
LOGGER.error("Failed to add host by SolidFireHostListener as host has no associated cluster id");
return false;
}
SolidFireUtil.hostAddedToCluster(hostId, host.getClusterId(), SolidFireUtil.PROVIDER_NAME,
clusterDao, hostDao, storagePoolDao, storagePoolDetailsDao);
clusterDao, hostDao, storagePoolDao, storagePoolDetailsDao);
handleVMware(host, true, ModifyTargetsCommand.TargetTypeToRemove.NEITHER);

View File

@ -67,13 +67,18 @@ public class SolidFireSharedHostListener implements HypervisorHostListener {
HostVO host = hostDao.findById(hostId);
if (host == null) {
LOGGER.error("Failed to add host by SolidFireSharedHostListener as host was not found with id = " + hostId);
LOGGER.error(String.format("Failed to add host by SolidFireSharedHostListener as host was not found with id = %s ", hostId));
return false;
}
if (host.getClusterId() == null) {
LOGGER.error("Failed to add host by SolidFireSharedHostListener as host has no associated cluster id");
return false;
}
SolidFireUtil.hostAddedToCluster(hostId, host.getClusterId(), SolidFireUtil.SHARED_PROVIDER_NAME,
clusterDao, hostDao, storagePoolDao, storagePoolDetailsDao);
clusterDao, hostDao, storagePoolDao, storagePoolDetailsDao);
handleVMware(host, true, ModifyTargetsCommand.TargetTypeToRemove.NEITHER);