On Apr 02 13:30, Hrvoje Ribicic wrote:
> Due to the need to determine the size of the temporary disk used for
> the VM helper, an RPC call capable of supplying this information has
> been added. It can be extended as needed to supply additional
> information provided by Python's os.stat.
>
> Signed-off-by: Hrvoje Ribicic <[email protected]>
> ---
> lib/backend.py | 17 +++++++++++++++++
> lib/rpc_defs.py | 3 +++
> lib/server/noded.py | 8 ++++++++
> src/Ganeti/Constants.hs | 9 +++++++++
> 4 files changed, 37 insertions(+)
>
> diff --git a/lib/backend.py b/lib/backend.py
> index 3118242..98a6fb7 100644
> --- a/lib/backend.py
> +++ b/lib/backend.py
> @@ -4631,6 +4631,23 @@ def ConfigureOVS(ovs_name, ovs_link):
> result.output), log=True)
>
>
> +def GetFileInfo(file_path):
> + """ Checks if a file exists and returns information related to it.
> +
> + @type file_path: string
> + @param file_path: Name of file to examine.
@return, @rtype
> +
> + """
> + try:
> + stat_info = os.stat(file_path)
> + values_dict = {
> + constants.STAT_SIZE: stat_info.st_size,
> + }
> + return True, values_dict
> + except IOError:
> + return False, {}
> +
> +
> class HooksRunner(object):
> """Hook runner.
>
> diff --git a/lib/rpc_defs.py b/lib/rpc_defs.py
> index ccf2359..4b81712 100644
> --- a/lib/rpc_defs.py
> +++ b/lib/rpc_defs.py
> @@ -557,6 +557,9 @@ _MISC_CALLS = [
> ("set_watcher_pause", MULTI, None, constants.RPC_TMO_URGENT, [
> ("until", None, None),
> ], None, None, "Set watcher pause end"),
> + ("get_file_info", SINGLE, None, constants.RPC_TMO_NORMAL, [
RPC_TMO_URGENT instead of NORMAL?
> + ("file_path", None, None),
> + ], None, None, "Checks if a file exists and reports on it"),
> ]
>
> CALLS = {
> diff --git a/lib/server/noded.py b/lib/server/noded.py
> index cbffa8e2..4fe42b7 100644
> --- a/lib/server/noded.py
> +++ b/lib/server/noded.py
> @@ -961,6 +961,14 @@ class NodeRequestHandler(http.server.HttpServerHandler):
> (until, ) = params
> return backend.SetWatcherPause(until)
>
> + @staticmethod
> + def perspective_get_file_info(params):
> + """Retrieves the status of an import or export daemon.
Docstring is incorrect.
> +
> + """
> + (path, ) = params
> + return backend.GetFileInfo(path)
> +
> # os -----------------------
>
> @staticmethod
> diff --git a/src/Ganeti/Constants.hs b/src/Ganeti/Constants.hs
> index c2e3e36..8be545a 100644
> --- a/src/Ganeti/Constants.hs
> +++ b/src/Ganeti/Constants.hs
> @@ -4867,3 +4867,12 @@ debugModeConfidentialityWarning :: String
> debugModeConfidentialityWarning =
> "ALERT: %s started in debug mode.\n\
> \ Private and secret parameters WILL be logged!\n"
> +
> +-- * Stat dictionary entries
> +--
> +-- The get_file_info function returns a number of values as a dictionary, and
s/GetFileInfo/get_file_info/ or s/function/RPC
Rest LGTM.
Thanks,
Jose
> +-- the following constants are both descriptions and means of accessing them.
> +
> +-- | The size of the file
> +statSize :: String
> +statSize = "size"
> --
> 1.9.1.423.g4596e3a
>
--
Jose Antonio Lopes
Ganeti Engineering
Google Germany GmbH
Dienerstr. 12, 80331, München
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores
Steuernummer: 48/725/00206
Umsatzsteueridentifikationsnummer: DE813741370