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

V4 design 2.0 sdk fixes #700

Merged
merged 9 commits into from
Dec 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

const dataSourceNameClusters = "data.nutanix_clusters_v2.test"

func TestAccNutanixClustersV2DataSource_basic(t *testing.T) {
func TestAccV2NutanixClustersDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand All @@ -24,7 +24,7 @@ func TestAccNutanixClustersV2DataSource_basic(t *testing.T) {
})
}

func TestAccNutanixClustersV2DataSource_filter(t *testing.T) {
func TestAccV2NutanixClustersDataSource_filter(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand All @@ -40,7 +40,7 @@ func TestAccNutanixClustersV2DataSource_filter(t *testing.T) {
})
}

func TestAccNutanixClustersV2DataSource_limit(t *testing.T) {
func TestAccV2NutanixClustersDataSource_limit(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

const dataSourceNameCluster = "data.nutanix_cluster_v2.test"

func TestAccNutanixClusterV2DataSource_basic(t *testing.T) {
func TestAccV2NutanixClusterDataSource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

const datasourceNameHostEntities = "data.nutanix_hosts_v2.test"

func TestAccNutanixHostEntitiesV2Datasource_Basic(t *testing.T) {
func TestAccV2NutanixHostEntitiesDatasource_Basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand All @@ -25,7 +25,7 @@ func TestAccNutanixHostEntitiesV2Datasource_Basic(t *testing.T) {
})
}

func TestAccNutanixHostEntitiesV2Datasource_WithLimit(t *testing.T) {
func TestAccV2NutanixHostEntitiesDatasource_WithLimit(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package clustersv2

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -356,7 +355,6 @@ func DatasourceNutanixHostEntityV2Read(ctx context.Context, d *schema.ResourceDa
if err != nil {
return diag.Errorf("error while fetching host entity : %v", err)
}
fmt.Println(resp)

getResp := resp.Data.GetValue().(import1.Host)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

const datasourceNameHostEntity = "data.nutanix_host_v2.test"

func TestAccNutanixHostEntityV2Datasource_Basic(t *testing.T) {
func TestAccV2NutanixHostEntityDatasource_Basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand All @@ -27,7 +27,7 @@ func TestAccNutanixHostEntityV2Datasource_Basic(t *testing.T) {
})
}

func TestAccNutanixHostEntityV2Datasource_WithNoClsExtId(t *testing.T) {
func TestAccV2NutanixHostEntityDatasource_WithNoClsExtId(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand All @@ -40,7 +40,7 @@ func TestAccNutanixHostEntityV2Datasource_WithNoClsExtId(t *testing.T) {
})
}

func TestAccNutanixHostEntityV2Datasource_WithNoHostExtId(t *testing.T) {
func TestAccV2NutanixHostEntityDatasource_WithNoHostExtId(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ func unconfiguredNodeSchemaV2() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"host_name": {
Type: schema.TypeString,
Computed: true,
},
"host_type": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -183,26 +179,14 @@ func unconfiguredNodeSchemaV2() *schema.Resource {
},
},
},
"is_one_node_cluster_supported": {
Type: schema.TypeBool,
Computed: true,
},
"is_secure_booted": {
Type: schema.TypeBool,
Computed: true,
},
"is_two_node_cluster_supported": {
Type: schema.TypeBool,
Computed: true,
},
"node_position": {
Type: schema.TypeString,
Computed: true,
},
"node_serial_number": {
Type: schema.TypeString,
Computed: true,
},
"node_uuid": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -423,25 +407,12 @@ func flattenUnconfiguredNodes(nodeListItems []config.UnconfiguredNodeListItem) [
if v.RackableUnitSerial != nil {
node["rackable_unit_serial"] = *v.RackableUnitSerial
}
// These attributes are not present in the response of GA SDK
// if v.HostName != nil {
// node["host_name"] = *v.HostName
// }
// if v.IsOneNodeClusterSupported != nil {
// node["is_one_node_cluster_supported"] = *v.IsOneNodeClusterSupported
// }
// if v.IsSecureBooted != nil {
// node["is_secure_booted"] = *v.IsSecureBooted
// }
// if v.IsTwoNodeClusterSupported != nil {
// node["is_two_node_cluster_supported"] = *v.IsTwoNodeClusterSupported
// }
// if v.NodePosition != nil {
// node["node_position"] = *v.NodePosition
// }
// if v.NodeSerialNumber != nil {
// node["node_serial_number"] = *v.NodeSerialNumber
// }
if v.IsSecureBooted != nil {
node["is_secure_booted"] = *v.IsSecureBooted
}
if v.NodePosition != nil {
node["node_position"] = *v.NodePosition
}

nodeList[k] = node
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

const resourceNameDiscoverUnconfiguredNodes = "nutanix_clusters_discover_unconfigured_nodes_v2.test"

func TestAccNutanixClusterDiscoverUnconfiguredNodesV2Resource_basic(t *testing.T) {
func TestAccV2NutanixClusterDiscoverUnconfiguredNodesResource_basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package clustersv2_test

import (
"encoding/json"
"fmt"
"testing"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
acc "github.com/terraform-providers/terraform-provider-nutanix/nutanix/acctest"
)

Expand All @@ -20,7 +18,7 @@ const (
resourceName3NodesCluster = "nutanix_cluster_v2.cluster-3nodes"
)

func TestAccNutanixClusterAddNodeV2Resource_basic(t *testing.T) {
func TestAccV2NutanixClusterAddNodeResource_Basic(t *testing.T) {
r := acctest.RandInt()
clusterName := fmt.Sprintf("tf-3node-cluster-%d", r)

Expand All @@ -32,14 +30,6 @@ func TestAccNutanixClusterAddNodeV2Resource_basic(t *testing.T) {
Config: testAccClustersConfig(clusterName),
Check: resource.ComposeTestCheckFunc(
// add node to cluster check
func(s *terraform.State) error {
aJSON, _ := json.MarshalIndent(s.RootModule().Resources[resourceName3NodesCluster].Primary.Attributes, "", " ")
fmt.Println("############################################")
fmt.Printf("Resource Attributes: \n%v", string(aJSON))
fmt.Println("############################################")

return nil
},
// unconfigured Nodes check
resource.TestCheckResourceAttr(resourceNameDiscoverUnconfiguredClusterNodes, "unconfigured_nodes.#", "3"),

Expand All @@ -63,16 +53,6 @@ func TestAccNutanixClusterAddNodeV2Resource_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceNameFetchUnconfiguredNodeNetwork, "nodes_networking_details.#", "1"),
resource.TestCheckResourceAttrSet(resourceNameFetchUnconfiguredNodeNetwork, "nodes_networking_details.0.network_info.#"),
resource.TestCheckResourceAttrSet(resourceNameFetchUnconfiguredNodeNetwork, "nodes_networking_details.0.uplinks.#"),

// add node to cluster check
func(s *terraform.State) error {
aJSON, _ := json.MarshalIndent(s.RootModule().Resources[resourceNameAddNodeToCluster].Primary.Attributes, "", " ")
fmt.Println("############################################")
fmt.Printf("Resource Attributes: \n%v", string(aJSON))
fmt.Println("############################################")

return nil
},
),
},
{
Expand Down
Loading
Loading