Commit ff030c75 authored by Jose A. Lopes's avatar Jose A. Lopes
Browse files

Add 'force_variant' to RPC 'os_validate'

Move function 'CheckOSVariant' to the node and add parameter
'force_variant' to RPC 'os_validate', thus making the node verify the
OS variant together with the rest of the OS params.
Signed-off-by: default avatarJose A. Lopes <>
Reviewed-by: default avatarPetr Pudlak <>
parent 11825d94
......@@ -3735,7 +3735,37 @@ def _CheckOSPList(os_obj, parameters):
" by the OS %s: %s" % (, utils.CommaJoin(delta)))
def ValidateOS(required, osname, checks, osparams):
def _CheckOSVariant(os_obj, name):
"""Check whether an OS name conforms to the os variants specification.
@type os_obj: L{objects.OS}
@param os_obj: OS object to check
@type name: string
@param name: OS name passed by the user, to check for validity
@rtype: NoneType
@return: None
@raise RPCFail: if OS variant is not valid
variant = objects.OS.GetVariant(name)
if not os_obj.supported_variants:
if variant:
_Fail("OS '%s' does not support variants ('%s' passed)" %
(, variant))
if not variant:
_Fail("OS name '%s' must include a variant" % name)
if variant not in os_obj.supported_variants:
_Fail("OS '%s' does not support variant '%s'" % (, variant))
def ValidateOS(required, osname, checks, osparams, force_variant):
"""Validate the given OS parameters.
@type required: boolean
......@@ -3766,6 +3796,9 @@ def ValidateOS(required, osname, checks, osparams):
return False
if not force_variant:
_CheckOSVariant(tbv, osname)
if max(tbv.api_versions) < constants.OS_API_V20:
return True
......@@ -1318,7 +1318,7 @@ class LUClusterSetParams(LogicalUnit):
# check the parameter validity (remote check)
CheckOSParams(self, False, [self.cfg.GetMasterNode()],
os_name, os_params)
os_name, os_params, False)
def _CheckDiskTemplateConsistency(self):
"""Check whether the disk templates that are going to be disabled
......@@ -365,7 +365,7 @@ def MergeAndVerifyDiskState(op_input, obj_input):
return None
def CheckOSParams(lu, required, node_uuids, osname, osparams):
def CheckOSParams(lu, required, node_uuids, osname, osparams, force_variant):
"""OS parameters validation.
@type lu: L{LogicalUnit}
......@@ -392,7 +392,7 @@ def CheckOSParams(lu, required, node_uuids, osname, osparams):
if osname:
result = lu.rpc.call_os_validate(node_uuids, required, osname,
osparams, force_variant)
for node_uuid, nres in result.items():
# we don't check for offline cases since this should be run only
# against the master node and/or an instance's nodes
......@@ -1313,7 +1313,8 @@ class LUInstanceCreate(LogicalUnit):
CheckNodeHasOS(self, pnode.uuid, self.op.os_type, self.op.force_variant)
# check OS parameters (remotely)
CheckOSParams(self, True, node_uuids, self.op.os_type, self.os_full)
CheckOSParams(self, True, node_uuids, self.op.os_type, self.os_full,
CheckNicsBridgesExist(self, self.nics, self.pnode.uuid)
......@@ -3188,7 +3189,8 @@ class LUInstanceSetParams(LogicalUnit):
CheckOSParams(self, True, node_uuids, instance_os,
self.os_inst = {}
......@@ -331,7 +331,8 @@ class LUInstanceReinstall(LogicalUnit):
CheckOSParams(self, True, node_uuids, instance_os, self.osparams)
CheckOSParams(self, True, node_uuids, instance_os, self.osparams,
def _ReinstallOSScripts(self, instance, osparams, debug_level):
"""Reinstall OS scripts on an instance.
......@@ -470,6 +470,7 @@ _OS_CALLS = [
("name", None, None),
("checks", None, None),
("params", None, None),
("force_variant", None, None),
], None, None, "Run a validation routine for a given OS"),
("os_get", SINGLE, None, constants.RPC_TMO_FAST, [
("name", None, None),
......@@ -984,8 +984,8 @@ class NodeRequestHandler(http.server.HttpServerHandler):
"""Run a given OS' validation routine.
required, name, checks, params = params
return backend.ValidateOS(required, name, checks, params)
required, name, checks, params, force_variant = params
return backend.ValidateOS(required, name, checks, params, force_variant)
# extstorage -----------------------
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