On Fri, Jun 6, 2014 at 10:51 AM, 'Jose A. Lopes' via ganeti-devel <
[email protected]> wrote:

> This RPC will be needed so that changes to the cluster parameters for
> enabled hypervisors, user shutdown, and vm capable nodes, can
> start/stop the KVM daemon as necessary.
>
> Signed-off-by: Jose A. Lopes <[email protected]>
> ---
>  lib/backend.py      | 22 ++++++++++++++++++++++
>  lib/rpc_defs.py     |  4 ++++
>  lib/server/noded.py |  8 ++++++++
>  3 files changed, 34 insertions(+)
>
> diff --git a/lib/backend.py b/lib/backend.py
> index 98acdf0..062f952 100644
> --- a/lib/backend.py
> +++ b/lib/backend.py
> @@ -1247,6 +1247,28 @@ def GetCryptoTokens(token_requests):
>    return tokens
>
>
> +def EnsureDaemon(daemon_name, run):
> +  """Ensures the given daemon is running or stopped.
> +
> +  @type daemon_name: string
> +  @param daemon_name: name of the daemon (e.g., constants.KVMD)
> +
> +  @type run: bool
> +  @param run: whether to start or stop the daemon
> +
> +  """
> +  allowed_daemons = [constants.KVMD]
> +
> +  if daemon_name not in allowed_daemons:
> +    fn = lambda _: False
>

Why not throw an error here?


> +  elif run:
> +    fn = utils.EnsureDaemon
> +  else:
> +    fn = utils.StopDaemon
> +
> +  return fn(daemon_name)
> +
> +
>  def GetBlockDevSizes(devices):
>    """Return the size of the given block devices
>
> diff --git a/lib/rpc_defs.py b/lib/rpc_defs.py
> index 6650c43..87891ca 100644
> --- a/lib/rpc_defs.py
> +++ b/lib/rpc_defs.py
> @@ -509,6 +509,10 @@ _NODE_CALLS = [
>      ("token_request", None,
>       "List of tuples of requested crypto token types, actions"),
>      ], None, None, "Handle crypto tokens of the node."),
> +  ("node_ensure_daemon", MULTI, None, constants.RPC_TMO_URGENT, [
> +    ("daemon", None, "Daemon name"),
> +    ("run", None, "Whether the daemon should be running or stopped"),
> +    ], None, None, "Ensure daemon is running on the node."),
>    ]
>
>  _MISC_CALLS = [
> diff --git a/lib/server/noded.py b/lib/server/noded.py
> index 9731925..ecaa18e 100644
> --- a/lib/server/noded.py
> +++ b/lib/server/noded.py
> @@ -872,6 +872,14 @@ class
> NodeRequestHandler(http.server.HttpServerHandler):
>      token_requests = params[0]
>      return backend.GetCryptoTokens(token_requests)
>
> +  @staticmethod
> +  def perspective_node_ensure_daemon(params):
> +    """Ensure daemon is running.
> +
> +    """
> +    (daemon_name, run) = params
> +    return backend.EnsureDaemon(daemon_name, run)
> +
>    # cluster --------------------------
>
>    @staticmethod
> --
> 2.0.0.526.g5318336
>
>

Reply via email to