diff --git a/app/controllers/volume_controller.rb b/app/controllers/volume_controller.rb index 4ff7a56..a1c13d2 100644 --- a/app/controllers/volume_controller.rb +++ b/app/controllers/volume_controller.rb @@ -47,7 +47,7 @@ class VolumeController < ApplicationController puts command `#{command}` #redirect_to '/volume/index' - + render :json => { :volume_info => volume_info(volume_name, index), } @@ -56,16 +56,14 @@ class VolumeController < ApplicationController def volume_unmount node = Node.take volume_name = params[:volume_name] - index = params[:index] # make command string command = String.new command << "sudo umount #{node.host_ip}:/#{volume_name}" puts command `#{command}` - #redirect_to '/volume/index' - + volume = volumes.find{ |v| v['Volume Name'].delete(' ') == volume_name} render :json => { - :volume_info => volume_info(volume_name, index), + :volume_info => volume_info(volume, 0), } end @@ -78,7 +76,7 @@ class VolumeController < ApplicationController # make command string command = String.new command << "sshpass -p#{node.user_password} " - command << "ssh #{node.host_name}@#{node.host_ip} " + command << "ssh #{node.user_name}@#{node.host_ip} " command << "gluster volume create #{volume_name} " if !volume_type.include? "Distribute" command << "#{volume_type.downcase} #{num_of_brick}" @@ -104,36 +102,28 @@ class VolumeController < ApplicationController def volume_stop node = Node.take volume_name = params[:volume_name] - index = params[:index] # make command string command = String.new - command << "yes | sshpass -p#{node.user_password} " - command << "ssh #{node.host_name}@#{node.host_ip} " - command << "gluster volume stop #{volume_name}" + command << "yes | sshpass -p#{node.user_password} ssh #{node.user_name}@#{node.host_ip} gluster volume stop #{volume_name}" puts command `#{command}` - #redirect_to '/volume/index' - + volume = volumes.find{ |v| v['Volume Name'].delete(' ') == volume_name} render :json => { - :volume_info => volume_info(volume_name, index), + :volume_info => volume_info(volume, 0), } end def volume_start node = Node.take volume_name = params[:volume_name] - index = params[:index] # make command string command = String.new - command << "sshpass -p#{node.user_password} " - command << "ssh #{node.host_name}@#{node.host_ip} " - command << " gluster volume start #{volume_name}" + command << "sshpass -p#{node.user_password} ssh #{node.user_name}@#{node.host_ip} gluster volume start #{volume_name}" puts command `#{command}` - #redirect_to '/volume/index' - + volume = volumes.find{ |v| v['Volume Name'].delete(' ') == volume_name} render :json => { - :volume_info => volume_info(volume_name, index), + :volume_info => volume_info(volume, 0), } end @@ -142,11 +132,9 @@ class VolumeController < ApplicationController volume_name = params[:volume_name] # make command string command = String.new - command << "yes | sshpass -p#{node.user_password} " - command << "ssh #{node.host_name}@#{node.host_ip} " - command << " gluster volume delete #{volume_name}" + command << "yes | sshpass -p#{node.user_password} ssh #{node.user_name}@#{node.host_ip} gluster volume delete #{volume_name}" puts command `#{command}` - redirect_to '/volume/index' + redirect_to "/volume/index" end end diff --git a/app/helpers/volume_helper.rb b/app/helpers/volume_helper.rb index b3cf0b6..ce73574 100644 --- a/app/helpers/volume_helper.rb +++ b/app/helpers/volume_helper.rb @@ -13,7 +13,7 @@ module VolumeHelper html << "
" html << "
" # left title - html << "

Infomation #{volume['Volume Name']}

" + html << "

Infomation #{volume['Volume Name']}

" # right title html << "" html << "" + html << "" + html << "" html << "
" html << "
" - html << "
" + html << "
" # left content html << "
" html << "
" @@ -48,21 +50,26 @@ module VolumeHelper html << "
" # buttons if volume["Mount State"] == "mounted" - html << "" + html << "" elsif volume["Status"] == " Started" - html << "" - html << "" + # need to fix this a tag to button + html << "" + html << " Mount" + html << "" else - html << "" - html << "" + html << "" end html << "
" @@ -85,7 +92,8 @@ module VolumeHelper html << "
" html << "
" html << "
" - html + + return html end def mount_table(dir = @current_dir, id = "mount_table", class_option = "table table-striped table-bordered jambo_table") diff --git a/app/views/volume/index.html.erb b/app/views/volume/index.html.erb index c52836a..0716312 100644 --- a/app/views/volume/index.html.erb +++ b/app/views/volume/index.html.erb @@ -242,93 +242,135 @@ $(document).on("click", "#mount_table_div .chupper", function(){ + - - - - - - - - - - \ No newline at end of file + diff --git a/config/routes.rb b/config/routes.rb index c0fe943..8a00cc7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,10 +21,10 @@ Rails.application.routes.draw do post 'file_upload/:volume_name' => 'volume#file_upload' post 'volume/mount' => "volume#volume_mount" post 'volume/create' => "volume#volume_create" - get 'volume/unmount/:volume_name' => "volume#volume_unmount" - get 'volume/start/:volume_name' => "volume#volume_start" - get 'volume/stop/:volume_name' => "volume#volume_stop" - get 'volume/delete/:volume_name' => "volume#volume_delete" + post 'volume/unmount' => "volume#volume_unmount" + post 'volume/start' => "volume#volume_start" + post 'volume/stop' => "volume#volume_stop" + post 'volume/delete' => "volume#volume_delete" #Node get 'node/index' => 'node#index'