Add top tiles to dashboard
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class VolumeController < ApplicationController
|
||||
before_action :require_login
|
||||
before_action :require_login
|
||||
|
||||
def index
|
||||
file_directory("/mnt")
|
||||
@@ -28,49 +28,49 @@ class VolumeController < ApplicationController
|
||||
end
|
||||
|
||||
def volume_mount
|
||||
conf = get_conf
|
||||
node = Node.take
|
||||
volume_name = params[:volume_name]
|
||||
mount_point = params[:mount_point]
|
||||
# make command string
|
||||
command = String.new
|
||||
command << "sudo mount -t glusterfs #{conf['host_ip']}:/#{volume_name} #{mount_point}"
|
||||
command << "sudo mount -t glusterfs #{node.host_ip}:/#{volume_name} #{mount_point}"
|
||||
puts command
|
||||
`#{command}`
|
||||
redirect_to '/volume/index'
|
||||
end
|
||||
|
||||
def volume_unmount
|
||||
conf = get_conf
|
||||
node = Node.take
|
||||
volume_name = params[:volume_name]
|
||||
# make command string
|
||||
command = String.new
|
||||
command << "sudo umount #{conf['host_ip']}:/#{volume_name}"
|
||||
command << "sudo umount #{node.host_ip}:/#{volume_name}"
|
||||
puts command
|
||||
`#{command}`
|
||||
redirect_to '/volume/index'
|
||||
end
|
||||
|
||||
def volume_create
|
||||
conf = get_conf
|
||||
node = Node.take
|
||||
volume_name = params[:volume_name]
|
||||
volume_type = params[:volume_type]
|
||||
num_of_brick = params[:num_of_brick]
|
||||
bricks = params[:bricks]
|
||||
# make command string
|
||||
command = String.new
|
||||
command << "sshpass -p#{conf['user_password']} "
|
||||
command << "ssh #{conf['user_name']}@#{conf['host_ip']} "
|
||||
command << "sshpass -p#{node.user_password} "
|
||||
command << "ssh #{node.host_name}@#{node.host_ip} "
|
||||
command << "gluster volume create #{volume_name} "
|
||||
if !volume_type.include? "Distribute"
|
||||
command << "#{volume_type.downcase} #{num_of_brick}"
|
||||
end
|
||||
conf_all = get_conf_all
|
||||
nodes = Node.all
|
||||
bricks.each do |t|
|
||||
host_name = t.split(":/")[0]
|
||||
brick_name = t.split(":/")[1]
|
||||
host_ip = ""
|
||||
conf_all.each do |u|
|
||||
next if !u['host_name'].eql? host_name
|
||||
nodes.each do |u|
|
||||
next if !u.host_name.eql? host_name
|
||||
host_ip = u['host_ip']
|
||||
end
|
||||
brick = "#{host_ip}:/#{brick_name}"
|
||||
@@ -83,12 +83,12 @@ class VolumeController < ApplicationController
|
||||
end
|
||||
|
||||
def volume_stop
|
||||
conf = get_conf
|
||||
node = Node.take
|
||||
volume_name = params[:volume_name]
|
||||
# make command string
|
||||
command = String.new
|
||||
command << "yes | sshpass -p#{conf['user_password']} "
|
||||
command << "ssh #{conf['user_name']}@#{conf['host_ip']} "
|
||||
command << "yes | sshpass -p#{node.user_password} "
|
||||
command << "ssh #{node.host_name}@#{node.host_ip} "
|
||||
command << "gluster volume stop #{volume_name}"
|
||||
puts command
|
||||
`#{command}`
|
||||
@@ -96,12 +96,12 @@ class VolumeController < ApplicationController
|
||||
end
|
||||
|
||||
def volume_start
|
||||
conf = get_conf
|
||||
node = Node.take
|
||||
volume_name = params[:volume_name]
|
||||
# make command string
|
||||
command = String.new
|
||||
command << "sshpass -p#{conf['user_password']} "
|
||||
command << "ssh #{conf['user_name']}@#{conf['host_ip']} "
|
||||
command << "sshpass -p#{node.user_password} "
|
||||
command << "ssh #{node.host_name}@#{node.host_ip} "
|
||||
command << " gluster volume start #{volume_name}"
|
||||
puts command
|
||||
`#{command}`
|
||||
@@ -109,12 +109,12 @@ class VolumeController < ApplicationController
|
||||
end
|
||||
|
||||
def volume_delete
|
||||
conf = get_conf
|
||||
node = Node.take
|
||||
volume_name = params[:volume_name]
|
||||
# make command string
|
||||
command = String.new
|
||||
command << "yes | sshpass -p#{conf['user_password']} "
|
||||
command << "ssh #{conf['user_name']}@#{conf['host_ip']} "
|
||||
command << "yes | sshpass -p#{node.user_password} "
|
||||
command << "ssh #{node.host_name}@#{node.host_ip} "
|
||||
command << " gluster volume delete #{volume_name}"
|
||||
puts command
|
||||
`#{command}`
|
||||
|
||||
Reference in New Issue
Block a user