shwstppr commented on code in PR #8875:
URL: https://github.com/apache/cloudstack/pull/8875#discussion_r1608235310


##########
api/src/main/java/org/apache/cloudstack/api/response/VirtualMachineResponse.java:
##########
@@ -0,0 +1,116 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.response;
+
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+
+import com.cloud.serializer.Param;
+import com.cloud.vm.VirtualMachine;
+import com.google.gson.annotations.SerializedName;
+
+@EntityReference(value = VirtualMachine.class)
+public class VirtualMachineResponse extends BaseResponse {
+    @SerializedName("id")
+    @Param(description = "the ID of the VM")
+    private String id;
+
+    @SerializedName("type")
+    @Param(description = "the type of VM")
+    private String type;
+
+    @SerializedName("name")
+    @Param(description = "the name of the VM")
+    private String name;
+
+    @SerializedName("clusterid")
+    @Param(description = "the Pod ID for the system VM")
+    private String clusterId;
+
+    @SerializedName("clustername")
+    @Param(description = "the Pod name for the system VM", since = "4.13.2")

Review Comment:
   ```suggestion
       @Param(description = "the Pod name for the system VM")
   ```



##########
server/src/main/java/com/cloud/storage/StorageManagerImpl.java:
##########
@@ -1211,10 +1211,13 @@ private void 
changeStoragePoolScopeToCluster(StoragePoolVO primaryStorage, Long
         List<VirtualMachine.State> states = Arrays.asList(State.Starting, 
State.Running, State.Stopping, State.Migrating, State.Restoring);
 
         Long id = primaryStorage.getId();
-        List<VolumeVO> volumesInOtherClusters = 
volumeDao.listByPoolIdVMStatesNotInCluster(clusterId, states, id);
-        if (volumesInOtherClusters.size() > 0) {
-            throw new CloudRuntimeException(String.format("Cannot change scope 
of the pool %s to cluster %s as there are VMs running on other clusters which 
are using volumes on this storage pool",
-                    primaryStorage.getName(), clusterVO.getName()));
+        Pair<List<VMInstanceVO>, Integer> vmsNotInClusterUsingPool = 
_vmInstanceDao.listByVmsNotInClusterUsingPool(clusterId, id);
+        if (vmsNotInClusterUsingPool.second() != 0) {
+            throw new CloudRuntimeException(String.format("Cannot change scope 
of the storage pool [%s] to cluster [%s] %s %s %s",
+                    primaryStorage.getName(), clusterVO.getName(),
+                    "as there are VMs with volumes in this pool that are 
running on other clusters.",
+                    "All such User VMs must be stopped and System VMs must be 
destroyed before proceeding.",
+                    "Please use the API findAffectedVmsForStorageScopeChange 
to get the list."));

Review Comment:
   curious - why are we adding constant strings with format?



##########
api/src/main/java/org/apache/cloudstack/api/response/VirtualMachineResponse.java:
##########
@@ -0,0 +1,116 @@
+// Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   Why do we need this class? Is it possible to use UserVmResponse or do we 
also have affected VR and system VMs?



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