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


##########
api/src/main/java/org/apache/cloudstack/api/response/VolumeResponse.java:
##########
@@ -96,6 +96,10 @@ public class VolumeResponse extends 
BaseResponseWithTagInformation implements Co
     @Param(description = "state of the virtual machine")
     private String virtualMachineState;
 
+    @SerializedName("vmtype")

Review Comment:
   better to add this in ApiConstants



##########
api/src/main/java/com/cloud/vm/UserVmService.java:
##########
@@ -425,6 +425,8 @@ UserVm createVirtualMachine(DeployVMCmd cmd) throws 
InsufficientCapacityExceptio
 
     UserVm getUserVm(long vmId);
 
+    VirtualMachine getVm(long vmId);

Review Comment:
   Does it make more sense to define this in VirtualMachineManager class?



##########
ui/src/utils/path.js:
##########
@@ -0,0 +1,33 @@
+// 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.
+
+export function createPathBasedOnVmType (vmtype, virtualmachineid) {
+  let path = ''
+  switch (vmtype) {
+    case 'ConsoleProxy':
+    case 'SecondaryStorageVm':
+      path = '/systemvm/'
+      break
+    case 'DomainRouter':
+      path = '/router/'
+      break
+    default:
+      path = '/vm/'
+  }
+
+  return path + virtualmachineid
+}

Review Comment:
   does it make more sense to add this code in `ui/src/utils/plugins.js`?



##########
api/src/main/java/org/apache/cloudstack/api/command/admin/vm/MigrateVirtualMachineWithVolumeCmd.java:
##########
@@ -152,20 +153,17 @@ public ApiCommandResourceType getApiResourceType() {
     @Override
     public void execute() {
         if (hostId == null && MapUtils.isEmpty(migrateVolumeTo)) {
-            throw new InvalidParameterValueException(String.format("Either %s 
or %s  must be passed for migrating the VM", ApiConstants.HOST_ID, 
ApiConstants.MIGRATE_TO));
-        }
-
-        UserVm userVm = _userVmService.getUserVm(getVirtualMachineId());
-        if (userVm == null) {
-            throw new InvalidParameterValueException("Unable to find the VM by 
id=" + getVirtualMachineId());
+            throw new InvalidParameterValueException(String.format("Either %s 
or %s must be passed for migrating the VM.", ApiConstants.HOST_ID, 
ApiConstants.MIGRATE_TO));
         }
 
+        VirtualMachine userVm = _userVmService.getVm(getVirtualMachineId());

Review Comment:
   `userVm` variable name should be changed here



##########
api/src/main/java/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java:
##########
@@ -88,6 +88,10 @@ public class ListVolumesCmd extends 
BaseListTaggedResourcesCmd implements UserCm
             RoleType.Admin})
     private Boolean display;
 
+    @Parameter(name = ApiConstants.LIST_SYSTEM_VMS, type = 
CommandType.BOOLEAN, description = "list system VMs; only ROOT admin is 
eligible to pass this parameter", since = "4.17",

Review Comment:
   is support added for this in UI, in migrate VM form?
   `since` should be 4.18 now



##########
api/src/main/java/org/apache/cloudstack/api/command/admin/vm/MigrateVirtualMachineWithVolumeCmd.java:
##########
@@ -195,4 +192,16 @@ public void execute() {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, 
e.getMessage());
         }
     }
+
+    private void setResponseBasedOnVmType(VirtualMachine userVm, 
VirtualMachine migratedVm) {
+        if (VirtualMachine.Type.User.equals(userVm.getType())) {
+            UserVmResponse userVmResponse = 
_responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", 
(UserVm) migratedVm).get(0);
+            userVmResponse.setResponseName(getCommandName());
+            setResponseObject(userVmResponse);
+            return;
+        }
+        SystemVmResponse systemVmResponse = 
_responseGenerator.createSystemVmResponse(migratedVm);
+        systemVmResponse.setResponseName(getCommandName());
+        setResponseObject(systemVmResponse);

Review Comment:
   I hope these different response types won't affect UI, worth checking



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