Skip to content

Commit

Permalink
Merge pull request #38 from angelabriel/master
Browse files Browse the repository at this point in the history
bsc#1160564 - add commands for listing enabled Notes/Solutions
  • Loading branch information
angelabriel authored Jan 27, 2020
2 parents 64b4746 + ca1161b commit f43296f
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func InitialiseApp(sysconfigPrefix, stateDirPrefix string, allNotes map[string]n
// PrintNoteApplyOrder prints out the order of the currently applied notes
func (app *App) PrintNoteApplyOrder(writer io.Writer) {
if len(app.NoteApplyOrder) != 0 {
fmt.Fprintf(writer, "\ncurrent order of applied notes is: %s\n\n", strings.Join(app.NoteApplyOrder, " "))
fmt.Fprintf(writer, "\ncurrent order of enabled notes is: %s\n\n", strings.Join(app.NoteApplyOrder, " "))
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func TestReadConfig(t *testing.T) {
// Read from testdata config 'testdata/etc/sysconfig/saptune'
tuneApp = InitialiseApp(TstFilesInGOPATH, "", AllTestNotes, AllTestSolutions)
matchTxt := `
current order of applied notes is: 2205917 2684254 1680803
current order of enabled notes is: 2205917 2684254 1680803
`
buffer := bytes.Buffer{}
Expand Down
24 changes: 22 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ func PrintHelpAndExit(exitStatus int) {
Daemon control:
saptune daemon [ start | status | stop ]
Tune system according to SAP and SUSE notes:
saptune note [ list | verify ]
saptune note [ list | verify | enabled ]
saptune note [ apply | simulate | verify | customise | create | revert | show | delete ] NoteID
saptune note rename NoteID newNoteID
Tune system for all notes applicable to your SAP solution:
saptune solution [ list | verify ]
saptune solution [ list | verify | enabled ]
saptune solution [ apply | simulate | verify | revert ] SolutionName
Revert all parameters tuned by the SAP notes or solutions:
saptune revert all
Expand Down Expand Up @@ -633,6 +633,8 @@ func NoteAction(actionName, noteID, newNoteID string) {
NoteActionRename(os.Stdin, os.Stdout, noteID, newNoteID, NoteTuningSheets, ExtraTuningSheets, OverrideTuningSheets, tuneApp)
case "revert":
NoteActionRevert(os.Stdout, noteID, tuneApp)
case "enabled":
NoteActionEnabled(os.Stdout, tuneApp)
default:
PrintHelpAndExit(1)
}
Expand Down Expand Up @@ -925,6 +927,15 @@ func NoteActionRevert(writer io.Writer, noteID string, tuneApp *app.App) {
fmt.Fprintf(writer, "Parameters tuned by the note have been successfully reverted.\n")
}

// NoteActionEnabled lists all enabled Note definitions as list separated
// by blanks
func NoteActionEnabled(writer io.Writer, tuneApp *app.App) {
if len(tuneApp.NoteApplyOrder) != 0 {
fmt.Fprintf(writer, "%s", strings.Join(tuneApp.NoteApplyOrder, " "))
}
}


// SolutionAction Solution actions like apply, revert, verify asm.
func SolutionAction(actionName, solName string) {
switch actionName {
Expand All @@ -938,6 +949,8 @@ func SolutionAction(actionName, solName string) {
SolutionActionSimulate(os.Stdout, solName, tuneApp)
case "revert":
SolutionActionRevert(os.Stdout, solName, tuneApp)
case "enabled":
SolutionActionEnabled(os.Stdout, tuneApp)
default:
PrintHelpAndExit(1)
}
Expand Down Expand Up @@ -1057,6 +1070,13 @@ func SolutionActionRevert(writer io.Writer, solName string, tuneApp *app.App) {
fmt.Fprintf(writer, "Parameters tuned by the notes referred by the SAP solution have been successfully reverted.\n")
}

// SolutionActionEnabled prints out the enabled solution definition
func SolutionActionEnabled(writer io.Writer, tuneApp *app.App) {
if len(tuneApp.TuneForSolutions) != 0 {
fmt.Fprintf(writer, "%s", tuneApp.TuneForSolutions[0])
}
}

// getFileName returns the corresponding filename of a given noteID
// additional it returns a boolean value which is pointing out that the Note
// the Note is a custom Note (extraNote = true) or an internal one
Expand Down
24 changes: 22 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ Hints or values not yet handled by saptune. So please read carefully, check and
# which parameters are NOT handled and the reason.

current order of applied notes is: simpleNote
current order of enabled notes is: simpleNote
The running system is currently well-tuned according to all of the enabled notes.
`
Expand Down Expand Up @@ -225,7 +225,7 @@ Hints or values not yet handled by saptune. So please read carefully, check and
# which parameters are NOT handled and the reason.

current order of applied notes is: simpleNote
current order of enabled notes is: simpleNote
The system fully conforms to the specified note.
`
Expand All @@ -236,6 +236,16 @@ The system fully conforms to the specified note.
checkOut(t, txt, verifyMatchText)
})

// Test NoteActionEnabled
t.Run("NoteActionEnabled", func(t *testing.T) {
enabledMatchText := "simpleNote"

buffer := bytes.Buffer{}
NoteActionEnabled(&buffer, tApp)
txt := buffer.String()
checkOut(t, txt, enabledMatchText)
})

// Test NoteActionRevert
t.Run("NoteActionRevert", func(t *testing.T) {
var revertMatchText = `Parameters tuned by the note have been successfully reverted.
Expand Down Expand Up @@ -636,6 +646,16 @@ The system fully conforms to the tuning guidelines of the specified SAP solution
checkOut(t, txt, verifyMatchText)
})

// Test SolutionActionEnabled
t.Run("SolutionActionEnabled", func(t *testing.T) {
enabledMatchText := "sol1"

buffer := bytes.Buffer{}
SolutionActionEnabled(&buffer, tApp)
txt := buffer.String()
checkOut(t, txt, enabledMatchText)
})

// Test SolutionActionRevert
t.Run("SolutionActionRevert", func(t *testing.T) {
var revertMatchText = `Parameters tuned by the notes referred by the SAP solution have been successfully reverted.
Expand Down
2 changes: 1 addition & 1 deletion ospackage/man/saptune-note.5
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
.\" */
.\"

.TH "saptune-note" "5" "January 2029" "" "saptune note file format description"
.TH "saptune-note" "5" "January 2020" "" "saptune note file format description"
.SH NAME
saptune\-note - Note definition files for saptune version \fB2\fP
.SH DESCRIPTION
Expand Down
10 changes: 8 additions & 2 deletions ospackage/man/saptune_v2.8
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ATTENTION: If you still use version \fB1\fP of saptune please refer to man page
[ start | status | stop ]

\fBsaptune note\fP
[ list | verify ]
[ list | verify | enabled ]

\fBsaptune note\fP
[ apply | simulate | verify | customise | create | revert | show | delete ] NoteID
Expand All @@ -34,7 +34,7 @@ ATTENTION: If you still use version \fB1\fP of saptune please refer to man page
rename NoteID newNoteID

\fBsaptune solution\fP
[ list | verify ]
[ list | verify | enabled ]

\fBsaptune solution\fP
[ apply | simulate | verify | revert ] SolutionName
Expand Down Expand Up @@ -101,6 +101,9 @@ Currently implemented notes are marked with '\fB+\fP', if manually enabled, '\fB
.br
If an \fBoverride\fP file exists for a NoteID, the note is marked with '\fBO\fP'.
.TP
.B enabled
Print all current enabled notes as a list separated by blanks.
.TP
.B verify
If a Note ID is specified, saptune verifies the current running system against the recommendations specified in the Note. If Note ID is not specified, saptune verifies all system parameters against all implemented Notes. As a result you will see a table containing the following columns

Expand Down Expand Up @@ -241,6 +244,9 @@ The currently implemented solution is marked with '\fB*\fP' and is highlighted w
.br
If an \fBoverride\fP file exists for a solution, the solution is marked with '\fBO\fP'.
.TP
.B enabled
Print the current enabled solution.
.TP
.B simulate
Show all notes that are associated with the specified SAP solution, and all changes that will be applied once the solution is activated.
.TP
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# v1.3
#
# saptune daemon [ start | status | stop ]
# saptune note [ list | verify ]
# saptune note [ list | verify | enabled ]
# saptune note [ apply | simulate | verify | customise | revert | create | show | delete ] NoteID
# saptune note rename NoteID NoteID
# saptune solution [ list | verify ]
# saptune solution [ list | verify | enabled ]
# saptune solution [ apply | simulate | verify | revert ] SolutionName
# saptune revert all
# saptune version
Expand All @@ -26,9 +26,9 @@ _saptune() {
2) case "${prev}" in
daemon) opts="start status stop"
;;
solution) opts="list verify apply simulate revert"
solution) opts="list verify apply simulate revert enabled"
;;
note) opts="list verify apply simulate customise revert create show delete rename"
note) opts="list verify apply simulate customise revert create show delete rename enabled"
;;
revert) opts="all"
;;
Expand Down

0 comments on commit f43296f

Please sign in to comment.