From 5fd211e56bff965b77866fe7c221408a570ab7eb Mon Sep 17 00:00:00 2001 From: Youngkyun Kim Date: Sun, 11 Sep 2016 12:46:58 -0400 Subject: [PATCH] Update volume create --- app/controllers/volume_controller.rb | 29 ++++++++++++++++++++++------ app/views/volume/index.html.erb | 20 +++++++++---------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/app/controllers/volume_controller.rb b/app/controllers/volume_controller.rb index cbf4a71..dc18b16 100644 --- a/app/controllers/volume_controller.rb +++ b/app/controllers/volume_controller.rb @@ -64,16 +64,33 @@ class VolumeController < ApplicationController end def volume_create + @config = get_conf volume_name = params[:volume_name] + volume_type = params[:volume_type] + num_of_brick = params[:num_of_brick] 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_str << t - bricks_str << " " + command << t + command << " " end - puts "gluster volume create " + volume_name + " " + bricks_str + "force" - `sshpass -p#{@config["host_password"]} ssh #{@config["host_port"]} #{@config["host_user"]}@#{@config["host_ip"]} \ - gluster volume create #{volume_name} #{bricks_str} force` + command << "force" + puts command + `#{command}` redirect_to '/volume/index' end diff --git a/app/views/volume/index.html.erb b/app/views/volume/index.html.erb index 8a668db..7f53060 100644 --- a/app/views/volume/index.html.erb +++ b/app/views/volume/index.html.erb @@ -169,7 +169,14 @@ <% if t["Mount State"] == "Mounted" %> Unmount - <% elsif t["Status"] == " Stopped" %> + <% elsif t["Status"] == " Started" %> + + +

Stop

+
+ + Mount + <% else %>

Start

@@ -177,13 +184,6 @@
Delete - <% else %> - - -

Stop

-
- - Mount <% end %> @@ -350,7 +350,7 @@ var brick = ""; if(server_name == "<%=@config['server_name']%>"){ brick += "<%=@config['host_ip']%>"; - brick += "/"; + brick += ":/"; brick += brick_name; bricks.push(brick); console.log(brick); @@ -366,7 +366,7 @@ $.ajax({ method: "POST", 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){ console.log("volume create success"); }