Commit 6217e295 authored by Iustin Pop's avatar Iustin Pop
Browse files

Export the hypervisor.ValidateParameters over RPC

The newly-added node-specific ValidateParams hypervisor method is
exported over RPC, using the semi-standard (success, message) return
value. Multi-node call, so that we call on both primary and secondary at
once.

Reviewed-by: ultrotter
parent f48148c3
......@@ -605,6 +605,16 @@ class NodeHttpServer(http.HttpServer):
return backend.JobQueueRename(old, new)
# hypervisor ---------------
@staticmethod
def perspective_hypervisor_validate_params(params):
"""Validate the hypervisor parameters.
"""
(hvname, hvparams) = params
return backend.ValidateHVParams(hvname, hvparams)
def ParseOptions():
"""Parse the command line options.
......
......@@ -1794,6 +1794,25 @@ def CloseBlockDevices(disks):
return (True, "All devices secondary")
def ValidateHVParams(hvname, hvparams):
"""Validates the given hypervisor parameters.
@type hvname: string
@param hvname: the hypervisor name
@type hvparams: dict
@param hvparams: the hypervisor parameters to be validated
@rtype: tuple (bool, str)
@return: tuple of (success, message)
"""
try:
hv_type = hypervisor.GetHypervisor(hvname)
hv_type.ValidateParameters(hvparams)
return (True, "Validation passed")
except errors.HypervisorError, err:
return (False, str(err))
class HooksRunner(object):
"""Hook runner.
......
......@@ -876,3 +876,25 @@ class RpcRunner(object):
c.run()
result = c.getresult()
return result
def call_hypervisor_validate_params(self, node_list, hvname, hvparams):
"""Validate the hypervisor params.
This is a multi-node call.
@type node_list: list
@param node_list: the list of nodes to query
@type hvname: string
@param hvname: the hypervisor name
@type hvparams: dict
@param hvparams: the hypervisor parameters to be validated
"""
cluster = self._cfg.GetClusterInfo()
hv_full = cluster.FillDict(cluster.hvparams.get(hvname, {}), hvparams)
c = Client("hypervisor_validate_params", [hvname, hv_full])
c.connect_list(node_list)
c.run()
result = c.getresult()
return result
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