Class: CORL::Node::FogBase

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



48
49
50
# File 'lib/core/plugin/fog_node.rb', line 48

def api_key
  myself[:api_key]
end

#api_key=(api_key) ⇒ Object




44
45
46
# File 'lib/core/plugin/fog_node.rb', line 44

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

#api_userObject



38
39
40
# File 'lib/core/plugin/fog_node.rb', line 38

def api_user
  myself[:api_user]
end

#api_user=(api_user) ⇒ Object


Property accessors / modifiers



34
35
36
# File 'lib/core/plugin/fog_node.rb', line 34

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

#auth_urlObject



58
59
60
# File 'lib/core/plugin/fog_node.rb', line 58

def auth_url
  myself[:auth_url]
end

#auth_url=(auth_url) ⇒ Object




54
55
56
# File 'lib/core/plugin/fog_node.rb', line 54

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

#connection_optionsObject



68
69
70
# File 'lib/core/plugin/fog_node.rb', line 68

def connection_options
  myself[:connection_options]
end

#connection_options=(options) ⇒ Object




64
65
66
# File 'lib/core/plugin/fog_node.rb', line 64

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

#create(options = {}) ⇒ Object


Node operations



121
122
123
124
125
126
127
128
129
# File 'lib/core/plugin/fog_node.rb', line 121

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




189
190
191
192
193
194
195
196
# File 'lib/core/plugin/fog_node.rb', line 189

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




211
212
213
214
215
216
217
218
# File 'lib/core/plugin/fog_node.rb', line 211

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




133
134
135
136
137
138
139
140
# File 'lib/core/plugin/fog_node.rb', line 133

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




155
156
157
158
159
160
161
162
# File 'lib/core/plugin/fog_node.rb', line 155

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




114
115
116
# File 'lib/core/plugin/fog_node.rb', line 114

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

#filter_output(type, data) ⇒ Object


Utilities



223
224
225
226
227
228
229
230
231
232
# File 'lib/core/plugin/fog_node.rb', line 223

def filter_output(type, data)
  data = super

  if type == :error
    if data.include?('stdin: is not a tty') || data.include?('unable to re-open stdin')
      data = ''
    end
  end
  data
end

#key_configObject




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

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

#machine_configObject


Settings groups



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

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
25
26
# File 'lib/core/plugin/fog_node.rb', line 13

def normalize(reload)
  super

  @region_info = Config.new({}, {}, true, false) unless reload

  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



86
87
88
89
90
91
92
93
94
# File 'lib/core/plugin/fog_node.rb', line 86

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

#region=(region) ⇒ Object



82
83
84
# File 'lib/core/plugin/fog_node.rb', line 82

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

#region_infoObject




74
75
76
# File 'lib/core/plugin/fog_node.rb', line 74

def region_info
  @region_info
end

#regionsObject



78
79
80
# File 'lib/core/plugin/fog_node.rb', line 78

def regions
  @region_info.keys
end

#reload(options = {}) ⇒ Object




178
179
180
181
182
183
184
185
# File 'lib/core/plugin/fog_node.rb', line 178

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




166
167
168
169
170
171
172
173
174
# File 'lib/core/plugin/fog_node.rb', line 166

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




200
201
202
203
204
205
206
207
# File 'lib/core/plugin/fog_node.rb', line 200

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




144
145
146
147
148
149
150
151
# File 'lib/core/plugin/fog_node.rb', line 144

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