Class: Vmreverter::AWS

Inherits:
Object
  • Object
show all
Defined in:
lib/vmreverter/hypervisor/aws.rb

Instance Method Summary collapse

Constructor Details

#initialize(blimpy_hosts, config) ⇒ AWS

AWS support will dynamically create a Security Group for you if you specify ports in the Blimpfile, this means you can easily stand up a machine with specific ports open. Blimpy uses a unique hash of the ports to avoid re-creating the Security Groups unless necessary. Blimpy will import your ~/.ssh/id_rsa.pub or ~/.ssh/id_dsa.pub into a Key Pair in every region that you use in your Blimpfiles.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/vmreverter/hypervisor/aws.rb', line 7

def initialize(blimpy_hosts, config)
  @config = config
  @options = config.options
  @logger = config.logger
  @blimpy_hosts = blimpy_hosts
  require 'rubygems' unless defined?(Gem)
  require 'yaml' unless defined?(YAML)
  begin
    require 'blimpy'
  rescue LoadError
    raise "Unable to load Blimpy, please ensure its installed"
  end

  @fleet = Blimpy.fleet do |fleet|
    @blimpy_hosts.each do |host|
      #use snapshot provided for this host - This is an AMI!
      # host
      #   ami-size: m1.small
      #   ami-region: 'us-west-2'
      #   security-group: 'Clients'

      if not host['snapshot']
        raise "No snapshot/ami provided for AWS provisioning"
      end

      @logger.debug "Configuring hypervision AWS for host #{host.name}(#{host['snapshot']}:#{host['amisize']}) "

      fleet.add(:aws) do |ship|
        ship.name = host.name
        ship.group = host['security-group']
        ship.image_id = host['snapshot']
        ship.flavor = host['amisize'] || 'm1.small'
        ship.region = host['ami-region'] || 'us-west-2'
        ship.tags = host['tags']
        ship.username = 'root'
      end #fleet
      @logger.debug "Configuration completed."
    end #blimpy_hosts
  end#fleet

  return self
end

Instance Method Details

#close_connectionObject



56
57
58
# File 'lib/vmreverter/hypervisor/aws.rb', line 56

def close_connection
  @fleet = nil
end

#invokeObject

init



50
51
52
53
54
# File 'lib/vmreverter/hypervisor/aws.rb', line 50

def invoke
  if (@config['HOSTS'][name]['launch'] == :on)
    revert
  end
end