How to call scaleVirtualMachine api with details parameter #9961
-
I am trying to call scaleVirtualMachine API using python, but the documentation is very vague on how to use details parameter I am trying to create request like this, is this wrong? can anyone pls suggest what is right way to call this api? request = { I get error { |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Can you try ["memory": "3072", "cpunumber": "2"] or similar ? |
Beta Was this translation helpful? Give feedback.
-
Hello, @YashasAnand The details[0].key=value So, for example, a VM with 512 MB of RAM and 1 vCPU can be scaled to 1024 MB of RAM and 2 vCPUs by executing the following API call through CloudMonkey: scale virtualmachine id=<vm-id> serviceofferingid=<compute-offering-id> details[0].memory=1024 details[0].cpuNumber=2 How does your Python script sends the request? Does each key in the request = {
'command': 'scaleVirtualMachine',
'id': '<virtual-machine-id>',
'serviceofferingid': '<compute-offering-id>',
'response': 'json',
'details[0].memory': 1024 ,
'details[0].cpuNumber': 2
} |
Beta Was this translation helpful? Give feedback.
-
Hi @bernardodemarco @weizhouapache Thank you for your respective responses. Below is my python code.
I am getting response like this but i dont observe any scaling happening on the vm even though i have domain admin access. Pls can you suggest what might be the issue.
|
Beta Was this translation helpful? Give feedback.
-
APIs in CloudStack can be synchronous/blocking, or asynchronous/non-blocking. Async APIs return a Since the query asyncjobresult jobid="<job-id>" When retrieving the result of a job related to the (localcloud) 🐱 > query asyncjobresult jobid=75f6ebd3-e4ed-477c-b6ff-2577e2e56c30
{
(...)
"jobresult": {
"virtualmachine": {
"account": "admin",
"affinitygroup": [],
"cpunumber": 1,
"cpuspeed": 512,
"created": "2024-11-21T15:07:09+0000",
"deleteprotection": false,
"details": {
"Message.ReservedCapacityFreed.Flag": "true",
"cpuNumber": "1",
"cpuSpeed": "512",
"memory": "512"
},
(...)
}
},
"jobresultcode": 0,
"jobresulttype": "object",
"jobstatus": 1,
"userid": "203addbc-4b71-11ef-87b4-cec422422af1"
} Given that, could you check the return of the |
Beta Was this translation helpful? Give feedback.
APIs in CloudStack can be synchronous/blocking, or asynchronous/non-blocking. Async APIs return a
jobid
, which can be used to poll the result of the API call.Since the
scaleVirtualMachine
API is asynchronous, thejobid
was returned, as expected. It means that the request was successfully authenticated and its response can be retrieved using thequeryAsyncJobResult
API:query asyncjobresult jobid="<job-id>"
When retrieving the result of a job related to the
scaleVirtualMachine
API, a successful response will be something like: