Class: CORL::Node::AWS

Inherits:
FogBase show all
Defined in:
lib/CORL/node/AWS.rb

Instance Method Summary collapse

Methods inherited from FogBase

#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=, #region_info, #regions, #reload, #stop, #upload

Instance Method Details

#create(options = {}) ⇒ Object


Node operations



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

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

#create_configObject




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

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

#image_search_text(image) ⇒ Object




105
106
107
108
109
# File 'lib/CORL/node/AWS.rb', line 105

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



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

def machine_config
  super do |config|
    config.import({
      :provider => 'AWS',
      :region   => region.to_s
    })

    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
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/CORL/node/AWS.rb', line 9

def normalize(reload)
  super do
    region_info.import({
      'us-east-1'      => 'US East       -- North Virginia',
      'us-west-1'      => 'US West       -- North California',
      'us-west-2'      => 'US West       -- Oregon',
      'eu-west-1'      => 'EU            -- Ireland',
      'ap-northeast-1' => 'Asia Pacific  -- Tokyo',
      'ap-southeast-1' => 'Asia Pacific  -- Singapore',
      'ap-southeast-2' => 'Asia Pacific  -- Sydney',
      'sa-east-1'      => 'South America -- Sao Paulo'
    })

    # Return machine provider
    :aws
  end
end

#render_image(image) ⇒ Object




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

def render_image(image)
  description = image.name
  description = image.description if image.description && ! image.description.empty?

  location = image.location.split('/').first
  sprintf("%-23s [ %-10s | %-6s ]   %s ( %s )", purple(image_id(image)), blue(image.state), image.architecture, yellow(description), cyan(location))
end

#render_machine_type(machine_type) ⇒ Object


Utilities



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

def render_machine_type(machine_type)
  sprintf("%-25s   %-50s  [ VCPUS: %-5s ] ( RAM: %6sMB | DISK: %8sGB )  ( BITS: %5s )",
    purple(machine_type_id(machine_type)),
    yellow(machine_type.name),
    blue(machine_type.cores.to_s),
    blue(machine_type.ram.to_s),
    blue(machine_type.disk.to_s),
    blue(machine_type.bits.to_s)
  )
end

#start(options = {}) ⇒ Object




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

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

#usable_image?(image) ⇒ Boolean


Checks

Returns:

  • (Boolean)


30
31
32
# File 'lib/CORL/node/AWS.rb', line 30

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