Parent

Class/Module Index [+]

Quicksearch

Fog::Compute::Brightbox::Server

Public Class Methods

new(attributes = {}) click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 42
def initialize(attributes = {})
  # Call super first to initialize the service object for our default image
  super
  self.image_id ||= service.default_image
end

Public Instance Methods

activate_console() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 166
def activate_console
  requires :identity
  response = service.activate_console_server(identity)
  [response["console_url"], response["console_token"], response["console_token_expires"]]
end
destroy() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 122
def destroy
  requires :identity
  service.destroy_server(identity)
  true
end
dns_name() click to toggle source

Returns the public DNS name of the server

@return [String]

# File lib/fog/brightbox/models/compute/server.rb, line 142
def dns_name
  ["public", fqdn].join(".")
end
flavor() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 128
def flavor
  requires :flavor_id
  service.flavors.get(flavor_id)
end
flavor_id() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 56
def flavor_id
  if t_flavour_id = attributes[:flavor_id]
    t_flavour_id
  elsif server_type
    server_type[:id] || server_type['id']
  end
end
flavor_id=(incoming_flavour_id) click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 68
def flavor_id=(incoming_flavour_id)
  attributes[:flavor_id] = incoming_flavour_id
end
image() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 133
def image
  requires :image_id
  service.images.get(image_id)
end
mapping_identity() click to toggle source

Replaces the server’s identifier with it’s interface’s identifier for Cloud IP mapping

@return [String] the identifier to pass to a Cloud IP mapping request

# File lib/fog/brightbox/models/compute/server.rb, line 193
def mapping_identity
  interfaces.first["id"]
end
private_ip_address() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 146
def private_ip_address
  if interfaces.empty?
    nil
  else
    interfaces.first["ipv4_address"]
  end
end
public_ip_address() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 154
def public_ip_address
  if cloud_ips.empty?
    nil
  else
    cloud_ips.first["public_ip"]
  end
end
ready?() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 162
def ready?
  state == "active"
end
reboot(use_hard_reboot = true) click to toggle source

Issues a hard reset to the server (or an OS level reboot command)

Default behaviour is a hard reboot because it is more reliable because the state of the server’s OS is irrelevant.

@example Hard reset

@server.reboot

@example Soft reset

@server.reboot(false)

@param [Boolean] use_hard_reboot @return [Boolean]

# File lib/fog/brightbox/models/compute/server.rb, line 90
def reboot(use_hard_reboot = true)
  requires :identity
  if ready?
    if use_hard_reboot
      service.reset_server(identity)
    else
      service.reboot_server(identity)
    end
  else
    # Not able to reboot if not ready in the first place
    false
  end
end
save() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 172
def save
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
  requires :image_id
  options = {
    :image => image_id,
    :name => name,
    :zone => zone_id,
    :user_data => user_data,
    :server_groups => server_groups
  }.delete_if { |k, v| v.nil? || v == "" }

  options.merge!(:server_type => flavor_id) unless flavor_id.nil? || flavor_id == ""

  data = service.create_server(options)
  merge_attributes(data)
  true
end
shutdown() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 116
def shutdown
  requires :identity
  service.shutdown_server(identity)
  true
end
snapshot() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 72
def snapshot
  requires :identity
  service.snapshot_server(identity)
end
start() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 104
def start
  requires :identity
  service.start_server(identity)
  true
end
stop() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 110
def stop
  requires :identity
  service.stop_server(identity)
  true
end
zone_id() click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 48
def zone_id
  if t_zone_id = attributes[:zone_id]
    t_zone_id
  elsif zone
    zone[:id] || zone['id']
  end
end
zone_id=(incoming_zone_id) click to toggle source
# File lib/fog/brightbox/models/compute/server.rb, line 64
def zone_id=(incoming_zone_id)
  attributes[:zone_id] = incoming_zone_id
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.