This commit is contained in:
bee0005 2016-09-21 09:21:33 +00:00
parent 179afe0bd7
commit 2f5e7afc80
2 changed files with 28 additions and 36 deletions

View File

@ -14,22 +14,22 @@ class ApplicationController < ActionController::Base
@config["user_password"] = one_node.user_password
end
output = `cat configure.conf`.split("\n")
output.each do |t|
if t.include? "project_path="
@config["project_path"] = t.split("project_path=")[1]
elsif t.include? "server_name="
@config["server_name"] = t.split("server_name=")[1]
elsif t.include? "host_user="
@config["host_user"] = t.split("host_user=")[1]
elsif t.include? "host_ip="
@config["host_ip"] = t.split("host_ip=")[1]
elsif t.include? "host_port=" and !t.split("host_port=")[1].nil?
@config["host_port"] = t.split("host_port=")[1] + " "
elsif t.include? "host_password="
@config["host_password"] = t.split("host_password=")[1]
end
end
# output = `cat configure.conf`.split("\n")
# output.each do |t|
# if t.include? "project_path="
# @config["project_path"] = t.split("project_path=")[1]
# elsif t.include? "server_name="
# @config["server_name"] = t.split("server_name=")[1]
# elsif t.include? "host_user="
# @config["host_user"] = t.split("host_user=")[1]
# elsif t.include? "host_ip="
# @config["host_ip"] = t.split("host_ip=")[1]
# elsif t.include? "host_port=" and !t.split("host_port=")[1].nil?
# @config["host_port"] = t.split("host_port=")[1] + " "
# elsif t.include? "host_password="
# @config["host_password"] = t.split("host_password=")[1]
# end
# end
return @config

View File

@ -62,12 +62,10 @@ class VolumeController < ApplicationController
bricks = params[:bricks]
# make command string
command = String.new
command << "sshpass -p" + @config["host_password"].to_s
command << "sshpass -p" + @config["user_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 << @config["user_name"].to_s + "@" + @config["host_ip"].to_s
command << " gluster volume create " + volume_name + " "
if !volume_type.include? "Distribute"
command << volume_type.downcase + " " + num_of_brick + " "
@ -86,12 +84,10 @@ class VolumeController < ApplicationController
volume_name = params[:volume_name]
# make command string
command = String.new
command << "yes | sshpass -p" + @config["host_password"].to_s
command << "yes | sshpass -p" + @config["user_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 << @config["user_name"].to_s + "@" + @config["host_ip"].to_s
command << " gluster volume stop " + volume_name
puts command
`#{command}`
@ -103,12 +99,10 @@ class VolumeController < ApplicationController
volume_name = params[:volume_name]
# make command string
command = String.new
command << "sshpass -p" + @config["host_password"].to_s
command << "sshpass -p" + @config["user_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 << @config["user_name"].to_s + "@" + @config["host_ip"].to_s
command << " gluster volume start " + volume_name.to_s
puts command
`#{command}`
@ -120,12 +114,10 @@ class VolumeController < ApplicationController
volume_name = params[:volume_name]
# make command string
command = String.new
command << "yes | sshpass -p" + @config["host_password"].to_s
command << "yes | sshpass -p" + @config["user_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 << @config["user_name"].to_s + "@" + @config["host_ip"].to_s
command << " gluster volume delete " + volume_name
puts command
`#{command}`