Parent

Files

Class/Module Index [+]

Quicksearch

Fog::Compute::Clodo::Server

Attributes

private_key[W]
private_key_path[W]
public_key[W]
public_key_path[W]
username[W]

Public Class Methods

new(attributes={}) click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 45
def initialize(attributes={})
  self.image_id   ||= attributes[:vps_os] ? attributes[:vps_os] : 666
  super attributes
end

Public Instance Methods

add_ip_address() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 79
def add_ip_address
  connection.add_ip_address(id)
end
delete_ip_address(ip_address) click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 87
def delete_ip_address(ip_address)
  connection.delete_ip_address(id, ip_address)
end
destroy() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 50
def destroy
  requires :id
  connection.delete_server(id)
  true
end
image() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 56
def image
  requires :image_id
  image_id # API does not support image details request. :-(
end
move_ip_address(ip_address) click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 83
def move_ip_address(ip_address)
  connection.move_ip_address(id, ip_address)
end
password() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 152
def password
 vps_root_pass
end
private_ip_address() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 61
def private_ip_address
  nil
end
private_key() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 70
def private_key
  @private_key ||= private_key_path && File.read(private_key_path)
end
private_key_path() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 65
def private_key_path
  @private_key_path ||= Fog.credentials[:private_key_path]
  @private_key_path &&= File.expand_path(@private_key_path)
end
public_ip_address() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 74
def public_ip_address
  pubaddrs = addresses && addresses['public'] ? addresses['public'].select {|ip| ip['primary_ip']} : nil
  pubaddrs && !pubaddrs.empty? ? pubaddrs.first['ip'] : nil
end
public_key() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 96
def public_key
  @public_key ||= public_key_path && File.read(public_key_path)
end
public_key_path() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 91
def public_key_path
  @public_key_path ||= Fog.credentials[:public_key_path]
  @public_key_path &&= File.expand_path(@public_key_path)
end
ready?() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 100
def ready?
  self.state == 'is_running'
end
reboot(type = 'SOFT') click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 104
def reboot(type = 'SOFT')
  requires :id
  connection.reboot_server(id, type)
  true
end
save() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 110
def save
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
  requires :image_id
  data = connection.create_server(image_id, attributes)
  merge_attributes(data.body['server'])
  true
end
scp(local_path, remote_path, upload_options = {}) click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 140
def scp(local_path, remote_path, upload_options = {})
  requires :public_ip_address, :username

  scp_options = {}
  scp_options[:key_data] = [private_key] if private_key
  Fog::SCP.new(public_ip_address, username, scp_options).upload(local_path, remote_path, upload_options)
end
setup(credentials = {}) click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 118
def setup(credentials = {})
  requires :public_ip_address, :identity, :public_key, :username
  Fog::SSH.new(public_ip_address, username, credentials).run([
    %{mkdir .ssh},
    %{echo "#{public_key}" >> ~/.ssh/authorized_keys},
    %{passwd -l #{username}},
    %{echo "#{MultiJson.encode(attributes)}" >> ~/attributes.json},
  ])
rescue Errno::ECONNREFUSED
  sleep(1)
  retry
end
ssh(commands) click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 131
def ssh(commands)
  requires :public_ip_address, :identity, :username

  options = {}
  options[:key_data] = [private_key] if private_key
  options[:password] = password if password
  Fog::SSH.new(public_ip_address, username, options).run(commands)
end
username() click to toggle source
# File lib/fog/clodo/models/compute/server.rb, line 148
def username
  @username ||= 'root'
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.