Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to configure dhcp server without gw #245

Merged
merged 1 commit into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nsxt/resource_nsxt_logical_dhcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func resourceNsxtLogicalDhcpServer() *schema.Resource {
"gateway_ip": {
Type: schema.TypeString,
Description: "Gateway IP",
Required: true,
Optional: true,
ValidateFunc: validateSingleIP(),
},
"domain_name": {
Expand Down
12 changes: 5 additions & 7 deletions nsxt/resource_nsxt_logical_dhcp_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ func TestAccResourceNsxtLogicalDhcpServer_noOpts(t *testing.T) {
edgeClusterName := getEdgeClusterName()
ip1 := "1.1.1.10/24"
ip2 := "1.1.1.20"
ip3 := "1.1.1.21"
ip1upd := "2.1.1.10/24"
ip2upd := "2.1.1.20"
ip3 := "1.1.1.21"
ip4 := "1.1.1.22"

resource.Test(t, resource.TestCase{
Expand All @@ -92,16 +92,15 @@ func TestAccResourceNsxtLogicalDhcpServer_noOpts(t *testing.T) {
},
Steps: []resource.TestStep{
{
Config: testAccNSXLogicalDhcpServerCreateNoOptsTemplate(edgeClusterName, prfName, ip1, ip2, ip3),
Config: testAccNSXLogicalDhcpServerCreateNoOptsTemplate(edgeClusterName, prfName, ip1, ip2),
Check: resource.ComposeTestCheckFunc(
testAccNSXLogicalDhcpServerExists(prfName, testResourceName),
resource.TestCheckResourceAttr(testResourceName, "display_name", prfName),
resource.TestCheckResourceAttr(testResourceName, "description", "Acceptance Test"),
resource.TestCheckResourceAttrSet(testResourceName, "dhcp_profile_id"),
resource.TestCheckResourceAttr(testResourceName, "dhcp_server_ip", ip1),
resource.TestCheckResourceAttr(testResourceName, "gateway_ip", ip2),
resource.TestCheckResourceAttr(testResourceName, "dns_name_servers.#", "1"),
resource.TestCheckResourceAttr(testResourceName, "dns_name_servers.0", ip3),
resource.TestCheckResourceAttr(testResourceName, "dns_name_servers.0", ip2),
resource.TestCheckResourceAttr(testResourceName, "dhcp_option_121.#", "0"),
resource.TestCheckResourceAttr(testResourceName, "dhcp_generic_option.#", "0"),
resource.TestCheckResourceAttr(testResourceName, "tag.#", "1"),
Expand Down Expand Up @@ -282,22 +281,21 @@ resource "nsxt_logical_dhcp_server" "test" {
}`, updatedName, ip1, ip2, ip3, ip4, ip5, ip5)
}

func testAccNSXLogicalDhcpServerCreateNoOptsTemplate(edgeClusterName string, name string, ip1 string, ip2 string, ip3 string) string {
func testAccNSXLogicalDhcpServerCreateNoOptsTemplate(edgeClusterName string, name string, ip1 string, ip2 string) string {
return testAccNSXDhcpServerProfileCreateForServerTemplate(edgeClusterName) + fmt.Sprintf(`
resource "nsxt_logical_dhcp_server" "test" {
display_name = "%s"
description = "Acceptance Test"
dhcp_profile_id = "${nsxt_dhcp_server_profile.PRF.id}"
dhcp_server_ip = "%s"
gateway_ip = "%s"
domain_name = "abc.com"
dns_name_servers = ["%s"]

tag {
scope = "scope1"
tag = "tag1"
}
}`, name, ip1, ip2, ip3)
}`, name, ip1, ip2)
}

func testAccNSXLogicalDhcpServerUpdateNoOptsTemplate(edgeClusterName string, updatedName string, ip1 string, ip2 string, ip3 string, ip4 string) string {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/logical_dhcp_server.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The following arguments are supported:
* `description` - (Optional) Description of this resource.
* `dhcp_profile_id` - (Required) DHCP profile uuid.
* `dhcp_server_ip` - (Required) DHCP server IP in cidr format.
* `gateway_ip` - (Required) Gateway IP.
* `gateway_ip` - (Optional) Gateway IP.
* `domain_name` - (Optional) Domain name.
* `dns_name_servers` - (Optional) DNS IPs.
* `dhcp_option_121` - (Optional) DHCP classless static routes.
Expand Down