Files

Class/Module Index [+]

Quicksearch

Fog::Compute::Rackspace::Server

Attributes

password[R]
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/rackspace/models/compute/server.rb, line 24
def initialize(attributes={})
  self.flavor_id  ||= 1  # 256 server
  self.image_id   ||= 49 # Ubuntu 10.04 LTS 64bit
  super
end

Public Instance Methods

destroy() click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 30
def destroy
  requires :id
  connection.delete_server(id)
  true
end
flavor() click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 36
def flavor
  requires :flavor_id
  connection.flavors.get(flavor_id)
end
image() click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 41
def image
  requires :image_id
  connection.images.get(image_id)
end
images() click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 46
def images
  requires :id
  connection.images(:server => self)
end
private_ip_address() click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 51
def private_ip_address
  nil
end
private_key() click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 60
def private_key
  @private_key ||= private_key_path && File.read(private_key_path)
end
private_key_path() click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 55
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/rackspace/models/compute/server.rb, line 64
def public_ip_address
  addresses['public'].first
end
public_key() click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 73
def public_key
  @public_key ||= public_key_path && File.read(public_key_path)
end
public_key_path() click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 68
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/rackspace/models/compute/server.rb, line 77
def ready?
  self.state == 'ACTIVE'
end
reboot(type = 'SOFT') click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 81
def reboot(type = 'SOFT')
  requires :id
  connection.reboot_server(id, type)
  true
end
save() click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 87
def save
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
  requires :flavor_id, :image_id
  options = {
    'metadata'    => metadata,
    'name'        => name,
    'personality' => personality
  }
  options = options.reject {|key, value| value.nil?}
  data = connection.create_server(flavor_id, image_id, options)
  merge_attributes(data.body['server'])
  true
end
setup(credentials = {}) click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 101
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},
    %{echo "#{MultiJson.encode(metadata)}" >> ~/metadata.json}
  ])
rescue Errno::ECONNREFUSED
  sleep(1)
  retry
end
username() click to toggle source
# File lib/fog/rackspace/models/compute/server.rb, line 115
def username
  @username ||= 'root'
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.