Skip to content

Commit

Permalink
Add esxIpAddress to server
Browse files Browse the repository at this point in the history
We add a new field `esxIpAddress` to the server model.
This field is an outlier - it does not fit cleanly into a declarative
model.

The field is used as part of an `add-hypervisor-server` RPC-style call.
It is not part of (and never will be part of) the newly created
server's attributes.

My understanding is that `esxIpAddress` will typically be set to something like
an ephemeral DHCP address that exists only when a server is first racked.  Once
add-hypervisor-server has completed, the newly created server's IP address will
have been changed to the `hypervisor_host.hypervisor_host_ip` value. This value
will be returned as `hypervisorHost.hypervisorHostIp` in subsequent http GET
requests to the relevant `/servers/<id>` endpoint.

The `esxIpAddress` value will be retained as part of the terraform
configuration for the server, however once a server has been created
this value is no longer of interest.
  • Loading branch information
stuart-mclaren-hpe committed Dec 13, 2024
1 parent 1f5aa9b commit 8d78a96
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions internal/resources/server/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion internal/simulator/fixtures/servers/create/post.json
Original file line number Diff line number Diff line change
@@ -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"}}]}
10 changes: 10 additions & 0 deletions test/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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",
),
)
}

Expand Down

0 comments on commit 8d78a96

Please sign in to comment.