Commit d9037ebf authored by Lisa Velden's avatar Lisa Velden

Add new command gnt-debug test-osparams

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: default avatarLisa Velden <velden@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent 62c9bf41
...@@ -583,6 +583,16 @@ def TestJobqueue(opts, _): ...@@ -583,6 +583,16 @@ def TestJobqueue(opts, _):
return 0 return 0
def TestOsParams(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 def ListLocks(opts, args): # pylint: disable=W0613
"""List all locks. """List all locks.
...@@ -785,6 +795,10 @@ commands = { ...@@ -785,6 +795,10 @@ commands = {
"test-jobqueue": ( "test-jobqueue": (
TestJobqueue, ARGS_NONE, [PRIORITY_OPT], TestJobqueue, ARGS_NONE, [PRIORITY_OPT],
"", "Test a few aspects of the job queue"), "", "Test a few aspects of the job queue"),
"test-osparams": (
TestOsParams, ARGS_NONE, [OSPARAMS_SECRET_OPT] + SUBMIT_OPTS,
"[--os-parameters-secret <params>]",
"Test secret os parameter transmission"),
"locks": ( "locks": (
ListLocks, ARGS_NONE, ListLocks, ARGS_NONE,
[NOHDR_OPT, SEP_OPT, FIELDS_OPT, INTERVAL_OPT, VERBOSE_OPT], [NOHDR_OPT, SEP_OPT, FIELDS_OPT, INTERVAL_OPT, VERBOSE_OPT],
......
...@@ -128,6 +128,7 @@ from ganeti.cmdlib.misc import \ ...@@ -128,6 +128,7 @@ from ganeti.cmdlib.misc import \
LUExtStorageDiagnose, \ LUExtStorageDiagnose, \
LURestrictedCommand LURestrictedCommand
from ganeti.cmdlib.test import \ from ganeti.cmdlib.test import \
LUTestOsParams, \
LUTestDelay, \ LUTestDelay, \
LUTestJqueue, \ LUTestJqueue, \
LUTestAllocator LUTestAllocator
...@@ -353,6 +353,23 @@ class LUTestJqueue(NoHooksLU): ...@@ -353,6 +353,23 @@ class LUTestJqueue(NoHooksLU):
return True 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): class LUTestAllocator(NoHooksLU):
"""Run allocator tests. """Run allocator tests.
......
...@@ -99,6 +99,13 @@ TEST-JOBQUEUE ...@@ -99,6 +99,13 @@ TEST-JOBQUEUE
Executes a few tests on the job queue. This command might generate Executes a few tests on the job queue. This command might generate
failed jobs deliberately. failed jobs deliberately.
TEST_OSPARAMS
~~~~~~~~~~~~~
**test-osparams** {--os-parameters-secret *param*=*value*... }
Tests secret os parameter transmission.
LOCKS LOCKS
~~~~~ ~~~~~
......
...@@ -465,6 +465,10 @@ opTestJqueue :: String ...@@ -465,6 +465,10 @@ opTestJqueue :: String
opTestJqueue = opTestJqueue =
"Utility opcode to test some aspects of the job queue." "Utility opcode to test some aspects of the job queue."
opTestOsParams :: String
opTestOsParams =
"Utility opcode to test secret os parameter transmission."
opTestDummy :: String opTestDummy :: String
opTestDummy = opTestDummy =
"Utility opcode used by unittests." "Utility opcode used by unittests."
......
...@@ -903,6 +903,12 @@ $(genOpCode "OpCode" ...@@ -903,6 +903,12 @@ $(genOpCode "OpCode"
, pJQueueFail , pJQueueFail
], ],
[]) [])
, ("OpTestOsParams",
[t| () |],
OpDoc.opTestOsParams,
[ pInstOsParamsSecret
],
[])
, ("OpTestDummy", , ("OpTestDummy",
[t| () |], [t| () |],
OpDoc.opTestDummy, OpDoc.opTestDummy,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment