Class: CORL::Node::Fog

Inherits:
Object
  • Object
show all
Defined in:
lib/core/plugin/fog_node.rb

Direct Known Subclasses

AWS, Rackspace

Instance Method Summary collapse

Instance Method Details

#api_keyObject



46
47
48
# File 'lib/core/plugin/fog_node.rb', line 46

def api_key
  myself[:api_key]
end

#api_key=(api_key) ⇒ Object




42
43
44
# File 'lib/core/plugin/fog_node.rb', line 42

def api_key=api_key
  myself[:api_key] = api_key
end

#api_userObject



36
37
38
# File 'lib/core/plugin/fog_node.rb', line 36

def api_user
  myself[:api_user]
end

#api_user=(api_user) ⇒ Object


Property accessors / modifiers



32
33
34
# File 'lib/core/plugin/fog_node.rb', line 32

def api_user=api_user
  myself[:api_user] = api_user
end

#auth_urlObject



56
57
58
# File 'lib/core/plugin/fog_node.rb', line 56

def auth_url
  myself[:auth_url]
end

#auth_url=(auth_url) ⇒ Object




52
53
54
# File 'lib/core/plugin/fog_node.rb', line 52

def auth_url=auth_url
  myself[:auth_url] = auth_url
end

#connection_optionsObject



66
67
68
# File 'lib/core/plugin/fog_node.rb', line 66

def connection_options
  myself[:connection_options]
end

#connection_options=(options) ⇒ Object




62
63
64
# File 'lib/core/plugin/fog_node.rb', line 62

def connection_options=options
  myself[:connection_options] = options
end

#create(options = {}) ⇒ Object


Node operations



115
116
117
118
119
120
121
122
123
# File 'lib/core/plugin/fog_node.rb', line 115

def create(options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:create))
      config.defaults(key_config)
    end
    yield(op, config) if block_given?      
  end
end

#create_image(options = {}) ⇒ Object




183
184
185
186
187
188
189
190
# File 'lib/core/plugin/fog_node.rb', line 183

def create_image(options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:image))
    end
    yield(op, config) if block_given?
  end
end

#destroy(options = {}) ⇒ Object




205
206
207
208
209
210
211
212
# File 'lib/core/plugin/fog_node.rb', line 205

def destroy(options = {})    
  super do |op, config|
    if op == :config
      config.import(exec_options(:destroy))
    end
    yield(op, config) if block_given?
  end
end

#download(remote_path, local_path, options = {}) ⇒ Object




127
128
129
130
131
132
133
134
# File 'lib/core/plugin/fog_node.rb', line 127

def download(remote_path, local_path, options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:download))
    end
    yield(op, config) if block_given?
  end
end

#exec(options = {}) ⇒ Object




149
150
151
152
153
154
155
156
# File 'lib/core/plugin/fog_node.rb', line 149

def exec(options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:exec))
    end
    yield(op, config) if block_given?
  end
end

#exec_options(name, options = {}) ⇒ Object




108
109
110
# File 'lib/core/plugin/fog_node.rb', line 108

def exec_options(name, options = {})
  extended_config(name, options).export
end

#filter_output(type, data) ⇒ Object


Utilities



217
218
219
# File 'lib/core/plugin/fog_node.rb', line 217

def filter_output(type, data)
  super
end

#key_configObject




102
103
104
# File 'lib/core/plugin/fog_node.rb', line 102

def key_config
  { :private_key_path => private_key, :public_key_path  => public_key }
end

#machine_configObject


Settings groups



93
94
95
96
97
98
# File 'lib/core/plugin/fog_node.rb', line 93

def machine_config
  super do |config|        
    config[:connection_options] = connection_options if connection_options
    yield(config) if block_given?
  end
end

#normalize(reload) ⇒ Object


Node plugin interface



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/core/plugin/fog_node.rb', line 13

def normalize(reload)
  super
  
  myself.region  = region 
    
  unless reload
    machine_provider = :fog
    machine_provider = yield if block_given?
                      
    myself.machine = create_machine(:machine, machine_provider, machine_config)
  end
end

#regionObject



80
81
82
83
84
85
86
87
88
# File 'lib/core/plugin/fog_node.rb', line 80

def region
  if region = myself[:region]
    region
  else
    first_region  = regions.first
    myself.region = first_region
    first_region
  end
end

#region=(region) ⇒ Object



76
77
78
# File 'lib/core/plugin/fog_node.rb', line 76

def region=region
  myself[:region] = region
end

#regionsObject




72
73
74
# File 'lib/core/plugin/fog_node.rb', line 72

def regions
  []
end

#reload(options = {}) ⇒ Object




172
173
174
175
176
177
178
179
# File 'lib/core/plugin/fog_node.rb', line 172

def reload(options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:reload))
    end
    yield(op, config) if block_given?
  end
end

#start(options = {}) ⇒ Object




160
161
162
163
164
165
166
167
168
# File 'lib/core/plugin/fog_node.rb', line 160

def start(options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:start))
      config.defaults(key_config)
    end
    yield(op, config) if block_given?
  end
end

#stop(options = {}) ⇒ Object




194
195
196
197
198
199
200
201
# File 'lib/core/plugin/fog_node.rb', line 194

def stop(options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:stop))
    end
    yield(op, config) if block_given?
  end
end

#upload(local_path, remote_path, options = {}) ⇒ Object




138
139
140
141
142
143
144
145
# File 'lib/core/plugin/fog_node.rb', line 138

def upload(local_path, remote_path, options = {})
  super do |op, config|
    if op == :config
      config.import(exec_options(:upload))
    end
    yield(op, config) if block_given?
  end
end