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


##########
server/src/main/java/com/cloud/storage/StorageManagerImpl.java:
##########
@@ -814,11 +855,16 @@ public PrimaryDataStoreInfo 
createPool(CreateStoragePoolCmd cmd) throws Resource
         params.put("managed", cmd.isManaged());
         params.put("capacityBytes", cmd.getCapacityBytes());
         params.put("capacityIops", cmd.getCapacityIops());
+        params.putAll(uriParams);
 
         DataStoreLifeCycle lifeCycle = storeProvider.getDataStoreLifeCycle();
         DataStore store = null;
         try {
-            store = lifeCycle.initialize(params);
+            if(params.get("scheme").toString().equals("file")){
+                store = createLocalStorage(params);
+            }else{
+                store = lifeCycle.initialize(params);
+            }

Review Comment:
   ```suggestion
               if (params.get("scheme").toString().equals("file")) {
                   store = createLocalStorage(params);
               } else {
                   store = lifeCycle.initialize(params);
               }
   ```



##########
plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java:
##########
@@ -138,64 +134,26 @@ public DataStore initialize(Map<String, Object> dsInfos) {
 
         PrimaryDataStoreParameters parameters = new 
PrimaryDataStoreParameters();
 
-        UriUtils.UriInfo uriInfo = UriUtils.getUriInfo(url);
-
-        String scheme = uriInfo.getScheme();
-        String storageHost = uriInfo.getStorageHost();
-        String storagePath = uriInfo.getStoragePath();
-        try {
-            if (scheme == null) {
-                throw new InvalidParameterValueException("scheme is null " + 
url + ", add nfs:// (or cifs://) as a prefix");
-            } else if (scheme.equalsIgnoreCase("nfs")) {
-                if (storageHost == null || storagePath == null || 
storageHost.trim().isEmpty() || storagePath.trim().isEmpty()) {
-                    throw new InvalidParameterValueException("host or path is 
null, should be nfs://hostname/path");
-                }
-            } else if (scheme.equalsIgnoreCase("cifs")) {
-                // Don't validate against a URI encoded URI.
-                URI cifsUri = new URI(url);
-                String warnMsg = 
UriUtils.getCifsUriParametersProblems(cifsUri);
-                if (warnMsg != null) {
-                    throw new InvalidParameterValueException(warnMsg);
-                }
-            } else if (scheme.equalsIgnoreCase("sharedMountPoint")) {
-                if (storagePath == null) {
-                    throw new InvalidParameterValueException("host or path is 
null, should be sharedmountpoint://localhost/path");
-                }
-            } else if (scheme.equalsIgnoreCase("rbd")) {
-                if (storagePath == null) {
-                    throw new InvalidParameterValueException("host or path is 
null, should be rbd://hostname/pool");
-                }
-            } else if (scheme.equalsIgnoreCase("gluster")) {
-                if (storageHost == null || storagePath == null || 
storageHost.trim().isEmpty() || storagePath.trim().isEmpty()) {
-                    throw new InvalidParameterValueException("host or path is 
null, should be gluster://hostname/volume");
-                }
-            }
-        } catch (URISyntaxException e) {
-            throw new InvalidParameterValueException(url + " is not a valid 
uri");
-        }

Review Comment:
   Are all of these validations really unnecessary? `scheme`, ` host` and 
`hostPath` will never be null?



##########
server/src/main/java/com/cloud/api/query/QueryManagerImpl.java:
##########
@@ -2769,10 +2769,29 @@ private Pair<List<AsyncJobJoinVO>, Integer> 
searchForAsyncJobsInternal(ListAsync
 
     @Override
     public ListResponse<StoragePoolResponse> 
searchForStoragePools(ListStoragePoolsCmd cmd) {
-        Pair<List<StoragePoolJoinVO>, Integer> result = 
searchForStoragePoolsInternal(cmd);
-        ListResponse<StoragePoolResponse> response = new 
ListResponse<StoragePoolResponse>();
+        Pair<List<StoragePoolJoinVO>, Integer> result = cmd.getHostId() != 
null ? searchForLocalStorages(cmd) : searchForStoragePoolsInternal(cmd);
+        return createStoragesPoolResponse(result);
+    }
+
+    private Pair<List<StoragePoolJoinVO>, Integer> 
searchForLocalStorages(ListStoragePoolsCmd cmd) {
+        long id = cmd.getHostId();
+        String scope = "HOST";

Review Comment:
   We could use the ScopeType enum here.



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