Parent

Class/Module Index [+]

Quicksearch

Fog::Compute::Cloudstack::Server

Attributes

disk_offering_id[RW]
ip_address[RW]
ip_to_network_list[RW]
network_ids[RW]
public_ip_address[RW]
public_ip_address=[RW]
security_group_ids[W]

Public Instance Methods

addresses() click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 48
def addresses
  nics.map{|nic| Address.new(nic)}
end
destroy(options={}) click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 68
def destroy(options={})
  requires :id
  data = service.destroy_virtual_machine(options.merge({'id'=> self.id}))
  service.jobs.new(data["destroyvirtualmachineresponse"])
end
flavor() click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 74
def flavor
  service.flavors.get(self.flavor_id)
end
ip_addresses() click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 52
def ip_addresses
  addresses.map{|a| a.ip_address}
end
private_ip_address() click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 64
def private_ip_address
  private_ip_addresses.first
end
private_ip_addresses() click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 60
def private_ip_addresses
  ip_addresses - public_ip_addresses
end
public_ip_addresses() click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 56
def public_ip_addresses
  if public_ip_address.nil? then [public_ip_address] else [] end
end
ready?() click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 78
def ready?
  state == 'Running'
end
reboot() click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 82
def reboot
  requires :id
  data = service.reboot_virtual_machine('id' => self.id) # FIXME: does this ever fail?
  service.jobs.new(data["rebootvirtualmachineresponse"])
end
save() click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 100
def save
  requires :image_id, :flavor_id, :zone_id

  options = {
    'templateid'        => image_id,
    'serviceofferingid' => flavor_id,
    'zoneid'            => zone_id,
    'networkids'        => network_ids,
    'diskofferingid'    => disk_offering_id,
    'name'              => name,
    'displayname'       => display_name,
    'group'             => group,
    'domainid'          => domain_id,
    'hostid'            => host_id,
    'ipaddress'         => ip_address,
    'iptonetworklist'   => ip_to_network_list,
    'projectid'         => project_id,
    'keypair'           => key_name,
    'userdata'           => user_data,
  }

  options.merge!('networkids' => network_ids) if network_ids
  options.merge!('securitygroupids' => security_group_ids) unless security_group_ids.empty?

  data = service.deploy_virtual_machine(options)
  merge_attributes(data['deployvirtualmachineresponse'])
end
security_group_ids() click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 92
def security_group_ids
  @security_group_ids || (self.security_group_list || []).map{|sg| sg["id"]}
end
security_groups() click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 96
def security_groups
  security_group_ids.map{|id| service.security_groups.get(id)}
end
security_groups=(security_groups) click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 88
def security_groups=(security_groups)
  self.security_group_ids= Array(security_groups).map(&:id)
end
start() click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 128
def start
  requires :id
  data = service.start_virtual_machine("id" => self.id)
  service.jobs.new(data["startvirtualmachineresponse"])
end
stop(options={}) click to toggle source
# File lib/fog/cloudstack/models/compute/server.rb, line 134
def stop(options={})
  requires :id
  unless options.is_a?(Hash)
    Fog::Logger.deprecation("Passing force as a boolean option has been deprecated. Please pass a hash with 'force' => (true|false)")
    options = {'force' => options}
  end
  data = service.stop_virtual_machine(options.merge({'id' => self.id}))
  service.jobs.new(data["stopvirtualmachineresponse"])
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.