2016-02-10 21:30:32 +01:00
|
|
|
package triton
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-03-31 00:25:27 +02:00
|
|
|
"log"
|
2016-06-26 23:18:17 +02:00
|
|
|
"regexp"
|
2016-02-10 21:30:32 +01:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
"github.com/davecgh/go-spew/spew"
|
2016-02-10 21:30:32 +01:00
|
|
|
"github.com/hashicorp/terraform/helper/acctest"
|
|
|
|
"github.com/hashicorp/terraform/helper/resource"
|
|
|
|
"github.com/hashicorp/terraform/terraform"
|
2017-03-31 00:25:27 +02:00
|
|
|
"github.com/joyent/triton-go"
|
2016-02-10 21:30:32 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestAccTritonMachine_basic(t *testing.T) {
|
|
|
|
machineName := fmt.Sprintf("acctest-%d", acctest.RandInt())
|
|
|
|
config := fmt.Sprintf(testAccTritonMachine_basic, machineName)
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testCheckTritonMachineDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
2017-03-31 00:25:27 +02:00
|
|
|
{
|
2016-02-10 21:30:32 +01:00
|
|
|
Config: config,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckTritonMachineExists("triton_machine.test"),
|
|
|
|
func(*terraform.State) error {
|
|
|
|
time.Sleep(10 * time.Second)
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-06-26 23:18:17 +02:00
|
|
|
func TestAccTritonMachine_dns(t *testing.T) {
|
|
|
|
machineName := fmt.Sprintf("acctest-%d", acctest.RandInt())
|
|
|
|
dns_output := fmt.Sprintf(testAccTritonMachine_dns, machineName)
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testCheckTritonMachineDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
2017-03-31 00:25:27 +02:00
|
|
|
{
|
2016-06-26 23:18:17 +02:00
|
|
|
Config: dns_output,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckTritonMachineExists("triton_machine.test"),
|
2017-03-31 00:25:27 +02:00
|
|
|
func(state *terraform.State) error {
|
2016-06-26 23:18:17 +02:00
|
|
|
time.Sleep(10 * time.Second)
|
2017-03-31 00:25:27 +02:00
|
|
|
log.Printf("[DEBUG] %s", spew.Sdump(state))
|
2016-06-26 23:18:17 +02:00
|
|
|
return nil
|
|
|
|
},
|
2017-03-31 00:25:27 +02:00
|
|
|
resource.TestMatchOutput("domain_names", regexp.MustCompile(".*acctest-.*")),
|
2016-06-26 23:18:17 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-04-19 16:42:29 +02:00
|
|
|
func TestAccTritonMachine_nic(t *testing.T) {
|
|
|
|
machineName := fmt.Sprintf("acctest-%d", acctest.RandInt())
|
2017-03-31 00:25:27 +02:00
|
|
|
config := testAccTritonMachine_singleNIC(machineName, acctest.RandIntRange(1024, 2048))
|
2016-04-19 16:42:29 +02:00
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testCheckTritonMachineDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
2017-03-31 00:25:27 +02:00
|
|
|
{
|
2016-04-19 16:42:29 +02:00
|
|
|
Config: config,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckTritonMachineExists("triton_machine.test"),
|
|
|
|
func(*terraform.State) error {
|
|
|
|
time.Sleep(10 * time.Second)
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
testCheckTritonMachineHasFabric("triton_machine.test", "triton_fabric.test"),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
func TestAccTritonMachine_addNIC(t *testing.T) {
|
2016-04-19 16:42:29 +02:00
|
|
|
machineName := fmt.Sprintf("acctest-%d", acctest.RandInt())
|
2017-03-31 00:25:27 +02:00
|
|
|
vlanNumber := acctest.RandIntRange(1024, 2048)
|
|
|
|
|
|
|
|
singleNICConfig := testAccTritonMachine_singleNIC(machineName, vlanNumber)
|
|
|
|
dualNICConfig := testAccTritonMachine_dualNIC(machineName, vlanNumber)
|
2016-04-19 16:42:29 +02:00
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testCheckTritonMachineDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
2017-03-31 00:25:27 +02:00
|
|
|
{
|
|
|
|
Config: singleNICConfig,
|
2016-04-19 16:42:29 +02:00
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckTritonMachineExists("triton_machine.test"),
|
|
|
|
func(*terraform.State) error {
|
|
|
|
time.Sleep(10 * time.Second)
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
),
|
|
|
|
},
|
2017-03-31 00:25:27 +02:00
|
|
|
{
|
|
|
|
Config: dualNICConfig,
|
2016-04-19 16:42:29 +02:00
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckTritonMachineExists("triton_machine.test"),
|
2017-03-31 00:25:27 +02:00
|
|
|
testCheckTritonMachineHasFabric("triton_machine.test", "triton_fabric.test_add"),
|
2016-04-19 16:42:29 +02:00
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-02-10 21:30:32 +01:00
|
|
|
func testCheckTritonMachineExists(name string) resource.TestCheckFunc {
|
|
|
|
return func(s *terraform.State) error {
|
|
|
|
// Ensure we have enough information in state to look up in API
|
|
|
|
rs, ok := s.RootModule().Resources[name]
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("Not found: %s", name)
|
|
|
|
}
|
2017-03-31 00:25:27 +02:00
|
|
|
conn := testAccProvider.Meta().(*triton.Client)
|
2016-02-10 21:30:32 +01:00
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
machine, err := conn.Machines().GetMachine(&triton.GetMachineInput{
|
|
|
|
ID: rs.Primary.ID,
|
|
|
|
})
|
2016-02-10 21:30:32 +01:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Bad: Check Machine Exists: %s", err)
|
|
|
|
}
|
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
if machine == nil {
|
2016-02-10 21:30:32 +01:00
|
|
|
return fmt.Errorf("Bad: Machine %q does not exist", rs.Primary.ID)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-19 16:42:29 +02:00
|
|
|
func testCheckTritonMachineHasFabric(name, fabricName string) resource.TestCheckFunc {
|
|
|
|
return func(s *terraform.State) error {
|
|
|
|
// Ensure we have enough information in state to look up in API
|
|
|
|
machine, ok := s.RootModule().Resources[name]
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("Not found: %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
network, ok := s.RootModule().Resources[fabricName]
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("Not found: %s", fabricName)
|
|
|
|
}
|
2017-03-31 00:25:27 +02:00
|
|
|
conn := testAccProvider.Meta().(*triton.Client)
|
2016-04-19 16:42:29 +02:00
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
nics, err := conn.Machines().ListNICs(&triton.ListNICsInput{
|
|
|
|
MachineID: machine.Primary.ID,
|
|
|
|
})
|
2016-04-19 16:42:29 +02:00
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Bad: Check NICs Exist: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, nic := range nics {
|
|
|
|
if nic.Network == network.Primary.ID {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Errorf("Bad: Machine %q does not have Fabric %q", machine.Primary.ID, network.Primary.ID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-10 21:30:32 +01:00
|
|
|
func testCheckTritonMachineDestroy(s *terraform.State) error {
|
2017-03-31 00:25:27 +02:00
|
|
|
conn := testAccProvider.Meta().(*triton.Client)
|
2016-02-10 21:30:32 +01:00
|
|
|
|
|
|
|
for _, rs := range s.RootModule().Resources {
|
|
|
|
if rs.Type != "triton_machine" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
resp, err := conn.Machines().GetMachine(&triton.GetMachineInput{
|
|
|
|
ID: rs.Primary.ID,
|
|
|
|
})
|
2016-02-10 21:30:32 +01:00
|
|
|
if err != nil {
|
2017-03-31 00:25:27 +02:00
|
|
|
if triton.IsResourceNotFound(err) {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return err
|
2016-02-10 21:30:32 +01:00
|
|
|
}
|
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
if resp != nil && resp.State != machineStateDeleted {
|
2016-02-10 21:30:32 +01:00
|
|
|
return fmt.Errorf("Bad: Machine %q still exists", rs.Primary.ID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-04-12 20:10:53 +02:00
|
|
|
func TestAccTritonMachine_firewall(t *testing.T) {
|
|
|
|
machineName := fmt.Sprintf("acctest-%d", acctest.RandInt())
|
|
|
|
disabled_config := fmt.Sprintf(testAccTritonMachine_firewall_0, machineName)
|
|
|
|
enabled_config := fmt.Sprintf(testAccTritonMachine_firewall_1, machineName)
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testCheckTritonMachineDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
2017-03-31 00:25:27 +02:00
|
|
|
{
|
2016-04-12 20:10:53 +02:00
|
|
|
Config: enabled_config,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckTritonMachineExists("triton_machine.test"),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"triton_machine.test", "firewall_enabled", "true"),
|
|
|
|
),
|
|
|
|
},
|
2017-03-31 00:25:27 +02:00
|
|
|
{
|
2016-04-12 20:10:53 +02:00
|
|
|
Config: disabled_config,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckTritonMachineExists("triton_machine.test"),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"triton_machine.test", "firewall_enabled", "false"),
|
|
|
|
),
|
|
|
|
},
|
2017-03-31 00:25:27 +02:00
|
|
|
{
|
2016-04-12 20:10:53 +02:00
|
|
|
Config: enabled_config,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckTritonMachineExists("triton_machine.test"),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"triton_machine.test", "firewall_enabled", "true"),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-04-21 01:14:06 +02:00
|
|
|
func TestAccTritonMachine_metadata(t *testing.T) {
|
|
|
|
machineName := fmt.Sprintf("acctest-%d", acctest.RandInt())
|
2016-04-21 01:46:45 +02:00
|
|
|
basic := fmt.Sprintf(testAccTritonMachine_metadata_1, machineName)
|
|
|
|
add_metadata := fmt.Sprintf(testAccTritonMachine_metadata_1, machineName)
|
2016-06-12 03:57:39 +02:00
|
|
|
add_metadata_2 := fmt.Sprintf(testAccTritonMachine_metadata_2, machineName)
|
|
|
|
add_metadata_3 := fmt.Sprintf(testAccTritonMachine_metadata_3, machineName)
|
2016-04-21 01:14:06 +02:00
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
Providers: testAccProviders,
|
|
|
|
CheckDestroy: testCheckTritonMachineDestroy,
|
|
|
|
Steps: []resource.TestStep{
|
2017-03-31 00:25:27 +02:00
|
|
|
{
|
2016-04-21 01:14:06 +02:00
|
|
|
Config: basic,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckTritonMachineExists("triton_machine.test"),
|
|
|
|
),
|
|
|
|
},
|
2017-03-31 00:25:27 +02:00
|
|
|
{
|
2016-04-21 01:14:06 +02:00
|
|
|
Config: add_metadata,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckTritonMachineExists("triton_machine.test"),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"triton_machine.test", "user_data", "hello"),
|
|
|
|
),
|
|
|
|
},
|
2017-03-31 00:25:27 +02:00
|
|
|
{
|
2016-06-12 03:57:39 +02:00
|
|
|
Config: add_metadata_2,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckTritonMachineExists("triton_machine.test"),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"triton_machine.test",
|
|
|
|
"tags.triton.cns.services", "test-cns-service"),
|
|
|
|
),
|
|
|
|
},
|
2017-03-31 00:25:27 +02:00
|
|
|
{
|
2016-06-12 03:57:39 +02:00
|
|
|
Config: add_metadata_3,
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
testCheckTritonMachineExists("triton_machine.test"),
|
|
|
|
resource.TestCheckResourceAttr(
|
|
|
|
"triton_machine.test",
|
|
|
|
"tags.triton.cns.services", "test-cns-service"),
|
|
|
|
),
|
|
|
|
},
|
2016-04-21 01:14:06 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-02-10 21:30:32 +01:00
|
|
|
var testAccTritonMachine_basic = `
|
|
|
|
resource "triton_machine" "test" {
|
|
|
|
name = "%s"
|
2016-07-12 01:23:09 +02:00
|
|
|
package = "g4-general-4G"
|
2017-03-31 00:25:27 +02:00
|
|
|
image = "fb5fe970-e6e4-11e6-9820-4b51be190db9"
|
2016-02-10 21:30:32 +01:00
|
|
|
|
|
|
|
tags = {
|
|
|
|
test = "hello!"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2016-04-12 20:10:53 +02:00
|
|
|
|
|
|
|
var testAccTritonMachine_firewall_0 = `
|
|
|
|
resource "triton_machine" "test" {
|
|
|
|
name = "%s"
|
2016-07-12 01:23:09 +02:00
|
|
|
package = "g4-general-4G"
|
2016-04-21 01:46:45 +02:00
|
|
|
image = "c20b4b7c-e1a6-11e5-9a4d-ef590901732e"
|
2016-04-12 20:10:53 +02:00
|
|
|
|
|
|
|
firewall_enabled = 0
|
|
|
|
}
|
|
|
|
`
|
|
|
|
var testAccTritonMachine_firewall_1 = `
|
|
|
|
resource "triton_machine" "test" {
|
|
|
|
name = "%s"
|
2016-07-12 01:23:09 +02:00
|
|
|
package = "g4-general-4G"
|
2017-03-31 00:25:27 +02:00
|
|
|
image = "fb5fe970-e6e4-11e6-9820-4b51be190db9"
|
2016-04-12 20:10:53 +02:00
|
|
|
|
|
|
|
firewall_enabled = 1
|
|
|
|
}
|
|
|
|
`
|
2016-04-21 01:14:06 +02:00
|
|
|
|
|
|
|
var testAccTritonMachine_metadata_1 = `
|
|
|
|
resource "triton_machine" "test" {
|
|
|
|
name = "%s"
|
2016-07-12 01:23:09 +02:00
|
|
|
package = "g4-general-4G"
|
2016-04-21 01:46:45 +02:00
|
|
|
image = "c20b4b7c-e1a6-11e5-9a4d-ef590901732e"
|
2016-04-21 01:14:06 +02:00
|
|
|
|
|
|
|
user_data = "hello"
|
|
|
|
|
|
|
|
tags = {
|
2016-04-19 16:42:29 +02:00
|
|
|
test = "hello!"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2016-06-12 03:57:39 +02:00
|
|
|
var testAccTritonMachine_metadata_2 = `
|
|
|
|
variable "tags" {
|
|
|
|
default = {
|
|
|
|
test = "hello!"
|
|
|
|
triton.cns.services = "test-cns-service"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resource "triton_machine" "test" {
|
|
|
|
name = "%s"
|
|
|
|
package = "g4-highcpu-128M"
|
2017-03-31 00:25:27 +02:00
|
|
|
image = "fb5fe970-e6e4-11e6-9820-4b51be190db9"
|
2016-06-12 03:57:39 +02:00
|
|
|
|
|
|
|
user_data = "hello"
|
|
|
|
|
|
|
|
tags = "${var.tags}"
|
|
|
|
}
|
|
|
|
`
|
|
|
|
var testAccTritonMachine_metadata_3 = `
|
|
|
|
resource "triton_machine" "test" {
|
|
|
|
name = "%s"
|
|
|
|
package = "g4-highcpu-128M"
|
2017-03-31 00:25:27 +02:00
|
|
|
image = "fb5fe970-e6e4-11e6-9820-4b51be190db9"
|
2016-06-12 03:57:39 +02:00
|
|
|
|
|
|
|
user_data = "hello"
|
2016-04-19 16:42:29 +02:00
|
|
|
|
2016-06-12 03:57:39 +02:00
|
|
|
tags = {
|
|
|
|
test = "hello!"
|
|
|
|
triton.cns.services = "test-cns-service"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
2017-03-31 00:25:27 +02:00
|
|
|
var testAccTritonMachine_singleNIC = func(name string, vlanNumber int) string {
|
|
|
|
return fmt.Sprintf(`resource "triton_vlan" "test" {
|
|
|
|
vlan_id = %d
|
|
|
|
name = "%s-vlan"
|
|
|
|
description = "test vlan"
|
|
|
|
}
|
|
|
|
|
2016-04-19 16:42:29 +02:00
|
|
|
resource "triton_fabric" "test" {
|
2017-03-31 00:25:27 +02:00
|
|
|
name = "%s-network"
|
|
|
|
description = "test network"
|
|
|
|
vlan_id = "${triton_vlan.test.vlan_id}"
|
2016-04-19 16:42:29 +02:00
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
subnet = "10.10.0.0/24"
|
|
|
|
gateway = "10.10.0.1"
|
|
|
|
provision_start_ip = "10.10.0.10"
|
|
|
|
provision_end_ip = "10.10.0.250"
|
2016-04-19 16:42:29 +02:00
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
resolvers = ["8.8.8.8", "8.8.4.4"]
|
2016-04-19 16:42:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "triton_machine" "test" {
|
2017-03-31 00:25:27 +02:00
|
|
|
name = "%s-instance"
|
|
|
|
package = "g4-highcpu-128M"
|
|
|
|
image = "fb5fe970-e6e4-11e6-9820-4b51be190db9"
|
2016-04-19 16:42:29 +02:00
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
tags = {
|
|
|
|
test = "Test"
|
2016-04-19 16:42:29 +02:00
|
|
|
}
|
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
nic {
|
|
|
|
network = "${triton_fabric.test.id}"
|
|
|
|
}
|
|
|
|
}`, vlanNumber, name, name, name)
|
|
|
|
}
|
|
|
|
|
|
|
|
var testAccTritonMachine_dualNIC = func(name string, vlanNumber int) string {
|
|
|
|
return fmt.Sprintf(`resource "triton_vlan" "test" {
|
|
|
|
vlan_id = %d
|
|
|
|
name = "%s-vlan"
|
|
|
|
description = "test vlan"
|
2016-04-19 16:42:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "triton_fabric" "test" {
|
2017-03-31 00:25:27 +02:00
|
|
|
name = "%s-network"
|
|
|
|
description = "test network"
|
|
|
|
vlan_id = "${triton_vlan.test.vlan_id}"
|
|
|
|
|
|
|
|
subnet = "10.10.0.0/24"
|
|
|
|
gateway = "10.10.0.1"
|
|
|
|
provision_start_ip = "10.10.0.10"
|
|
|
|
provision_end_ip = "10.10.0.250"
|
|
|
|
|
|
|
|
resolvers = ["8.8.8.8", "8.8.4.4"]
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "triton_fabric" "test_add" {
|
|
|
|
name = "%s-network-2"
|
|
|
|
description = "test network 2"
|
|
|
|
vlan_id = "${triton_vlan.test.vlan_id}"
|
2016-04-19 16:42:29 +02:00
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
subnet = "172.23.0.0/24"
|
|
|
|
gateway = "172.23.0.1"
|
|
|
|
provision_start_ip = "172.23.0.10"
|
|
|
|
provision_end_ip = "172.23.0.250"
|
2016-04-19 16:42:29 +02:00
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
resolvers = ["8.8.8.8", "8.8.4.4"]
|
2016-04-19 16:42:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "triton_machine" "test" {
|
2017-03-31 00:25:27 +02:00
|
|
|
name = "%s-instance"
|
|
|
|
package = "g4-highcpu-128M"
|
|
|
|
image = "fb5fe970-e6e4-11e6-9820-4b51be190db9"
|
2016-04-19 16:42:29 +02:00
|
|
|
|
2017-03-31 00:25:27 +02:00
|
|
|
tags = {
|
|
|
|
test = "Test"
|
|
|
|
}
|
|
|
|
|
|
|
|
nic {
|
|
|
|
network = "${triton_fabric.test.id}"
|
2016-04-19 16:42:29 +02:00
|
|
|
}
|
2017-03-31 00:25:27 +02:00
|
|
|
nic {
|
|
|
|
network = "${triton_fabric.test_add.id}"
|
|
|
|
}
|
|
|
|
}`, vlanNumber, name, name, name, name)
|
2016-04-21 01:14:06 +02:00
|
|
|
}
|
2016-06-26 23:18:17 +02:00
|
|
|
|
|
|
|
var testAccTritonMachine_dns = `
|
|
|
|
provider "triton" {
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "triton_machine" "test" {
|
|
|
|
name = "%s"
|
|
|
|
package = "g4-highcpu-128M"
|
2017-03-31 00:25:27 +02:00
|
|
|
image = "fb5fe970-e6e4-11e6-9820-4b51be190db9"
|
2016-06-26 23:18:17 +02:00
|
|
|
}
|
2017-03-31 00:25:27 +02:00
|
|
|
|
2016-06-26 23:18:17 +02:00
|
|
|
output "domain_names" {
|
|
|
|
value = "${join(", ", triton_machine.test.domain_names)}"
|
|
|
|
}
|
|
|
|
`
|