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/18 11:01:14 UTC

[GitHub] [cloudstack] shwstppr opened a new pull request #4591: api, server: add rootdiskid param in importUnmanagedInstance API

shwstppr opened a new pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591


   ### Description
   
   Adds an optional rootdiskid parameter in importUnmanagedInstance API. It will allow the user of the API to select a particular disk as ROOT volume for the imported VM
   
   <!--- ********************************************************************************* -->
   <!--- NOTE: AUTOMATATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. -->
   <!--- PLEASE PUT AN 'X' in only **ONE** box -->
   <!--- ********************************************************************************* -->
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [x] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [x] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [ ] Minor
   - [ ] Trivial
   
   
   ### Screenshots (if appropriate):
   
   
   ### How Has This Been Tested?
   <!-- Please describe in detail how you tested your changes. -->
   <!-- Include details of your testing environment, and the tests you ran to -->
   <!-- see how your change affects other areas of the code, etc. -->
   
   
   <!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/master/CONTRIBUTING.md) document -->
   


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



[GitHub] [cloudstack] shwstppr commented on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
shwstppr commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-766709036


   @blueorangutan package


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



[GitHub] [cloudstack] shwstppr commented on a change in pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
shwstppr commented on a change in pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#discussion_r564507970



##########
File path: server/src/main/java/org/apache/cloudstack/vm/VmImportManagerImpl.java
##########
@@ -500,6 +500,35 @@ private StoragePool getStoragePool(final UnmanagedInstanceTO.Disk disk, final Da
         return storagePool;
     }
 
