Patch name: we usually verb first, so make it Add new command...

On Mon, Jul 6, 2015 at 10:20 PM, 'Lisa Velden' via ganeti-devel <
[email protected]> wrote:

> 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,
>

Since you are not setting OS params - they are not saved anywhere - I
recommend renaming this to TestOsParams.


> +    "[--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.
>

s/os/OS/


> +
> +  """
> +  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
>
>
Hrvoje Ribicic
Ganeti Engineering
Google Germany GmbH
Dienerstr. 12, 80331, München

Geschäftsführer: Graham Law, Christine Elizabeth Flores
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

Reply via email to