Class: CORL::Node::Rackspace

Inherits:
FogBase
  • Object
show all
Defined in:
lib/CORL/node/rackspace.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



57
58
59
60
61
62
63
# File 'lib/CORL/node/rackspace.rb', line 57

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

#create_configObject




50
51
52
# File 'lib/CORL/node/rackspace.rb', line 50

def create_config
  { :name => hostname, :flavor_id => machine_type, :image_id => image }
end

#image_search_text(image) ⇒ Object




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

def image_search_text(image)
  sprintf("%s %s %s", image_id(image), image.name, image.state)
end

#machine_configObject


Settings groups



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/CORL/node/rackspace.rb', line 34

def machine_config
  super do |config|
    config.import({
      :provider         => 'rackspace',
      :version          => :v2,
      :rackspace_region => region
    })

    config[:rackspace_username] = api_user if api_user
    config[:rackspace_api_key]  = api_key if api_key
    config[:rackspace_auth_url] = auth_url if auth_url
  end
end

#normalize(reload) ⇒ Object


Node plugin interface



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/CORL/node/rackspace.rb', line 9

def normalize(reload)
  super do
    region_info.import({
      :dfw => 'Dallas',
      :ord => 'Chicago',
      :lon => 'London (for UK accounts)'
    })
    # Return machine provider
    :rackspace
  end
end

#render_image(image) ⇒ Object




90
91
92
# File 'lib/CORL/node/rackspace.rb', line 90

def render_image(image)
  sprintf("%-47s [ %-10s ]   %s", purple(image_id(image)), blue(image.state), yellow(image.name))
end

#render_machine_type(machine_type) ⇒ Object


Utilities



78
79
80
81
82
83
84
85
86
# File 'lib/CORL/node/rackspace.rb', line 78

def render_machine_type(machine_type)
  sprintf("%-30s  %-35s  [ VCPUS: %-5s ] ( RAM: %6sMB | DISK: %4sGB )",
    purple(machine_type_id(machine_type)),
    yellow(machine_type.name),
    blue(machine_type.vcpus.to_s),
    blue(machine_type.ram.to_s),
    blue(machine_type.disk.to_s)
  )
end

#start(options = {}) ⇒ Object




67
68
69
70
71
72
73
# File 'lib/CORL/node/rackspace.rb', line 67

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

#usable_image?(image) ⇒ Boolean


Checks

Returns:

  • (Boolean)


24
25
26
# File 'lib/CORL/node/rackspace.rb', line 24

def usable_image?(image)
  image.state != 'DELETED'
end