Skip to content

Commit

Permalink
Feat/1.8.1 (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishekism9450 authored Apr 18, 2023
1 parent 5e3f83a commit 3ceb4bd
Show file tree
Hide file tree
Showing 54 changed files with 870 additions and 82 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## 1.8.1 (April 18, 2023)
[Full Changelog](https://github.com/nutanix/terraform-provider-nutanix/compare/feat/1.8.0-ga...feat/1.8.1)

**New Feature:**
- Added a datasource for NDB network available ips. [\#570](https://github.com/nutanix/terraform-provider-nutanix/pull/570)

New Data Source :
- nutanix_ndb_network_available_ips

**Implemented enhancements:**
- Handling the case if ndb cluster id is given wrong. [\#571](https://github.com/nutanix/terraform-provider-nutanix/pull/571)
- Support for imports on ndb day-2 actions. [\#561](https://github.com/nutanix/terraform-provider-nutanix/pull/561)
- Changing the provider version in ndb examples from beta to ga. [\#580](https://github.com/nutanix/terraform-provider-nutanix/pull/580)

**Fixed bugs:**
- Tf ntnx provider crash for wrong ndb cluster id. [\#567](https://github.com/nutanix/terraform-provider-nutanix/issues/567)
- lcm_config should be Set without plugin crash in clone resource. [\#583](https://github.com/nutanix/terraform-provider-nutanix/issues/583)

**Closed issues:**
- NDB datasource for network available ips. [\#569](https://github.com/nutanix/terraform-provider-nutanix/issues/569)
- Support for adding import on ndb day2 actions. [\#582](https://github.com/nutanix/terraform-provider-nutanix/issues/582)
- How to configure IP address for Nutanix Packer images. [\#576](https://github.com/nutanix/terraform-provider-nutanix/issues/576)


## 1.8.0 (Feb 23, 2023)
[Full Changelog](https://github.com/nutanix/terraform-provider-nutanix/compare/feat/v1.8.0-beta-2...feat/1.8.0-ga)

Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Terraform provider plugin to integrate with Nutanix Enterprise Cloud

NOTE: The latest version of the Nutanix provider is [v1.8.0-beta.2](https://github.com/nutanix/terraform-provider-nutanix/releases/tag/v1.8.0-beta.2)
NOTE: The latest version of the Nutanix provider is [v1.8.1](https://github.com/nutanix/terraform-provider-nutanix/releases/tag/v1.8.1)

Modules based on Terraform Nutanix Provider can be found here : [Modules](https://github.com/nutanix/terraform-provider-nutanix/tree/master/modules)
## Build, Quality Status
Expand Down Expand Up @@ -79,7 +79,9 @@ Foundation Central based modules and examples : Foundation based modules & examp
> For the 1.8.0 release of the provider, it will have N-2 compatibility with the Nutanix database service. This release was tested with v2.5.1.1, v2.5.1 and v2.5 versions.
Note: For 1.8.0 release, only postgress database type is qualified and officially supported. Older versions of NDB may not support some resources.
> For the 1.8.1 release of the provider, it will have N-2 compatibility with the Nutanix database service. This release was tested with v2.5.1.1, v2.5.1 and v2.5 versions.
Note: For NDB related modules, only postgress database type is qualified and officially supported. Older versions of NDB may not support some resources.

Checkout example : https://github.com/nutanix/terraform-provider-nutanix/blob/master/examples/ndb/

Expand Down Expand Up @@ -285,6 +287,7 @@ From foundation getting released in 1.5.0-beta, provider configuration will acco
* nutanix_ndb_networks
* nutanix_ndb_maintenance_window
* nutanix_ndb_maintenance_windows
* nutanix_ndb_network_available_ips

## Quick Install

Expand Down
38 changes: 30 additions & 8 deletions client/era/era_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ type Service interface {
UpdateTimeMachineCluster(ctx context.Context, tmsID string, clsID string, body *TmsClusterIntentInput) (*TmsClusterResponse, error)
DeleteTimeMachineCluster(ctx context.Context, tmsID string, clsID string, body *DeleteTmsClusterInput) (*ProvisionDatabaseResponse, error)
CreateTags(ctx context.Context, body *CreateTagsInput) (*TagsIntentResponse, error)
ReadTags(ctx context.Context, id string) (*GetTagsResponse, error)
ReadTags(ctx context.Context, id string, name string) (*GetTagsResponse, error)
UpdateTags(ctx context.Context, body *GetTagsResponse, id string) (*GetTagsResponse, error)
DeleteTags(ctx context.Context, id string) (*string, error)
ListTags(ctx context.Context) (*ListTagsResponse, error)
ListTags(ctx context.Context, entityType string) (*ListTagsResponse, error)
CreateNetwork(ctx context.Context, body *NetworkIntentInput) (*NetworkIntentResponse, error)
GetNetwork(ctx context.Context, id string, name string) (*NetworkIntentResponse, error)
UpdateNetwork(ctx context.Context, body *NetworkIntentInput, id string) (*NetworkIntentResponse, error)
Expand All @@ -91,6 +91,7 @@ type Service interface {
CreateCluster(ctx context.Context, body *ClusterIntentInput) (*ProvisionDatabaseResponse, error)
UpdateCluster(ctx context.Context, req *ClusterUpdateInput, id string) (*ListClusterResponse, error)
DeleteCluster(ctx context.Context, req *DeleteClusterInput, id string) (*ProvisionDatabaseResponse, error)
GetAvailableIPs(ctx context.Context, id string) (*GetNetworkAvailableIPs, error)
}

type ServiceClient struct {
Expand Down Expand Up @@ -317,7 +318,7 @@ func (sc ServiceClient) GetOperation(req GetOperationRequest) (*GetOperationResp
}

func (sc ServiceClient) GetDatabaseInstance(ctx context.Context, dbInstanceID string) (*GetDatabaseResponse, error) {
httpReq, err := sc.c.NewRequest(ctx, http.MethodGet, fmt.Sprintf("/databases/%s?detailed=false&load-dbserver-cluster=false", dbInstanceID), nil)
httpReq, err := sc.c.NewRequest(ctx, http.MethodGet, fmt.Sprintf("/databases/%s?detailed=true&load-dbserver-cluster=false", dbInstanceID), nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -759,8 +760,16 @@ func (sc ServiceClient) CreateTimeMachineCluster(ctx context.Context, tmsID stri
return res, sc.c.Do(ctx, httpReq, res)
}

func (sc ServiceClient) ReadTags(ctx context.Context, id string) (*GetTagsResponse, error) {
httpReq, err := sc.c.NewRequest(ctx, http.MethodGet, fmt.Sprintf("/tags?id=%s", id), nil)
func (sc ServiceClient) ReadTags(ctx context.Context, id, name string) (*GetTagsResponse, error) {
path := "/tags"
if id != "" {
path += fmt.Sprintf("?id=%s", id)
}
if name != "" {
path += fmt.Sprintf("?name=%s", name)
}

httpReq, err := sc.c.NewRequest(ctx, http.MethodGet, path, nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -898,8 +907,12 @@ func (sc ServiceClient) DeleteNetwork(ctx context.Context, id string) (*string,
return res, sc.c.Do(ctx, httpReq, res)
}

func (sc ServiceClient) ListTags(ctx context.Context) (*ListTagsResponse, error) {
httpReq, err := sc.c.NewRequest(ctx, http.MethodGet, "/tags", nil)
func (sc ServiceClient) ListTags(ctx context.Context, entityType string) (*ListTagsResponse, error) {
path := "/tags"
if entityType != "" {
path += fmt.Sprintf("?entityType=%s", entityType)
}
httpReq, err := sc.c.NewRequest(ctx, http.MethodGet, path, nil)
if err != nil {
return nil, err
}
Expand All @@ -909,7 +922,7 @@ func (sc ServiceClient) ListTags(ctx context.Context) (*ListTagsResponse, error)
}

func (sc ServiceClient) ListNetwork(ctx context.Context) (*ListNetworkResponse, error) {
httpReq, err := sc.c.NewRequest(ctx, http.MethodGet, "/resources/networks", nil)
httpReq, err := sc.c.NewRequest(ctx, http.MethodGet, "/resources/networks?detailed=true", nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1057,3 +1070,12 @@ func (sc ServiceClient) UpdateCluster(ctx context.Context, req *ClusterUpdateInp
res := new(ListClusterResponse)
return res, sc.c.Do(ctx, httpReq, res)
}

func (sc ServiceClient) GetAvailableIPs(ctx context.Context, id string) (*GetNetworkAvailableIPs, error) {
httpReq, err := sc.c.NewRequest(ctx, http.MethodGet, fmt.Sprintf("/profiles/%s/get-available-ips", id), nil)
if err != nil {
return nil, err
}
res := new(GetNetworkAvailableIPs)
return res, sc.c.Do(ctx, httpReq, res)
}
18 changes: 16 additions & 2 deletions client/era/era_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1598,8 +1598,10 @@ type GetTagsResponse struct {

type ListTagsResponse []*GetTagsResponse
type IPAddresses struct {
IP *string `json:"ip,omitempty"`
Status *string `json:"status,omitempty"`
IP *string `json:"ip,omitempty"`
Status *string `json:"status,omitempty"`
DBServerID *string `json:"dbserverID,omitempty"`
DBServerName *string `json:"dbserverName,omitempty"`
}

type IPPools struct {
Expand Down Expand Up @@ -1635,6 +1637,7 @@ type NetworkIntentResponse struct {
PropertiesMap *NetworkPropertiesmap `json:"propertiesMap,omitempty"`
StretchedVlanID *string `json:"stretchedVlanId,omitempty"`
IPPools []*IPPools `json:"ipPools,omitempty"`
IPAddresses []*IPAddresses `json:"ipAddresses,omitempty"`
}

type ListNetworkResponse []*NetworkIntentResponse
Expand Down Expand Up @@ -1969,3 +1972,14 @@ type ClusterUpdateInput struct {
Description *string `json:"description,omitempty"`
IPAddresses []*string `json:"ipAddresses,omitempty"`
}

type GetNetworkAvailableIPs []struct {
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
PropertyName *string `json:"propertyName,omitempty"`
Type *string `json:"type,omitempty"`
ClusterID *string `json:"clusterId,omitempty"`
ClusterName *string `json:"clusterName,omitempty"`
IPAddresses []*string `json:"ipAddresses,omitempty"`
Managed bool `json:"managed,omitempty"`
}
2 changes: 1 addition & 1 deletion examples/ndb/database_instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform{
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "1.8.0-beta.2"
version = "1.8.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ndb/database_restore/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform{
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "1.8.0-beta.2"
version = "1.8.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ndb/linked_databases/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform{
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "1.8.0-beta.2"
version = "1.8.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ndb/profiles/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform{
required_providers {
nutanix = {
source = "nutanix/nutanix"
version = "1.8.0-beta.2"
version = "1.8.0"
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions nutanix/common_schema_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
)

var requiredResourceFields map[string][]string = map[string][]string{
"era_provision_database": {"databasetype", "softwareprofileid", "softwareprofileversionid", "computeprofileid",
"networkprofileid", "dbparameterprofileid", "nxclusterid", "sshpublickey", "timemachineinfo", "nodes"},
"era_provision_database": {"databasetype", "dbparameterprofileid", "timemachineinfo", "nodes"},
}

func schemaValidation(resourceName string, d *schema.ResourceData) error {
Expand Down
2 changes: 1 addition & 1 deletion nutanix/data_source_nutanix_ndb_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func dataSourceNutanixEraClusterRead(ctx context.Context, d *schema.ResourceData
resp, err := conn.Service.GetCluster(ctx, clusterID.(string), clusterName.(string))

if err != nil {
diag.FromErr(err)
return diag.FromErr(err)
}

if err := d.Set("id", resp.ID); err != nil {
Expand Down
23 changes: 22 additions & 1 deletion nutanix/data_source_nutanix_ndb_cluster_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package nutanix

import (
"regexp"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccEraClusterDataSource_basic(t *testing.T) {
// r := randIntBetween(31, 40)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccEraPreCheck(t) },
Providers: testAccProviders,
Expand Down Expand Up @@ -45,6 +45,19 @@ func TestAccEraClusterDataSource_ByName(t *testing.T) {
})
}

func TestAccEraClusterDataSource_WithWrongID(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccEraPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccEraClusterDataSourceConfigWithWrongID(),
ExpectError: regexp.MustCompile("exit status 1"),
},
},
})
}

func testAccEraClusterDataSourceConfig() string {
return `
data "nutanix_ndb_clusters" "test1" {}
Expand All @@ -66,3 +79,11 @@ func testAccEraClusterDataSourceConfigByName() string {
}
`
}

func testAccEraClusterDataSourceConfigWithWrongID() string {
return `
data "nutanix_ndb_cluster" "test" {
cluster_id = "0000000-0000-0000-0000-00000000000"
}
`
}
89 changes: 89 additions & 0 deletions nutanix/data_source_nutanix_ndb_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
era "github.com/terraform-providers/terraform-provider-nutanix/client/era"
)

func dataSourceNutanixEraNetwork() *schema.Resource {
Expand Down Expand Up @@ -81,6 +82,62 @@ func dataSourceNutanixEraNetwork() *schema.Resource {
},
},
},
"ip_addresses": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ip": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"dbserver_id": {
Type: schema.TypeString,
Computed: true,
},
"dbserver_name": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
"ip_pools": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"start_ip": {
Type: schema.TypeString,
Computed: true,
},
"end_ip": {
Type: schema.TypeString,
Computed: true,
},
"addresses": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"ip": {
Type: schema.TypeString,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
},
},
},
}
}
Expand Down Expand Up @@ -135,6 +192,38 @@ func dataSourceNutanixEraNetworkRead(ctx context.Context, d *schema.ResourceData
d.Set("stretched_vlan_id", resp.StretchedVlanID)
}

if resp.IPAddresses != nil {
d.Set("ip_addresses", flattenIPAddress(resp.IPAddresses))
}
if resp.IPPools != nil {
d.Set("ip_pools", flattenIPPools(resp.IPPools))
}
d.SetId(*resp.ID)
return nil
}

func flattenIPAddress(ips []*era.IPAddresses) []interface{} {
if len(ips) > 0 {
ipList := make([]interface{}, 0)

for _, v := range ips {
ip := map[string]interface{}{}

if v.IP != nil {
ip["ip"] = v.IP
}
if v.Status != nil {
ip["status"] = v.Status
}
if v.DBServerID != nil {
ip["dbserver_id"] = v.DBServerID
}
if v.DBServerName != nil {
ip["dbserver_name"] = v.DBServerName
}
ipList = append(ipList, ip)
}
return ipList
}
return nil
}
Loading

0 comments on commit 3ceb4bd

Please sign in to comment.