Class: Skewer::AWS::Node

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

Overview

Build out an AWS node using Fog.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aws_id, group_names, options = {}) ⇒ Node

Returns a new instance of Node.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/aws/node.rb', line 10

def initialize(aws_id, group_names, options = {})
  if options[:aws_node]
    @node = options[:aws_node]
  else
    @service = self.class.find_service(options)
    node_options = {
        :image_id => aws_id,
        :flavor_id => SkewerConfig.get('flavor_id'),
        :username => SkewerConfig.get('aws_username'),
        :groups => group_names
    }

    if options[:key_name]
      node_options[:key_name] = options[:key_name]
    end

    if SkewerConfig.instance.get('key_name')
      node_options[:key_name] = SkewerConfig.get('key_name')
    end

    @node = @service.servers.bootstrap(node_options)
  end
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



8
9
10
# File 'lib/aws/node.rb', line 8

def node
  @node
end

Class Method Details

.find_by_name(dns_name, service = self.find_service({})) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/aws/node.rb', line 42

def self.find_by_name(dns_name, service = self.find_service({}))
  node = service.servers.select { |server| server.dns_name == dns_name }[0]
  if node
    return self.new(nil, nil, {:aws_node => node})
  else
    return false
  end
end

.find_service(options) ⇒ Object



34
35
36
# File 'lib/aws/node.rb', line 34

def self.find_service(options)
  options[:service] ? options[:service] : AWS::Service.new.service
end

Instance Method Details

#destroyObject



38
39
40
# File 'lib/aws/node.rb', line 38

def destroy
  @node.destroy
end