Skip to content

Commit

Permalink
Sync from server repo (a0662278500)
Browse files Browse the repository at this point in the history
  • Loading branch information
releng committed Sep 27, 2024
1 parent 4c8e997 commit 1f08c17
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 30 deletions.
1 change: 1 addition & 0 deletions vclusterops/fetch_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func (vcc VClusterCommands) VFetchCoordinationDatabase(options *VFetchCoordinati
vnode.Subcluster = n.Subcluster.Name
vnode.StorageLocations = n.StorageLocations
vnode.IsPrimary = n.IsPrimary
vnode.Sandbox = n.Subcluster.SandboxName
}

return vdb, runError
Expand Down
9 changes: 5 additions & 4 deletions vclusterops/nma_read_catalog_editor_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,11 @@ type nmaVNode struct {
StorageLocations []string `json:"storage_locations"`
Tag json.Number `json:"tag"`
Subcluster struct {
Name string `json:"sc_name"`
IsPrimary bool `json:"is_primary_sc"`
IsDefault bool `json:"is_default"`
IsSandbox bool `json:"sandbox"`
Name string `json:"sc_name"`
IsPrimary bool `json:"is_primary_sc"`
IsDefault bool `json:"is_default"`
IsSandbox bool `json:"sandbox"`
SandboxName string `json:"sandbox_name"`
} `json:"sc_details"`
}

Expand Down
49 changes: 25 additions & 24 deletions vclusterops/nma_save_restore_points_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,49 @@ import (
"errors"
"fmt"

"github.com/vertica/vcluster/vclusterops/util"
"github.com/vertica/vcluster/vclusterops/vlog"
)

type nmaSaveRestorePointsOp struct {
opBase
dbName string
username string
archiveName string
sandbox string
saveRestorePointsRequestData
sandbox string
}

type saveRestorePointsRequestData struct {
DBName string `json:"dbname"`
ArchiveName string `json:"archive_name"`
UserName string `json:"username"`
DBName string `json:"dbname"`
ArchiveName string `json:"archive_name"`
UserName string `json:"username"`
Password *string `json:"password"`
}

// This op is used to save restore points in a database
func makeNMASaveRestorePointsOp(logger vlog.Printer, hosts []string, dbName, username string,
archiveName string, sandbox string) nmaSaveRestorePointsOp {
return nmaSaveRestorePointsOp{
opBase: opBase{
name: "NMASaveRestorePointsOp",
description: "Run save restore point query",
logger: logger.WithName("NMASaveRestorePointsOp"),
hosts: hosts,
},
dbName: dbName,
username: username,
archiveName: archiveName,
sandbox: sandbox,
func makeNMASaveRestorePointsOp(logger vlog.Printer, hosts []string,
saveRestorepointrequestData *saveRestorePointsRequestData, sandbox string,
usePassword bool) (nmaSaveRestorePointsOp, error) {
op := nmaSaveRestorePointsOp{}
op.name = "NMASaveRestorePointsOp"
op.description = "Run save restore point query"
op.logger = logger.WithName("NMASaveRestorePointsOp")
op.hosts = hosts
op.saveRestorePointsRequestData = *saveRestorepointrequestData
op.sandbox = sandbox

if usePassword {
err := util.ValidateUsernameAndPassword(op.name, usePassword, op.UserName)
if err != nil {
return op, err
}
}
return op, nil
}

// make https json data
func (op *nmaSaveRestorePointsOp) setupRequestBody() (map[string]string, error) {
hostRequestBodyMap := make(map[string]string, len(op.hosts))
for _, host := range op.hosts {
requestData := saveRestorePointsRequestData{}
requestData.DBName = op.dbName
requestData.ArchiveName = op.archiveName
requestData.UserName = op.username
requestData := op.saveRestorePointsRequestData

dataBytes, err := json.Marshal(requestData)
if err != nil {
Expand Down
15 changes: 13 additions & 2 deletions vclusterops/save_restore_points.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ func (options *VSaveRestorePointOptions) validateAnalyzeOptions(logger vlog.Prin
if err := options.validateUserName(logger); err != nil {
return err
}
if err := options.setUsePassword(logger); err != nil {
return err
}
return options.analyzeOptions()
}

Expand Down Expand Up @@ -162,9 +165,17 @@ func (vcc VClusterCommands) produceSaveRestorePointsInstructions(options *VSaveR
hosts = vdb.filterUpHostlist(hosts, options.Sandbox)
bootstrapHost := []string{getInitiator(hosts)}

nmaSaveRestorePointOp := makeNMASaveRestorePointsOp(vcc.Log, bootstrapHost,
options.DBName, options.UserName, options.ArchiveName, options.Sandbox)
requestData := saveRestorePointsRequestData{}
requestData.ArchiveName = options.ArchiveName
requestData.DBName = options.DBName
requestData.UserName = options.UserName
requestData.Password = options.Password

nmaSaveRestorePointOp, err := makeNMASaveRestorePointsOp(vcc.Log, bootstrapHost,
&requestData, options.Sandbox, options.usePassword)
if err != nil {
return instructions, err
}
instructions = append(instructions,
&nmaHealthOp,
&nmaSaveRestorePointOp)
Expand Down

0 comments on commit 1f08c17

Please sign in to comment.