需要这么复杂吗
- # a private-ip pools, each return 10 ips
- private def get_private_ips
- # ip = net_id + host_id
- # host_id : 1..250
- # will divide into 10 groups used by maximum 10 cluster jobs
- host_ids = [] of Int32
- 25.times do |i|
host_ids << i * 10 + 1
- end # [1, 11, ..., 241]
- net_id = "192.168.222"
- index = @redis.get_seqno % 25
- host_id = host_ids[index]
- ips = [] of String
- 10.times do |i|
ips << "#{net_id}.#{host_id + i}"
- end
- ips
- end
- def get_commit_date(job) if (job["upstream_repo"] != "") && (job["upstream_commit"] != "") data = JSON.parse(%({"git_repo": "#{job["upstream_repo"]}.git",
@@ -198,6 +217,9 @@ class Sched # collect all job ids job_ids = [] of String
- # an array consists of 10 ips
- ips = get_private_ips
- # steps for each host cluster_config.each do |host, config| tbox_group = host.to_s
@@ -219,7 +241,13 @@ 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(" ")
direct_macs = config["macs"].as_a
direct_ips = [] of String
direct_macs.size.times do
direct_ips << ips.pop {raise "more than 10 macs"}
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