Skip to content

Commit

Permalink
Merge pull request #358 from terraform-providers/federation_rebase
Browse files Browse the repository at this point in the history
Federation rebase
  • Loading branch information
annakhm authored Jun 16, 2020
2 parents 3233ece + 63e7611 commit aa5b2c9
Show file tree
Hide file tree
Showing 958 changed files with 169,790 additions and 8,003 deletions.
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

0 comments on commit aa5b2c9

Please sign in to comment.