Class: Pec::Init
Class Method Summary collapse
Class Method Details
.create_fog_config ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/pec/init.rb', line 24 def create_fog_config thor = Thor.new if !File.exist?(File.("~/.fog")) || thor.yes?("Do you want to overwrite the existing ~/.fog? [y/N]") thor.say("Start Configure by OpenStack", :yellow) params = {} params = %w(auth_url username api_key tenant).inject({}) do |user_input, c| user_input["openstack_#{c}"] = thor.ask("openstack #{c}:") user_input end thor.say("Configure Complete!", :blue) if open(File.("~/.fog"), "w") do |e| YAML.dump({ "default" => params }, e) end end end |
.create_sample_config ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/pec/init.rb', line 15 def create_sample_config unless File.exist?("Pec.yaml") open("Pec.yaml","w") do |e| YAML.dump(Pec::Configure::Sample.pec_file, e) end puts "create configure file Pec.yaml".green end end |
.create_template_dir ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/pec/init.rb', line 4 def create_template_dir dirname = "user_datas" unless FileTest.exist?(dirname) FileUtils.mkdir_p(dirname) open("#{dirname}/web_server.yaml.sample","w") do |e| YAML.dump(Pec::Configure::Sample.user_data, e) end if FileTest.exist?(dirname) puts "create directry user_datas".green end end |