node_roles = env.params.query["node_roles"] node_ip = env.params.query["ip"]
direct_ips = env.params.query["direct_ips"]
direct_macs = env.params.query["direct_macs"]
can keep align with "=", like below: node_roles = env.params.query["node_roles"] node_ip = env.params.query["ip"] direct_ips = env.params.query["direct_ips"] direct_macs = env.params.query["direct_macs"]
It's a not recommended style to align variables. Can use the style in containers like Hash.
Thanks, RenWen
Thanks, Kaiyi
update_cluster_state(cluster_id, job_id, "roles", node_roles) update_cluster_state(cluster_id, job_id, "ip", node_ip)
update_cluster_state(cluster_id, job_id, "direct_ips", direct_ips)
when "roles_ip" role = "server"update_cluster_state(cluster_id, job_id, "direct_macs", direct_macs)
server_ip = get_ip(cluster_id, role)
return "server=#{server_ip}"
role_state = get_role_state(cluster_id, role)
raise "Missing #{role} state in cluster state" unless role_state
return "server=#{role_state["ip"]}\n" \
"direct_server_ips=#{role_state["direct_ips"]}"
end
# show cluster state return @redis.hash_get("sched/cluster_state", cluster_id) end
- # get the ip of role from cluster_state
- def get_ip(cluster_id, role)
- # get the node state of role from cluster_state
- private def get_role_state(cluster_id, role) cluster_state = get_cluster_state(cluster_id)
- cluster_state.each_value do |config|
if %(#{config["roles"]}) == role
return config["ip"]
- cluster_state.each_value do |role_state|
if %(#{role_state["roles"]}) == role
end endreturn role_state end
-- 2.23.0