JoaoJandre commented on code in PR #6699:
URL: https://github.com/apache/cloudstack/pull/6699#discussion_r1263948870


##########
server/src/main/java/com/cloud/storage/StorageManagerImpl.java:
##########
@@ -648,6 +651,38 @@ public boolean stop() {
         return true;
     }
 
+    private DataStore createLocalStorage(Map<String, Object> poolInfos) throws 
ConnectionException{
+        Object existingUuid = poolInfos.get("uuid");
+        if( existingUuid == null ){
+            poolInfos.put("uuid", UUID.randomUUID().toString());
+        }
+        String hostAddress = poolInfos.get("host").toString();
+        Host host = _hostDao.findByName(hostAddress);
+
+        if( host == null )
+            host = _hostDao.findByIp(hostAddress);
+
+        if( host == null )
+            host = _hostDao.findByPublicIp(hostAddress);
+
+        if( host == null )
+            throw new InvalidParameterValueException(String.format("host %s 
not found",hostAddress));

Review Comment:
   ```suggestion
           if( host == null ) {
               host = _hostDao.findByIp(hostAddress);
   
               if( host == null ) {
                   host = _hostDao.findByPublicIp(hostAddress);
   
                   if( host == null ) {
                       throw new 
InvalidParameterValueException(String.format("host %s not found",hostAddress));
                   }
                }
            }
   ```
   No need to recheck if host is null three times if its not null the first 
time.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to