python - Create a vm or cloud service on azure using libcloud? -


i’m having problem libcloud/drivers/azure.py when create vm or cloud service, receive 400 bad request without body. me out of please?

here code:

# connecthandler use pem file create connection server, return azurenodedriver objet conn = _connecthandler.api_connect(compute_ressource) try:     result = conn.ex_create_cloud_service(name= "testcloudservicezt200", location= "central us") except exception e:     logger.error(e) else:     return result 

and here got in return: <libclouderror in <libcloud.compute.drivers.azure.azurenodedriver object @ 0x7fceaeb457d0> 'message: bad request, body: , status code: 400'>

could please tell me why error, , maybe give me examples of azure.py, grateful. thx!!

the azure driver seems new, since it's not included in latest release available via pypi. had same problem, used ipdb @ request , xml created azure driver. @ first thought found number of problems, after looking @ source , not output of debugger boils down simple fix.

the following curl request works me:

curl -v -e {path_to_pem_file} -h 'x-ms-version: 2015-04-01' -h 'content-type: application/xml' -d '<?xml version="1.0" encoding="utf-8"?><createhostedservice xmlns="http://schemas.microsoft.com/windowsazure"><servicename>test-cloudservice-libcloud-azure-driver</servicename><label>dgvzdc1jbg91zhnlcnzpy2utbgliy2xvdwqtyxp1cmutzhjpdmvycg==</label><location>west europe</location></createhostedservice>' https://management.core.windows.net/{subscription_id}/services/hostedservices 

but xml generated azure driver contains encoding='utf8', doesn't work. has utf-8. if replace line 2710 in current head of github repo (e105433e941262e03eb3bb922db47dabdd8efa75) result = ensure_string(et.tostring(doc, encoding='utf-8')), works, encoding='utf8' culprit, @ least me.

i have opened pull request, hope solves issue well: https://github.com/apache/libcloud/pull/538


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -