Skip to content

Commit

Permalink
Feat/m era ha (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishekism9450 authored Jan 11, 2023
1 parent 1e3c112 commit 7081b2f
Show file tree
Hide file tree
Showing 7 changed files with 860 additions and 128 deletions.
2 changes: 1 addition & 1 deletion client/era/era_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,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=true&load-dbserver-cluster=true", dbInstanceID), nil)
httpReq, err := sc.c.NewRequest(ctx, http.MethodGet, fmt.Sprintf("/databases/%s?detailed=false&load-dbserver-cluster=false", dbInstanceID), nil)
if err != nil {
return nil, err
}
Expand Down
120 changes: 71 additions & 49 deletions client/era/era_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,47 +232,69 @@ type Dailyschedule struct {
}

type Schedule struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
UniqueName string `json:"uniqueName"`
OwnerID string `json:"ownerId"`
SystemPolicy bool `json:"systemPolicy"`
GlobalPolicy bool `json:"globalPolicy"`
Datecreated string `json:"dateCreated"`
Datemodified string `json:"dateModified"`
Snapshottimeofday *Snapshottimeofday `json:"snapshotTimeOfDay"`
Continuousschedule *Continuousschedule `json:"continuousSchedule"`
Weeklyschedule *Weeklyschedule `json:"weeklySchedule"`
Dailyschedule *Dailyschedule `json:"dailySchedule"`
Monthlyschedule *Monthlyschedule `json:"monthlySchedule"`
Quartelyschedule *Quartelyschedule `json:"quartelySchedule"`
Yearlyschedule *Yearlyschedule `json:"yearlySchedule"`
ReferenceCount int `json:"referenceCount"`
StartTime string `json:"startTime"`
TimeZone string `json:"timeZone"`
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
UniqueName *string `json:"uniqueName,omitempty"`
OwnerID *string `json:"ownerId,omitempty"`
StartTime *string `json:"startTime,omitempty"`
TimeZone *string `json:"timeZone,omitempty"`
Datecreated *string `json:"dateCreated,omitempty"`
Datemodified *string `json:"dateModified,omitempty"`
ReferenceCount *int `json:"referenceCount,omitempty"`
SystemPolicy bool `json:"systemPolicy,omitempty"`
GlobalPolicy bool `json:"globalPolicy,omitempty"`
Snapshottimeofday *Snapshottimeofday `json:"snapshotTimeOfDay,omitempty"`
Continuousschedule *Continuousschedule `json:"continuousSchedule,omitempty"`
Weeklyschedule *Weeklyschedule `json:"weeklySchedule,omitempty"`
Dailyschedule *Dailyschedule `json:"dailySchedule,omitempty"`
Monthlyschedule *Monthlyschedule `json:"monthlySchedule,omitempty"`
Quartelyschedule *Quartelyschedule `json:"quartelySchedule,omitempty"`
Yearlyschedule *Yearlyschedule `json:"yearlySchedule,omitempty"`
}

type PrimarySLA struct {
SLAID *string `json:"slaId,omitempty"`
NxClusterIds []*string `json:"nxClusterIds,omitempty"`
}

type SLADetails struct {
PrimarySLA *PrimarySLA `json:"primarySla,omitempty"`
}

