Update volume create
This commit is contained in:
parent
1f8e23e6a5
commit
5fd211e56b
@ -64,16 +64,33 @@ class VolumeController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def volume_create
|
def volume_create
|
||||||
|
@config = get_conf
|
||||||
volume_name = params[:volume_name]
|
volume_name = params[:volume_name]
|
||||||
|
volume_type = params[:volume_type]
|
||||||
|
num_of_brick = params[:num_of_brick]
|
||||||
bricks = params[:bricks]
|
bricks = params[:bricks]
|
||||||
bricks_str = ""
|
command = String.new
|
||||||
|
command << "sshpass"
|
||||||
|
command << " -p"
|
||||||
|
command << @config["host_password"].to_s
|
||||||
|
command << " ssh "
|
||||||
|
command << @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|
|
bricks.each do |t|
|
||||||
bricks_str << t
|
command << t
|
||||||
bricks_str << " "
|
command << " "
|
||||||
end
|
end
|
||||||
puts "gluster volume create " + volume_name + " " + bricks_str + "force"
|
command << "force"
|
||||||
`sshpass -p#{@config["host_password"]} ssh #{@config["host_port"]} #{@config["host_user"]}@#{@config["host_ip"]} \
|
puts command
|
||||||
gluster volume create #{volume_name} #{bricks_str} force`
|
`#{command}`
|
||||||
redirect_to '/volume/index'
|
redirect_to '/volume/index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -169,7 +169,14 @@
|
|||||||
|
|
||||||
<% 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"] == " Stopped" %>
|
<% elsif t["Status"] == " Started" %>
|
||||||
|
<a class="btn btn-app" href="/volume/stop/<%=t['Volume Name'].delete(' ')%>">
|
||||||
|
<i class="fa fa-pause" style="color:#d9534f;"></i>
|
||||||
|
<p style="color:#d9534f;">Stop</p>
|
||||||
|
</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>
|
||||||
|
<% 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(' ')%>">
|
||||||
<i class="fa fa-play" style="color:#26B99A;"></i>
|
<i class="fa fa-play" style="color:#26B99A;"></i>
|
||||||
<p style="color:#26B99A;">Start</p>
|
<p style="color:#26B99A;">Start</p>
|
||||||
@ -177,13 +184,6 @@
|
|||||||
<a class="btn btn-app" href="/volume/delete/<%=t['Volume Name'].delete(' ')%>">
|
<a class="btn btn-app" href="/volume/delete/<%=t['Volume Name'].delete(' ')%>">
|
||||||
<i class="fa fa-trash"></i> Delete
|
<i class="fa fa-trash"></i> Delete
|
||||||
</a>
|
</a>
|
||||||
<% else %>
|
|
||||||
<a class="btn btn-app" href="/volume/stop/<%=t['Volume Name'].delete(' ')%>">
|
|
||||||
<i class="fa fa-pause" style="color:#d9534f;"></i>
|
|
||||||
<p style="color:#d9534f;">Stop</p>
|
|
||||||
</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>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -350,7 +350,7 @@
|
|||||||
var brick = "";
|
var brick = "";
|
||||||
if(server_name == "<%=@config['server_name']%>"){
|
if(server_name == "<%=@config['server_name']%>"){
|
||||||
brick += "<%=@config['host_ip']%>";
|
brick += "<%=@config['host_ip']%>";
|
||||||
brick += "/";
|
brick += ":/";
|
||||||
brick += brick_name;
|
brick += brick_name;
|
||||||
bricks.push(brick);
|
bricks.push(brick);
|
||||||
console.log(brick);
|
console.log(brick);
|
||||||
@ -366,7 +366,7 @@
|
|||||||
$.ajax({
|
$.ajax({
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: "/volume/create",
|
url: "/volume/create",
|
||||||
data: { volume_name : volume_name, bricks : bricks },
|
data: { volume_name : volume_name, volume_type : volume_type, num_of_brick : num_of_brick, bricks : bricks },
|
||||||
success : function(result){
|
success : function(result){
|
||||||
console.log("volume create success");
|
console.log("volume create success");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user