Class/Module Index [+]

Quicksearch

Fog::Compute::Bluebox::Server

Attributes

hostname[RW]
lb_applications[RW]
lb_backends[RW]
lb_services[RW]
password[RW]

Public Class Methods

new(attributes={}) click to toggle source
# File lib/fog/bluebox/models/compute/server.rb, line 27
def initialize(attributes={})
  self.flavor_id    ||= '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
  self.image_id     ||= 'a8f05200-7638-47d1-8282-2474ef57c4c3' # Scientific Linux 6
  self.location_id  ||= '37c2bd9a-3e81-46c9-b6e2-db44a25cc675' # Seattle, WA
  super
end

Public Instance Methods

destroy() click to toggle source
# File lib/fog/bluebox/models/compute/server.rb, line 34
def destroy
  requires :id
  service.destroy_block(id)
  true
end
flavor() click to toggle source
# File lib/fog/bluebox/models/compute/server.rb, line 40
def flavor
  requires :flavor_id
  service.flavors.get(flavor_id)
end
image() click to toggle source
# File lib/fog/bluebox/models/compute/server.rb, line 45
def image
  requires :image_id
  service.images.get(image_id)
end
location() click to toggle source
# File lib/fog/bluebox/models/compute/server.rb, line 50
def location
  requires :location_id
  service.locations.get(location_id)
end
private_ip_address() click to toggle source
# File lib/fog/bluebox/models/compute/server.rb, line 55
def private_ip_address
  nil
end
public_ip_address() click to toggle source
# File lib/fog/bluebox/models/compute/server.rb, line 59
def public_ip_address
  if ip = ips.first
    ip['address']
  end
end
ready?() click to toggle source
# File lib/fog/bluebox/models/compute/server.rb, line 65
def ready?
  self.state == 'running'
end
reboot(type = 'SOFT') click to toggle source
# File lib/fog/bluebox/models/compute/server.rb, line 69
def reboot(type = 'SOFT')
  requires :id
  service.reboot_block(id, type)
  true
end
save() click to toggle source
# File lib/fog/bluebox/models/compute/server.rb, line 75
def save
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
  requires :flavor_id, :image_id, :location_id
  options = {}

  unless persisted?  # new record
    raise(ArgumentError, "password or public_key is required for this operation") if !password && !public_key
    options['ssh_public_key'] = public_key if public_key
    options['password'] = password if @password
  end

  if @lb_backends
    options['lb_backends'] = lb_backends
  elsif @lb_services
    options['lb_services'] = lb_services
  elsif @lb_applications
    options['lb_applications'] = lb_applications
  end

  options['username'] = username
  options['hostname'] = hostname if @hostname
  data = service.create_block(flavor_id, image_id, location_id, options)
  merge_attributes(data.body)
  true
end
setup(credentials = {}) click to toggle source
# File lib/fog/bluebox/models/compute/server.rb, line 101
def setup(credentials = {})
  requires :identity, :ips, :public_key, :username
  Fog::SSH.new(public_ip_address, username, credentials).run([
    %{mkdir .ssh},
    %{echo "#{public_key}" >> ~/.ssh/authorized_keys},
    %{passwd -l #{username}},
    %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json}
  ])
rescue Errno::ECONNREFUSED
  sleep(1)
  retry
end
username() click to toggle source
# File lib/fog/bluebox/models/compute/server.rb, line 114
def username
  @username ||= 'deploy'
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.