I am attempting to use python-ovh to simply create an instance but it is giving me trouble. The API documentation actually seems to put out invalid Python code (at least for Python3..) and I'm not sure what I'm doing wrong. I believe I'm passing correct JSON but the API doesn't like it. I am having a really hard time finding example code through searches also.
My code:
self.inst = {}
self.inst['flavorId'] = self.flavorid
self.inst['imageId'] = self.imageid
self.inst['name'] = self.name
self.inst['region'] = self.region
self.inst['monthlyBilling'] = False
try:
self.instance = client.post("/cloud/project/" + self.servicename + "/instance",
json.dumps(self.inst, separators=(",",":"))
)
except ovh.APIError as e:
print("JSON: " + json.dumps(self.inst, separators=(",",":")))
print("Ooops, failed to create instance:", e)
Debug output:
JSON: {\"flavorId\":\"14c5fa3f-fdad-45c4-9cd1-14dd99c341ee\",\"imageId\":\"92bee304-a24f-4db5-9896-864da799f905\",\"name\":\"ovhcloud-test-1\",\"region\":\"BHS5\",\"monthlyBilling\":false}
Error output:
Ooops, failed to create instance: Missing parameter(s): flavorId, name, region \nOVH-Query-ID: CA.ext-3.6101d265.2209.d74765fb-6227-4105-a24b-c46c74f3e508\n"
the API docs tell me to do this:
result = client.post('/cloud/project/xxxxxx/instance',
='{"flavorId":"14c5fa3f-fdad-45c4-9cd1-14dd99c34","imageId":"92bee304-a24f-4db5-9896-864da799f905","monthlyBilling":false,"name":"testinstance","region":"BHS5","userData":"testdata"}', // Request Body (type: cloud.ProjectInstanceCreation)
)
But that gives syntax errors and doesn't really work with variable substitution either.
Can anyone help tell me what I'm doing wrong?
Python API: Creating an instance doesn't like my JSON?
Related questions
- IPv6 subnet/extra IPv6 IPs on cloud instances/VPS
7408
31.01.2018 07:31
- Problem with Windows Server 2019 activation
6880
30.12.2020 04:04
- Is the Plesk License included?
6471
02.01.2018 11:56
- Ubuntu 20.04 image in OVH has been marked as DEPECRATED
5676
04.12.2020 23:28
- Private Network shared between two or more Public Cloud projects
4891
11.03.2021 13:19
- Automatic Block storage backup - how?
4639
06.05.2020 17:31
- Error has occurred creating your Public Cloud project
4231
08.10.2021 08:52
- CORS in Object Storage
4220
03.11.2020 06:02
- Setup clickhouse with s3 high performance storage class (express onezone)
4130
16.10.2025 13:28
- [ALPHA] On-demand bare metal instances in Public Cloud
4037
14.05.2019 07:08