You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/01/14 08:45:35 UTC

[GitHub] [cloudstack] shwstppr commented on a change in pull request #4548: Bug/disk order bug during ingest

shwstppr commented on a change in pull request #4548:
URL: https://github.com/apache/cloudstack/pull/4548#discussion_r557214366



##########
File path: plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
##########
@@ -7274,9 +7277,7 @@ public int compare(final UnmanagedInstanceTO.Disk disk1, final UnmanagedInstance
                 }
 
                 int extractInt(UnmanagedInstanceTO.Disk disk) {
-                    String num = disk.getLabel().replaceAll("\\D", "");
-                    // return 0 if no digits found
-                    return num.isEmpty() ? 0 : Integer.parseInt(num);
+                    return disk.getPosition() + (disk.getControllerUnit() * 100);

Review comment:
       @DK101010 I'm not sure if this formula is giving correct position/order for the disk.
   I tried listUnamanagedInstance API for a VM with 2 data disks and results were incorrect with this change
   ![Screenshot from 2021-01-14 14-08-56](https://user-images.githubusercontent.com/153340/104565707-ac2fb400-5672-11eb-8d20-302442cd6565.png)
   
   **With changes** - Root disk is showing up at second position in order
   ```
   > list unmanagedinstances clusterid=2b35fefc-892a-4393-9ccf-30229c1a999b name=importtest
   {
     "count": 1,
     "unmanagedinstance": [
       {
         "clusterid": "2b35fefc-892a-4393-9ccf-30229c1a999b",
         "cpucorepersocket": 1,
         "cpunumber": 1,
         "cpuspeed": 0,
         "disk": [
           {
             "capacity": 21474836480,
             "controller": "lsilogic",
             "controllerunit": 0,
             "datastorehost": "10.10.0.16",
             "datastorename": "4ea48dd0701d3385a5cbb8921ee1d1d4",
             "datastorepath": "/acs/primary/pr4385-t3314-vmware-65u2/pr4385-t3314-vmware-65u2-esxi-pri2",
             "datastoretype": "NFS",
             "id": "35-2000",
             "imagepath": "[4ea48dd0701d3385a5cbb8921ee1d1d4] importtest/importtest_61.vmdk",
             "label": "Hard disk 2",
             "position": 0
           },
           {
             "capacity": 2147483648,
             "controller": "ide",
             "controllerunit": 0,
             "datastorehost": "10.10.0.16",
             "datastorename": "4ea48dd0701d3385a5cbb8921ee1d1d4",
             "datastorepath": "/acs/primary/pr4385-t3314-vmware-65u2/pr4385-t3314-vmware-65u2-esxi-pri2",
             "datastoretype": "NFS",
             "id": "35-3001",
             "imagepath": "[4ea48dd0701d3385a5cbb8921ee1d1d4] importtest/importtest_62.vmdk",
             "label": "Hard disk 1",
             "position": 1
           },
           {
             "capacity": 5368709120,
             "controller": "lsilogic",
             "controllerunit": 0,
             "datastorehost": "10.10.0.16",
             "datastorename": "4ea48dd0701d3385a5cbb8921ee1d1d4",
             "datastorepath": "/acs/primary/pr4385-t3314-vmware-65u2/pr4385-t3314-vmware-65u2-esxi-pri2",
             "datastoretype": "NFS",
             "id": "35-2001",
             "imagepath": "[4ea48dd0701d3385a5cbb8921ee1d1d4] importtest/importtest_63.vmdk",
             "label": "Hard disk 3",
             "position": 1
           }
         ],
         "hostid": "fd9a2641-ce6e-456e-be78-4b1b63c2b2ac",
         "memory": 512,
         "name": "importtest",
         "nic": [
           {
             "adaptertype": "E1000",
             "id": "Network adapter 1",
             "macaddress": "02:00:44:4f:00:12",
             "networkname": "cloud.guest.2183.200.1-vSwitch1",
             "vlanid": 2183
           }
         ],
         "osdisplayname": "CentOS 4/5 or later (64-bit)",
         "osid": "centos64Guest",
         "powerstate": "PowerOn"
       }
     ]
   }
   ```
   
   **Without change** - Root disk at first place
   ```
   > list unmanagedinstances clusterid=2b35fefc-892a-4393-9ccf-30229c1a999b name=importtest
   {
     "count": 1,
     "unmanagedinstance": [
       {
         "clusterid": "2b35fefc-892a-4393-9ccf-30229c1a999b",
         "cpucorepersocket": 1,
         "cpunumber": 1,
         "cpuspeed": 0,
         "disk": [
           {
             "capacity": 2147483648,
             "controller": "ide",
             "controllerunit": 0,
             "datastorehost": "10.10.0.16",
             "datastorename": "4ea48dd0701d3385a5cbb8921ee1d1d4",
             "datastorepath": "/acs/primary/pr4385-t3314-vmware-65u2/pr4385-t3314-vmware-65u2-esxi-pri2",
             "datastoretype": "NFS",
             "id": "35-3001",
             "imagepath": "[4ea48dd0701d3385a5cbb8921ee1d1d4] importtest/importtest_62.vmdk",
             "label": "Hard disk 1",
             "position": 1
           },
           {
             "capacity": 21474836480,
             "controller": "lsilogic",
             "controllerunit": 0,
             "datastorehost": "10.10.0.16",
             "datastorename": "4ea48dd0701d3385a5cbb8921ee1d1d4",
             "datastorepath": "/acs/primary/pr4385-t3314-vmware-65u2/pr4385-t3314-vmware-65u2-esxi-pri2",
             "datastoretype": "NFS",
             "id": "35-2000",
             "imagepath": "[4ea48dd0701d3385a5cbb8921ee1d1d4] importtest/importtest_61.vmdk",
             "label": "Hard disk 2",
             "position": 0
           },
           {
             "capacity": 5368709120,
             "controller": "lsilogic",
             "controllerunit": 0,
             "datastorehost": "10.10.0.16",
             "datastorename": "4ea48dd0701d3385a5cbb8921ee1d1d4",
             "datastorepath": "/acs/primary/pr4385-t3314-vmware-65u2/pr4385-t3314-vmware-65u2-esxi-pri2",
             "datastoretype": "NFS",
             "id": "35-2001",
             "imagepath": "[4ea48dd0701d3385a5cbb8921ee1d1d4] importtest/importtest_63.vmdk",
             "label": "Hard disk 3",
             "position": 1
           }
         ],
         "hostid": "fd9a2641-ce6e-456e-be78-4b1b63c2b2ac",
         "memory": 512,
         "name": "importtest",
         "nic": [
           {
             "adaptertype": "E1000",
             "id": "Network adapter 1",
             "macaddress": "02:00:44:4f:00:12",
             "networkname": "cloud.guest.2183.200.1-vSwitch1",
             "vlanid": 2183
           }
         ],
         "osdisplayname": "CentOS 4/5 or later (64-bit)",
         "osid": "centos64Guest",
         "powerstate": "PowerOn"
       }
     ]
   }
   
   ```




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org