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.



##########
plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java:
##########
@@ -550,7 +509,16 @@ private HypervisorType getHypervisorType(long hostId) {
 
     @Override
     public boolean attachHost(DataStore store, HostScope scope, 
StoragePoolInfo existingInfo) {
-        dataStoreHelper.attachHost(store, scope, existingInfo);
+        DataStore dataStore = dataStoreHelper.attachHost(store, scope, 
existingInfo);
+        if(existingInfo.getCapacityBytes() == 0){
+            try {
+                storageMgr.connectHostToSharedPool(scope.getScopeId(), 
dataStore.getId());
+            } catch (StorageUnavailableException ex) {
+                
java.util.logging.Logger.getLogger(CloudStackPrimaryDataStoreLifeCycleImpl.class.getName()).log(Level.SEVERE,
 null, ex);
+            } catch (StorageConflictException ex) {
+                
java.util.logging.Logger.getLogger(CloudStackPrimaryDataStoreLifeCycleImpl.class.getName()).log(Level.SEVERE,
 null, ex);

Review Comment:
   Why not just use the `s_logger`?



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