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


   ### Description
   
   `listServiceOffering` API when called for a running VM only fails to list 
all possible offerings especially the custom offerings and all offerings when 
VM is deployed using a custom offering.
   This PR improves the list behviour by adding adding appropriate conditions 
for the custom offerings.
   
   Fixes #5412
   <!--- Describe your changes in DETAIL - And how has behaviour functionally 
changed. -->
   
   <!-- For new features, provide link to FS, dev ML discussion etc. -->
   <!-- In case of bug fix, the expected and actual behaviours, steps to 
reproduce. -->
   
   <!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be 
closed when this PR gets merged -->
   <!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
   <!-- Fixes: # -->
   
   <!--- 
*********************************************************************************
 -->
   <!--- 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
   - [ ] 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/main/CONTRIBUTING.md) 
document -->
   
   Offerings and VMs
   ```
   (local) 🦐 > list serviceofferings 
filter=id,name,cpunumber,cpuspeed,memory,serviceofferingdetails
   {
     "count": 6,
     "serviceoffering": [
       {
         "cpunumber": 1,
         "cpuspeed": 500,
         "id": "c17c21bb-faa4-4c14-9774-142260546670",
         "memory": 512,
         "name": "Small Instance"
       },
       {
         "cpunumber": 1,
         "cpuspeed": 1000,
         "id": "0a785dc5-ff8d-48ed-82b2-e24cbd9587b9",
         "memory": 1024,
         "name": "Medium Instance"
       },
       {
         "cpunumber": 1,
         "cpuspeed": 1000,
         "id": "3801bb99-4077-4685-919f-2ae51fce90a9",
         "memory": 1536,
         "name": "fixed"
       },
       {
         "cpuspeed": 1000,
         "id": "fe7de1af-b045-4749-a88f-c20a50082c7b",
         "name": "Constrained",
         "serviceofferingdetails": {
           "maxcpunumber": "4",
           "maxmemory": "2560",
           "mincpunumber": "1",
           "minmemory": "256"
         }
       },
       {
         "id": "3799cd94-8284-485e-81f0-bc3c1e6a29f9",
         "name": "Unconstrained"
       },
       {
         "cpuspeed": 1000,
         "id": "b1423e9e-9fcf-48c1-b156-b563cf9bf4dd",
         "name": "Constrained-1",
         "serviceofferingdetails": {
           "maxcpunumber": "4",
           "maxmemory": "3072",
           "mincpunumber": "2",
           "minmemory": "512"
         }
       }
     ]
   }
   (local) 🦐 > list virtualmachines 
ids=112b9b4a-12e9-4cfc-8bd7-0e49eabb211f,00774881-64cf-45d1-8c9c-7bdaf7f195da 
filter=id,name,serviceofferingid,serviceofferingname,details,state
   {
     "count": 2,
     "virtualmachine": [
       {
         "details": {
           "cpuNumber": "2",
           "memory": "1024"
         },
         "id": "00774881-64cf-45d1-8c9c-7bdaf7f195da",
         "name": "t5",
         "serviceofferingid": "fe7de1af-b045-4749-a88f-c20a50082c7b",
         "serviceofferingname": "Constrained",
         "state": "Running"
       },
       {
         "details": {},
         "id": "112b9b4a-12e9-4cfc-8bd7-0e49eabb211f",
         "name": "t3",
         "serviceofferingid": "c17c21bb-faa4-4c14-9774-142260546670",
         "serviceofferingname": "Small Instance",
         "state": "Running"
       }
     ]
   }
   ````
   
   Before change:
   ```
   (local) 🐣 > list serviceofferings 
filter=id,name,cpunumber,cpuspeed,memory,serviceofferingdetails 
virtualmachineid=112b9b4a-12e9-4cfc-8bd7-0e49eabb211f 
   {
     "count": 2,
     "serviceoffering": [
       {
         "cpunumber": 1,
         "cpuspeed": 1000,
         "id": "0a785dc5-ff8d-48ed-82b2-e24cbd9587b9",
         "memory": 1024,
         "name": "Medium Instance"
       },
       {
         "cpunumber": 1,
         "cpuspeed": 1000,
         "id": "3801bb99-4077-4685-919f-2ae51fce90a9",
         "memory": 1536,
         "name": "fixed"
       }
     ]
   }
   (local) 🐓 > list serviceofferings 
filter=id,name,cpunumber,cpuspeed,memory,serviceofferingdetails 
virtualmachineid=00774881-64cf-45d1-8c9c-7bdaf7f195da 
   ```
   
   After change:
   ```
   (local) 🐕 > list serviceofferings 
filter=id,name,cpunumber,cpuspeed,memory,serviceofferingdetails 
virtualmachineid=112b9b4a-12e9-4cfc-8bd7-0e49eabb211f 
   {
     "count": 5,
     "serviceoffering": [
       {
         "cpunumber": 1,
         "cpuspeed": 1000,
         "id": "0a785dc5-ff8d-48ed-82b2-e24cbd9587b9",
         "memory": 1024,
         "name": "Medium Instance"
       },
       {
         "cpunumber": 1,
         "cpuspeed": 1000,
         "id": "3801bb99-4077-4685-919f-2ae51fce90a9",
         "memory": 1536,
         "name": "fixed"
       },
       {
         "cpuspeed": 1000,
         "id": "fe7de1af-b045-4749-a88f-c20a50082c7b",
         "name": "Constrained",
         "serviceofferingdetails": {
           "maxcpunumber": "4",
           "maxmemory": "2560",
           "mincpunumber": "1",
           "minmemory": "256"
         }
       },
       {
         "id": "3799cd94-8284-485e-81f0-bc3c1e6a29f9",
         "name": "Unconstrained"
       },
       {
         "cpuspeed": 1000,
         "id": "b1423e9e-9fcf-48c1-b156-b563cf9bf4dd",
         "name": "Constrained-1",
         "serviceofferingdetails": {
           "maxcpunumber": "4",
           "maxmemory": "3072",
           "mincpunumber": "2",
           "minmemory": "512"
         }
       }
     ]
   }
   (local) 🦑 > list serviceofferings 
filter=id,name,cpunumber,cpuspeed,memory,serviceofferingdetails 
virtualmachineid=00774881-64cf-45d1-8c9c-7bdaf7f195da 
   {
     "count": 3,
     "serviceoffering": [
       {
         "cpuspeed": 1000,
         "id": "fe7de1af-b045-4749-a88f-c20a50082c7b",
         "name": "Constrained",
         "serviceofferingdetails": {
           "maxcpunumber": "4",
           "maxmemory": "2560",
           "mincpunumber": "1",
           "minmemory": "256"
         }
       },
       {
         "id": "3799cd94-8284-485e-81f0-bc3c1e6a29f9",
         "name": "Unconstrained"
       },
       {
         "cpuspeed": 1000,
         "id": "b1423e9e-9fcf-48c1-b156-b563cf9bf4dd",
         "name": "Constrained-1",
         "serviceofferingdetails": {
           "maxcpunumber": "4",
           "maxmemory": "3072",
           "mincpunumber": "2",
           "minmemory": "512"
         }
       }
     ]
   }
   ```


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