Skip to content

Commit

Permalink
Change virtual guest attribute names to match bare metal and api (#39)
Browse files Browse the repository at this point in the history
* name to hostname
* cpu to cores
* ram to memory
* user_data to user_metadata
* ssh_keys to ssh_key_ids
  • Loading branch information
renier authored Oct 27, 2016
1 parent 0ceb788 commit ccccd77
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 155 deletions.
16 changes: 8 additions & 8 deletions cookbooks/docker-swarm/docker.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ data "softlayer_ssh_key" "my_key" {
}

resource "softlayer_virtual_guest" "manager" {
name = "docker-swarm-manager"
hostname = "docker-swarm-manager"
domain = "demo.com"
os_reference_code = "UBUNTU_LATEST"
datacenter = "${var.datacenter}"
cpu = 1
ram = 1024
cores = 1
memory = 1024
local_disk = true

ssh_keys = [
ssh_key_ids = [
"${data.softlayer_ssh_key.my_key.id}"
]

Expand All @@ -28,15 +28,15 @@ resource "softlayer_virtual_guest" "manager" {

resource "softlayer_virtual_guest" "worker" {
count = "${var.worker_count}"
name = "docker-swarm-worker${count.index}"
hostname = "docker-swarm-worker${count.index}"
domain = "demo.com"
os_reference_code = "UBUNTU_LATEST"
datacenter = "${var.datacenter}"
cpu = 1
ram = 1024
cores = 1
memory = 1024
local_disk = true

ssh_keys = [
ssh_key_ids = [
"${data.softlayer_ssh_key.my_key.id}"
]

Expand Down
18 changes: 9 additions & 9 deletions cookbooks/elasticsearch-haproxy/es.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ data "softlayer_ssh_key" "esk_key" {

resource "softlayer_virtual_guest" "esk-node" {
count = "${var.node_count}"
name = "esk-node${count.index+1}"
hostname = "esk-node${count.index+1}"
domain = "demo.com"
os_reference_code = "UBUNTU_LATEST"
datacenter = "${var.datacenter}"
private_network_only = true
cpu = 1
ram = 1024
cores = 1
memory = 1024
local_disk = true

ssh_keys = [
ssh_key_ids = [
"${data.softlayer_ssh_key.esk_key.id}"
]

Expand All @@ -38,17 +38,17 @@ resource "softlayer_virtual_guest" "esk-node" {
}

resource "softlayer_virtual_guest" "haproxy" {
name = "esk-haproxy"
hostname = "esk-haproxy"
domain = "demo.com"
os_reference_code = "UBUNTU_LATEST"
datacenter = "${var.datacenter}"
private_network_only = false
cpu = 1
ram = 1024
cores = 1
memory = 1024
local_disk = true
user_data = "${join(" ", softlayer_virtual_guest.esk-node.*.ipv4_address_private)}"
user_metadata = "${join(" ", softlayer_virtual_guest.esk-node.*.ipv4_address_private)}"

ssh_keys = [
ssh_key_ids = [
"${data.softlayer_ssh_key.esk_key.id}"
]

Expand Down
8 changes: 4 additions & 4 deletions cookbooks/elasticsearch/es.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ resource "softlayer_lb_local_service_group" "es_lb_sg" {

resource "softlayer_virtual_guest" "es-vm" {
count = "${var.node_count}"
name = "es-vm${count.index+1}"
hostname = "es-vm${count.index+1}"
domain = "demo.com"
os_reference_code = "UBUNTU_LATEST"
datacenter = "${var.datacenter}"
hourly_billing = true
cpu = 1
ram = 1024
cores = 1
memory = 1024
disks = [25]
local_disk = true

ssh_keys = [
ssh_key_ids = [
"${data.softlayer_ssh_key.es_key.id}"
]

Expand Down
2 changes: 1 addition & 1 deletion docs/datasources/softlayer_ssh_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ reference the `id` property in a softlayer_virtual_guest resource:
```hcl
resource "softlayer_virtual_guest" "vm1" {
...
ssh_keys = ["${data.softlayer_ssh_key.public_key.id}"]
ssh_key_ids = ["${data.softlayer_ssh_key.public_key.id}"]
...
}
```
Expand Down
14 changes: 7 additions & 7 deletions docs/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ resource "softlayer_ssh_key" "testkey1" {
# Virtual Server created with existing SSH Key already in SoftLayer
# inventory and not created using this Terraform template.
resource "softlayer_virtual_guest" "host-a" {
name = "host-a.example.com"
hostname = "host-a.example.com"
domain = "example.com"
ssh_keys = [123456]
ssh_key_ids = [123456]
os_reference_code = "DEBIAN_7_64"
datacenter = "ams01"
network_speed = 10
cpu = 1
ram = 1024
cores = 1
memory = 1024
}
# Virtual Server created with a mix of previously existing and
# Terraform created/managed resources.
resource "softlayer_virtual_guest" "host-b" {
name = "host-b.example.com"
hostname = "host-b.example.com"
domain = "example.com"
ssh_keys = [123456, "${softlayer_ssh_key.test_key_1.id}"]
os_reference_code = "CENTOS_6_64"
datacenter = "ams01"
network_speed = 10
cpu = 1
ram = 1024
cores = 1
memory = 1024
}
```

Expand Down
12 changes: 6 additions & 6 deletions docs/resources/softlayer_scale_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ resource "softlayer_scale_group" "test_scale_group" {
type = "HTTP"
}
virtual_guest_member_template = {
name = "test_virtual_guest_name"
hostname = "test_virtual_guest_name"
domain = "example.com"
cpu = 1
ram = 1024
public_network_speed = 100
cores = 1
memory = 1024
network_speed = 100
hourly_billing = true
os_reference_code = "DEBIAN_7_64"
# Optional Fields for virtual guest template (SL defaults apply):
local_disk = false
disks = [25]
datacenter = "sng01"
post_install_script_uri = ""
ssh_keys = [383111]
user_data = "#!/bin/bash ..."
ssh_key_ids = [383111]
user_metadata = "#!/bin/bash ..."
}
# Optional Fields for scale_group:
network_vlan_ids = [1234567, 7654321]
Expand Down
24 changes: 12 additions & 12 deletions docs/resources/softlayer_virtual_guest.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ Provides a `virtual_guest` resource. This allows virtual guests to be created, u
```hcl
# Create a new virtual guest using image "Debian"
resource "softlayer_virtual_guest" "twc_terraform_sample" {
name = "twc-terraform-sample-name"
hostname = "twc-terraform-sample-name"
domain = "bar.example.com"
os_reference_code = "DEBIAN_7_64"
datacenter = "wdc01"
network_speed = 10
hourly_billing = true
private_network_only = false
cpu = 1
ram = 1024
cores = 1
memory = 1024
disks = [25, 10, 20]
user_data = "{\"value\":\"newvalue\"}"
user_metadata = "{\"value\":\"newvalue\"}"
dedicated_acct_host_only = true
local_disk = false
public_vlan_id = 1391277
Expand All @@ -27,13 +27,13 @@ resource "softlayer_virtual_guest" "twc_terraform_sample" {
# Create a new virtual guest using block device template, tags,
# and subnets
resource "softlayer_virtual_guest" "terraform-sample-BDTGroup" {
name = "terraform-sample-blockDeviceTemplateGroup"
hostname = "terraform-sample-blockDeviceTemplateGroup"
domain = "bar.example.com"
datacenter = "ams01"
public_network_speed = 10
hourly_billing = false
cpu = 1
ram = 1024
cores = 1
memory = 1024
local_disk = false
image_id = 12345
tags = [
Expand All @@ -49,16 +49,16 @@ resource "softlayer_virtual_guest" "terraform-sample-BDTGroup" {

The following arguments are supported:

* `name` | *string*
* `hostname` | *string*
* Hostname for the computing instance.
* **Optional**
* `domain` | *string*
* Domain for the computing instance.
* **Required**
* `cpu` | *int*
* `cores` | *int*
* The number of CPU cores to allocate.
* **Required**
* `ram` | *int*
* `memory` | *int*
* The amount of memory to allocate in megabytes.
* **Required**
* `datacenter` | *string*
Expand Down Expand Up @@ -109,10 +109,10 @@ The following arguments are supported:
* Block device and disk image settings for the computing instance
* *Optional*
* *Default*: The smallest available capacity for the primary disk will be used. If an image template is specified the disk capacity will be be provided by the template.
* `user_data` | *string*
* `user_metadata` | *string*
* Arbitrary data to be made available to the computing instance.
* *Optional*
* `ssh_keys` | *array* of numbers
* `ssh_key_ids` | *array* of numbers
* SSH key _IDs_ to install on the computing instance upon provisioning.
* *Optional*

Expand Down
8 changes: 4 additions & 4 deletions softlayer/resource_softlayer_lb_local_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ func TestAccSoftLayerLbLocalService_Basic(t *testing.T) {

const testAccCheckSoftLayerLbLocalServiceConfig_basic = `
resource "softlayer_virtual_guest" "test_server_1" {
name = "terraform-test"
hostname = "terraform-test"
domain = "bar.example.com"
os_reference_code = "DEBIAN_7_64"
datacenter = "tok02"
network_speed = 10
hourly_billing = true
private_network_only = false
cpu = 1
ram = 1024
cores = 1
memory = 1024
disks = [25, 10, 20]
user_data = "{\"value\":\"newvalue\"}"
user_metadata = "{\"value\":\"newvalue\"}"
dedicated_acct_host_only = true
local_disk = false
}
Expand Down
20 changes: 10 additions & 10 deletions softlayer/resource_softlayer_lb_vpx_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,29 @@ func TestAccSoftLayerLbVpxService_Basic(t *testing.T) {
var testAccCheckSoftLayerLbVpxServiceConfig_basic = `
resource "softlayer_virtual_guest" "vm1" {
name = "vm1"
hostname = "vm1"
domain = "example.com"
image = "DEBIAN_7_64"
os_reference_code = "DEBIAN_7_64"
datacenter = "wdc01"
public_network_speed = 10
network_speed = 10
hourly_billing = true
private_network_only = false
cpu = 1
ram = 1024
cores = 1
memory = 1024
disks = [25]
local_disk = false
}
resource "softlayer_virtual_guest" "vm2" {
name = "vm2"
hostname = "vm2"
domain = "example.com"
image = "DEBIAN_7_64"
os_reference_code = "DEBIAN_7_64"
datacenter = "wdc01"
public_network_speed = 10
network_speed = 10
hourly_billing = true
private_network_only = false
cpu = 1
ram = 1024
cores = 1
memory = 1024
disks = [25]
local_disk = false
}
Expand Down
10 changes: 5 additions & 5 deletions softlayer/resource_softlayer_scale_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,12 @@ func populateMemberTemplateResourceData(template datatypes.Virtual_Guest) []map[

d := make(map[string]interface{})

d["name"] = *template.Hostname
d["hostname"] = *template.Hostname
d["domain"] = *template.Domain
d["datacenter"] = *template.Datacenter.Name
d["network_speed"] = *template.NetworkComponents[0].MaxSpeed
d["cpu"] = *template.StartCpus
d["ram"] = *template.MaxMemory
d["cores"] = *template.StartCpus
d["memory"] = *template.MaxMemory
d["private_network_only"] = *template.PrivateNetworkOnlyFlag
d["hourly_billing"] = *template.HourlyBillingFlag
d["local_disk"] = *template.LocalDiskFlag
Expand All @@ -431,14 +431,14 @@ func populateMemberTemplateResourceData(template datatypes.Virtual_Guest) []map[
}

if len(template.UserData) > 0 {
d["user_data"] = *template.UserData[0].Value
d["user_metadata"] = *template.UserData[0].Value
}

sshKeys := make([]interface{}, 0, len(template.SshKeys))
for _, elem := range template.SshKeys {
sshKeys = append(sshKeys, *elem.Id)
}
d["ssh_keys"] = sshKeys
d["ssh_key_ids"] = sshKeys

disks := make([]interface{}, 0, len(template.BlockDevices))
for _, elem := range template.BlockDevices {
Expand Down
Loading

0 comments on commit ccccd77

Please sign in to comment.