Class/Module Index [+]

Quicksearch

Fog::Compute::Glesys::Server

Public Instance Methods

destroy(options = {}) click to toggle source
# File lib/fog/glesys/models/compute/server.rb, line 50
def destroy(options = {})
  requires :identity
  service.destroy(options.merge!({:serverid => identity}))
end
ip(ip) click to toggle source
# File lib/fog/glesys/models/compute/server.rb, line 111
def ip(ip)
  Fog::Compute::Glesys::Ips.new(:serverid => identity, :server => self, :service => service).get(ip)
end
ips() click to toggle source
# File lib/fog/glesys/models/compute/server.rb, line 107
def ips
  Fog::Compute::Glesys::Ips.new(:serverid => identity, :server => self, :service => service).all
end
public_ip_address(options = {}) click to toggle source
# File lib/fog/glesys/models/compute/server.rb, line 115
def public_ip_address(options = {})

  return nil if iplist.nil?

  type = options[:type] || nil

  ips = case type
    when :ipv4 then iplist.select { |ip| ip["version"] == 4 }
    when :ipv6 then iplist.select { |ip| ip["version"] == 6 }
    else iplist.sort_by { |ip| ip["version"] }
  end

  if ips.empty?
    nil
  else
    ips.first["ipaddress"]
  end
end
ready?() click to toggle source
# File lib/fog/glesys/models/compute/server.rb, line 31
def ready?
  state == 'running'
end
reboot() click to toggle source
# File lib/fog/glesys/models/compute/server.rb, line 45
def reboot
  requires :identity
  service.reboot(:serverid => identity)
end
save() click to toggle source
# File lib/fog/glesys/models/compute/server.rb, line 55
def save
  raise "Operation not supported" if self.identity
  requires :hostname, :rootpassword

  options = {
    :datacenter     => datacenter   || "Falkenberg",
    :platform       => platform     || "Xen",
    :hostname       => hostname,
    :templatename   => templatename || "Debian-6 x64",
    :disksize       => disksize     || "10",
    :memorysize     => memorysize   || "512",
    :cpucores       => cpucores     || "1",
    :rootpassword   => rootpassword,
    :transfer       => transfer     || "500",
  }
  data = service.create(options)
  merge_attributes(data.body['response']['server'])
  data.status == 200 ? true : false
end
setup(credentials = {}) click to toggle source
# File lib/fog/glesys/models/compute/server.rb, line 75
def setup(credentials = {})
  requires :public_ip_address, :username
  require 'net/ssh'

  attrs = attributes.dup
  attrs.delete(:rootpassword)

  commands = [
    %{mkdir -p .ssh},
    %{echo "#{Fog::JSON.encode(Fog::JSON.sanitize(attrs))}" >> ~/attributes.json}
  ]
  if public_key
    commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
  end

  if credentials[:password].nil? && !rootpassword.nil?
    credentials[:password] = rootpassword
  end

  # wait for glesys to be ready
  wait_for { sshable?(credentials) }

  Fog::SSH.new(public_ip_address, username, credentials).run(commands)
end
ssh(command, options={}, &block) click to toggle source
# File lib/fog/glesys/models/compute/server.rb, line 100
def ssh(command, options={}, &block)
  if options[:password].nil? && !rootpassword.nil?
    options[:password] = rootpassword
  end
  super(command, options, &block)
end
start() click to toggle source
# File lib/fog/glesys/models/compute/server.rb, line 35
def start
  requires :identity
  service.start(:serverid => identity)
end
stop() click to toggle source
# File lib/fog/glesys/models/compute/server.rb, line 40
def stop
  requires :identity
  service.stop(:serverid => identity)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.