You can not get the vm data by terraform because terraform just allow us to create, update and delete.
You can see the following documentation:
https://github.com/softlayer/terraform-provider-softlayer/blob/master/docs/resources/softlayer_virtual_guest.md
- You can use the data of "operatingSystemReferenceCode" in "os_reference_code" terraform, but you have to change the variable "os_reference_code" to "image".
Here is an example of a template to create a VM by terraform.
provider "softlayer" {
username = "set me"
api_key = "set me"
}
# Create a new virtual guest
resource "softlayer_virtual_guest" "twc_terraform_sample" {
name = "my_server_1"
domain = "bar.example.com"
image = "UBUNTU_LATEST"
region = "ams01"
public_network_speed = 10
hourly_billing = true
private_network_only = false
cpu = 1
ram = 1024
disks = [25, 10, 20]
dedicated_acct_host_only = true
local_disk = false
}
- To get the OS list you have to use the following python code:
"""
Get Item Prices
Retrieve a collection of SoftLayer_Product_Item_Prices that are valid for this package.
Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getItemPrices
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import SoftLayer
import json
USERNAME = set me'
API_KEY = 'set me'
object_mask = 'mask[item[id,softwareDescription]]'
client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
result = client['SoftLayer_Product_Package'].getItemPrices(id=835, mask = object_mask)
print(json.dumps(result))
The "operatingSystemReferenceCode" that you got from the method getCreateObjectOptions()
of the service “'Virtual_Guest” is the same that the "referenceCode" that you will find in this code example and you will get the OS price.
e.g. The "operatingSystemReferenceCode" = ‘WIN_2012-STD_64’
You have to choose the OS depending of the "recurringFee" that you want.
The OS priceId will be “id”: 175797.
{
"id": 175797,
"recurringFee": "17",
"item": {
"id": 4233,
"softwareDescription": {
"controlPanel": 0,
"id": 1076,
"licenseTermValue": null,
"longDescription": "Microsoft Windows 2012 FULL STD 64 bit 2012 FULL STD x64",
"manufacturer": "Microsoft",
"name": "Windows 2012 FULL STD 64 bit",
"operatingSystem": 1,
"referenceCode": "WIN_2012-STD_64",
"upgradeSoftwareDescriptionId": null,
"upgradeSwDescId": null,
"version": "2012 FULL STD x64",
"virtualLicense": 0,
"virtualizationPlatform": 0,
"requiredUser": "Administrator"
}
}
},
In the item prices there is not the LATEST versions of the OS because when you send the request the server will take the last version of this OS.
e.g
UBUNTU_ LATEST, WIN_ LATEST, etc.
The OS prices depend of the Flavor that you will choose and the Flavor will change depending of the datacenter that will be choosing.
Yes, the OS prices differ from vm cores, to get the prices you have to see in the result of the example code the following attributes:
"capacityRestrictionMaximum": "32",
"capacityRestrictionMinimum": "17",
"capacityRestrictionType": "CORE",
In this case the OS price will be depending of the "capacityRestrictionMinimum” and "capacityRestrictionMaximum" of the CORE:
e.g. For this example the capacity is from 17 to 32 CORE and the OS price will be "recurringFee": "68" for the "referenceCode": "WIN_2012-STD_64" OS.
{
"currentPriceFlag": null,
"hourlyRecurringFee": ".098",
"id": 175801,
"itemId": 4233,
"laborFee": "0",
"locationGroupId": null,
"onSaleFlag": null,
"oneTimeFee": "0",
"quantity": null,
"recurringFee": "68",
"setupFee": "0",
"sort": 16,
"tierMinimumThreshold": null,
"capacityRestrictionMaximum": "32",
"capacityRestrictionMinimum": "17",
"capacityRestrictionType": "CORE",
"item": {
"id": 4233,
"softwareDescription": {
"controlPanel": 0,
"id": 1076,
"licenseTermValue": null,
"longDescription": "Microsoft Windows 2012 FULL STD 64 bit 2012 FULL STD x64",
"manufacturer": "Microsoft",
"name": "Windows 2012 FULL STD 64 bit",
"operatingSystem": 1,
"referenceCode": "WIN_2012-STD_64",
"upgradeSoftwareDescriptionId": null,
"upgradeSwDescId": null,
"version": "2012 FULL STD x64",
"virtualLicense": 0,
"virtualizationPlatform": 0,
"requiredUser": "Administrator"
}
}