diff --git a/examples/main.tf b/examples/main.tf index a657a1f..d86bf37 100644 --- a/examples/main.tf +++ b/examples/main.tf @@ -42,6 +42,7 @@ resource "hpegl_pc_server" "test" { } server_network = [ { + esx_ip_address = "10.0.0.88" data_ip_infos = [ { ip_address = "16.182.105.217" diff --git a/internal/resources/server/resource.go b/internal/resources/server/resource.go index 051a94c..9d44bfc 100644 --- a/internal/resources/server/resource.go +++ b/internal/resources/server/resource.go @@ -106,6 +106,8 @@ func parseNetworksToPostFormat(dataP *ServerModel) ( NewV1beta1SystemsItemAddHypervisorServersPostRequestBody_serverNetwork() net.SetDataIpInfos(dataIps) net.SetIloMgmtIpInfo(iloIPInfos) + esxIPAddress := serverNetwork.EsxIpAddress.ValueString() + net.SetEsxIpAddress(&esxIPAddress) postRequestNetworks = []privatecloudbusiness. V1beta1SystemsItemAddHypervisorServersPostRequestBody_serverNetworkable{net} @@ -352,6 +354,12 @@ func doRead( // TODO: (API) Add esxRootCredentialId when FF-31524 is addressed // TODO: (API) Add iloAdminCredentialId when FF-31525 is addressed + + // Note: esxIpAddress is an outlier: it is part of an RPC-style + // call. It only exists for the duration of the add-hypervisor-server + // operation, and is never used again. It does not fit cleanly into + // terraform's declarative model. We will never be able to read this + // value back from the server. } func doCreate( diff --git a/internal/simulator/fixtures/servers/create/post.json b/internal/simulator/fixtures/servers/create/post.json index 75252b9..5c725cf 100644 --- a/internal/simulator/fixtures/servers/create/post.json +++ b/internal/simulator/fixtures/servers/create/post.json @@ -1 +1 @@ - {"esxRootCredentialId":"cccfcad1-85b7-4162-b16e-f7cadc2c46b5","hypervisorClusterId":"acd4daea-e5e3-5f35-8be3-ce4a4b6d946c","iloAdminCredentialId":"dddfcad1-85b7-4162-b16e-f7cadc2c46b5","serverNetwork":[{"dataIpInfos":[{"ipAddress":"16.182.105.217"}],"iloMgmtIpInfo":{"gateway":"16.182.104.1","ipAddress":"16.182.105.216","subnetMask":"255.255.248.0"}}]} + {"esxRootCredentialId":"cccfcad1-85b7-4162-b16e-f7cadc2c46b5","hypervisorClusterId":"acd4daea-e5e3-5f35-8be3-ce4a4b6d946c","iloAdminCredentialId":"dddfcad1-85b7-4162-b16e-f7cadc2c46b5","serverNetwork":[{"esxIpAddress":"10.0.0.88","dataIpInfos":[{"ipAddress":"16.182.105.217"}],"iloMgmtIpInfo":{"gateway":"16.182.104.1","ipAddress":"16.182.105.216","subnetMask":"255.255.248.0"}}]} diff --git a/test/server/server_test.go b/test/server/server_test.go index 63a3b81..502a04e 100644 --- a/test/server/server_test.go +++ b/test/server/server_test.go @@ -90,6 +90,7 @@ func TestAccServerResource(t *testing.T) { } server_network = [ { + esx_ip_address = "10.0.0.88" data_ip_infos = [ { ip_address = "16.182.105.217" @@ -138,6 +139,10 @@ func TestAccServerResource(t *testing.T) { "hpegl_pc_server.test", "hypervisor_host.hypervisor_host_ip", ), + resource.TestCheckResourceAttrSet( + "hpegl_pc_server.test", + "server_network.0.esx_ip_address", + ), checkUUIDAttr("hpegl_pc_server.test", "id"), checkUUIDAttr("hpegl_pc_server.test", "system_id"), checkUUIDAttr("hpegl_pc_server.test", "esx_root_credential_id"), @@ -213,6 +218,11 @@ func TestAccServerResource(t *testing.T) { "hypervisor_host.hypervisor_host_ip", "16.182.105.217", ), + resource.TestCheckResourceAttr( + "hpegl_pc_server.test", + "server_network.0.esx_ip_address", + "10.0.0.88", + ), ) }