This is an automated email from the ASF dual-hosted git repository.
nvazquez pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push:
new 9f23fbe [Simulator] Fix NPE in SolidFireHostListener (#5955)
9f23fbe is described below
commit 9f23fbe7b6a7ac155c42e648943efd546bc9b4c9
Author: Pearl Dsilva <[email protected]>
AuthorDate: Sat Feb 12 17:02:19 2022 +0530
[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
<[email protected]>
Co-authored-by: sureshanaparti
<[email protected]>
---
.../storage/datastore/provider/SolidFireHostListener.java | 9 +++++++--
.../storage/datastore/provider/SolidFireSharedHostListener.java | 9 +++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git
a/plugins/storage/volume/solidfire/src/main/java/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java
b/plugins/storage/volume/solidfire/src/main/java/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java
index 4fffb70..84a3fa9 100644
---
a/plugins/storage/volume/solidfire/src/main/java/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java
+++
b/plugins/storage/volume/solidfire/src/main/java/org/apache/cloudstack/storage/datastore/provider/SolidFireHostListener.java
@@ -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);
diff --git
a/plugins/storage/volume/solidfire/src/main/java/org/apache/cloudstack/storage/datastore/provider/SolidFireSharedHostListener.java
b/plugins/storage/volume/solidfire/src/main/java/org/apache/cloudstack/storage/datastore/provider/SolidFireSharedHostListener.java
index 575a302..e01e982 100644
---
a/plugins/storage/volume/solidfire/src/main/java/org/apache/cloudstack/storage/datastore/provider/SolidFireSharedHostListener.java
+++
b/plugins/storage/volume/solidfire/src/main/java/org/apache/cloudstack/storage/datastore/provider/SolidFireSharedHostListener.java
@@ -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);