projects
/
ganeti-local
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LUSetInstanceParams: abstract _GetUpdatedParams
[ganeti-local]
/
doc
/
examples
/
dumb-allocator
diff --git
a/doc/examples/dumb-allocator
b/doc/examples/dumb-allocator
index
2996e49
..
c59d75f
100755
(executable)
--- a/
doc/examples/dumb-allocator
+++ b/
doc/examples/dumb-allocator
@@
-25,6
+25,7
@@
that fits in both memory and disk space, without any consideration for
equal spread or VCPU oversubscription.
"""
equal spread or VCPU oversubscription.
"""
+
import simplejson
import sys
import simplejson
import sys
@@
-73,12
+74,14
@@
def main():
nodes = data["nodes"]
request = data["request"]
req_type = request["type"]
nodes = data["nodes"]
request = data["request"]
req_type = request["type"]
+ offline_nodes = [name for name in nodes if nodes[name]["offline"]]
+ drained_nodes = [name for name in nodes if nodes[name]["offline"]]
if req_type == "allocate":
if req_type == "allocate":
- forbidden_nodes = []
+ forbidden_nodes = offline_nodes + drained_nodes
inst_data = request
elif req_type == "relocate":
idict = data["instances"][request["name"]]
inst_data = request
elif req_type == "relocate":
idict = data["instances"][request["name"]]
- forbidden_nodes = idict["nodes"]
+ forbidden_nodes = idict["nodes"] + offline_nodes + drained_nodes
inst_data = idict
inst_data["disk_space_total"] = request["disk_space_total"]
else:
inst_data = idict
inst_data["disk_space_total"] = request["disk_space_total"]
else:
@@
-95,12
+98,13
@@
def main():
result_nodes.append(new_selection)
result = {
result_nodes.append(new_selection)
result = {
- "success": True,
- "info": "Allocation successful",
- "nodes": result_nodes,
- }
+ "success": True,
+ "info": "Allocation successful",
+ "nodes": result_nodes,
+ }
print simplejson.dumps(result, indent=2)
return 0
print simplejson.dumps(result, indent=2)
return 0
+
if __name__ == "__main__":
sys.exit(main())
if __name__ == "__main__":
sys.exit(main())