Class: Yun::Connection
- Inherits:
-
Object
- Object
- Yun::Connection
- Defined in:
- lib/yun/model/connection.rb
Instance Method Summary collapse
- #create(attributes = {}, &block) ⇒ Object
- #find(node_name) ⇒ Object
-
#initialize(options) ⇒ Connection
constructor
A new instance of Connection.
- #list ⇒ Object
Constructor Details
#initialize(options) ⇒ Connection
Returns a new instance of Connection.
5 6 7 |
# File 'lib/yun/model/connection.rb', line 5 def initialize @servers = Fog::Compute.new().servers end |
Instance Method Details
#create(attributes = {}, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/yun/model/connection.rb', line 9 def create attributes={}, &block fog_attributes = FogAttributes.new attributes server = @servers.create fog_attributes server.wait_for do instance_eval(&block) if block_given? ready? end Node.new server end |
#find(node_name) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/yun/model/connection.rb', line 25 def find node_name node = list.find do |node| node.name == node_name and not node.is_destroyed? end if node == nil puts "Error: Cannot find node #{node_name}" exit 1 end node end |