Update node add function

This commit is contained in:
kyg516 2016-09-21 18:31:38 +09:00
parent 2f5e7afc80
commit 06f7a66feb

View File

@ -1,24 +1,16 @@
module VolumeHelper module VolumeHelper
def get_conf def get_conf
config = Hash.new @config = Hash.new
output = `cat configure.conf`.split("\n")
output.each do |t| one_node = Node.take
if t.include? "project_path=" if !one_node.nil?
config["project_path"] = t.split("project_path=")[1] @config["host_name"] = one_node.host_name
elsif t.include? "server_name=" @config["host_ip"] = one_node.host_ip
config["server_name"] = t.split("server_name=")[1] @config["user_name"] = one_node.user_name
elsif t.include? "host_user=" @config["user_password"] = one_node.user_password
config["host_user"] = t.split("host_user=")[1]
elsif t.include? "host_ip="
config["host_ip"] = t.split("host_ip=")[1]
elsif t.include? "host_port=" and !t.split("host_port=")[1].nil?
config["host_port"] = t.split("host_port=")[1] + " "
elsif t.include? "host_password="
config["host_password"] = t.split("host_password=")[1]
end
end end
return config return @config
end end
def get_volumes def get_volumes
@ -27,7 +19,7 @@ module VolumeHelper
command = "df -P" command = "df -P"
df = `#{command}` df = `#{command}`
conf = get_conf conf = get_conf
command = "sshpass -p#{conf['host_password']} ssh #{conf['host_user']}@#{conf['host_ip']} gluster volume info" command = "sshpass -p#{conf['user_password']} ssh #{conf['user_name']}@#{conf['host_ip']} gluster volume info"
info = `#{command}`.split("\n") info = `#{command}`.split("\n")
info << "\n" info << "\n"
info.each do |t| info.each do |t|