-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DE14434:GL Metal terraform provider not providing fields related to H… (
#76) * DE14434:GL Metal terraform provider not providing fields related to Host network connection
- Loading branch information
Showing
5 changed files
with
168 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
output "ips" { | ||
# Output a map of hostame with all the IP addresses assigned on each network. | ||
# Output a map of hostname with each network's IP address. | ||
value = zipmap(hpegl_metal_host.terra_host.*.name, hpegl_metal_host.terra_host.*.connections) | ||
} | ||
|
||
output "subnets" { | ||
# Output a map of hostname with each network's subnet address. | ||
value = zipmap(hpegl_metal_host.terra_host.*.name, hpegl_metal_host.terra_host.*.connections_subnet) | ||
} | ||
|
||
output "gateways" { | ||
# Output a map of hostname with each network's gateway address. | ||
value = zipmap(hpegl_metal_host.terra_host.*.name, hpegl_metal_host.terra_host.*.connections_gateway) | ||
} | ||
|
||
output "vlans" { | ||
# Output a map of hostname with each network's vlan. | ||
value = zipmap(hpegl_metal_host.terra_host.*.name, hpegl_metal_host.terra_host.*.connections_vlan) | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// (C) Copyright 2022 Hewlett Packard Enterprise Development LP | ||
|
||
package resources | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/hewlettpackard/hpegl-metal-client/v1/pkg/client" | ||
) | ||
|
||
func Test_setConnectionsValues(t *testing.T) { | ||
someName := "someName" | ||
someVlan := int32(22) | ||
someIP := "someip" | ||
someSubnet := "somesubnet" | ||
someGateway := "somegateway" | ||
|
||
conns := []client.HostConnection{ | ||
{ | ||
Networks: []client.HostNetworkConnection{ | ||
{ | ||
Name: someName, | ||
IP: someIP, | ||
Subnet: someSubnet, | ||
Gateway: someGateway, | ||
VLAN: someVlan, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
d := schema.TestResourceDataRaw(t, hostSchema(), map[string]interface{}{}) | ||
|
||
// test | ||
err := setConnectionsValues(d, conns) | ||
assert.Nil(t, err) | ||
|
||
connIPs, ok := d.Get(hConnections).(map[string]interface{}) | ||
assert.True(t, ok, "type assertion failed") | ||
assert.Equal(t, 1, len(connIPs)) | ||
assert.Equal(t, someIP, connIPs[someName]) | ||
|
||
connSubNets, ok := d.Get(hConnectionsSubnet).(map[string]interface{}) | ||
assert.True(t, ok, "type assertion failed") | ||
assert.Equal(t, 1, len(connSubNets)) | ||
assert.Equal(t, someSubnet, connSubNets[someName]) | ||
|
||
connGateways, ok := d.Get(hConnectionsGateway).(map[string]interface{}) | ||
assert.True(t, ok, "type assertion failed") | ||
assert.Equal(t, 1, len(connGateways)) | ||
assert.Equal(t, someGateway, connGateways[someName]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.1.11 | ||
0.1.12 |