Skip to content

Commit

Permalink
Some minor adjustments to PR
Browse files Browse the repository at this point in the history
  • Loading branch information
paultyng committed Jun 1, 2021
1 parent 832d6b1 commit afa4ab9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/resources/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ resource "unifi_network" "wan" {
- **dhcp_start** (String) The IPv4 address where the DHCP range of addresses starts.
- **dhcp_stop** (String) The IPv4 address where the DHCP range of addresses stops.
- **dhcpd_boot_enabled** (Boolean) Toggles on the DHCP boot options. Should be set to true when you want to have dhcpd_boot_filename, and dhcpd_boot_server to take effect.
- **dhcpd_boot_server** (String) Specifies the IPv4 address of a TFTP server to network boot from.
- **dhcpd_boot_filename** (String) Specifies the file to PXE boot from on the dhcpd_boot_server.
- **dhcpd_boot_server** (String) Specifies the IPv4 address of a TFTP server to network boot from.
- **domain_name** (String) The domain name of this network.
- **igmp_snooping** (Boolean) Specifies whether IGMP snooping is enabled or not.
- **ipv6_interface_type** (String) Specifies which type of IPv6 connection to use. Defaults to `none`.
Expand Down
11 changes: 6 additions & 5 deletions internal/provider/resource_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,19 @@ func resourceNetwork() *schema.Resource {
},
"dhcpd_boot_enabled": {
Description: "Toggles on the DHCP boot options. Should be set to true when you want to have dhcpd_boot_filename, and dhcpd_boot_server to take effect.",
Type: schema.TypeBool,
Optional: true,
Type: schema.TypeBool,
Optional: true,
},
"dhcpd_boot_server": {
Description: "Specifies the IPv4 address of a TFTP server to network boot from.",
Type: schema.TypeString,
Type: schema.TypeString,
// TODO: IPv4 validation?
Optional: true,
},
"dhcpd_boot_filename": {
Description: "Specifies the file to PXE boot from on the dhcpd_boot_server.",
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
},
"domain_name": {
Description: "The domain name of this network.",
Expand Down
46 changes: 46 additions & 0 deletions internal/provider/resource_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,25 @@ func TestAccNetwork_dhcp_dns(t *testing.T) {
})
}

func TestAccNetwork_dhcp_boot(t *testing.T) {
vlanID := getTestVLAN(t)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { preCheck(t) },
ProviderFactories: providerFactories,
// TODO: CheckDestroy: ,
Steps: []resource.TestStep{
{
Config: testAccNetworkConfigDHCPBoot(vlanID),
Check: resource.ComposeTestCheckFunc(
// TODO: ...
),
},
importStep("unifi_network.test"),
},
})
}

func TestAccNetwork_v6(t *testing.T) {
vlanID1 := getTestVLAN(t)
vlanID2 := getTestVLAN(t)
Expand Down Expand Up @@ -265,6 +284,33 @@ func quoteStrings(src []string) []string {
return dst
}

func testAccNetworkConfigDHCPBoot(vlan int) string {
return fmt.Sprintf(`
locals {
subnet = cidrsubnet("10.0.0.0/8", 6, %[1]d)
vlan_id = %[1]d
}
resource "unifi_network" "test" {
name = "tfacc"
purpose = "corporate"
subnet = local.subnet
vlan_id = local.vlan_id
dhcp_start = cidrhost(local.subnet, 6)
dhcp_stop = cidrhost(local.subnet, 254)
dhcp_enabled = true
domain_name = "foo.local"
dhcpd_boot_enabled = true
dhcpd_boot_server = "192.168.1.180"
dhcpd_boot_filename = "test.boot"
dhcp_dns = ["192.168.1.101", "192.168.1.102"]
}
`, vlan)
}

func testAccNetworkConfig(vlan int, igmpSnoop bool, dhcpDNS []string) string {
return fmt.Sprintf(`
locals {
Expand Down

0 comments on commit afa4ab9

Please sign in to comment.