Skip to content

Commit 63688b8

Browse files
fix(network-instance): network_instance ip schema (#64)
* fix(network-instance): schema / gateway not computed * test ip * fix ip test
1 parent 23a1b8b commit 63688b8

File tree

4 files changed

+31
-34
lines changed

4 files changed

+31
-34
lines changed

resources/network_instance_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ func testNetworkInstanceAttributes(t *testing.T, got, expected *models.NetworkIn
138138
ignoredFields := []string{
139139
"ID",
140140
"Revision",
141-
"IP",
142141
"DNSList",
143142
"DeviceID",
144143
"ProjectID",

resources/testdata/network_instance/create_complete.tf

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,22 @@ resource "zedcloud_network_instance" "complete" {
4343
]
4444
hostname = "wwww.ns1.example.com"
4545
}
46-
# computed or changed by api?
47-
# ip {
48-
# # not supported by API
49-
# # domain = "htttp://example.com"
50-
# # gateway = "10.1.0.1"
46+
ip {
47+
domain = "htttp://example.com"
5148

52-
# dhcp_range {
53-
# end = "10.2.255.254"
54-
# start = "10.2.0.128"
55-
# }
56-
# dns = [
57-
# "10.2.0.1"
58-
# ]
59-
# mask = "255.255.255.0"
60-
# ntp = "10.1.0.2"
61-
# }
49+
gateway = "10.0.20.1"
50+
subnet = "10.0.20.0/24"
51+
52+
dhcp_range {
53+
end = "10.0.20.100"
54+
start = "10.0.20.50"
55+
}
56+
# dns = [
57+
# "10.0.20.1"
58+
# ]
59+
mask = "255.255.255.0"
60+
ntp = "10.1.0.2"
61+
}
6262
opaque {
6363
oconfig = "Test OConfig"
6464
type = "OPAQUE_CONFIG_TYPE_UNSPECIFIED"

resources/testdata/network_instance/create_complete_expected.yaml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ dnslist:
1111
- 10.1.2.1
1212
- 10.1.2.2
1313
hostname: wwww.ns2.example.com
14-
# ip:
15-
# dhcprange:
16-
# end: 10.2.255.254
17-
# start: 10.2.0.128
18-
# dns:
19-
# - 10.2.0.1
20-
# domain: ""
21-
# gateway: 10.2.0.1
22-
# mask: 255.255.255.0
23-
# ntp: 10.1.0.2
24-
# subnet: 10.2.0.0/16
14+
ip:
15+
domain: "htttp://example.com"
16+
gateway: "10.0.20.1"
17+
subnet: "10.0.20.0/24"
18+
dhcprange:
19+
end: "10.0.20.100"
20+
start: "10.0.20.50"
21+
dns: []
22+
mask: "255.255.255.0"
23+
ntp: "10.1.0.2"
2524
kind: NETWORK_INSTANCE_KIND_LOCAL
2625
lisp: null
2726
name: complete

schemas/dhcp_server.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ func DHCPServerModelFromMap(m map[string]interface{}) *models.DhcpServerConfig {
5656
dnsSlice = append(dnsSlice, i.(string))
5757
}
5858
}
59-
domain := m["domain"].(string)
60-
gateway := m["gateway"].(string)
61-
mask := m["mask"].(string)
62-
ntp := m["ntp"].(string)
63-
subnet := m["subnet"].(string)
59+
domain, _ := m["domain"].(string)
60+
gateway, _ := m["gateway"].(string)
61+
mask, _ := m["mask"].(string)
62+
ntp, _ := m["ntp"].(string)
63+
subnet, _ := m["subnet"].(string)
6464
return &models.DhcpServerConfig{
6565
DhcpRange: dhcpRange,
6666
DNS: dns,
@@ -109,7 +109,6 @@ func DHCPServer() map[string]*schema.Schema {
109109
Schema: DhcpIPRange(),
110110
},
111111
Optional: true,
112-
Computed: true,
113112
},
114113

115114
"dns": {
@@ -131,7 +130,7 @@ func DHCPServer() map[string]*schema.Schema {
131130
"gateway": {
132131
Description: `IP Address of Network Gateway`,
133132
Type: schema.TypeString,
134-
Computed: true,
133+
Optional: true,
135134
},
136135

137136
"mask": {

0 commit comments

Comments
 (0)