Update and fix volume controller

This commit is contained in:
Youngkyun Kim 2016-09-03 10:54:41 +00:00
parent 54977ac9a1
commit 0ec7d042f2

View File

@ -1,22 +1,27 @@
class VolumeController < ApplicationController
def index
@config = get_conf
@volumes = Array.new
volume = Hash.new
file_directory("/mnt")
get_conf
info = get_info.split("\n")
if get_info.blank?
if info.blank?
flash[:danger] = "Check Server"
else
info = get_info.split("\n")
df = get_df
puts df
parse_info(info)
end
end
for t in 1..(info.length-1)
if info[t].include? ":"
temp = info[t].split(":")
def parse_info(info)
@volumes = Array.new
volume = Hash.new
df = get_df
info.each do |t|
next if t.equal? info.first
if t.include? ":"
temp = t.split(":")
volume[temp[0]] = temp[1]
else
if df.include? volume['Volume Name'].delete(' ')
@ -31,17 +36,14 @@ class VolumeController < ApplicationController
end
end
@volumes << volume
# puts @volumes
end
end
def get_df
@config = get_conf
return `df -P`
end
def get_info
@config = get_conf
return `sshpass -p#{@config["host_password"]} ssh #{@config["host_port"]} #{@config["host_user"]}@#{@config["host_ip"]} gluster volume info`
end
@ -52,16 +54,13 @@ class VolumeController < ApplicationController
redirect_to '/volume/info'
end
def volume_mount
@config = get_conf
volume_name = params[:volume_name]
mount_point = params[:mount_point]
volume_name = volume_name.delete(' ')
puts "mount -t glusterfs " + @config["host_ip"] + ":/" + volume_name + " " + mount_point
`mount -t glusterfs #{@config["host_ip"]}:/#{volume_name} #{mount_point}`
redirect_to '/volume/index'
end