Skip to content

Commit f9adc58

Browse files
committed
PI-414 : Fixed issues w/ post not using JSON formatted data
1 parent c055f89 commit f9adc58

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

stackdio/client/__init__.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import os
1+
import json
22
import logging
3+
import os
34

45
from .http import HttpMixin, use_admin_auth, endpoint
56
from .exceptions import StackException
@@ -54,7 +55,7 @@ def create_provider(self, **kwargs):
5455
for key in form_data.keys():
5556
form_data[key] = kwargs.get(key)
5657

57-
return self._post(endpoint, data=form_data, jsonify=True)
58+
return self._post(endpoint, data=json.dumps(form_data), jsonify=True)
5859

5960

6061
@endpoint("providers/")
@@ -83,7 +84,7 @@ def create_profile(self, title, image_id, ssh_user, cloud_provider,
8384
"cloud_provider": cloud_provider,
8485
"default_instance_size": default_instance_size
8586
}
86-
return self._post(endpoint, data=data, jsonify=True)
87+
return self._post(endpoint, data=json.dumps(data), jsonify=True)
8788

8889

8990
@endpoint("profiles/")
@@ -107,7 +108,7 @@ def import_formula(self, formula_uri, public=True):
107108
"uri": formula_uri,
108109
"public": public,
109110
}
110-
return self._post(endpoint, data=data, jsonify=True)
111+
return self._post(endpoint, data=json.dumps(data), jsonify=True)
111112

112113

113114
@endpoint("blueprints/")
@@ -131,7 +132,7 @@ def create_blueprint(self, blueprint, provider="ec2"):
131132
self.get_formula(component["id"][0]),
132133
component["id"][1])
133134

134-
return self._post(endpoint, data=blueprint, jsonify=True)
135+
return self._post(endpoint, data=json.dumps(blueprint), jsonify=True)
135136

136137

137138
@use_admin_auth
@@ -145,7 +146,7 @@ def create_security_group(self, name, description, cloud_provider, is_default=Tr
145146
"cloud_provider": cloud_provider,
146147
"is_default": is_default
147148
}
148-
return self._post(endpoint, data=data, jsonify=True)
149+
return self._post(endpoint, data=json.dumps(data), jsonify=True)
149150

150151

151152
@endpoint("settings/")
@@ -161,7 +162,7 @@ def set_public_key(self, public_key):
161162
data = {
162163
"public_key": public_key
163164
}
164-
return self._put(endpoint, data=data, jsonify=True)
165+
return self._put(endpoint, data=json.dumps(data), jsonify=True)
165166

166167

167168
@endpoint("formulas/")
@@ -336,7 +337,7 @@ def get_zone(self, title, type_name="ec2"):
336337
@endpoint("stacks/")
337338
def launch_stack(self, stack_data):
338339
"""Launch a stack as described by stack_data"""
339-
return self._post(endpoint, data=stack_data, jsonify=True)['results']
340+
return self._post(endpoint, data=json.dumps(stack_data), jsonify=True)['results']
340341

341342

342343
@endpoint("stacks/{stack_id}/hosts/")
@@ -389,4 +390,4 @@ def do_action(self, stack_id, action):
389390

390391
data = {"action": action}
391392

392-
return self._post(endpoint, data=data, jsonify=True)
393+
return self._post(endpoint, data=json.dumps(data), jsonify=True)

stackdio/client/http.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ def wrapper(*args, **kwargs):
5050
return wrapper
5151

5252

53-
54-
5553
def endpoint(path):
5654
"""Takes a path extension and appends to the known API base url.
5755
The result of this is then added to the decorated functions global

0 commit comments

Comments
 (0)