Class/Module Index [+]

Quicksearch

Fog::Compute::Ninefold::Server

Public Class Methods

new(attributes={}) click to toggle source

attribute :account_id, :aliases => "account", :squash => "id" attribute :image_id, :aliases => "image", :squash => "id" attribute :flavor_id, :aliases => "server_type", :squash => "id" attribute :zone_id, :aliases => "zone", :squash => "id"

# File lib/fog/ninefold/models/compute/server.rb, line 70
def initialize(attributes={})
  merge_attributes({
    :flavor_id => 105, # '1CPU, 384MB, 80GB HDD'
    :image_id  => 421  # 'XEN Basic Ubuntu 10.04 Server x64 PV r2.0'
  })
  super
end

Public Instance Methods

destroy() click to toggle source
# File lib/fog/ninefold/models/compute/server.rb, line 102
def destroy
  requires :identity
  self.jobid = extract_job_id(service.destroy_virtual_machine(:id => identity))
  true
end
flavor() click to toggle source
# File lib/fog/ninefold/models/compute/server.rb, line 108
def flavor
  requires :flavor_id
  service.flavors.get(flavor_id)
end
image() click to toggle source
# File lib/fog/ninefold/models/compute/server.rb, line 113
def image
  requires :image_id
  service.images.get(image_id)
end
ipaddress() click to toggle source

This is temporary - we need to model nics.

# File lib/fog/ninefold/models/compute/server.rb, line 79
def ipaddress
  nic[0] ? nic[0]['ipaddress'] : nil
end
ready?() click to toggle source
# File lib/fog/ninefold/models/compute/server.rb, line 118
def ready?
  if jobid
    # we do this by polling the last job id status.
    res = service.query_async_job_result(:jobid => jobid)
    if res['jobstatus'] == 0
      false
    else
      # update with new values.
      merge_attributes(res['jobresult']['virtualmachine'])
      true
    end
  else # No running job, we are ready. Refresh data.
    reload
    true
  end
end
reboot() click to toggle source
# File lib/fog/ninefold/models/compute/server.rb, line 83
def reboot
  requires :identity
  self.jobid = extract_job_id(service.reboot_virtual_machine(:id => identity))
  puts "jobid: " + jobid.to_s
  true
end
save() click to toggle source
# File lib/fog/ninefold/models/compute/server.rb, line 135
def save
  raise "Operation not supported" if self.identity
  requires :flavor_id, :image_id, :zoneid

  unless networkids
    # No network specified, use first in this zone.
    networks = service.list_networks(:zoneid => zoneid)
    if networks.empty?
      raise "No networks. Please create one, or specify a network ID"
    else
      # use the network with the lowest ID - the safe default
      self.networkids = networks.sort {|x,y| x['id'] <=> y['id']}[0]['id']
    end
  end

  options = {
    :serviceofferingid => flavor_id,
    :templateid => image_id,
    :name => name,
    :zoneid => zoneid,
    :networkids => networkids,
    :account => account,
    :diskofferingid => diskofferingid,
    :displayname => displayname,
    :domainid => domainid,
    :group => group,
    :hypervisor => hypervisor,
    :keypair => keypair,
    :securitygroupids => securitygroupids,
    :size => size,
    :userdata => userdata
  }.delete_if {|k,v| v.nil? || v == "" }
  data = service.deploy_virtual_machine(options)
  merge_attributes(data)
  true
end
start() click to toggle source
# File lib/fog/ninefold/models/compute/server.rb, line 90
def start
  requires :identity
  self.jobid = extract_job_id(service.start_virtual_machine(:id => identity))
  true
end
stop() click to toggle source
# File lib/fog/ninefold/models/compute/server.rb, line 96
def stop
  requires :identity
  self.jobid = extract_job_id(service.stop_virtual_machine(:id => identity))
  true
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.