Update volume controller

This commit is contained in:
Youngkyun Kim 2016-08-27 07:50:36 -04:00
parent 6bebf599ce
commit 8fe78e8384
11 changed files with 31 additions and 16 deletions

View File

@ -1,11 +1,10 @@
class VolumeController < ApplicationController class VolumeController < ApplicationController
def info def info
mnt_path = "/opt/gluster-web-interface/app/mntpoint"
file_directory('/home/ubuntu')
@volumes = Array.new @volumes = Array.new
volume = Hash.new volume = Hash.new
i = 0 i = 0
if get_info.blank? if get_info.blank?
flash[:danger] = "Check Server" flash[:danger] = "Check Server"
else else
@ -15,11 +14,13 @@ class VolumeController < ApplicationController
temp = output[t].split(":") temp = output[t].split(":")
volume[temp[0]] = temp[1] volume[temp[0]] = temp[1]
else else
volume["files"] = file_directory(mnt_path + "/" + volume["Volume Name"].delete(' '), volume["Volume Name"].delete(' '))
@volumes[i] = volume @volumes[i] = volume
volume = Hash.new volume = Hash.new
i+=1 i+=1
end end
end end
volume["files"] = file_directory(mnt_path + "/" + volume["Volume Name"].delete(' '), volume["Volume Name"].delete(' '))
@volumes[i] = volume @volumes[i] = volume
puts @volumes puts @volumes
end end
@ -37,13 +38,24 @@ class VolumeController < ApplicationController
end end
def file_directory(dir) def file_directory(dir, dir_name)
puts "start///////"
puts "dir: " + dir
puts "dir_name: " + dir_name
@current_dir = dir @current_dir = dir
`sudo mkdir #{dir}`
`sudo mount.glusterfs gluster-1:/#{dir_name} #{dir}`
dir_list = `ls #{@current_dir} -l` dir_list = `ls #{@current_dir} -l`
puts dir_list
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 i = 0
@total_list = parsing_list[0] @total_list = parsing_list[0]
@ -52,12 +64,14 @@ class VolumeController < ApplicationController
parsing_file = parsing_list[t].split(" ") parsing_file = parsing_list[t].split(" ")
file["auth"] = parsing_file[0] file["auth"] = parsing_file[0]
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[i] = file
file = Hash.new file = Hash.new
i+=1 i+=1
end end
puts @files puts files
return files
end end
end end

Binary file not shown.

View File

View File

View File

View File

View File

View File

@ -4,7 +4,7 @@
<div class=""> <div class="">
<div class="page-title"> <div class="page-title">
<div class="title_left"> <div class="title_left">
<h3>Volume Info </h3> <h3>Volume</h3>
</div> </div>
<div class="title_right"> <div class="title_right">
<div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search"> <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
@ -84,7 +84,8 @@
</thead> </thead>
<tbody> <tbody>
<%@files.each do |t|%> <%f = t["files"]%>
<%f.each do |t|%>
<tr> <tr>
<td><%=t["name"]%></td> <td><%=t["name"]%></td>
<td><%=t["auth"][0]%></td> <td><%=t["auth"][0]%></td>
@ -156,4 +157,4 @@
}); });
}); });
TableManageButtons.init(); TableManageButtons.init();
</script> </script>

View File

@ -1,2 +1,2 @@
host: host
124.63.216.174:2222 gluster-1 192.168.0.10 gluster-1