compute()
click to toggle source
def compute
set_connection unless @compute
@compute
end
compute=(compute)
click to toggle source
def compute=compute
@compute = compute
end
create(options = {}, &code)
click to toggle source
def create(options = {}, &code)
super do |config|
if compute
code.call(config) if code
myself.server = compute.servers.bootstrap(config.export)
end
myself.server ? true : false
end
end
create_image(options = {}, &code)
click to toggle source
def create_image(options = {}, &code)
super do |config|
image_name = sprintf("%s (%s)", node.plugin_name, Time.now.to_s)
success = code ? code.call(image_name, config, success) : true
success = init_ssh_session(true, config.get(:tries, 5), config.get(:sleep_time, 5)) if success
end
end
created?()
click to toggle source
def created?
server && ! server.state != 'DELETED'
end
destroy(options = {}, &code)
click to toggle source
def destroy(options = {}, &code)
super do |config|
success = server.destroy
success = code.call(config) if success && code
close_ssh_session if success
success
end
end
download(remote_path, local_path, options = {}, &code)
click to toggle source
def download(remote_path, local_path, options = {}, &code)
super do |config, success|
ssh_download(remote_path, local_path, config, &code)
end
end
exec(commands, options = {}, &code)
click to toggle source
def exec(commands, options = {}, &code)
super do |config|
ssh_exec(commands, config, &code)
end
end
image()
click to toggle source
def image
return server.image.id if server
nil
end
images()
click to toggle source
def images
return compute.images if compute
[]
end
load()
click to toggle source
def load
super do
myself.server = plugin_name if compute && plugin_name
! plugin_name && @server.nil? ? false : true
end
end
machine_type()
click to toggle source
def machine_type
return server.flavor.id if server
nil
end
machine_types()
click to toggle source
def machine_types
return compute.flavors if compute
[]
end
private_ip()
click to toggle source
def private_ip
return server.private_ip_address if server
nil
end
public_ip()
click to toggle source
def public_ip
return server.public_ip_address if server
nil
end
reload(options = {}, &code)
click to toggle source
def reload(options = {}, &code)
super do |config|
success = code ? code.call(config) : true
success = init_ssh_session(true, config.get(:tries, 5), config.get(:sleep_time, 5)) if success
end
end
running?()
click to toggle source
def running?
created? && server.ready?
end
server()
click to toggle source
def server
compute
load unless @server
@server
end
server=(id)
click to toggle source
def server=id
@server = nil
if id.is_a?(String)
@server = compute.servers.get(id) unless id.empty?
elsif ! id.nil?
@server = id
end
init_server
end
ssh_wait_for_ready()
click to toggle source
def ssh_wait_for_ready
server.wait_for { ready? }
end
state()
click to toggle source
def state
return translate_state(server.state) if server
nil
end
stop(options = {})
click to toggle source
def stop(options = {})
super do |config|
success = false
success = destroy(config.import({ :stop => true })) if create_image(config)
end
end
terminal(user, options = {})
click to toggle source
def terminal(user, options = {})
super do |config|
ssh_terminal(user, config)
end
end
upload(local_path, remote_path, options = {}, &code)
click to toggle source
def upload(local_path, remote_path, options = {}, &code)
super do |config, success|
ssh_upload(local_path, remote_path, config, &code)
end
end