[Why]
nodes need communicate with each other when running cluster jobs. after adding 2 fileds,
'direct_ips' and 'direct_macs', can bind ips to macs.
'macs' get from cluster file ('$LKP_SRC/cluster/*'),
'ips' set by scheduler default: 192.168.<211..254>.<host_id>
Signed-off-by: Ren Wen <15991987063(a)163.com>
---
src/lib/sched.cr | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr
index a18bdee..1d5b5c4 100644
--- a/src/lib/sched.cr
+++ b/src/lib/sched.cr
@@ -198,6 +198,10 @@ class Sched
# collect all job ids
job_ids = [] of String
+ # used to set ips
+ ip_prefix = "192.168."
+ host_id = 1
+
# steps for each host
cluster_config.each do |host, config|
tbox_group = host.to_s
@@ -219,7 +223,18 @@ class Sched
job["testbox"] = tbox_group
job.update_tbox_group(tbox_group)
job["node_roles"] = config["roles"].as_a.join(" ")
- job["node_macs"] = config["macs"].as_a.join(" ")
+
+ # host macs and host ips
+ direct_macs = config["macs"].as_a
+ direct_ips = [] of String
+ net_id = "#{ip_prefix}#{254 - job_id.hash%44}" # 192.168.<211..254>
+ direct_macs.size.times do
+ raise "more than 255 macs" if host_id > 255
+ direct_ips << "#{net_id}.#{host_id}"
+ host_id += 1
+ end
+ job["direct_macs"] = direct_macs.join(" ")
+ job["direct_ips"] = direct_ips.join(" ")
response = add_job(job, job_id)
message = (response["error"]? ? response["error"]["root_cause"] : "")
--
2.23.0