Skip to content

Commit

Permalink
Feat/1.8.0-beta.1 Release with Nutanix Database Service based resourc…
Browse files Browse the repository at this point in the history
…es and datasources (nutanix#501)

Co-authored-by: Abhishekism9450 <[email protected]>
Co-authored-by: Abhishek Chaudhary <[email protected]>
  • Loading branch information
3 people authored Oct 12, 2022
1 parent a8f9268 commit abdd924
Show file tree
Hide file tree
Showing 46 changed files with 8,059 additions and 11 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## 1.8.0-beta.1 (Oct 12, 2022)

[Full Changelog](https://github.com/nutanix/terraform-provider-nutanix/compare/v1.7.1...v1.8.0-beta.1)

**New Feature:**

- Feat/1.8.0-beta.1 Release with Nutanix Database Service based resources and datasources [\#501] (https://github.com/nutanix/terraform-provider-nutanix/pull/501)

New Data Sources :
- nutanix_ndb_cluster
- nutanix_ndb_clusters
- nutanix_ndb_database
- nutanix_ndb_databases
- nutanix_ndb_profile
- nutanix_ndb_profiles
- nutanix_ndb_sla
- nutanix_ndb_slas

New Resources :
- nutanix_ndb_database

## 1.7.1 (August 31, 2022)
[Full Changelog](https://github.com/nutanix/terraform-provider-nutanix/compare/v1.7.0...v1.7.1)

Expand Down
34 changes: 32 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.7.1](https://github.com/nutanix/terraform-provider-nutanix/releases/tag/v1.7.1)
NOTE: The latest version of the Nutanix provider is [v1.8.0-beta.1](https://github.com/nutanix/terraform-provider-nutanix/releases/tag/v1.8.0-beta.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 @@ -72,6 +72,13 @@ Foundation Central based examples : https://github.com/nutanix/terraform-provide

Foundation Central based modules and examples : Foundation based modules & examples : https://github.com/nutanix/terraform-provider-nutanix/blob/master/modules/foundationCentral/

## Nutanix Database Service
> For the 1.8.0-beta.1 release of the provider, it will have N-1 compatibility with the Nutanix database service. This release was tested with v2.4 and v2.4.1 versions.
Note: For 1.8.0-beta.1 release, only postgress database type is qualified and officially supported.

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

## Example Usage

See the Examples folder for a handful of main.tf demos as well as some pre-compiled binaries.
Expand Down Expand Up @@ -128,11 +135,25 @@ provider "nutanix" {
}
```

## Additional fields for using Nutanix Database Service:

* **ndb_username** - (Optional) Username of Nutanix Database Service server
* **ndb_password** - (Optional) Password of Nutanix Database Service server
* **ndb_endpoint** - (Optional) IP of Nutanix Database Service server

```hcl
provider "nutanix" {
ndb_username = var.ndb_username
ndb_password = var.ndb_password
ndb_endpoint = var.ndb_endpoint
}
```

### Provider Configuration Requirements & Warnings
From foundation getting released in 1.5.0-beta, provider configuration will accomodate prism central and foundation apis connection details. **It will show warnings for disabled api connections as per the attributes given in provider configuration in above mentioned format**. The below are the required attributes for corresponding provider componenets :
* endpoint, username and password are required fields for using Prism Central & Karbon based resources and data sources
* foundation_endpoint is required field for using Foundation based resources and data sources

* ndb_username, ndb_password and ndb_endpoint are required fields for using NDB based resources and data sources
## Resources

* nutanix_access_control_policy
Expand Down Expand Up @@ -161,6 +182,7 @@ From foundation getting released in 1.5.0-beta, provider configuration will acco
* nutanix_static_routes
* nutanix_floating_ip
* nutanix_user_groups
* nutanix_ndb_database

## Data Sources

Expand Down Expand Up @@ -215,6 +237,14 @@ From foundation getting released in 1.5.0-beta, provider configuration will acco
* nutanix_floating_ip
* nutanix_floating_ips
* nutanix_static_routes
* nutanix_ndb_cluster
* nutanix_ndb_clusters
* nutanix_ndb_database
* nutanix_ndb_databases
* nutanix_ndb_profile
* nutanix_ndb_profiles
* nutanix_ndb_sla
* nutanix_ndb_slas

## Quick Install

Expand Down
3 changes: 3 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ type Credentials struct {
FoundationEndpoint string // Required field for connecting to foundation VM APIs
FoundationPort string // Port for connecting to foundation VM APIs
RequiredFields map[string][]string // RequiredFields is client to its required fields mapping for validations and usage in every client
NdbEndpoint string // Required field for connecting to Era VM APIs.
NdbUsername string
NdbPassword string
}

// AdditionalFilter specification for client side filters
Expand Down
16 changes: 8 additions & 8 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ func setup() (*http.ServeMux, *Client, *httptest.Server) {
mux := http.NewServeMux()
server := httptest.NewServer(mux)

client, _ := NewClient(&Credentials{"", "username", "password", "", "", true, false, "", "", "", nil}, testUserAgent, testAbsolutePath, false)
client, _ := NewClient(&Credentials{"", "username", "password", "", "", true, false, "", "", "", nil, "", "", ""}, testUserAgent, testAbsolutePath, false)
client.BaseURL, _ = url.Parse(server.URL)

return mux, client, server
}

func TestNewClient(t *testing.T) {
c, err := NewClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil}, testUserAgent, testAbsolutePath, false)
c, err := NewClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil, "", "", ""}, testUserAgent, testAbsolutePath, false)

if err != nil {
t.Errorf("Unexpected Error: %v", err)
Expand All @@ -52,7 +52,7 @@ func TestNewClient(t *testing.T) {
}

func TestNewBaseClient(t *testing.T) {
c, err := NewBaseClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil}, testAbsolutePath, true)
c, err := NewBaseClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil, "", "", ""}, testAbsolutePath, true)
if err != nil {
t.Errorf("Unexpected Error: %v", err)
}
Expand All @@ -69,7 +69,7 @@ func TestNewBaseClient(t *testing.T) {
}

func TestNewRequest(t *testing.T) {
c, err := NewClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil}, testUserAgent, testAbsolutePath, false)
c, err := NewClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil, "", "", ""}, testUserAgent, testAbsolutePath, false)

if err != nil {
t.Errorf("Unexpected Error: %v", err)
Expand All @@ -93,7 +93,7 @@ func TestNewRequest(t *testing.T) {
}

func TestNewUploadRequest(t *testing.T) {
c, err := NewClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil}, testUserAgent, testAbsolutePath, true)
c, err := NewClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil, "", "", ""}, testUserAgent, testAbsolutePath, true)

if err != nil {
t.Errorf("Unexpected Error: %v", err)
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestNewUploadRequest(t *testing.T) {
}

func TestNewUnAuthRequest(t *testing.T) {
c, err := NewClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil}, testUserAgent, testAbsolutePath, true)
c, err := NewClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil, "", "", ""}, testUserAgent, testAbsolutePath, true)

if err != nil {
t.Errorf("Unexpected Error: %v", err)
Expand Down Expand Up @@ -176,7 +176,7 @@ func TestNewUnAuthRequest(t *testing.T) {
}

func TestNewUnAuthFormEncodedRequest(t *testing.T) {
c, err := NewClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil}, testUserAgent, testAbsolutePath, true)
c, err := NewClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil, "", "", ""}, testUserAgent, testAbsolutePath, true)

if err != nil {
t.Errorf("Unexpected Error: %v", err)
Expand Down Expand Up @@ -219,7 +219,7 @@ func TestNewUnAuthFormEncodedRequest(t *testing.T) {
}

func TestNewUnAuthUploadRequest(t *testing.T) {
c, err := NewClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil}, testUserAgent, testAbsolutePath, true)
c, err := NewClient(&Credentials{"foo.com", "username", "password", "", "", true, false, "", "", "", nil, "", "", ""}, testUserAgent, testAbsolutePath, true)

if err != nil {
t.Errorf("Unexpected Error: %v", err)
Expand Down
49 changes: 49 additions & 0 deletions client/era/era.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package era

import (
"fmt"
"strings"

"github.com/terraform-providers/terraform-provider-nutanix/client"
)

const (
libraryVersion = "v0.9"
absolutePath = "era/" + libraryVersion
clientName = "ndb"
)

type Client struct {
client *client.Client
Service Service
}

func NewEraClient(credentials client.Credentials) (*Client, error) {
var baseClient *client.Client

// check if all required fields are present. Else create an empty client
if credentials.NdbUsername != "" && credentials.NdbPassword != "" && credentials.NdbEndpoint != "" {
credentials.URL = fmt.Sprintf(credentials.NdbEndpoint)
credentials.Password = credentials.NdbPassword
credentials.Username = credentials.NdbUsername

c, err := client.NewBaseClient(&credentials, absolutePath, false)
if err != nil {
return nil, err
}
baseClient = c
} else {
errorMsg := fmt.Sprintf("NDB Client is missing. "+
"Please provide required details - %s in provider configuration.", strings.Join(credentials.RequiredFields[clientName], ", "))

baseClient = &client.Client{ErrorMsg: errorMsg}
}

era := &Client{
client: baseClient,
Service: ServiceClient{
c: baseClient,
},
}
return era, nil
}
Loading

0 comments on commit abdd924

Please sign in to comment.