Class: CORL::Node::AWS

Inherits:
Fog
  • Object
show all
Defined in:
lib/CORL/node/AWS.rb

Instance Method Summary collapse

Methods inherited from Fog

#api_key, #api_key=, #api_user, #api_user=, #auth_url, #auth_url=, #connection_options, #connection_options=, #create_image, #destroy, #download, #exec, #exec_options, #filter_output, #key_config, #region, #region=, #reload, #stop, #upload

Instance Method Details

#create(options = {}) ⇒ Object


Node operations



62
63
64
65
66
67
68
# File 'lib/CORL/node/AWS.rb', line 62

def create(options = {})
  super do |op, config|
    if op == :config
      config.defaults(create_config)
    end
  end
end

#create_configObject




55
56
57
# File 'lib/CORL/node/AWS.rb', line 55

def create_config
  { :flavor_id => machine_type, :image_id => image, :username => user }  
end

#image_search_text(image) ⇒ Object




103
104
105
106
107
# File 'lib/CORL/node/AWS.rb', line 103

def image_search_text(image)
  location = image.location.split('/').first
  location = location.match(/^\d+$/) ? '' : location
  sprintf("%s %s %s %s %s %s %s", image_id(image), image.name, image.description, image.state, image.architecture, image.owner_id, location)
end

#machine_configObject


Settings groups



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/CORL/node/AWS.rb', line 41

def machine_config
  super do |config|
    config.import({ 
      :provider => 'AWS',
      :region   => region
    })
  
    config[:aws_access_key_id]     = api_user if api_user
    config[:aws_secret_access_key] = api_key if api_key
  end
end

#normalize(reload) ⇒ Object


Node plugin interface



9
10
11
12
13
# File 'lib/CORL/node/AWS.rb', line 9

def normalize(reload)
  super do
    :aws
  end
end

#regionsObject


Property accessors / modifiers



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/CORL/node/AWS.rb', line 25

def regions
  [
    'us-east-1', 
    'us-west-1', 
    'us-west-2',
    'eu-west-1',
    'ap-northeast-1', 
    'ap-southeast-1', 
    'ap-southeast-2',       
    'sa-east-1'
  ]
end

#render_image(image) ⇒ Object




96
97
98
99
# File 'lib/CORL/node/AWS.rb', line 96

def render_image(image)
  location = image.location.split('/').first
  sprintf("[  %20s  ][ %10s ] %10s - %s (%s)", image_id(image), image.state, image.architecture, image.name, location)
end

#render_machine_type(machine_type) ⇒ Object


Utilities



83
84
85
86
87
88
89
90
91
92
# File 'lib/CORL/node/AWS.rb', line 83

def render_machine_type(machine_type)
  sprintf("[  %20s  ][ VCPUS: %5.1f ] %-40s ( RAM: %6iMB | DISK: %8iGB )  ( BITS: %2i )", 
    machine_type_id(machine_type), 
    machine_type.cores, 
    machine_type.name, 
    machine_type.ram, 
    machine_type.disk, 
    machine_type.bits
  )
end

#start(options = {}) ⇒ Object




72
73
74
75
76
77
78
# File 'lib/CORL/node/AWS.rb', line 72

def start(options = {})
  super do |op, config|
    if op == :config
      config.defaults(create_config)
    end
  end
end

#usable_image?(image) ⇒ Boolean


Checks

Returns:

  • (Boolean)


18
19
20
# File 'lib/CORL/node/AWS.rb', line 18

def usable_image?(image)
  image.state == 'available' && image.name
end