Skip to content
Snippets Groups Projects
Commit eb0994e7 authored by Iustin Pop's avatar Iustin Pop
Browse files

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
parent 27579978
No related branches found
No related tags found
No related merge requests found
......@@ -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)" %
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment