diff --git a/examples/advanced/README.md b/examples/advanced/README.md index 3309be9..3fe7b7d 100644 --- a/examples/advanced/README.md +++ b/examples/advanced/README.md @@ -21,11 +21,11 @@ resource "virtomize_iso" "debian_iso" { networks = [{ dhcp = true no_internet = false, - mac = "00-1B-63-84-45-E5" + mac = "ca:8c:65:0d:e7:57" },{ dhcp = false domain = "custom_domain" - mac = "00-1B-63-84-45-E6" + mac = "ca:8c:65:0d:e7:58" ip_net = "10.0.0.0/24" gateway = "10.0.0.1" dns = ["1.1.1.1", "8.8.8.8"] @@ -82,7 +82,7 @@ Please consult your network admin for the correct values for these parameters. { dhcp = false domain = "custom_domain" - mac = "00-1B-63-84-45-E6" + mac = "ca:8c:65:0d:e7:58" ip_net = "10.0.0.0/24" gateway = "10.0.0.1" dns = ["1.1.1.1", "8.8.8.8"] diff --git a/examples/advanced/virtomize.tf b/examples/advanced/virtomize.tf index 16bd717..7c7a7fc 100644 --- a/examples/advanced/virtomize.tf +++ b/examples/advanced/virtomize.tf @@ -34,11 +34,11 @@ resource "virtomize_iso" "debian_iso" { networks = [{ dhcp = true no_internet = false - mac = "00-1B-63-84-45-E5" + mac = "ca:8c:65:0d:e7:57" },{ dhcp = false domain = "custom_domain" - mac = "00-1B-63-84-45-E6" + mac = "ca:8c:65:0d:e7:58" ip_net = "10.0.0.0/24" gateway = "10.0.0.1" dns = ["1.1.1.1", "8.8.8.8"] diff --git a/examples/vmware/README.md b/examples/vmware/README.md index 2627f94..36ec1da 100644 --- a/examples/vmware/README.md +++ b/examples/vmware/README.md @@ -99,10 +99,15 @@ To use multiple network adapters, follow [the official documentation](https://registry.terraform.io/providers/hashicorp/vsphere/1.17.0/docs/resources/virtual_machine) and add the `use_static_mac` and `mac_address` properties to the individual network interfaces. +Notice that at least in our test the vSphere provider prefer MAC addresses to be in the format +`xx:xx:xx:xx:xx:xx` +instead of +`xx-xx-xx-xx-xx-xx`. + ```terraform network_interface { network_id = "${data.vsphere_network.mgmt_lan.id}" use_static_mac = true - mac_address = "CA-8C-65-0D-E7-58" + mac_address = "ca:8c:65:0d:e7:57" } ``` \ No newline at end of file diff --git a/provider/provider_test.go b/provider/provider_test.go index 196b330..4f0f02b 100644 --- a/provider/provider_test.go +++ b/provider/provider_test.go @@ -47,6 +47,43 @@ resource "virtomize_iso" "debian_iso" { }) } +func TestSimpleIsoLifeCycleStaticConfig(t *testing.T) { + testConfiguration := ` +provider "virtomize" { + # apitoken = retrieved from env variables + # localstorage = use local folder +} + +resource "virtomize_iso" "debian_iso" { + name = "debian_iso" + distribution = "debian" + version = "11" + hostname = "examplehost" + networks = [{ + dhcp = false + domain = "custom_domain" + mac = "ca:8c:65:0d:e7:58" + ip_net = "10.0.0.0/24" + gateway = "10.0.0.1" + dns = ["1.1.1.1", "8.8.8.8"] + no_internet = false + }] + }` + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + { + Config: testConfiguration, + Check: resource.ComposeTestCheckFunc( + checkSimpleIsoProperties, + ), + }, + }, + }) +} + func checkSimpleIsoProperties(state *terraform.State) error { resource_name := "virtomize_iso.debian_iso" rs, ok := state.RootModule().Resources[resource_name] diff --git a/provider/resource_iso.go b/provider/resource_iso.go index 6df71af..3d57536 100644 --- a/provider/resource_iso.go +++ b/provider/resource_iso.go @@ -324,7 +324,7 @@ func stringListWithValidElements(list []types.String) []string { continue } - result = append(result, item.String()) + result = append(result, item.ValueString()) } return result