+    private Pair<UnmanagedInstanceTO.Disk, List<UnmanagedInstanceTO.Disk>> getRootAndDataDisks(List<UnmanagedInstanceTO.Disk> disks, final Map<String, Long> dataDiskOfferingMap) {
+        UnmanagedInstanceTO.Disk rootDisk = null;
+        List<UnmanagedInstanceTO.Disk> dataDisks = new ArrayList<>();
+        if (disks.size() == 1) {
+            rootDisk = disks.get(0);
+            return new Pair<>(rootDisk, dataDisks);
+        }
+        Set<String> callerDiskIds = dataDiskOfferingMap.keySet();
+        if (callerDiskIds.size() != disks.size() - 1) {
+            String msg = String.format("VM has total %d disks for which %d disk offering mappings provided. %d disks need a disk offering for import", disks.size(), callerDiskIds.size(), disks.size()-1);
+            LOGGER.error(String.format("%s. %s parameter can be used to provide disk offerings for the disks", msg, ApiConstants.DATADISK_OFFERING_LIST));
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg);
+        }
+        List<String> diskIdsWithoutOffering = new ArrayList<>();
+        for (UnmanagedInstanceTO.Disk disk : disks) {
+            String diskId = disk.getDiskId();
+            if (!callerDiskIds.contains(diskId)) {
+                diskIdsWithoutOffering.add(diskId);

Review comment:
       Same as above




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



[GitHub] [cloudstack] DK101010 commented on pull request #4591: api, server: add rootdiskid param in importUnmanagedInstance API

Posted by GitBox <gi...@apache.org>.
DK101010 commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762830326


   > @rhtyd done
   > 
   > @DK101010 I'm also deliberating of a way to select correct root disk without adding new param in API. For API, we already need to pass a diskid-diskoffering map for all data disks so with that info we can simply select the remaining disk as the root disk (will have to refactor some error messages and change the logic). Does that make sense?
   
   @shwstppr I'm not quite sure if I understand you right. The VCenter give you a list that enables you to find the right root disk?
   
   The diskoffering-map in CS will be created based on the collection sort algo. in my last PR and is wrong in case of that the HardDisk1 not the root disk is. (When I remind me right)  


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



[GitHub] [cloudstack] rhtyd commented on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
rhtyd commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-767399577


   @blueorangutan test 


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



[GitHub] [cloudstack] blueorangutan removed a comment on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
blueorangutan removed a comment on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762246078


   @DK101010 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


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



[GitHub] [cloudstack] blueorangutan commented on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-766731948


   Packaging result: ✔centos7 ✖centos8 ✔debian. JID-2585


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



[GitHub] [cloudstack] blueorangutan commented on pull request #4591: api, server: add rootdiskid param in importUnmanagedInstance API

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762265216


   Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2546


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



[GitHub] [cloudstack] shwstppr commented on a change in pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
shwstppr commented on a change in pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#discussion_r564507733



##########
File path: server/src/main/java/org/apache/cloudstack/vm/VmImportManagerImpl.java
##########
@@ -500,6 +500,35 @@ private StoragePool getStoragePool(final UnmanagedInstanceTO.Disk disk, final Da
         return storagePool;
     }
 
+    private Pair<UnmanagedInstanceTO.Disk, List<UnmanagedInstanceTO.Disk>> getRootAndDataDisks(List<UnmanagedInstanceTO.Disk> disks, final Map<String, Long> dataDiskOfferingMap) {
+        UnmanagedInstanceTO.Disk rootDisk = null;
+        List<UnmanagedInstanceTO.Disk> dataDisks = new ArrayList<>();
+        if (disks.size() == 1) {
+            rootDisk = disks.get(0);
+            return new Pair<>(rootDisk, dataDisks);
+        }
+        Set<String> callerDiskIds = dataDiskOfferingMap.keySet();
+        if (callerDiskIds.size() != disks.size() - 1) {
+            String msg = String.format("VM has total %d disks for which %d disk offering mappings provided. %d disks need a disk offering for import", disks.size(), callerDiskIds.size(), disks.size()-1);
+            LOGGER.error(String.format("%s. %s parameter can be used to provide disk offerings for the disks", msg, ApiConstants.DATADISK_OFFERING_LIST));
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg);
+        }
+        List<String> diskIdsWithoutOffering = new ArrayList<>();
+        for (UnmanagedInstanceTO.Disk disk : disks) {
+            String diskId = disk.getDiskId();
+            if (!callerDiskIds.contains(diskId)) {
+                diskIdsWithoutOffering.add(diskId);
+                rootDisk = disk;
+            } else {
+                dataDisks.add(disk);
+            }
+        }
+        if (diskIdsWithoutOffering.size() > 1) {

Review comment:
       Whole list is processed to fund out disha for which offering is not provided. List is used in error message. Knowing names which user missed will be helpful




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



[GitHub] [cloudstack] rhtyd commented on pull request #4591: api, server: add rootdiskid param in importUnmanagedInstance API

Posted by GitBox <gi...@apache.org>.
rhtyd commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762229765


   @shwstppr if this is a bugfix, pl change branch to 4.15 and milestone to 4.15.1.0


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



[GitHub] [cloudstack] DK101010 commented on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
DK101010 commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-769031737


   @shwstppr I've tested it in our environment and it works perfectly. 


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



[GitHub] [cloudstack] sureshanaparti commented on a change in pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on a change in pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#discussion_r564402783



##########
File path: server/src/main/java/org/apache/cloudstack/vm/VmImportManagerImpl.java
##########
@@ -500,6 +500,35 @@ private StoragePool getStoragePool(final UnmanagedInstanceTO.Disk disk, final Da
         return storagePool;
     }
 
+    private Pair<UnmanagedInstanceTO.Disk, List<UnmanagedInstanceTO.Disk>> getRootAndDataDisks(List<UnmanagedInstanceTO.Disk> disks, final Map<String, Long> dataDiskOfferingMap) {
+        UnmanagedInstanceTO.Disk rootDisk = null;
+        List<UnmanagedInstanceTO.Disk> dataDisks = new ArrayList<>();
+        if (disks.size() == 1) {
+            rootDisk = disks.get(0);
+            return new Pair<>(rootDisk, dataDisks);
+        }
+        Set<String> callerDiskIds = dataDiskOfferingMap.keySet();
+        if (callerDiskIds.size() != disks.size() - 1) {
+            String msg = String.format("VM has total %d disks for which %d disk offering mappings provided. %d disks need a disk offering for import", disks.size(), callerDiskIds.size(), disks.size()-1);
+            LOGGER.error(String.format("%s. %s parameter can be used to provide disk offerings for the disks", msg, ApiConstants.DATADISK_OFFERING_LIST));
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg);
+        }
+        List<String> diskIdsWithoutOffering = new ArrayList<>();
+        for (UnmanagedInstanceTO.Disk disk : disks) {
+            String diskId = disk.getDiskId();
+            if (!callerDiskIds.contains(diskId)) {
+                diskIdsWithoutOffering.add(diskId);
+                rootDisk = disk;
+            } else {
+                dataDisks.add(disk);
+            }
+        }
+        if (diskIdsWithoutOffering.size() > 1) {

Review comment:
       @shwstppr can throw error as soon as `diskIdsWithoutOffering` size is more than 1? Not required to process the entire list of disks.




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



[GitHub] [cloudstack] DK101010 edited a comment on pull request #4591: api, server: add rootdiskid param in importUnmanagedInstance API

Posted by GitBox <gi...@apache.org>.
DK101010 edited a comment on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762830326


   > @rhtyd done
   > 
   > @DK101010 I'm also deliberating of a way to select correct root disk without adding new param in API. For API, we already need to pass a diskid-diskoffering map for all data disks so with that info we can simply select the remaining disk as the root disk (will have to refactor some error messages and change the logic). Does that make sense?
   
   @shwstppr I'm not quite sure if I understand you right. The VCenter give you a list that enables you to find the right root disk?
   
   The diskoffering-map in CS will be created based on the collection sort algo. in my last PR and is wrong in case of that the HardDisk1 is not the root disk. (When I remind me right)  


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



[GitHub] [cloudstack] sureshanaparti commented on a change in pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on a change in pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#discussion_r564419856



##########
File path: server/src/main/java/org/apache/cloudstack/vm/VmImportManagerImpl.java
##########
@@ -500,6 +500,35 @@ private StoragePool getStoragePool(final UnmanagedInstanceTO.Disk disk, final Da
         return storagePool;
     }
 
+    private Pair<UnmanagedInstanceTO.Disk, List<UnmanagedInstanceTO.Disk>> getRootAndDataDisks(List<UnmanagedInstanceTO.Disk> disks, final Map<String, Long> dataDiskOfferingMap) {
+        UnmanagedInstanceTO.Disk rootDisk = null;
+        List<UnmanagedInstanceTO.Disk> dataDisks = new ArrayList<>();
+        if (disks.size() == 1) {
+            rootDisk = disks.get(0);
+            return new Pair<>(rootDisk, dataDisks);
+        }
+        Set<String> callerDiskIds = dataDiskOfferingMap.keySet();
+        if (callerDiskIds.size() != disks.size() - 1) {
+            String msg = String.format("VM has total %d disks for which %d disk offering mappings provided. %d disks need a disk offering for import", disks.size(), callerDiskIds.size(), disks.size()-1);
+            LOGGER.error(String.format("%s. %s parameter can be used to provide disk offerings for the disks", msg, ApiConstants.DATADISK_OFFERING_LIST));
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg);
+        }
+        List<String> diskIdsWithoutOffering = new ArrayList<>();
+        for (UnmanagedInstanceTO.Disk disk : disks) {
+            String diskId = disk.getDiskId();
+            if (!callerDiskIds.contains(diskId)) {
+                diskIdsWithoutOffering.add(diskId);

Review comment:
       `diskIdsWithoutOffering` may not be required.  throw error when `rootDisk != null` here, should be Ok?




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



[GitHub] [cloudstack] DK101010 commented on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
DK101010 commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-766767282


   > @DK101010 I've refactored logic for handling disks and `datadiskofferinglist` param. As mentioned in the description, correct ROOT disk should be selected now and there won't any need for new API parameters. Will be great if you can test
   
   I'm a little bit skeptical regards the offeringMap :D but I will test it this week.


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



[GitHub] [cloudstack] DK101010 commented on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
DK101010 commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-766767282


   > @DK101010 I've refactored logic for handling disks and `datadiskofferinglist` param. As mentioned in the description, correct ROOT disk should be selected now and there won't any need for new API parameters. Will be great if you can test
   
   I'm a little bit skeptical regards the offeringMap :D but I will test it this week.


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



[GitHub] [cloudstack] shwstppr commented on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
shwstppr commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-766678915


   @DK101010 I've refactored logic for handling disks and `datadiskofferinglist` param. As mentioned in the description, correct ROOT disk should be selected now and there won't any need for new API parameters. Will be great if you can test


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



[GitHub] [cloudstack] shwstppr commented on a change in pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
shwstppr commented on a change in pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#discussion_r564507733



##########
File path: server/src/main/java/org/apache/cloudstack/vm/VmImportManagerImpl.java
##########
@@ -500,6 +500,35 @@ private StoragePool getStoragePool(final UnmanagedInstanceTO.Disk disk, final Da
         return storagePool;
     }
 
+    private Pair<UnmanagedInstanceTO.Disk, List<UnmanagedInstanceTO.Disk>> getRootAndDataDisks(List<UnmanagedInstanceTO.Disk> disks, final Map<String, Long> dataDiskOfferingMap) {
+        UnmanagedInstanceTO.Disk rootDisk = null;
+        List<UnmanagedInstanceTO.Disk> dataDisks = new ArrayList<>();
+        if (disks.size() == 1) {
+            rootDisk = disks.get(0);
+            return new Pair<>(rootDisk, dataDisks);
+        }
+        Set<String> callerDiskIds = dataDiskOfferingMap.keySet();
+        if (callerDiskIds.size() != disks.size() - 1) {
+            String msg = String.format("VM has total %d disks for which %d disk offering mappings provided. %d disks need a disk offering for import", disks.size(), callerDiskIds.size(), disks.size()-1);
+            LOGGER.error(String.format("%s. %s parameter can be used to provide disk offerings for the disks", msg, ApiConstants.DATADISK_OFFERING_LIST));
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg);
+        }
+        List<String> diskIdsWithoutOffering = new ArrayList<>();
+        for (UnmanagedInstanceTO.Disk disk : disks) {
+            String diskId = disk.getDiskId();
+            if (!callerDiskIds.contains(diskId)) {
+                diskIdsWithoutOffering.add(diskId);
+                rootDisk = disk;
+            } else {
+                dataDisks.add(disk);
+            }
+        }
+        if (diskIdsWithoutOffering.size() > 1) {

Review comment:
       Whole list is processed to fund out disha for which offering is not provided. List is used in error message. Knowing IDs which user missed or incorrectly passed will be helpful




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



[GitHub] [cloudstack] DaanHoogland merged pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
DaanHoogland merged pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591


   


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



[GitHub] [cloudstack] shwstppr commented on a change in pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
shwstppr commented on a change in pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#discussion_r564507733



##########
File path: server/src/main/java/org/apache/cloudstack/vm/VmImportManagerImpl.java
##########
@@ -500,6 +500,35 @@ private StoragePool getStoragePool(final UnmanagedInstanceTO.Disk disk, final Da
         return storagePool;
     }
 
+    private Pair<UnmanagedInstanceTO.Disk, List<UnmanagedInstanceTO.Disk>> getRootAndDataDisks(List<UnmanagedInstanceTO.Disk> disks, final Map<String, Long> dataDiskOfferingMap) {
+        UnmanagedInstanceTO.Disk rootDisk = null;
+        List<UnmanagedInstanceTO.Disk> dataDisks = new ArrayList<>();
+        if (disks.size() == 1) {
+            rootDisk = disks.get(0);
+            return new Pair<>(rootDisk, dataDisks);
+        }
+        Set<String> callerDiskIds = dataDiskOfferingMap.keySet();
+        if (callerDiskIds.size() != disks.size() - 1) {
+            String msg = String.format("VM has total %d disks for which %d disk offering mappings provided. %d disks need a disk offering for import", disks.size(), callerDiskIds.size(), disks.size()-1);
+            LOGGER.error(String.format("%s. %s parameter can be used to provide disk offerings for the disks", msg, ApiConstants.DATADISK_OFFERING_LIST));
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg);
+        }
+        List<String> diskIdsWithoutOffering = new ArrayList<>();
+        for (UnmanagedInstanceTO.Disk disk : disks) {
+            String diskId = disk.getDiskId();
+            if (!callerDiskIds.contains(diskId)) {
+                diskIdsWithoutOffering.add(diskId);
+                rootDisk = disk;
+            } else {
+                dataDisks.add(disk);
+            }
+        }
+        if (diskIdsWithoutOffering.size() > 1) {

Review comment:
       Whole list is processed to find out disks for which offering is not provided. List is used in error message. Knowing IDs which user missed or incorrectly passed will be helpful




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



[GitHub] [cloudstack] sureshanaparti commented on a change in pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
sureshanaparti commented on a change in pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#discussion_r567677076



##########
File path: server/src/main/java/org/apache/cloudstack/vm/VmImportManagerImpl.java
##########
@@ -500,6 +500,35 @@ private StoragePool getStoragePool(final UnmanagedInstanceTO.Disk disk, final Da
         return storagePool;
     }
 
+    private Pair<UnmanagedInstanceTO.Disk, List<UnmanagedInstanceTO.Disk>> getRootAndDataDisks(List<UnmanagedInstanceTO.Disk> disks, final Map<String, Long> dataDiskOfferingMap) {
+        UnmanagedInstanceTO.Disk rootDisk = null;
+        List<UnmanagedInstanceTO.Disk> dataDisks = new ArrayList<>();
+        if (disks.size() == 1) {
+            rootDisk = disks.get(0);
+            return new Pair<>(rootDisk, dataDisks);
+        }
+        Set<String> callerDiskIds = dataDiskOfferingMap.keySet();
+        if (callerDiskIds.size() != disks.size() - 1) {
+            String msg = String.format("VM has total %d disks for which %d disk offering mappings provided. %d disks need a disk offering for import", disks.size(), callerDiskIds.size(), disks.size()-1);
+            LOGGER.error(String.format("%s. %s parameter can be used to provide disk offerings for the disks", msg, ApiConstants.DATADISK_OFFERING_LIST));
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, msg);
+        }
+        List<String> diskIdsWithoutOffering = new ArrayList<>();
+        for (UnmanagedInstanceTO.Disk disk : disks) {
+            String diskId = disk.getDiskId();
+            if (!callerDiskIds.contains(diskId)) {
+                diskIdsWithoutOffering.add(diskId);
+                rootDisk = disk;
+            } else {
+                dataDisks.add(disk);
+            }
+        }
+        if (diskIdsWithoutOffering.size() > 1) {

Review comment:
       Ok got that @shwstppr 




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



[GitHub] [cloudstack] shwstppr commented on pull request #4591: api, server: add rootdiskid param in importUnmanagedInstance API

Posted by GitBox <gi...@apache.org>.
shwstppr commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762795009


   @rhtyd done
   
   @DK101010 I'm also deliberating of a way to select correct root disk without adding new param in API. For API, we already need to pass a diskid-diskoffering map for all data disks so with that info we can simply select the remaining disk as the root disk (will have to refactor some error messages and change the logic). Does that make sense?


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



[GitHub] [cloudstack] blueorangutan commented on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-766709960






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



[GitHub] [cloudstack] blueorangutan commented on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-767400329


   @rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


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



[GitHub] [cloudstack] blueorangutan commented on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-767814595


   <b>Trillian test result (tid-3416)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 40480 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4591-t3416-kvm-centos7.zip
   Intermittent failure detected: /marvin/tests/smoke/test_kubernetes_clusters.py
   Smoke tests completed. 82 look OK, 1 have error(s)
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   test_03_deploy_and_upgrade_kubernetes_cluster | `Failure` | 259.54 | test_kubernetes_clusters.py
   test_04_deploy_and_scale_kubernetes_cluster | `Failure` | 4118.10 | test_kubernetes_clusters.py
   


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



[GitHub] [cloudstack] blueorangutan commented on pull request #4591: api, server: add rootdiskid param in importUnmanagedInstance API

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762246078


   @DK101010 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


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



[GitHub] [cloudstack] shwstppr commented on pull request #4591: api, server: add rootdiskid param in importUnmanagedInstance API

Posted by GitBox <gi...@apache.org>.
shwstppr commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762175350


   @blueorangutan package
   
   @DK101010 I've drafted this PR to add an optional param for selecting root disk while import


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



[GitHub] [cloudstack] blueorangutan removed a comment on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
blueorangutan removed a comment on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762246078


   @DK101010 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


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



[GitHub] [cloudstack] DK101010 commented on pull request #4591: api, server: add rootdiskid param in importUnmanagedInstance API

Posted by GitBox <gi...@apache.org>.
DK101010 commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762245373


   > @blueorangutan package
   > 
   > @DK101010 I've drafted this PR to add an optional param for selecting root disk while import
   
   @shwstppr Great, for me it looks good. If you want then I can test it in my environment this week. 


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



[GitHub] [cloudstack] shwstppr commented on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
shwstppr commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-766678915






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



[GitHub] [cloudstack] blueorangutan commented on pull request #4591: api, server: add rootdiskid param in importUnmanagedInstance API

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762194292


   Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2544


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



[GitHub] [cloudstack] blueorangutan commented on pull request #4591: server: select root disk based on user input during vm import

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-766709960


   @shwstppr a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


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



[GitHub] [cloudstack] blueorangutan commented on pull request #4591: api, server: add rootdiskid param in importUnmanagedInstance API

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762176110


   @shwstppr a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


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



[GitHub] [cloudstack] blueorangutan commented on pull request #4591: api, server: add rootdiskid param in importUnmanagedInstance API

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #4591:
URL: https://github.com/apache/cloudstack/pull/4591#issuecomment-762264541


   Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2545


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