Class/Module Index [+]

Quicksearch

Fog::Compute::Vmfusion::Server

Attributes

password[RW]

Public Instance Methods

clone(name) click to toggle source

Fussion doesn't have the concept of templates so one just clones regular VMs.

# File lib/fog/vmfusion/models/compute/server.rb, line 26
def clone(name)
  requires :raw

  ::Fission::VM.clone(@raw[:fission].name,name)
  return service.servers.get(name)
end
destroy(options = { :force => false }) click to toggle source

Destroy, deletes the VM from the local disk but only hard stops the VM before doing so if you set :force to true.

# File lib/fog/vmfusion/models/compute/server.rb, line 35
def destroy(options = { :force => false })
  requires :raw

  if ready?
    if options[:force]
      stop
    end
  end

  @raw[:fission].delete
end
halt() click to toggle source

Halt and poweroff are just synonyms for stop.

# File lib/fog/vmfusion/models/compute/server.rb, line 76
def halt
  stop
end
ipaddress() click to toggle source

We obtain the first ipaddress. This should generally be a safe assumption for Fusion. Even if an address is provided via NAT, bridge, or host only it will by accessible from the host machine the VM resides on.

# File lib/fog/vmfusion/models/compute/server.rb, line 149
def ipaddress
  requires :raw
  ip(@raw[:fission])
end
mac_addresses() click to toggle source

Collecting all mac_addresses the VM has...mostly just because we are doing the same thing for the vSphere provider.

# File lib/fog/vmfusion/models/compute/server.rb, line 173
def mac_addresses
  requires :raw
  macs(@raw[:fission])
end
path() click to toggle source

Path to the VM's vmx file on the local disk.

# File lib/fog/vmfusion/models/compute/server.rb, line 140
def path
  requires :raw
  @raw[:fission].path
end
power_state() click to toggle source

The power state of the VM is commonly going to be three values; running, not running, or suspended.

# File lib/fog/vmfusion/models/compute/server.rb, line 129
def power_state
  requires :raw
  @raw[:fission].state.data
end
poweroff() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 80
def poweroff
  stop
end
private_ip_address() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 163
def private_ip_address
  ipaddress
end
public_ip_address() click to toggle source

Keeping these three methods around for API compatibility reasons. Makes the vmfusion provider function similar to cloud providers and the vsphere provider. Future goal is to add an actual private and public concept. Needs changes to fission and a determination what is a public or private address here; bridge, nat, host-only.

# File lib/fog/vmfusion/models/compute/server.rb, line 159
def public_ip_address
  ipaddress
end
ready?() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 134
def ready?
  requires :raw
  @raw[:fission].running?.data
end
reboot() click to toggle source

Attempt a graceful shutdown, wait for the VM to completely shutdown and then start it again.

# File lib/fog/vmfusion/models/compute/server.rb, line 99
def reboot
  if ready?
    shutdown
    wait_for { ! ready? }
    start
    return true
  else
    return false
  end
end
resume() click to toggle source

Resuming from suspend is the same thing as start to Fusion.

# File lib/fog/vmfusion/models/compute/server.rb, line 111
def resume
  start
end
save() click to toggle source

There is currently no documented model of creating VMs from scratch sans Fusion's wizard.

# 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

SCP something to our VM.

# File lib/fog/vmfusion/models/compute/server.rb, line 187
def scp(local_path, remote_path, upload_options = {})
  requires :ipaddress, :username

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

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

Sets up a new SSH key on the VM so one doesn't need to use a password ever again.

# File lib/fog/vmfusion/models/compute/server.rb, line 199
def setup(credentials = {})
  requires :public_key, :ipaddress, :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(ipaddress, 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(ipaddress, username, credentials).run(commands)
end
shutdown() click to toggle source

This is a graceful shutdown but Fusion is only capable of a graceful shutdown if tools are installed. Fusion does the right thing though and if graceful can't be initiated it just does a hard stop.

# File lib/fog/vmfusion/models/compute/server.rb, line 87
def shutdown
  requires :raw
  if ready?
    @raw[:fission].stop
    return true
  else
    return false
  end
end
ssh(commands) click to toggle source

Simply spawn an SSH session.

# File lib/fog/vmfusion/models/compute/server.rb, line 182
def ssh(commands)
  super(commands, password ? {:password => password} : {})
end
start(options = { :headless => false }) click to toggle source

Start is pretty self explanatory...if you pass :headless as true you won't get a console on launch.

# File lib/fog/vmfusion/models/compute/server.rb, line 49
def start(options = { :headless => false })
  requires :raw

  unless ready?
    @raw[:fission].start(:headless => options[:headless])
    return true
  else
    return false
  end
end
state() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 167
def state
  power_state
end
stop() click to toggle source

Stop is a hard stop, like pulling out the power cord.

# File lib/fog/vmfusion/models/compute/server.rb, line 64
def stop
  requires :raw

  if ready?
    @raw[:fission].stop(:hard => true)
    return true
  else
    return false
  end
end
suspend() click to toggle source
# File lib/fog/vmfusion/models/compute/server.rb, line 115
def suspend
  requires :raw
  if ready?
    @raw[:fission].suspend
    return true
  else
    return false
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.