Sha256: c1365199112e02523153b1a54365566d5485c3705d868716213c874cd925b8dd

Contents?: true

Size: 739 Bytes

Versions: 2

Compression:

Stored size: 739 Bytes

Contents

require 'yun/model'

module Yun
  class Connection
    def initialize options
      @servers = Fog::Compute.new(options).servers
    end

    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

    def list
      @servers.map do |server|
        Node.new server
      end
    end

    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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yun-0.0.6 lib/yun/model/connection.rb
yun-0.0.5 lib/yun/model/connection.rb