which takes secret parameters with --os-secret-parameters and writes them to stdout. This command can be used to test the transmission of secret parameters.
Signed-off-by: Lisa Velden <[email protected]> --- lib/client/gnt_debug.py | 14 ++++++++++++++ lib/cmdlib/__init__.py | 1 + lib/cmdlib/test.py | 17 +++++++++++++++++ man/gnt-debug.rst | 7 +++++++ src/Ganeti/Hs2Py/OpDoc.hs | 4 ++++ src/Ganeti/OpCodes.hs | 6 ++++++ 6 files changed, 49 insertions(+) diff --git a/lib/client/gnt_debug.py b/lib/client/gnt_debug.py index d05fbc2..ee0721c 100644 --- a/lib/client/gnt_debug.py +++ b/lib/client/gnt_debug.py @@ -583,6 +583,16 @@ def TestJobqueue(opts, _): return 0 +def SetOsParams(opts, _): + """Set secret os parameters. + + """ + op = opcodes.OpTestOsParams(osparams_secret=opts.osparams_secret) + SubmitOrSend(op, opts) + + return 0 + + def ListLocks(opts, args): # pylint: disable=W0613 """List all locks. @@ -785,6 +795,10 @@ commands = { "test-jobqueue": ( TestJobqueue, ARGS_NONE, [PRIORITY_OPT], "", "Test a few aspects of the job queue"), + "test-osparams": ( + SetOsParams, ARGS_NONE, [OSPARAMS_SECRET_OPT] + SUBMIT_OPTS, + "[--os-parameters-secret <params>]", + "Test secret os parameter transmission"), "locks": ( ListLocks, ARGS_NONE, [NOHDR_OPT, SEP_OPT, FIELDS_OPT, INTERVAL_OPT, VERBOSE_OPT], diff --git a/lib/cmdlib/__init__.py b/lib/cmdlib/__init__.py index ee02417..5fd9b8d 100644 --- a/lib/cmdlib/__init__.py +++ b/lib/cmdlib/__init__.py @@ -128,6 +128,7 @@ from ganeti.cmdlib.misc import \ LUExtStorageDiagnose, \ LURestrictedCommand from ganeti.cmdlib.test import \ + LUTestOsParams, \ LUTestDelay, \ LUTestJqueue, \ LUTestAllocator diff --git a/lib/cmdlib/test.py b/lib/cmdlib/test.py index 5ec7c92..1df15d2 100644 --- a/lib/cmdlib/test.py +++ b/lib/cmdlib/test.py @@ -353,6 +353,23 @@ class LUTestJqueue(NoHooksLU): return True +class LUTestOsParams(NoHooksLU): + """Utility LU to test secret os parameter transmission. + + """ + REQ_BGL = False + + def ExpandNames(self): + self.needed_locks = {} + + def Exec(self, feedback_fn): + if self.op.osparams_secret: + msg = "Secret os parameters: %s" % self.op.osparams_secret.Unprivate() + feedback_fn(msg) + else: + raise errors.OpExecError("Opcode needs secret parameters") + + class LUTestAllocator(NoHooksLU): """Run allocator tests. diff --git a/man/gnt-debug.rst b/man/gnt-debug.rst index 6614c12..e934d0e 100644 --- a/man/gnt-debug.rst +++ b/man/gnt-debug.rst @@ -99,6 +99,13 @@ TEST-JOBQUEUE Executes a few tests on the job queue. This command might generate failed jobs deliberately. +TEST_OSPARAMS +~~~~~~~~~~~~~ + +**test-osparams** {--os-parameters-secret *param*=*value*... } + +Tests secret os parameter transmission. + LOCKS ~~~~~ diff --git a/src/Ganeti/Hs2Py/OpDoc.hs b/src/Ganeti/Hs2Py/OpDoc.hs index 82aba2f..aee68db 100644 --- a/src/Ganeti/Hs2Py/OpDoc.hs +++ b/src/Ganeti/Hs2Py/OpDoc.hs @@ -465,6 +465,10 @@ opTestJqueue :: String opTestJqueue = "Utility opcode to test some aspects of the job queue." +opTestOsParams :: String +opTestOsParams = + "Utility opcode to test secret os parameter transmission." + opTestDummy :: String opTestDummy = "Utility opcode used by unittests." diff --git a/src/Ganeti/OpCodes.hs b/src/Ganeti/OpCodes.hs index 271b409..209943d 100644 --- a/src/Ganeti/OpCodes.hs +++ b/src/Ganeti/OpCodes.hs @@ -903,6 +903,12 @@ $(genOpCode "OpCode" , pJQueueFail ], []) + , ("OpTestOsParams", + [t| () |], + OpDoc.opTestOsParams, + [ pInstOsParamsSecret + ], + []) , ("OpTestDummy", [t| () |], OpDoc.opTestDummy, -- 2.4.3.573.g4eafbef
