Merge pull request #82 from cloudbees/master

Adds a new box type 'existing'
This commit is contained in:
R. Tyler Croy 2013-07-03 16:37:25 -07:00
commit 2d2c711bfc
2 changed files with 71 additions and 8 deletions

View File

@ -0,0 +1,64 @@
require 'ostruct'
require 'fog/core/timeout'
require 'fog/core/wait_for'
require 'etc'
module Blimpy::Boxes
# Fake box type for physical computer accessible through SSH
class Existing < Blimpy::Box
attr_accessor :host
def self.fog_server_for_instance(id, blimpdata)
ExistingServer.new(id,blimpdata[:host])
end
def initialize(server=nil)
super(server)
@username = Etc.getlogin
end
def validate!
if @host.nil?
raise Blimpy::BoxValidationError, "Don't know which box to log into --- the host property is not set."
end
end
def wait_for_state(until_state, &block)
# this magical box type becomes any state instantly
end
private
def create_host
ExistingServer.new(@name,@host)
end
end
class ExistingServer
def initialize(name,host)
@name = name
@host = host
end
def dns_name
@host
end
def private_dns_name
@host
end
def id
@name
end
def wait_for(timeout=Fog.timeout, interval=1, &block)
Fog.wait_for(timeout, interval, &block)
end
# no-ops
def stop
end
def start
end
def destroy
end
end
end

View File

@ -1,6 +1,7 @@
require 'blimpy/helpers/state'
require 'blimpy/boxes/aws'
require 'blimpy/boxes/openstack'
require 'blimpy/boxes/existing'
module Blimpy
class Fleet
@ -14,8 +15,10 @@ module Blimpy
@airborn = false
end
BOXES = { :aws => Blimpy::Boxes::AWS, :openstack => Blimpy::Boxes::OpenStack, :existing => Blimpy::Boxes::Existing }
def valid_types
[:aws, :openstack]
BOXES.keys
end
def add(box_type, &block)
@ -26,16 +29,12 @@ module Blimpy
return false
end
box = nil
if box_type == :aws
box = Blimpy::Boxes::AWS.new
end
if box_type == :openstack
box = Blimpy::Boxes::OpenStack.new
end
box = BOXES[box_type]
if box.nil?
return false
else
box = box.new()
end
box.fleet_id = @id
@ships << box