From 00fe9e3806cfb52235d20ba7a5f76a265e6af434 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Sun, 4 Nov 2007 04:10:44 +0000 Subject: [PATCH] Make call_os_get a single node function call_os_get is never called with a real list of nodes, so there's no point in it being multi-node. Making it single-node till a usage for multi-node call is found. Reviewed-By: iustinp --- lib/cmdlib.py | 4 ++-- lib/rpc.py | 25 ++++++++++++------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 5864ee1cf..fb3b84ec3 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -2158,7 +2158,7 @@ class LUReinstallInstance(LogicalUnit): if pnode is None: raise errors.OpPrereqError("Primary node '%s' is unknown" % self.op.pnode) - os_obj = rpc.call_os_get([pnode.name], self.op.os_type)[pnode.name] + os_obj = rpc.call_os_get(pnode.name, self.op.os_type) if not isinstance(os_obj, objects.OS): raise errors.OpPrereqError("OS '%s' not in supported OS list for" " primary node" % self.op.os_type) @@ -2949,7 +2949,7 @@ class LUCreateInstance(LogicalUnit): (node, info['vg_free'], req_size)) # os verification - os_obj = rpc.call_os_get([pnode.name], self.op.os_type)[pnode.name] + os_obj = rpc.call_os_get(pnode.name, self.op.os_type) if not isinstance(os_obj, objects.OS): raise errors.OpPrereqError("OS '%s' not in supported os list for" " primary node" % self.op.os_type) diff --git a/lib/rpc.py b/lib/rpc.py index d84a85e04..82a78ebfc 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -653,25 +653,24 @@ def call_os_diagnose(node_list): return new_result -def call_os_get(node_list, name): +def call_os_get(node, name): """Returns an OS definition. - This is a multi-node call. + This is a single-node call. """ c = Client("os_get", [name]) - c.connect_list(node_list) + c.connect(node) c.run() - result = c.getresult() - new_result = {} - for node_name in result: - data = result[node_name] - if isinstance(data, dict): - new_result[node_name] = objects.OS.FromDict(data) - elif isinstance(data, tuple) and len(data) == 3: - new_result[node_name] = errors.InvalidOS(data[0], data[1], data[2]) - else: - new_result[node_name] = data + result = c.getresult().get(node, False) + + if isinstance(result, dict): + new_result = objects.OS.FromDict(result) + elif isinstance(result, tuple) and len(data) == 3: + new_result = errors.InvalidOS(result[0], result[1], result[2]) + else: + new_result = result + return new_result -- GitLab