Change all command on Volume controller
This commit is contained in:
parent
5fd211e56b
commit
c1a44853af
@ -16,7 +16,7 @@ class ApplicationController < ActionController::Base
|
|||||||
elsif t.include? "host_ip="
|
elsif t.include? "host_ip="
|
||||||
@config["host_ip"] = t.split("host_ip=")[1]
|
@config["host_ip"] = t.split("host_ip=")[1]
|
||||||
elsif t.include? "host_port=" and !t.split("host_port=")[1].nil?
|
elsif t.include? "host_port=" and !t.split("host_port=")[1].nil?
|
||||||
@config["host_port"] = "-p " + t.split("host_port=")[1] + " "
|
@config["host_port"] = t.split("host_port=")[1] + " "
|
||||||
elsif t.include? "host_password="
|
elsif t.include? "host_password="
|
||||||
@config["host_password"] = t.split("host_password=")[1]
|
@config["host_password"] = t.split("host_password=")[1]
|
||||||
end
|
end
|
||||||
|
@ -22,7 +22,7 @@ class VolumeController < ApplicationController
|
|||||||
temp = t.split(":")
|
temp = t.split(":")
|
||||||
volume[temp[0]] = temp[1]
|
volume[temp[0]] = temp[1]
|
||||||
else
|
else
|
||||||
String state = (df.include? volume['Volume Name'].delete(' ')) ? "Mounted" : "UnMounted"
|
String state = (df.include? volume['Volume Name'].delete(' ')) ? "mounted" : "unmounted"
|
||||||
volume['Mount State'] = state
|
volume['Mount State'] = state
|
||||||
@volumes << volume
|
@volumes << volume
|
||||||
volume = Hash.new
|
volume = Hash.new
|
||||||
@ -35,8 +35,16 @@ class VolumeController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_volume_info
|
def get_volume_info
|
||||||
return `sshpass -p#{@config["host_password"]} ssh #{@config["host_port"]} #{@config["host_user"]}@#{@config["host_ip"]} \
|
command = String.new
|
||||||
gluster volume info`
|
command << "sshpass -p" + @config["host_password"].to_s
|
||||||
|
command << " ssh "
|
||||||
|
if !@config["host_port"].nil?
|
||||||
|
command << "-p " + @config["host_port"].to_s + " "
|
||||||
|
end
|
||||||
|
command << @config["host_user"].to_s + "@" + @config["host_ip"].to_s
|
||||||
|
command << " gluster volume info"
|
||||||
|
puts command
|
||||||
|
return `#{command}`
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_upload
|
def file_upload
|
||||||
@ -47,78 +55,103 @@ class VolumeController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def volume_mount
|
def volume_mount
|
||||||
@config = get_conf
|
get_conf
|
||||||
volume_name = params[:volume_name]
|
volume_name = params[:volume_name]
|
||||||
mount_point = params[:mount_point]
|
mount_point = params[:mount_point]
|
||||||
puts "mount -t glusterfs " + @config["host_ip"] + ":/" + volume_name + " " + mount_point
|
# make command string
|
||||||
`mount -t glusterfs #{@config["host_ip"]}:/#{volume_name} #{mount_point}`
|
command = String.new
|
||||||
|
command << "mount -t glusterfs " + @config["host_ip"].to_s + ":/" + volume_name + " " + mount_point
|
||||||
|
puts command
|
||||||
|
`#{command}`
|
||||||
redirect_to '/volume/index'
|
redirect_to '/volume/index'
|
||||||
end
|
end
|
||||||
|
|
||||||
def volume_unmount
|
def volume_unmount
|
||||||
@config = get_conf
|
get_conf
|
||||||
volume_name = params[:volume_name]
|
volume_name = params[:volume_name]
|
||||||
puts "umount " + @config["host_ip"] + ":/" + volume_name
|
# make command string
|
||||||
`umount #{@config["host_ip"]}:/#{volume_name}`
|
command = String.new
|
||||||
|
command << "umount " + @config["host_ip"].to_s + ":/" + volume_name
|
||||||
|
puts command
|
||||||
|
`#{command}`
|
||||||
redirect_to '/volume/index'
|
redirect_to '/volume/index'
|
||||||
end
|
end
|
||||||
|
|
||||||
def volume_create
|
def volume_create
|
||||||
@config = get_conf
|
get_conf
|
||||||
volume_name = params[:volume_name]
|
volume_name = params[:volume_name]
|
||||||
volume_type = params[:volume_type]
|
volume_type = params[:volume_type]
|
||||||
num_of_brick = params[:num_of_brick]
|
num_of_brick = params[:num_of_brick]
|
||||||
bricks = params[:bricks]
|
bricks = params[:bricks]
|
||||||
command = String.new
|
# make command string
|
||||||
command << "sshpass"
|
command = String.new
|
||||||
command << " -p"
|
command << "sshpass -p" + @config["host_password"].to_s
|
||||||
command << @config["host_password"].to_s
|
command << " ssh "
|
||||||
command << " ssh "
|
if !@config["host_port"].nil?
|
||||||
command << @config["host_port"].to_s
|
command << "-p " + @config["host_port"].to_s + " "
|
||||||
command << " "
|
|
||||||
command << @config["host_user"].to_s
|
|
||||||
command << "@"
|
|
||||||
command << @config["host_ip"].to_s
|
|
||||||
command << " gluster volume create "
|
|
||||||
command << volume_name + " "
|
|
||||||
if !volume_type.include? "Distribute"
|
|
||||||
command << volume_type + " " + num_of_brick + " "
|
|
||||||
end
|
|
||||||
bricks.each do |t|
|
|
||||||
command << t
|
|
||||||
command << " "
|
|
||||||
end
|
end
|
||||||
command << "force"
|
command << @config["host_user"].to_s + "@" + @config["host_ip"].to_s
|
||||||
|
command << " gluster volume create " + volume_name + " "
|
||||||
|
if !volume_type.equal? "Distribute"
|
||||||
|
command << volume_type.downcase + " " + num_of_brick + " "
|
||||||
|
end
|
||||||
|
bricks.each do |t|
|
||||||
|
command << t + " "
|
||||||
|
end
|
||||||
|
command << "force"
|
||||||
puts command
|
puts command
|
||||||
`#{command}`
|
`#{command}`
|
||||||
redirect_to '/volume/index'
|
redirect_to '/volume/index'
|
||||||
end
|
end
|
||||||
|
|
||||||
def volume_stop
|
def volume_stop
|
||||||
@config = get_conf
|
get_conf
|
||||||
volume_name = params[:volume_name]
|
volume_name = params[:volume_name]
|
||||||
puts "gluster volume stop " + volume_name
|
# make command string
|
||||||
`yes | sshpass -p#{@config["host_password"]} ssh #{@config["host_port"]} #{@config["host_user"]}@#{@config["host_ip"]} \
|
command = String.new
|
||||||
gluster volume stop #{volume_name}`
|
command << "yes | sshpass -p" + @config["host_password"].to_s
|
||||||
|
command << " ssh "
|
||||||
|
if !@config["host_port"].nil?
|
||||||
|
command << "-p " + @config["host_port"].to_s + " "
|
||||||
|
end
|
||||||
|
command << @config["host_user"].to_s + "@" + @config["host_ip"].to_s
|
||||||
|
command << " gluster volume stop " + volume_name
|
||||||
|
puts command
|
||||||
|
`#{command}`
|
||||||
redirect_to '/volume/index'
|
redirect_to '/volume/index'
|
||||||
end
|
end
|
||||||
|
|
||||||
def volume_start
|
def volume_start
|
||||||
@config = get_conf
|
get_conf
|
||||||
volume_name = params[:volume_name]
|
volume_name = params[:volume_name]
|
||||||
puts "gluster volume start " + volume_name
|
# make command string
|
||||||
`sshpass -p#{@config["host_password"]} ssh #{@config["host_port"]} #{@config["host_user"]}@#{@config["host_ip"]} \
|
command = String.new
|
||||||
gluster volume start #{volume_name}`
|
command << "sshpass -p" + @config["host_password"].to_s
|
||||||
|
command << " ssh "
|
||||||
|
if !@config["host_port"].nil?
|
||||||
|
command << "-p " + @config["host_port"].to_s + " "
|
||||||
|
end
|
||||||
|
command << @config["host_user"].to_s + "@" + @config["host_ip"].to_s
|
||||||
|
command << " gluster volume start " + volume_name
|
||||||
|
puts command
|
||||||
|
`#{command}`
|
||||||
redirect_to '/volume/index'
|
redirect_to '/volume/index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def volume_delete
|
def volume_delete
|
||||||
@config = get_conf
|
get_conf
|
||||||
volume_name = params[:volume_name]
|
volume_name = params[:volume_name]
|
||||||
puts "gluster volume delete " + volume_name
|
# make command string
|
||||||
`yes | sshpass -p#{@config["host_password"]} ssh #{@config["host_port"]} #{@config["host_user"]}@#{@config["host_ip"]} \
|
command = String.new
|
||||||
gluster volume delete #{volume_name}`
|
command << "yes | sshpass -p" + @config["host_password"].to_s
|
||||||
|
command << " ssh "
|
||||||
|
if !@config["host_port"].nil?
|
||||||
|
command << "-p " + @config["host_port"].to_s + " "
|
||||||
|
end
|
||||||
|
command << @config["host_user"].to_s + "@" + @config["host_ip"].to_s
|
||||||
|
command << " gluster volume delete " + volume_name
|
||||||
|
puts command
|
||||||
|
`#{command}`
|
||||||
redirect_to '/volume/index'
|
redirect_to '/volume/index'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -167,14 +167,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<% if t["Mount State"] == "Mounted" %>
|
<% if t["Mount State"] == "mounted" %>
|
||||||
<a class="btn btn-app" href="/volume/unmount/<%=t['Volume Name'].delete(' ')%>"><i class="fa fa-upload"></i> Unmount</a>
|
<a class="btn btn-app" href="/volume/unmount/<%=t['Volume Name'].delete(' ')%>"><i class="fa fa-upload"></i> Unmount</a>
|
||||||
<% elsif t["Status"] == " Started" %>
|
<% elsif t["Status"] == " Started" %>
|
||||||
<a class="btn btn-app" href="/volume/stop/<%=t['Volume Name'].delete(' ')%>">
|
<a class="btn btn-app" href="/volume/stop/<%=t['Volume Name'].delete(' ')%>">
|
||||||
<i class="fa fa-pause" style="color:#d9534f;"></i>
|
<i class="fa fa-pause" style="color:#d9534f;"></i>
|
||||||
<p style="color:#d9534f;">Stop</p>
|
<p style="color:#d9534f;">Stop</p>
|
||||||
</a>
|
</a>
|
||||||
<!-- mount button push : popup event and post mount point -->
|
|
||||||
<a class="btn btn-app" href="/volume/index?volume_name=<%=t['Volume Name'].delete(' ')%>#popup_mount"><i class="fa fa-download"></i> Mount</a>
|
<a class="btn btn-app" href="/volume/index?volume_name=<%=t['Volume Name'].delete(' ')%>#popup_mount"><i class="fa fa-download"></i> Mount</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a class="btn btn-app" href="/volume/start/<%=t['Volume Name'].delete(' ')%>">
|
<a class="btn btn-app" href="/volume/start/<%=t['Volume Name'].delete(' ')%>">
|
||||||
@ -297,7 +296,7 @@
|
|||||||
new_body += "<div class='row' style='margin:0 0 10px 0'>";
|
new_body += "<div class='row' style='margin:0 0 10px 0'>";
|
||||||
new_body += "<label class='control-label col-md-3 col-sm-3 col-xs-12'>";
|
new_body += "<label class='control-label col-md-3 col-sm-3 col-xs-12'>";
|
||||||
if(i == 0)
|
if(i == 0)
|
||||||
new_body += "Bricks <span class='required'>*</span>";
|
new_body += "Bricks <span class='required'>*</span>";
|
||||||
new_body += "</label>";
|
new_body += "</label>";
|
||||||
new_body += "<div class='col-md-3 col-sm-3 col-xs-4'>";
|
new_body += "<div class='col-md-3 col-sm-3 col-xs-4'>";
|
||||||
new_body += "<select class='form-control'>";
|
new_body += "<select class='form-control'>";
|
||||||
|
Loading…
Reference in New Issue
Block a user