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

Federation rebase #358

Merged
merged 56 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
2783cb2
Add provider flag for a policy global manager env
asarfaty May 19, 2020
6ec0fa5
Update dependencies
annakhm May 19, 2020
6590e3e
policy_global_manager->policy_manager
asarfaty May 20, 2020
5b22c2f
Fix doc text
asarfaty May 20, 2020
310425e
Remove ConflictsWith spec in nested structure
annakhm May 20, 2020
506da61
Fix doc typo
annakhm May 20, 2020
7308506
Add global manager site data source
annakhm May 20, 2020
d84b0b6
Add missing vendor files
annakhm May 20, 2020
2232da9
GM switching profile data sources
asarfaty May 21, 2020
872da14
Refactor resource existance detection helper
annakhm May 23, 2020
5ad977b
Remove leftover debuging
asarfaty May 24, 2020
98a13b4
Add GM support for gateway qos profile data source
asarfaty May 24, 2020
a11ef94
GM service data source
asarfaty May 24, 2020
208932d
GM service support as resource
asarfaty May 26, 2020
7a7f0ca
Basic support for Tier0 on global manager
annakhm May 26, 2020
50e81a0
Fix error handling
asarfaty May 27, 2020
ed3f39e
Add support for Global Manager Transport Zone
May 26, 2020
a45a325
Remove log
May 26, 2020
ca74096
Minor fix, add Acc tests
May 27, 2020
9f27253
Add attribute to attributeRequiredGlobalManagerError, use site data s…
May 27, 2020
a840cb9
Support locale_service clause on GM tier0
annakhm May 28, 2020
1a28401
Fix doc for global manager TZ usage
May 28, 2020
313f0f3
Fix hcl issue
May 28, 2020
a1d1d3b
Use double converter utility for GM objects
annakhm May 29, 2020
d62c0d9
Use correct schema getter and cosmetic changes
annakhm May 29, 2020
a9cc1ef
Global manager realization data source
asarfaty May 27, 2020
d2647f5
Support GM edge cluster/node data sources
asarfaty Jun 1, 2020
c364103
GM support for Group
Jun 1, 2020
4d60401
Switch to H-API in policy T1 Gateway
annakhm Jun 1, 2020
fc72db4
Fix edge cluster & node data source
asarfaty Jun 2, 2020
51d6354
Make GM realization data source part of the policy one
asarfaty Jun 2, 2020
d96d419
Remove debug logs
asarfaty Jun 2, 2020
3c0895d
remove debug logs
asarfaty Jun 2, 2020
68bd873
Address comments, fix doc
Jun 2, 2020
e5760f0
Address more comments
Jun 2, 2020
f8c1ee7
Add Global Manager support for Tier1
annakhm Jun 3, 2020
061f328
Skip most of the acctests for Global Manager
annakhm Jun 4, 2020
8c9e376
Support for GM Security Policies
Jun 4, 2020
88d9567
Add Acc Tests for User-Defined site
Jun 4, 2020
851b4b3
Support intersite config for GM gateways
annakhm Jun 5, 2020
78948d4
Documentation for gateway intersite config
annakhm Jun 5, 2020
fb80972
fix test utils
asarfaty Jun 7, 2020
47ef1b0
Fix GM tests
asarfaty Jun 7, 2020
0ad9625
Refactor LB service test to fix destroy issue
annakhm Jun 9, 2020
4e119d2
Fix Acc Tests
Jun 9, 2020
fbcc008
Fix test
Jun 9, 2020
9aa23df
Parallellize data source acc tests
annakhm Jun 9, 2020
041545e
Address comments
Jun 10, 2020
bbe4e47
Support GM segment & vlan segment resources
asarfaty Jun 10, 2020
ae2a49c
Add GM-specific tests for gateways
annakhm Jun 11, 2020
d4f19cf
GM Gateway Policy Support
Jun 11, 2020
f4282ee
Add environment validator for GM-only tests
annakhm Jun 11, 2020
739c142
Fix tests and add connectivity path update test
asarfaty Jun 15, 2020
40b9257
Update vendor floder
annakhm Jun 15, 2020
502864b
Add missing vendor folders
annakhm Jun 16, 2020
63e7611
Adjust to golang 1.13
annakhm Jun 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ module github.com/terraform-providers/terraform-provider-nsxt
require (
github.com/google/uuid v1.1.1
github.com/hashicorp/go-version v1.2.0
github.com/hashicorp/terraform-plugin-sdk v1.1.0
github.com/hashicorp/terraform-plugin-sdk v1.12.0
github.com/vmware/go-vmware-nsxt v0.0.0-20191219213550-f4221331f638
github.com/vmware/vsphere-automation-sdk-go/lib v0.3.1
github.com/vmware/vsphere-automation-sdk-go/runtime v0.3.1
github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.4.0
github.com/vmware/vsphere-automation-sdk-go/services/nsxt-gm v0.2.0
)
105 changes: 43 additions & 62 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions nsxt/data_source_nsxt_edge_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func TestAccDataSourceNsxtEdgeCluster_basic(t *testing.T) {
edgeClusterName := getEdgeClusterName()
testResourceName := "data.nsxt_edge_cluster.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccOnlyLocalManager(t); testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down
6 changes: 3 additions & 3 deletions nsxt/data_source_nsxt_firewall_section_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
)

