class Fog::Compute::VirtualBox::Server

Public Class Methods

new(attributes={}) click to toggle source

property :accelerate_2d_video_enabled, T_BOOL property :accelerate_3d_enabled, T_BOOL property :access_error, :VirtualBoxErrorInfo, :readonly => true property :accessible, T_BOOL, :readonly => true property :audio_adapter, :AudioAdapter, :readonly => true property :bandwidth_control, :BandwidthControl, :readonly => true property :bios_settings, :BIOSSettings, :readonly => true property :chipset_type, :ChipsetType property :clipboard_mode, :ClipboardMode property :cpu_count, T_UINT32 property :cpu_execution_cap, T_UINT64 property :cpu_hot_plug_enabled, T_BOOL property :current_snapshot, :Snapshot, :readonly => true property :current_state_modified, T_BOOL, :readonly => true property :fault_tolerance_address, WSTRING property :fault_tolerance_password, WSTRING property :fault_tolerance_port, T_UINT64 property :fault_tolerance_state, :FaultToleranceState property :fault_tolerance_sync_interval, T_UINT64 property :firmware_type, :FirmwareType property :guest_property_notification_patterns, WSTRING property :hardware_uuid, WSTRING property :hardware_version, WSTRING property :hpet_enabled, T_BOOL property :io_cache_enabled, T_BOOL property :io_cache_size, T_UINT32 property :keyboard_hid_type, T_UINT32 property :last_state_change, T_INT64, :readonly => true property :log_folder, WSTRING, :readonly => true property :medium_attachments, [:MediumAttachment], :readonly => true property :memory_balloon_size, T_UINT64 property :monitor_count, T_UINT64 property :page_fusion_enabled, T_BOOL property :parent, :VirtualBox, :readonly => true property :pci_device_assignments, [:PciDeviceAttachment], :readonly => true property :pointing_hid_type, T_UINT32 property :session_pid, T_UINT64, :readonly => true property :session_type, WSTRING, :readonly => true property :settings_file_path, WSTRING, :readonly => true property :settings_modified, T_BOOL, :readonly => true property :shared_folders, [:SharedFolder], :readonly => true property :snapshot_count, T_UINT32, :readonly => true property :snapshot_folder, WSTRING property :state_file_path, WSTRING, :readonly => true property :storage_controllers, [:StorageController], :readonly => true property :teleporter_address, WSTRING property :teleporter_enabled, T_BOOL property :teleporter_password, WSTRING property :teleporter_port, T_UINT32 property :usb_controller, :USBController, :readonly => true property :vrde_server, :VRDEServer, :readonly => true

Calls superclass method Fog::Model.new
# File lib/fog/virtual_box/models/compute/server.rb, line 72
def initialize(attributes={})
  self.memory_size = 256
  self.rtc_use_utc = true
  self.vram_size   = 8
  super
end

Public Instance Methods

destroy() click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 79
def destroy
  requires :name, :raw
  unless raw.state == :powered_off
    stop
    wait_for { raw.session_state == :closed }
  end
  raw.unregister(:full)
  config_file = connection.compose_machine_filename(name)
  config_directory = config_file.split(File::SEPARATOR)[0...-1].join(File::SEPARATOR)
  FileUtils.rm_rf(config_directory)
  true
end
network_adapters() click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 92
def network_adapters
  Fog::Compute::VirtualBox::NetworkAdapters.new(
    :connection => connection,
    :machine => self
  )
end
private_ip_address() click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 99
def private_ip_address
  nil
end
public_ip_address() click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 103
def public_ip_address
  nil
end
ready?() click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 107
def ready?
  status == :running
end
reboot() click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 111
def reboot
  requires :raw
  session.console.reset
  true
end
save() click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 117
def save
  unless identity
    requires :name, :os
    self.raw = connection.create_machine(nil, name, os)
    connection.register_machine(raw)
    with_session do |session|
      for attribute in [:description, :memory_size, :rtc_use_utc, :vram_size]
        session.machine.send(:"#{attribute}=", attributes[attribute])
      end
      session.machine.save_settings
    end
    true
  else
    raise Fog::Errors::Error.new('Updating an existing server is not yet implemented. Contributions welcome!')
  end
end
setup(credentials = {}) click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 134
def setup(credentials = {})
  raise 'Not Implemented'
#   requires :addresses, :identity, :public_key, :username
#   Fog::SSH.new(addresses['public'].first, username, credentials).run([
#     %{mkdir .ssh},
#     %{echo "#{public_key}" >> ~/.ssh/authorized_keys},
#     %{passwd -l #{username}},
#     %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json},
#     %{echo "#{Fog::JSON.encode(metadata)}" >> ~/metadata.json}
#   ])
# rescue Errno::ECONNREFUSED
#   sleep(1)
#   retry
end
start(type = 'headless') click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 149
def start(type = 'headless')
  requires :raw
  # session, type in ['gui', 'headless'], key[=value]\n env variables
  raw.launch_vm_process(session, type, '').wait
  true
end
stop() click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 156
def stop
  requires :raw
  session.console.power_down.wait
  true
end
storage_controllers() click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 162
def storage_controllers
  Fog::Compute::VirtualBox::StorageControllers.new(
    :connection => connection,
    :machine    => self
  )
end

Private Instance Methods

raw() click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 171
def raw
  @raw
end
raw=(new_raw) click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 175
def raw=(new_raw)
  @raw = new_raw
  raw_attributes = {}
  for key in [:id, :description, :memory_size, :name, :os_type_id, :state]
    raw_attributes[key] = @raw.send(key)
  end
  merge_attributes(raw_attributes)
end
session() click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 184
def session
  ::VirtualBox::Lib.lib.session
end
with_session() { |session| ... } click to toggle source
# File lib/fog/virtual_box/models/compute/server.rb, line 188
def with_session
  raw.lock_machine(session, :write)
  yield session
  session.unlock_machine
end