From eb0994e71e7b320f79f75d92569ec1b20b0eb6e0 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 23 Apr 2008 11:04:07 +0000 Subject: [PATCH] Implement replace_secondary in the dumb allocator This patch allows the dumb allocator to perform the replace secondary request type. This is done simply by not allowing the current instances nodes as a valid selection, and using the existing instance data instead of the request (which doesn't have the instance info when doing the replace_secondary). Reviewed-by: ultrotter --- doc/examples/dumb-allocator | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/examples/dumb-allocator b/doc/examples/dumb-allocator index 53b9cd2da..9734af397 100755 --- a/doc/examples/dumb-allocator +++ b/doc/examples/dumb-allocator @@ -73,12 +73,20 @@ def main(): nodes = data["nodes"] request = data["request"] req_type = request["type"] - if req_type != "allocate": + if req_type == "allocate": + forbidden_nodes = [] + inst_data = request + elif req_type == "replace_secondary": + idict = data["instances"][request["name"]] + forbidden_nodes = idict["nodes"] + inst_data = idict + inst_data["disk_space_total"] = request["disk_space_total"] + else: return OutputError("Unsupported allocator mode '%s'" % req_type) result_nodes = [] while len(result_nodes) < request["required_nodes"]: - new_selection = SelectNode(nodes, request, result_nodes) + new_selection = SelectNode(nodes, inst_data, result_nodes+forbidden_nodes) if new_selection is None: return OutputError("Can't find a suitable node for position %s" " (already selected: %s)" % -- GitLab