diff options
author | Gaudenz Steinlin <gaudenz.steinlin@cloudscale.ch> | 2017-12-18 14:49:33 +0100 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2017-12-19 14:28:02 -0800 |
commit | 03eccdea19c61d7f9abcc1498307d83f969a614c (patch) | |
tree | 2e7892d88deff24fa59158c19aca92e0d14b1180 | |
parent | b375d5f3ea8e84ff330cd2fa0407d5d06c30e70b (diff) | |
download | ansible-03eccdea19c61d7f9abcc1498307d83f969a614c.tar.gz |
Send API parameters as JSON in cloudscale_server module
Use JSON to send the POST data to the API instead of an urlencoded
string. Urlencoding is not really a good match for some Python
datatypes.
This fixes an issue when submitting a list of SSH keys which did not get
translated properly.
Partial cherry-pick of the important parts of 4c94c6f9ba.
-rw-r--r-- | lib/ansible/modules/cloud/cloudscale/cloudscale_server.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/ansible/modules/cloud/cloudscale/cloudscale_server.py b/lib/ansible/modules/cloud/cloudscale/cloudscale_server.py index 8abea6784d..f39a634079 100644 --- a/lib/ansible/modules/cloud/cloudscale/cloudscale_server.py +++ b/lib/ansible/modules/cloud/cloudscale/cloudscale_server.py @@ -217,7 +217,6 @@ from datetime import datetime, timedelta from time import sleep from ansible.module_utils.basic import AnsibleModule -from ansible.module_utils.six.moves.urllib.parse import urlencode from ansible.module_utils.urls import fetch_url @@ -273,12 +272,14 @@ class AnsibleCloudscaleServer(object): def _post(self, api_call, data=None): + headers = self._auth_header.copy() if data is not None: - data = urlencode(data) + data = self._module.jsonify(data) + headers['Content-type'] = 'application/json' resp, info = fetch_url(self._module, API_URL+api_call, - headers = self._auth_header, + headers = headers, method='POST', data=data) |