Class: Machines::CloudMachine
- Inherits:
-
Object
- Object
- Machines::CloudMachine
- Defined in:
- lib/machines/cloud_machine.rb
Instance Method Summary collapse
Instance Method Details
#connect_to_cloud ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/machines/cloud_machine.rb', line 3 def connect_to_cloud begin require 'fog' rescue LoadError say 'fog gem required to use cloud features.' say 'Please "gem install fog".' raise end Fog.credential = 'machines_key' = symbolize_keys($conf.cloud.to_hash) .merge!(:region => $conf.machine.cloud.region) $conf.cloud.connection = Fog::Compute.new() end |
#create_server ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/machines/cloud_machine.rb', line 18 def create_server server = $conf.cloud.connection.servers.create( :private_key_path => $conf.machine.cloud.private_key_path, :public_key_path => $conf.machine.cloud.public_key_path, :username => $conf.machine.cloud.username, :flavor_id => $conf.machine.cloud.flavor_id, :image_id => $conf.machine.cloud.image_id) server.wait_for { ready? } end |
#symbolize_keys(hash) ⇒ Object
28 29 30 |
# File 'lib/machines/cloud_machine.rb', line 28 def symbolize_keys hash hash.inject({}){|new_hash, (k, v)| new_hash[k.to_sym] = v; new_hash } end |