From 14322c5c3abd36d42455243552ed7f77f2052b65 Mon Sep 17 00:00:00 2001 From: AngelaBriel Date: Thu, 23 Jan 2020 14:52:29 +0100 Subject: [PATCH 1/2] correct typo in the year in the man page headline --- ospackage/man/saptune-note.5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ospackage/man/saptune-note.5 b/ospackage/man/saptune-note.5 index 8e542677..d0e88323 100644 --- a/ospackage/man/saptune-note.5 +++ b/ospackage/man/saptune-note.5 @@ -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 From ca1161be92d11cd33d13187495fc6cb8edcc4674 Mon Sep 17 00:00:00 2001 From: AngelaBriel Date: Mon, 27 Jan 2020 11:28:40 +0100 Subject: [PATCH 2/2] add commands for listing enabled Notes/Solutions to saptune (bsc#1160564) --- app/app.go | 2 +- app/app_test.go | 2 +- main.go | 24 +++++++++++++++++-- main_test.go | 24 +++++++++++++++++-- ospackage/man/saptune_v2.8 | 10 ++++++-- .../completions/saptune.completion | 8 +++---- 6 files changed, 58 insertions(+), 12 deletions(-) diff --git a/app/app.go b/app/app.go index df7c55a2..a00926ce 100644 --- a/app/app.go +++ b/app/app.go @@ -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, " ")) } } diff --git a/app/app_test.go b/app/app_test.go index 9bfff51c..571881ba 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -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{} diff --git a/main.go b/main.go index ae64190b..49d440cc 100644 --- a/main.go +++ b/main.go @@ -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 @@ -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) } @@ -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 { @@ -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) } @@ -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 diff --git a/main_test.go b/main_test.go index 9cfc9769..bef4e88b 100644 --- a/main_test.go +++ b/main_test.go @@ -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. ` @@ -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. ` @@ -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. @@ -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. diff --git a/ospackage/man/saptune_v2.8 b/ospackage/man/saptune_v2.8 index 9b7a2a64..fcf7aedd 100644 --- a/ospackage/man/saptune_v2.8 +++ b/ospackage/man/saptune_v2.8 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/ospackage/usr/share/bash-completion/completions/saptune.completion b/ospackage/usr/share/bash-completion/completions/saptune.completion index 3e59e524..813da2e4 100644 --- a/ospackage/usr/share/bash-completion/completions/saptune.completion +++ b/ospackage/usr/share/bash-completion/completions/saptune.completion @@ -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 @@ -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" ;;