GitHub user YashasAnand edited a comment on the discussion: How to call 
scaleVirtualMachine api with details parameter

Hi @bernardodemarco @weizhouapache Thank you for your respective responses. 
Below is my python code. 



def generate_signature(baseurl, request, secretkey):
    encoded_request = {urllib.parse.quote_plus(k): 
urllib.parse.quote_plus(str(v)) for k, v in request.items()}
    
    sorted_request = sorted(encoded_request.items(), key=lambda x: x[0].lower())
    sig_str = '&'.join(['='.join([k.lower(), v.lower()]) for k, v in 
sorted_request])
    
    sig = hmac.new(secretkey.encode('utf-8'), sig_str.encode('utf-8'), 
hashlib.sha1).digest()
    
    encoded_sig = base64.b64encode(sig).decode('utf-8')
    final_signature = urllib.parse.quote_plus(encoded_sig)

    request_str = '&'.join(['='.join([k, v]) for k, v in 
encoded_request.items()])
    return final_signature, request_str
   
baseurl = 'basrurl'

request = {
    'command': 'scaleVirtualMachine',  
    'id': 'id',  # ID of the system VM
    'serviceofferingid': 'serviceofferingid', 
    'response': 'json', 
    'details[0].memory': 3072,
    'details[0].cpuNumber': 2

}
secretkey = 'secret key'

signature, request_str = generate_signature(baseurl, request, secretkey)

req = baseurl + request_str + '&signature=' + signature

print("Final Request URL:", req)


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.

`{
    "scalevirtualmachineresponse": {
        "jobid": "f75d1e48-132e-4b5c-9241-9115271dc08e"
    }
}` 

GitHub link: 
https://github.com/apache/cloudstack/discussions/9961#discussioncomment-11345010

----
This is an automatically sent email for users@cloudstack.apache.org.
To unsubscribe, please send an email to: users-unsubscr...@cloudstack.apache.org

Reply via email to