Class: CORL::Node::Rackspace

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



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

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

#create_configObject




52
53
54
# File 'lib/CORL/node/rackspace.rb', line 52

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

#image_search_text(image) ⇒ Object




98
99
100
# File 'lib/CORL/node/rackspace.rb', line 98

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

#machine_configObject


Settings groups



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

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
# File 'lib/CORL/node/rackspace.rb', line 9

def normalize(reload)
  super do
    :rackspace
  end
end

#regionsObject


Property accessors / modifiers



25
26
27
28
29
30
31
# File 'lib/CORL/node/rackspace.rb', line 25

def regions
  [ 
    :dfw, # Dallas
    :ord, # Chicago
    :lon  # London (for UK accounts)
  ]
end

#render_image(image) ⇒ Object




92
93
94
# File 'lib/CORL/node/rackspace.rb', line 92

def render_image(image)
  sprintf("[  %40s  ][ %10s ] %s", image_id(image), image.state, image.name)
end

#render_machine_type(machine_type) ⇒ Object


Utilities



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

def render_machine_type(machine_type)
  sprintf("[  %20s  ][ VCPUS: %2i ] %-30s ( RAM: %6iMB | DISK: %4iGB )", 
    machine_type_id(machine_type), 
    machine_type.vcpus, 
    machine_type.name, 
    machine_type.ram, 
    machine_type.disk
  )
end

#start(options = {}) ⇒ Object




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

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/rackspace.rb', line 18

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