type Timemachineinfo struct {
Name string `json:"name"`
Description string `json:"description"`
Slaid string `json:"slaId"`
Schedule Schedule `json:"schedule"`
Tags []*Tags `json:"tags,omitempty"`

Autotunelogdrive bool `json:"autoTuneLogDrive"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Slaid string `json:"slaId,omitempty"`
Schedule Schedule `json:"schedule,omitempty"`
Tags []*Tags `json:"tags,omitempty"`
Autotunelogdrive bool `json:"autoTuneLogDrive,omitempty"`
SLADetails *SLADetails `json:"slaDetails,omitempty"`
}

type Actionarguments struct {
Name string `json:"name"`
Value interface{} `json:"value"`
}

type NodesProperties struct {
Name string `json:"name"`
Value interface{} `json:"value"`
}

type IPInfos struct {
IPType *string `json:"ipType,omitempty"`
IPAddresses []*string `json:"ipAddresses,omitempty"`
}

type Nodes struct {
Properties []interface{} `json:"properties"`
Vmname string `json:"vmName,omitempty"`
Networkprofileid string `json:"networkProfileId,omitempty"`
DatabaseServerID string `json:"dbserverId,omitempty"`
Properties []*NodesProperties `json:"properties"`
Vmname *string `json:"vmName,omitempty"`
Networkprofileid *string `json:"networkProfileId,omitempty"`
DatabaseServerID *string `json:"dbserverId,omitempty"`
NxClusterID *string `json:"nxClusterId,omitempty"`
ComputeProfileID *string `json:"computeProfileId,omitempty"`
IPInfos []*IPInfos `json:"ipInfos,omitempty"`
}

// ProvisionDatabaseResponse structs
Expand Down Expand Up @@ -831,25 +853,25 @@ type Protectiondomain struct {
AssocEntities []string `json:"assocEntities,omitempty"`
}
type Databasenodes struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Ownerid string `json:"ownerId"`
Datecreated string `json:"dateCreated"`
Datemodified string `json:"dateModified"`
AccessLevel interface{} `json:"accessLevel,omitempty"`
Properties []interface{} `json:"properties"`
Tags []*Tags `json:"tags"`
Databaseid string `json:"databaseId"`
Status string `json:"status"`
Databasestatus string `json:"databaseStatus"`
Primary bool `json:"primary"`
Dbserverid string `json:"dbserverId"`
Softwareinstallationid string `json:"softwareInstallationId"`
Protectiondomainid string `json:"protectionDomainId"`
Info Info `json:"info"`
Metadata interface{} `json:"metadata"`
Protectiondomain *Protectiondomain `json:"protectionDomain"`
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Ownerid string `json:"ownerId"`
Datecreated string `json:"dateCreated"`
Datemodified string `json:"dateModified"`
AccessLevel interface{} `json:"accessLevel,omitempty"`
Properties []*DBInstanceProperties `json:"properties"`
Tags []*Tags `json:"tags"`
Databaseid string `json:"databaseId"`
Status string `json:"status"`
Databasestatus string `json:"databaseStatus"`
Primary bool `json:"primary"`
Dbserverid string `json:"dbserverId"`
Softwareinstallationid string `json:"softwareInstallationId"`
Protectiondomainid string `json:"protectionDomainId"`
Info Info `json:"info"`
Metadata interface{} `json:"metadata"`
Protectiondomain *Protectiondomain `json:"protectionDomain"`
// Valideastate bool `json:"validEaState"`
}

Expand Down
170 changes: 170 additions & 0 deletions examples/ndb/database_instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,173 @@ resource "nutanix_ndb_database" "dbp" {
}
}
}


## provision HA instance

resource "nutanix_ndb_database" "dbp" {
// database type
databasetype = "postgres_database"

// database name & descriptio
name = "test-pg-inst-HA-tf"
description = "adding description"

// adding the profiles details
softwareprofileid = "{{ software_profile_id }}"
softwareprofileversionid = "{{ software_profile_version_id }}"
computeprofileid = "{{ compute_profile_id }}"
networkprofileid = "{{ network_profile_id }}"
dbparameterprofileid = "{{ db_parameter_profile_id }}"

// required for HA instance
createdbserver = true
clustered = true

// node count (with haproxy server node)
nodecount= 4

// min required details for provisioning HA instance
postgresql_info{
listener_port = "5432"

database_size= "200"

db_password = "{{ database password}}"

database_names= "testdb1"

ha_instance{
proxy_read_port= "5001"

proxy_write_port = "5000"

cluster_name= "{{ cluster_name }}"

patroni_cluster_name = " {{ patroni_cluster_name }}"
}
}

nxclusterid= "1c42ca25-32f4-42d9-a2bd-6a21f925b725"
sshpublickey= "{{ ssh_public_key }}"

// nodes are required.

// HA proxy node
nodes{
properties{
name = "node_type"
value = "haproxy"
}
vmname = "{{ vm name }}"
nx_cluster_id = "{{ nx_cluster_id }}"
}

// Primary node for read/write ops
nodes{
properties{
name= "role"
value= "Primary"
}
properties{
name= "failover_mode"
value= "Automatic"
}
properties{
name= "node_type"
value= "database"
}

vmname = "{{ name of vm }}"
networkprofileid="{{ network_profile_id }}"
computeprofileid= "{{ compute_profile_id }}"
nx_cluster_id= "{{ nx_cluster_id }}"
}

// secondary nodes for read ops
nodes{
properties{
name= "role"
value= "Secondary"
}
properties{
name= "failover_mode"
value= "Automatic"
}
properties{
name= "node_type"
value= "database"
}
vmname = "{{ name of vm }}"
networkprofileid="{{ network_profile_id }}"
computeprofileid= "{{ compute_profile_id }}"
nx_cluster_id= "{{ nx_cluster_id }}"
}
nodes{
properties{
name= "role"
value= "Secondary"
}
properties{
name= "failover_mode"
value= "Automatic"
}
properties{
name= "node_type"
value= "database"
}

vmname = "{{ name of vm }}"
networkprofileid="{{ network_profile_id }}"
computeprofileid= "{{ compute_profile_id }}"
nx_cluster_id= "{{ nx_cluster_id }}"
}

// time machine required
timemachineinfo {
name= "test-pg-inst-HA"
description=""
sla_details{
primary_sla{
sla_id= "{{ required SLA}}0"
nx_cluster_ids= [
"{{ nx_cluster_id}}"
]
}
}
// schedule fields are optional
schedule {
snapshottimeofday{
hours= 16
minutes= 0
seconds= 0
}
continuousschedule{
enabled=true
logbackupinterval= 30
snapshotsperday=1
}
weeklyschedule{
enabled=true
dayofweek= "WEDNESDAY"
}
monthlyschedule{
enabled = true
dayofmonth= "27"
}
quartelyschedule{
enabled=true
startmonth="JANUARY"
dayofmonth= 27
}
yearlyschedule{
enabled= false
dayofmonth= 31
month="DECEMBER"
}
}
}

vm_password= "{{ vm_password}}"
autotunestagingdrive= true
}
Loading

0 comments on commit 7081b2f

Please sign in to comment.