Closed r2ronoha closed 5 years ago
Just a reference, here is a link to the API doc which shows that the attribute value is indeed a boolean - https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObjects/
And to clarify a thing - Libcloud driver actually still uses XML RPC API and not the JSON one.
Here is how the XML payload looked before your change / fix:
...
<member>
<name>hourlyBillingFlag</name>
<value><string>true</string></value>
</member>
...
And here is how it looks after:
...
<member>
<name>hourlyBillingFlag</name>
<value><boolean>1</boolean></value>
</member>
...
Resolved via #1335.
Summary
Softlayer server are always created as Hourly Billing, regardless of what value (False / True) is passed on the ex_hourly parameter to deploy_server or create_server
Detailed Information
In the create_node method of the Softlayer driver, the ex_hourly parameter is converted to string ('true' / 'false') to forward it in the data to the createObject method of the Softlayer API. Nonetheless, the API is expecting a boolean param, and it is setting the default value (hourly = true), resulting in always creating hourly billed instances.
{'domain': 'wandera.com', 'localDiskFlag': 'true', 'maxMemory': '4', 'blockDevices': [{'device': '0', 'diskImage': {'capacity': 100}}], 'networkComponents': [{'maxSpeed': 100}], 'datacenter': {'name': 'tor01'}, 'hourlyBillingFlag': 'false', 'hostname': 'test.example.com', 'startCpus': '2', 'operatingSystemReferenceCode': 'UBUNTU_18_64', 'sshKeys': [{'id': key_id}]}
-- Setting:'hourlyBillingFlag': 'false'
-- Result: Server created with Hourly BillingI did some manual tests directly to the SL API:
Same format as libcloud: -- Request:
curl -X POST --data '{"parameters":[[{"domain":"wandera.com","localDiskFlag":"true","maxMemory":"4","blockDevices":[{"device":"0","diskImage":{"capacity":100}}],"networkComponents":[{"maxSpeed":100}],"datacenter":{"name":"tor01"},"hourlyBillingFlag":"false","hostname":"test.example.com","startCpus":"2","operatingSystemReferenceCode":"UBUNTU_18_64","sshKeys":[{"id":key_id}]}]]}' -u <username>:<api_token> https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/createObjects.json
-- Setting:"hourlyBillingFlag": "false"
-- Result: Server created with Hourly BillingSent as boolean: -- Request:
curl -X POST --data '{"parameters":[[{"domain":"wandera.com","localDiskFlag":"true","maxMemory":"4","blockDevices":[{"device":"0","diskImage":{"capater":{"name":"tor01"},"hourlyBillingFlag":false,"hostname":"test.example.com","startCpus":"2","operatingSystemReferenceCode":"UBUNTU_18_64","sshKeys":[{"id":key_id}]}]]}' -u <username>:<api_token> https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/createObjects.json
-- Setting:"hourlyBillingFlag": false
-- Result: Server created with Monthly Billing