Add setup.sh and parsing code for configure.conf

This commit is contained in:
Youngkyun Kim 2016-08-28 04:36:02 -04:00
parent 13a67e201d
commit 7f2362ddb4
2 changed files with 30 additions and 9 deletions

View File

@ -2,10 +2,10 @@ class VolumeController < ApplicationController
helper_method :file_directory helper_method :file_directory
def info def info
file_directory('/opt/gluster-web-interface') file_directory(`pwd`)
@volumes = Array.new @volumes = Array.new
volume = Hash.new volume = Hash.new
i = 0
if get_info.blank? if get_info.blank?
flash[:danger] = "Check Server" flash[:danger] = "Check Server"
else else
@ -15,18 +15,39 @@ class VolumeController < ApplicationController
temp = output[t].split(":") temp = output[t].split(":")
volume[temp[0]] = temp[1] volume[temp[0]] = temp[1]
else else
@volumes[i] = volume @volumes << volume
volume = Hash.new volume = Hash.new
i+=1
end end
end end
@volumes[i] = volume @volumes << volume
puts @volumes puts @volumes
end end
end end
def get_conf
return `cat configure.conf`.split("\n")
end
def get_info def get_info
return `sshpass -pakfm77 ssh -p 2222 root@124.63.216.174 gluster volume info` conf_list = get_conf
host_user = "root"
host_ip = "127.0.0.1"
host_password = "secret"
host_port = ""
conf_list.each do |t|
if t.include? "host_name="
host_user = t.split("host_user=")[1]
elsif t.include? "host_ip="
host_ip = t.split("host_ip=")[1]
elsif t.include? "host_port=" and !t.split("host_port=")[1].nil?
host_port = "-p " + t.split("host_port=")[1] + " "
elsif t.include? "host_password="
host_password = t.split("host_password=")[1]
end
end
return `sshpass -p#{host_password} ssh #{host_port} #{host_user}@#{host_ip} gluster volume info`
end end
def file_upload def file_upload
@ -43,7 +64,7 @@ class VolumeController < ApplicationController
parsing_list = dir_list.split("\n") parsing_list = dir_list.split("\n")
@files = Array.new @files = Array.new
file = Hash.new file = Hash.new
i = 0
@total_list = parsing_list[0] @total_list = parsing_list[0]
for t in 1..(parsing_list.length-1) for t in 1..(parsing_list.length-1)
parsing_file = parsing_list[t].split(" ") parsing_file = parsing_list[t].split(" ")
@ -51,9 +72,8 @@ class VolumeController < ApplicationController
file["size"] = parsing_file[4] file["size"] = parsing_file[4]
file["date"] = parsing_file[5] + " " + parsing_file[6] + " "+ parsing_file[7] file["date"] = parsing_file[5] + " " + parsing_file[6] + " "+ parsing_file[7]
file["name"] = parsing_file[8] file["name"] = parsing_file[8]
@files[i] = file @files << file
file = Hash.new file = Hash.new
i+=1
end end
puts @files puts @files
return @files return @files

View File

@ -12,5 +12,6 @@ touch $CONF_PATH
echo "project_path=`pwd`" >> $CONF_PATH echo "project_path=`pwd`" >> $CONF_PATH
echo "server_name=gluster" >> $CONF_PATH echo "server_name=gluster" >> $CONF_PATH
echo "host_ip=127.0.0.1" >> $CONF_PATH echo "host_ip=127.0.0.1" >> $CONF_PATH
echo "host_port=" >> $CONF_PATH
echo "host_user=root" >> $CONF_PATH echo "host_user=root" >> $CONF_PATH
echo "host_password=secret" >> $CONF_PATH echo "host_password=secret" >> $CONF_PATH