func TestAccDataSourceNsxtFirewallSection_basic(t *testing.T) {
name := "terraform_test_firewall_section"
name := "terraform_ds_test_firewall_section"
testResourceName := "data.nsxt_firewall_section.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccOnlyLocalManager(t); testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
return testAccDataSourceNsxtFirewallSectionDeleteByName(name)
Expand Down
4 changes: 2 additions & 2 deletions nsxt/data_source_nsxt_ip_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func TestAccDataSourceNsxtIPPool_basic(t *testing.T) {
}
testResourceName := "data.nsxt_ip_pool.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccOnlyLocalManager(t); testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down
4 changes: 2 additions & 2 deletions nsxt/data_source_nsxt_logical_tier0_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func TestAccDataSourceNsxtLogicalTier0Router_basic(t *testing.T) {
routerName := getTier0RouterName()
testResourceName := "data.nsxt_logical_tier0_router.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccOnlyLocalManager(t); testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down
6 changes: 3 additions & 3 deletions nsxt/data_source_nsxt_logical_tier1_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
)

func TestAccDataSourceNsxtLogicalTier1Router_basic(t *testing.T) {
routerName := "terraform_test_tier1"
routerName := "terraform_ds_test_tier1"
testResourceName := "data.nsxt_logical_tier1_router.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccOnlyLocalManager(t); testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
return testAccDataSourceNsxtTier1RouterDeleteByName(routerName)
Expand Down
4 changes: 2 additions & 2 deletions nsxt/data_source_nsxt_mac_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func TestAccDataSourceNsxtMacPool_basic(t *testing.T) {
macPoolName := getMacPoolName()
testResourceName := "data.nsxt_mac_pool.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccOnlyLocalManager(t); testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down
6 changes: 3 additions & 3 deletions nsxt/data_source_nsxt_ns_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
)

func TestAccDataSourceNsxtNsGroup_basic(t *testing.T) {
groupName := "terraform_test_ns_group"
groupName := "terraform_ds_test_ns_group"
testResourceName := "data.nsxt_ns_group.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccOnlyLocalManager(t); testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
return testAccDataSourceNsxtNsGroupDeleteByName(groupName)
Expand Down
8 changes: 4 additions & 4 deletions nsxt/data_source_nsxt_ns_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
)

func TestAccDataSourceNsxtNsService_basic(t *testing.T) {
serviceName := "terraform_test_ns_service"
serviceName := "terraform_ds_test_ns_service"
testResourceName := "data.nsxt_ns_service.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccOnlyLocalManager(t); testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: func(state *terraform.State) error {
return testAccDataSourceNsxtNsServiceDeleteByName(serviceName)
Expand Down Expand Up @@ -46,7 +46,7 @@ func TestAccDataSourceNsxtNsService_systemOwned(t *testing.T) {
serviceName := "WINS"
testResourceName := "data.nsxt_ns_service.test"

resource.Test(t, resource.TestCase{
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
Expand Down
8 changes: 6 additions & 2 deletions nsxt/data_source_nsxt_policy_certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ func TestAccDataSourceNsxtPolicyCertificate_basic(t *testing.T) {
name := getTestCertificateName(false)
testResourceName := "data.nsxt_policy_certificate.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccEnvDefined(t, "NSXT_TEST_CERTIFICATE_NAME") },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccOnlyLocalManager(t)
testAccPreCheck(t)
testAccEnvDefined(t, "NSXT_TEST_CERTIFICATE_NAME")
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Expand Down
32 changes: 29 additions & 3 deletions nsxt/data_source_nsxt_policy_edge_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,44 @@ func dataSourceNsxtPolicyEdgeCluster() *schema.Resource {
"display_name": getDataSourceDisplayNameSchema(),
"description": getDataSourceDescriptionSchema(),
"path": getPathSchema(),
"site_path": {
Type: schema.TypeString,
Description: "Path of the site this Edge cluster belongs to",
Optional: true,
ValidateFunc: validatePolicyPath(),
},
},
}
}

func dataSourceNsxtPolicyEdgeClusterRead(d *schema.ResourceData, m interface{}) error {
// Read an edge cluster by name or id
connector := getPolicyConnector(m)
client := enforcement_points.NewDefaultEdgeClustersClient(connector)
objSitePath := d.Get("site_path").(string)

objID := d.Get("id").(string)
objName := d.Get("display_name").(string)

if !isPolicyGlobalManager(m) && objSitePath != "" {
return globalManagerOnlyError()
}
if isPolicyGlobalManager(m) {
if objSitePath == "" {
return attributeRequiredGlobalManagerError("site_path", "nsxt_policy_edge_cluster")
}

query := make(map[string]string)
globalPolicyEnforcementPointPath := getGlobalPolicyEnforcementPointPath(m, &objSitePath)
query["parent_path"] = globalPolicyEnforcementPointPath
_, err := policyDataSourceResourceReadWithValidation(d, getPolicyConnector(m), "PolicyEdgeCluster", query, false)
if err != nil {
return err
}
return nil
}

// Local manager
connector := getPolicyConnector(m)
client := enforcement_points.NewDefaultEdgeClustersClient(connector)
var obj model.PolicyEdgeCluster
if objID != "" {
// Get by id
Expand Down Expand Up @@ -74,7 +101,6 @@ func dataSourceNsxtPolicyEdgeClusterRead(d *schema.ResourceData, m interface{})
return fmt.Errorf("edge cluster '%s' was not found", objName)
}
}

d.SetId(*obj.Id)
d.Set("display_name", obj.DisplayName)
d.Set("description", obj.Description)
Expand Down
22 changes: 20 additions & 2 deletions nsxt/data_source_nsxt_policy_edge_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ func TestAccDataSourceNsxtPolicyEdgeCluster_basic(t *testing.T) {
edgeClusterName := getEdgeClusterName()
testResourceName := "data.nsxt_policy_edge_cluster.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
testAccNSXGlobalManagerSitePrecheck(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Expand All @@ -32,12 +35,27 @@ func TestAccDataSourceNsxtPolicyEdgeCluster_basic(t *testing.T) {
}

func testAccNsxtPolicyEdgeClusterReadTemplate(name string) string {
if testAccIsGlobalManager() {
return testAccNsxtGlobalPolicyEdgeClusterReadTemplate(name)
}
return fmt.Sprintf(`
data "nsxt_policy_edge_cluster" "test" {
display_name = "%s"
}`, name)
}

func testAccNsxtGlobalPolicyEdgeClusterReadTemplate(name string) string {
return fmt.Sprintf(`
data "nsxt_policy_site" "test" {
display_name = "%s"
}

data "nsxt_policy_edge_cluster" "test" {
display_name = "%s"
site_path = data.nsxt_policy_site.test.path
}`, getTestSiteName(), name)
}

func testAccNsxtPolicyNoEdgeClusterTemplate() string {
return fmt.Sprintf(` `)
}
32 changes: 25 additions & 7 deletions nsxt/data_source_nsxt_policy_edge_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/infra/sites/enforcement_points/edge_clusters"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model"
"strconv"
"strings"
)

Expand All @@ -34,17 +35,31 @@ func dataSourceNsxtPolicyEdgeNode() *schema.Resource {

func dataSourceNsxtPolicyEdgeNodeRead(d *schema.ResourceData, m interface{}) error {
// Read an edge node by name or id
edgeClusterPath := d.Get("edge_cluster_path").(string)
// Note - according to the documentation GetOkExists should be used
// for bool types, but in this case it works and GetOk doesn't
memberIndex, memberIndexSet := d.GetOkExists("member_index")

if isPolicyGlobalManager(m) {
query := make(map[string]string)
query["parent_path"] = edgeClusterPath
if memberIndexSet {
query["member_index"] = strconv.Itoa(memberIndex.(int))
}
_, err := policyDataSourceResourceReadWithValidation(d, getPolicyConnector(m), "PolicyEdgeNode", query, false)
if err != nil {
return err
}
return nil
}

// Local manager
connector := getPolicyConnector(m)
client := edge_clusters.NewDefaultEdgeNodesClient(connector)

edgeClusterPath := d.Get("edge_cluster_path").(string)
var obj model.PolicyEdgeNode
edgeClusterID := getPolicyIDFromPath(edgeClusterPath)
objID := d.Get("id").(string)
name, nameSet := d.GetOk("display_name")
objName := name.(string)
memberIndex, memberIndexSet := d.GetOk("member_index")
objMemberIndex := int64(memberIndex.(int))
var obj model.PolicyEdgeNode

if objID != "" {
// Get by id
objGet, err := client.Get(defaultSite, getPolicyEnforcementPoint(m), edgeClusterID, objID)
Expand All @@ -55,6 +70,9 @@ func dataSourceNsxtPolicyEdgeNodeRead(d *schema.ResourceData, m interface{}) err
obj = objGet
} else {
// Get by full name/prefix
name, nameSet := d.GetOk("display_name")
objName := name.(string)
objMemberIndex := int64(memberIndex.(int))
includeMarkForDeleteObjectsParam := false
objList, err := client.List(defaultSite, getPolicyEnforcementPoint(m), edgeClusterID, nil, &includeMarkForDeleteObjectsParam, nil, nil, nil, nil)
if err != nil {
Expand Down
17 changes: 9 additions & 8 deletions nsxt/data_source_nsxt_policy_edge_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ func TestAccDataSourceNsxtPolicyEdgeNode_basic(t *testing.T) {
edgeClusterName := getEdgeClusterName()
testResourceName := "data.nsxt_policy_edge_node.test"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
testAccNSXGlobalManagerSitePrecheck(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Expand All @@ -33,14 +36,12 @@ func TestAccDataSourceNsxtPolicyEdgeNode_basic(t *testing.T) {
}

func testAccNsxtPolicyEdgeNodeReadTemplate(name string) string {
return fmt.Sprintf(`
data "nsxt_policy_edge_cluster" "test" {
display_name = "%s"
}
return testAccNsxtPolicyEdgeClusterReadTemplate(name) + fmt.Sprintf(`

data "nsxt_policy_edge_node" "test" {
edge_cluster_path = data.nsxt_policy_edge_cluster.test.path
member_index = 0
}`, name)
member_index = 0
}`)
}

func testAccNsxtPolicyNoEdgeNodeTemplate() string {
Expand Down
7 changes: 7 additions & 0 deletions nsxt/data_source_nsxt_policy_gateway_qos_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ func dataSourceNsxtPolicyGatewayQosProfile() *schema.Resource {
}

func dataSourceNsxtPolicyGatewayQosProfileRead(d *schema.ResourceData, m interface{}) error {
if isPolicyGlobalManager(m) {
_, err := policyDataSourceResourceRead(d, getPolicyConnector(m), "GatewayQosProfile", nil)
if err != nil {
return err
}
return nil
}
connector := getPolicyConnector(m)
client := infra.NewDefaultGatewayQosProfilesClient(connector)

Expand Down
Loading