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

Avoid recreating gateway when locale service added #1517

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions nsxt/gateway_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func getPolicyLocaleServiceSchema(isTier1 bool) *schema.Schema {
}

elemSchema := map[string]*schema.Schema{
"nsx_id": getNsxIDSchema(),
"nsx_id": getFlexNsxIDSchema(false),
"edge_cluster_path": {
Type: schema.TypeString,
Description: "The path of the edge cluster connected to this gateway",
Expand Down Expand Up @@ -205,7 +205,7 @@ func getGatewayIntersiteConfigSchema() *schema.Schema {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "Locale Service for the gateway",
Description: "Intersite config for the gateway",
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down
36 changes: 36 additions & 0 deletions nsxt/resource_nsxt_policy_tier1_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func TestAccResourceNsxtPolicyTier1Gateway_withEdgeCluster(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "description", "Acceptance Test"),
resource.TestCheckResourceAttrSet(testResourceName, "edge_cluster_path"),
resource.TestCheckResourceAttr(testResourceName, "tier0_path", ""),
resource.TestCheckResourceAttr(testResourceName, "revision", "0"),
resource.TestCheckResourceAttr(realizationResourceName, "state", "REALIZED"),
),
},
Expand All @@ -263,6 +264,22 @@ func TestAccResourceNsxtPolicyTier1Gateway_withEdgeCluster(t *testing.T) {
resource.TestCheckResourceAttr(testResourceName, "description", "Acceptance Test"),
resource.TestCheckResourceAttrSet(testResourceName, "edge_cluster_path"),
resource.TestCheckResourceAttr(testResourceName, "tier0_path", ""),
// verify gateway was not recreated
resource.TestCheckResourceAttr(testResourceName, "revision", "1"),
resource.TestCheckResourceAttr(realizationResourceName, "state", "REALIZED"),
),
},
{
Config: testAccNsxtPolicyTier1CreateWithLocaleServiceTemplate(updateName, edgeClusterName),
Check: resource.ComposeTestCheckFunc(
testAccNsxtPolicyTier1Exists(testResourceName),
resource.TestCheckResourceAttr(testResourceName, "display_name", updateName),
resource.TestCheckResourceAttr(testResourceName, "description", "Acceptance Test"),
resource.TestCheckResourceAttr(testResourceName, "locale_service.#", "1"),
resource.TestCheckResourceAttrSet(testResourceName, "locale_service.0.edge_cluster_path"),
resource.TestCheckResourceAttr(testResourceName, "tier0_path", ""),
// verify gateway was not recreated
resource.TestCheckResourceAttr(testResourceName, "revision", "2"),
resource.TestCheckResourceAttr(realizationResourceName, "state", "REALIZED"),
),
},
Expand Down Expand Up @@ -710,6 +727,25 @@ data "nsxt_policy_realization_info" "realization_info" {
}`, edgeClusterName, name)
}

func testAccNsxtPolicyTier1CreateWithLocaleServiceTemplate(name string, edgeClusterName string) string {
return fmt.Sprintf(`
data "nsxt_policy_edge_cluster" "EC" {
display_name = "%s"
}

resource "nsxt_policy_tier1_gateway" "test" {
display_name = "%s"
description = "Acceptance Test"
locale_service {
edge_cluster_path = data.nsxt_policy_edge_cluster.EC.path
}
}

data "nsxt_policy_realization_info" "realization_info" {
path = nsxt_policy_tier1_gateway.test.path
}`, edgeClusterName, name)
}

func testAccNsxtPolicyTier1CreateWithTier0Template(name string, tier0Name string, failoverMode string) string {
return fmt.Sprintf(`
data "nsxt_policy_tier0_gateway" "T0" {
Expand Down
Loading