Parent

Files

Class/Module Index [+]

Quicksearch

Fog::Compute::Vmfusion::Server

Attributes

password[RW]
private_key[W]
private_key_path[W]
public_key[W]
public_key_path[W]
username[W]

Public Instance Methods

clone(name) click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 24
def clone(name)
  requires :raw

  ::Fission::VM.clone(@raw.name,name)
  return connection.servers.get(name)
end
destroy(options={ :force => false}) click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 31
def destroy(options={ :force => false})
  requires :raw

  if state=="running"
    if options[:force]
      @raw.stop
    end
  end

  ::Fission::VM.delete @raw.name
end
halt() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 77
def halt
  requires :raw
  if state=="running"
    @raw.halt
    return true
  else
    return false
  end

end
initalize(attributes={}) click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 17
def initalize(attributes={})
end
poweroff() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 88
def poweroff
  requires :raw
  halt
end
private_ip_address() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 117
def private_ip_address
  ip_address(:private)
end
private_key() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 187
def private_key
  @private_key ||= private_key_path && File.read(private_key_path)
end
private_key_path() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 182
def private_key_path
  @private_key_path ||= Fog.credentials[:private_key_path]
  @private_key_path &&= File.expand_path(@private_key_path)
end
public_ip_address() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 121
def public_ip_address
  ip_address(:public)
end
public_key() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 196
def public_key
  @public_key ||= public_key_path && File.read(public_key_path)
end
public_key_path() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 191
def public_key_path
  @public_key_path ||= Fog.credentials[:public_key_path]
  @public_key_path &&= File.expand_path(@public_key_path)
end
ready?() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 113
def ready?
  state == "running"
end
reboot() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 65
def reboot
  requires :raw
  if state=="running"
    @raw.stop
    wait_for { state!="running"}
    @raw.start
    return true
  else
    return false
  end
end
resume() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 98
def resume
  requires :raw
  @raw.resume
end
save() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 20
def save
  raise Fog::Errors::Error.new('Creating a new vm is not yet supported')
end
scp(local_path, remote_path, upload_options = {}) click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 142
def scp(local_path, remote_path, upload_options = {})
  requires :public_ip_address, :username

  scp_options = {}
  scp_options[:password] = password unless self.password.nil?
  scp_options[:key_data] = [private_key] if self.private_key

  Fog::SCP.new(public_ip_address, username, scp_options).upload(local_path, remote_path, upload_options)
end
setup(credentials = {}) click to toggle source

Sets up a new key

# File lib/fog/vmfusion/models/compute/server.rb, line 153
def setup(credentials = {})
  requires :public_key, :public_ip_address, :username

  credentials[:password] = password unless self.password.nil?
  credentails[:key_data] = [private_key] if self.private_key

  commands = [
    %{mkdir .ssh},
  ]
  if public_key
    commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
  end

  # wait for domain to be ready
  Timeout::timeout(360) do
    begin
      Timeout::timeout(8) do
        Fog::SSH.new(public_ip_address, username, credentials.merge(:timeout => 4)).run('pwd')
      end
    rescue Errno::ECONNREFUSED
      sleep(2)
      retry
    rescue Net::SSH::AuthenticationFailed, Timeout::Error
      retry
    end
  end
  Fog::SSH.new(public_ip_address, username, credentials).run(commands)
end
shutdown() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 93
def shutdown
  requires :raw
  stop
end
ssh(commands) click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 130
def ssh(commands)
  requires :public_ip_address, :username

  #requires :password, :private_key
  ssh_options={}
  ssh_options[:password] = password unless password.nil?
  ssh_options[:key_data] = [private_key] if private_key

  Fog::SSH.new(public_ip_address, @username, ssh_options).run(commands)

end
start() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 43
def start
  requires :raw

  unless state=="running"
    @raw.start
    return true
  else
    return false
  end
end
state() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 108
def state
  requires :raw
  @raw.state
end
stop() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 54
def stop
  requires :raw

  if state=="running"
    @raw.stop
    return true
  else
    return false
  end
end
suspend() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 103
def suspend
  requires :raw
  @raw.suspend
end
username() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 126
def username
  @username ||= 'root'
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.