class CORL::Machine::FogBase
Public Instance Methods
compute()
click to toggle source
# File lib/core/plugin/fog_machine.rb 57 def compute 58 set_connection unless @compute 59 @compute 60 end
compute=(compute)
click to toggle source
# File lib/core/plugin/fog_machine.rb 53 def compute=compute 54 @compute = compute 55 end
create(options = {}, &code)
click to toggle source
Calls superclass method
# File lib/core/plugin/fog_machine.rb 151 def create(options = {}, &code) 152 super do |config| 153 if compute 154 code.call(config) if code 155 myself.server = compute.servers.bootstrap(config.export) 156 end 157 myself.server ? true : false 158 end 159 end
create_image(options = {}, &code)
click to toggle source
Calls superclass method
# File lib/core/plugin/fog_machine.rb 204 def create_image(options = {}, &code) 205 super do |config| 206 image_name = sprintf("%s (%s)", node.plugin_name, Time.now.to_s) 207 208 success = code ? code.call(image_name, config, success) : true 209 success = init_ssh_session(true, config.get(:tries, 12), config.get(:sleep_time, 5)) if success 210 end 211 end
created?()
click to toggle source
# File lib/core/plugin/fog_machine.rb 23 def created? 24 server && ! server.state != 'DELETED' 25 end
destroy(options = {}, &code)
click to toggle source
Calls superclass method
# File lib/core/plugin/fog_machine.rb 224 def destroy(options = {}, &code) 225 super do |config| 226 success = server.destroy 227 success = code.call(config) if success && code 228 229 close_ssh_session if success 230 success 231 end 232 end
download(remote_path, local_path, options = {}, &code)
click to toggle source
Calls superclass method
# File lib/core/plugin/fog_machine.rb 163 def download(remote_path, local_path, options = {}, &code) 164 super do |config, success| 165 ssh_download(remote_path, local_path, config, &code) 166 end 167 end
exec(commands, options = {}, &code)
click to toggle source
Calls superclass method
# File lib/core/plugin/fog_machine.rb 179 def exec(commands, options = {}, &code) 180 super do |config| 181 ssh_exec(commands, config, &code) 182 end 183 end
image()
click to toggle source
# File lib/core/plugin/fog_machine.rb 125 def image 126 return server.image.id if server 127 nil 128 end
images()
click to toggle source
# File lib/core/plugin/fog_machine.rb 118 def images 119 return compute.images if compute 120 [] 121 end
load()
click to toggle source
Calls superclass method
# File lib/core/plugin/fog_machine.rb 142 def load 143 super do 144 myself.server = plugin_name if compute && plugin_name 145 ! plugin_name && @server.nil? ? false : true 146 end 147 end
machine_type()
click to toggle source
# File lib/core/plugin/fog_machine.rb 111 def machine_type 112 return server.flavor.id if server 113 nil 114 end
machine_types()
click to toggle source
# File lib/core/plugin/fog_machine.rb 104 def machine_types 105 return compute.flavors if compute 106 [] 107 end
normalize(reload)
click to toggle source
Calls superclass method
# File lib/core/plugin/fog_machine.rb 15 def normalize(reload) 16 super 17 myself.plugin_name = '' if myself.plugin_provider == myself.plugin_name.to_sym 18 end
private_ip()
click to toggle source
# File lib/core/plugin/fog_machine.rb 97 def private_ip 98 return server.private_ip_address if server 99 nil 100 end
public_ip()
click to toggle source
# File lib/core/plugin/fog_machine.rb 90 def public_ip 91 return server.public_ip_address if server 92 nil 93 end
reload(options = {}, &code)
click to toggle source
Calls superclass method
# File lib/core/plugin/fog_machine.rb 195 def reload(options = {}, &code) 196 super do |config| 197 success = code ? code.call(config) : true 198 success = init_ssh_session(true, config.get(:tries, 12), config.get(:sleep_time, 5)) if success 199 end 200 end
running?()
click to toggle source
# File lib/core/plugin/fog_machine.rb 29 def running? 30 created? && server.ready? 31 end
server()
click to toggle source
# File lib/core/plugin/fog_machine.rb 75 def server 76 compute 77 load unless @server 78 @server 79 end
server=(id)
click to toggle source
# File lib/core/plugin/fog_machine.rb 64 def server=id 65 @server = nil 66 67 if id.is_a?(String) 68 @server = compute.servers.get(id) unless id.empty? 69 elsif ! id.nil? 70 @server = id 71 end 72 init_server 73 end
ssh_wait_for_ready()
click to toggle source
# File lib/core/plugin/fog_machine.rb 237 def ssh_wait_for_ready 238 server.wait_for { ready? } 239 end
state()
click to toggle source
# File lib/core/plugin/fog_machine.rb 83 def state 84 return translate_state(server.state) if server 85 translate_state(:aborted) 86 end
stop(options = {})
click to toggle source
Calls superclass method
# File lib/core/plugin/fog_machine.rb 215 def stop(options = {}) 216 super do |config| 217 success = false 218 success = destroy(config.import({ :stop => true })) if create_image(config) 219 end 220 end
terminal(user, options = {})
click to toggle source
Calls superclass method
# File lib/core/plugin/fog_machine.rb 187 def terminal(user, options = {}) 188 super do |config| 189 ssh_terminal(user, config) 190 end 191 end
upload(local_path, remote_path, options = {}, &code)
click to toggle source
Calls superclass method
# File lib/core/plugin/fog_machine.rb 171 def upload(local_path, remote_path, options = {}, &code) 172 super do |config, success| 173 ssh_upload(local_path, remote_path, config, &code) 174 end 175 end
Protected Instance Methods
init_server() { || ... }
click to toggle source
# File lib/core/plugin/fog_machine.rb 133 def init_server 134 unless @server.nil? 135 yield # Implement in fog machine providers 136 end 137 end
set_connection() { || ... }
click to toggle source
# File lib/core/plugin/fog_machine.rb 36 def set_connection 37 logger.info("Initializing Fog Compute connection to cloud hosting provider") 38 logger.debug("Compute settings: #{export.inspect}") 39 40 ENV['DEBUG'] = 'true' if CORL.log_level == :debug 41 42 require 'fog' 43 Fog.timeout = 1000 44 45 yield if block_given? 46 47 myself.compute = ::Fog::Compute.new(export) 48 end