1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[virtualbox] Removed VirtualBox since it has many problems and the gem it's based on is no longer maintained.

Fixes #1621: Remove VirtualBox support
This commit is contained in:
Kevin Menard 2013-03-04 19:31:59 -05:00
parent 7b2cb00ae9
commit 8d19c989d4
20 changed files with 1 additions and 969 deletions

View file

@ -60,7 +60,6 @@ Gem::Specification.new do |s|
s.add_development_dependency('rspec', '~>1.3.1')
s.add_development_dependency('rbovirt', '>=0.0.11')
s.add_development_dependency('shindo', '~>0.3.4')
s.add_development_dependency('virtualbox', '~>0.9.1')
s.add_development_dependency('fission')
s.add_development_dependency('pry')
# s.add_development_dependency('ruby-libvirt','~>0.4.0')

View file

@ -87,7 +87,6 @@ require 'fog/bin/serverlove'
require 'fog/bin/stormondemand'
require 'fog/bin/terremark'
require 'fog/bin/vcloud'
require 'fog/bin/virtual_box'
require 'fog/bin/vmfusion'
require 'fog/bin/vsphere'
require 'fog/bin/voxel'

View file

@ -1,57 +0,0 @@
module VirtualBox # deviates from other bin stuff to accomodate gem
class << self
def class_for(key)
case key
when :compute
Fog::Compute::VirtualBox
else
raise ArgumentError, "Unrecognized service: #{key}"
end
end
def [](service)
@@connections ||= Hash.new do |hash, key|
hash[key] = case key
when :compute
Fog::Logger.warning("VirtualBox[:compute] is not recommended, use Compute[:virtualbox] for portability")
Fog::Compute.new(:provider => 'VirtualBox')
else
raise ArgumentError, "Unrecognized service: #{key.inspect}"
end
end
@@connections[service]
end
def available?
availability = if Gem::Specification.respond_to?(:find_all_by_name)
!Gem::Specification.find_all_by_name('virtualbox').empty? # newest rubygems
else
!Gem.source_index.find_name('virtualbox').empty? # legacy
end
if availability
for service in services
for collection in self.class_for(service).collections
unless self.respond_to?(collection)
self.class_eval <<-EOS, __FILE__, __LINE__
def self.#{collection}
self[:#{service}].#{collection}
end
EOS
end
end
end
end
availability
end
def collections
services.map {|service| self[service].collections}.flatten.sort_by {|service| service.to_s}
end
def services
Fog::VirtualBox.services
end
end
end

View file

@ -35,9 +35,6 @@ module Fog
when :stormondemand
require 'fog/storm_on_demand/compute'
Fog::Compute::StormOnDemand.new(attributes)
when :virtualbox
require 'fog/virtual_box/compute'
Fog::Compute::VirtualBox.new(attributes)
else
if self.providers.include?(provider)
require "fog/#{provider}/compute"

View file

@ -27,7 +27,6 @@ require 'fog/ovirt'
require 'fog/serverlove'
require 'fog/storm_on_demand'
require 'fog/vcloud'
require 'fog/virtual_box'
require 'fog/vmfusion'
require 'fog/vsphere'
require 'fog/voxel'

View file

@ -1,11 +0,0 @@
require 'fog/core'
module Fog
module VirtualBox
extend Fog::Provider
service(:compute, 'virtual_box/compute', 'Compute')
end
end

View file

@ -1,59 +0,0 @@
require 'fog/virtual_box'
require 'fog/compute'
module Fog
module Compute
class VirtualBox < Fog::Service
model_path 'fog/virtual_box/models/compute'
model :medium
collection :mediums
model :medium_format
model :nat_engine
model :nat_redirect
collection :nat_redirects
model :network_adapter
collection :network_adapters
model :server
collection :servers
model :storage_controller
collection :storage_controllers
class Mock
def initialize(options={})
Fog::Mock.not_implemented
end
end
class Real
def initialize(options={})
begin
require 'virtualbox'
rescue LoadError => e
retry if require('rubygems')
raise e.message
end
@service = ::VirtualBox::Global.global.lib.virtualbox
end
def respond_to?(method, *)
super or @service.respond_to? method
end
# hack to provide 'requests'
def method_missing(method_sym, *arguments, &block)
if @service.respond_to?(method_sym)
@service.send(method_sym, *arguments)
else
super
end
end
end
end
end
end

View file

@ -1,87 +0,0 @@
require 'fog/core/model'
require 'fog/virtual_box/models/compute/medium_format'
module Fog
module Compute
class VirtualBox
class Medium < Fog::Model
identity :id
attribute :auto_reset
attribute :base
attribute :children
attribute :description
attribute :device_type
attribute :format
attribute :host_drive
attribute :id
attribute :last_access_error
attribute :location
attribute :logical_size
attribute :machine_ids
attribute :medium_format
attribute :name
attribute :parent
attribute :read_only
attribute :size
attribute :state
attribute :type
attribute :variant
def destroy
requires :raw
raw.close
true
end
undef_method :medium_format
def medium_format
Fog::Compute::VirtualBox::MediumFormat.new(
:service => service,
:raw => raw.medium_format
)
end
def save
requires :device_type, :location, :read_only
if File.exists?(location)
access_mode = if read_only
:access_mode_read_only
else
:access_mode_read_write
end
self.raw = service.open_medium(location, device_type, access_mode)
else
raise Fog::Errors::Error.new('Creating a new medium is not yet implemented. Contributions welcome!')
end
end
private
def raw
@raw
end
def raw=(new_raw)
@raw = new_raw
raw_attributes = {}
for key in [:auto_reset, :base, :children, :description, :device_type, :format, :host_drive, :id, :last_access_error, :location, :logical_size, :machine_ids, :medium_format, :name, :parent, :read_only, :size, :state, :type, :variant]
raw_attributes[key] = @raw.send(key)
end
merge_attributes(raw_attributes)
end
end
end
end
end

View file

@ -1,34 +0,0 @@
require 'fog/core/model'
module Fog
module Compute
class VirtualBox
class MediumFormat < Fog::Model
identity :id
# attribute :capabilities
attribute :name
private
def raw
@raw
end
def raw=(new_raw)
@raw = new_raw
raw_attributes = {}
for key in [:id, :name]
raw_attributes[key] = @raw.send(key)
end
merge_attributes(raw_attributes)
end
end
end
end
end

View file

@ -1,32 +0,0 @@
require 'fog/core/collection'
require 'fog/virtual_box/models/compute/medium'
module Fog
module Compute
class VirtualBox
class Mediums < Fog::Collection
model Fog::Compute::VirtualBox::Medium
def all
data = []
data.concat(service.dvd_images)
data.concat(service.floppy_images)
data.concat(service.hard_disks)
data = data.map do |medium|
{:raw => medium}
end
load(data)
end
def get(medium_identity)
data = service.find_medium(medium_identity)
new(:raw => data)
end
end
end
end
end

View file

@ -1,65 +0,0 @@
require 'fog/core/model'
module Fog
module Compute
class VirtualBox
class NATEngine < Fog::Model
# identity :?
attribute :alias_mode
attribute :dns_pass_domain
attribute :dns_proxy
attribute :dns_use_host_resolver
attribute :host_ip
attribute :network
attribute :redirects
attribute :tftp_boot_file
attribute :tftp_next_server
attribute :tftp_prefix
attr_accessor :machine, :network_adapter
# def save
# unless identity
# requires :identity, :bus, :machine
# with_session do |session|
# self.raw = session.machine.add_storage_controller(identity, bus)
# end
# true
# else
# raise Fog::Errors::Error.new('Updating an existing storage_controller is not yet implemented. Contributions welcome!')
# end
# end
undef_method :redirects
def redirects
Fog::Compute::VirtualBox::NATRedirects.new(
:service => service,
:machine => machine,
:nat_engine => self
)
end
private
def raw
@raw
end
def raw=(new_raw)
@raw = new_raw
raw_attributes = {}
for key in [:alias_mode, :dns_pass_domain, :dns_proxy, :dns_use_host_resolver, :host_ip, :network, :redirects, :tftp_boot_file, :tftp_next_server, :tftp_prefix]
raw_attributes[key] = @raw.send(key)
end
merge_attributes(raw_attributes)
end
end
end
end
end

View file

@ -1,91 +0,0 @@
require 'fog/core/model'
module Fog
module Compute
class VirtualBox
class NATRedirect < Fog::Model
identity :name
attribute :name
attribute :protocol
attribute :host_ip
attribute :host_port
attribute :guest_ip
attribute :guest_port
attr_accessor :machine, :nat_engine
def destroy
requires :nat_engine, :name
with_session do |session|
raw_network_adapter = session.machine.get_network_adapter(nat_engine.network_adapter.slot)
raw_nat_engine = raw_network_adapter.nat_driver
raw_nat_engine.remove_redirect(name)
session.machine.save_settings
end
true
end
def initialize(attributes = {})
self.name = ''
self.protocol = :tcp
self.host_ip = ''
self.guest_ip = ''
super
end
undef_method :protocol=
def protocol=(new_protocol)
attributes[:protocol] = case new_protocol
when '0'
:udp
when '1'
:tcp
else
new_protocol
end
end
def save
requires :nat_engine, :name, :protocol, :host_ip, :host_port, :guest_ip, :guest_port
with_session do |session|
raw_network_adapter = session.machine.get_network_adapter(nat_engine.network_adapter.slot)
raw_nat_engine = raw_network_adapter.nat_driver
raw_nat_engine.add_redirect(name, protocol, host_ip, host_port, guest_ip, guest_port)
session.machine.save_settings
end
true
end
private
def raw
@raw
end
def raw=(new_raw)
@raw = new_raw
name, protocol, host_ip, host_port, guest_ip, guest_port = new_raw.split(',')
raw_attributes = {:name => name, :protocol => protocol, :host_ip => host_ip, :host_port => host_port, :guest_ip => guest_ip, :guest_port => guest_port}
merge_attributes(raw_attributes)
end
def session
::VirtualBox::Lib.lib.session
end
def with_session
raw_machine = machine.instance_variable_get(:@raw)
raw_machine.lock_machine(session, :write)
yield session
session.unlock_machine
end
end
end
end
end

View file

@ -1,41 +0,0 @@
require 'fog/core/collection'
require 'fog/virtual_box/models/compute/nat_redirect'
module Fog
module Compute
class VirtualBox
class NATRedirects < Fog::Collection
model Fog::Compute::VirtualBox::NATRedirect
attr_accessor :machine, :nat_engine
def all
requires :machine, :nat_engine
data = nat_engine.instance_variable_get(:@raw).redirects.map do |nat_redirect|
{
:machine => machine,
:raw => nat_redirect
}
end
load(data)
end
def get(nat_redirect_name)
requires :machine, :nat_engine
all.detect do |nat_redirect|
nat_redirect.name == nat_redirect_name
end
end
def new(attributes = {})
requires :machine, :nat_engine
super({:machine => machine, :nat_engine => nat_engine}.merge!(attributes))
end
end
end
end
end

View file

@ -1,82 +0,0 @@
require 'fog/core/model'
require 'fog/virtual_box/models/compute/nat_engine'
module Fog
module Compute
class VirtualBox
class NetworkAdapter < Fog::Model
identity :slot
attribute :adapter_type
attribute :attachment_type
attribute :bandwidth_limit
attribute :boot_priority
attribute :cable_connected
attribute :enabled
attribute :host_interface
attribute :internal_network
attribute :line_speed
attribute :mac_address
attribute :nat_driver
attribute :nat_network
attribute :trace_enabled
attribute :trace_file
attribute :vde_network
attr_accessor :machine
def save
with_session do |session|
session_raw = session.machine.get_network_adapter(slot)
# for attribute in [:adapter_type, :bandwidth_limit, :boot_priority, :cable_connected, :enabled, :host_interface, :internal_network, :line_speed, :mac_address, :nat_network, :trace_enabled, :trace_file]
# session_raw.send("#{attribute}=", attributes[attribute])
# end
session_raw.mac_address = mac_address
session.machine.save_settings
end
end
undef_method :nat_driver
def nat_driver
Fog::Compute::VirtualBox::NATEngine.new(
:service => service,
:machine => machine,
:network_adapter => self,
:raw => raw.nat_driver
)
end
private
def raw
@raw
end
def raw=(new_raw)
@raw = new_raw
raw_attributes = {}
for key in [:adapter_type, :attachment_type, :bandwidth_limit, :boot_priority, :cable_connected, :enabled, :host_interface, :internal_network, :line_speed, :mac_address, :nat_driver, :nat_network, :slot, :trace_enabled, :trace_file]
raw_attributes[key] = @raw.send(key)
end
merge_attributes(raw_attributes)
end
def session
::VirtualBox::Lib.lib.session
end
def with_session
raw_machine = machine.instance_variable_get(:@raw)
raw_machine.lock_machine(session, :write)
yield session
session.unlock_machine
end
end
end
end
end

View file

@ -1,42 +0,0 @@
require 'fog/core/collection'
require 'fog/virtual_box/models/compute/network_adapter'
module Fog
module Compute
class VirtualBox
class NetworkAdapters < Fog::Collection
model Fog::Compute::VirtualBox::NetworkAdapter
attr_accessor :machine
def all
requires :machine
data = []
raw_machine = machine.instance_variable_get(:@raw)
service.system_properties.network_adapter_count.times do |index|
data << {
:raw => raw_machine.get_network_adapter(index)
}
end
load(data)
end
def get(network_adapter_slot)
requires :machine
raw_machine = machine.instance_variable_get(:@raw)
network_adapter = raw_machine.get_network_adapter(network_adapter_slot)
new(:raw => network_adapter)
end
def new(attributes = {})
requires :machine
super({ :machine => machine }.merge!(attributes))
end
end
end
end
end

View file

@ -1,199 +0,0 @@
require 'fog/compute/models/server'
module Fog
module Compute
class VirtualBox
class Server < Fog::Compute::Server
identity :id
attribute :description
attribute :memory_size
attribute :name
attribute :os, :aliases => :os_type_id
attribute :rtc_use_utc
attribute :session_state
attribute :status, :aliases => :state
attribute :vram_size
# 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
def initialize(attributes={})
self.memory_size = 256
self.rtc_use_utc = true
self.vram_size = 8
super
end
def destroy
requires :name, :raw
unless raw.state == :powered_off
stop
wait_for { raw.session_state == :closed }
end
raw.unregister(:full)
config_file = service.compose_machine_filename(name)
config_directory = config_file.split(File::SEPARATOR)[0...-1].join(File::SEPARATOR)
FileUtils.rm_rf(config_directory)
true
end
def network_adapters
Fog::Compute::VirtualBox::NetworkAdapters.new(
:service => service,
:machine => self
)
end
def private_ip_address
nil
end
def public_ip_address
nil
end
def ready?
status == :running
end
def reboot
requires :raw
session.console.reset
true
end
def save
unless identity
requires :name, :os
self.raw = service.create_machine(nil, name, os)
service.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
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
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
def stop
requires :raw
session.console.power_down.wait
true
end
def storage_controllers
Fog::Compute::VirtualBox::StorageControllers.new(
:service => service,
:machine => self
)
end
private
def raw
@raw
end
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
def session
::VirtualBox::Lib.lib.session
end
def with_session
raw.lock_machine(session, :write)
yield session
session.unlock_machine
end
end
end
end
end

View file

@ -1,41 +0,0 @@
require 'fog/core/collection'
require 'fog/virtual_box/models/compute/server'
module Fog
module Compute
class VirtualBox
class Servers < Fog::Collection
model Fog::Compute::VirtualBox::Server
def all
data = service.machines.map do |machine|
{
:raw => machine
}
end
load(data)
end
def bootstrap(new_attributes = {})
raise 'Not Implemented'
# server = create(new_attributes)
# server.start
# server.wait_for { ready? }
# server.setup(:password => server.password)
# server
end
def get(server_id)
machine = service.find_machine(server_id)
new(:raw => machine)
rescue ::VirtualBox::Exceptions::ObjectNotFoundException
nil
end
end
end
end
end

View file

@ -1,83 +0,0 @@
require 'fog/core/model'
module Fog
module Compute
class VirtualBox
class StorageController < Fog::Model
identity :name
attribute :bootable
attribute :bus
attribute :controller_type
attribute :instance
attribute :max_devices_per_port_count
attribute :max_port_count
attribute :min_port_count
attribute :port_count
attribute :use_host_io_cache
attr_accessor :machine
def attach(medium, port, device = 0)
requires :identity, :machine
with_session do |session|
session.machine.attach_device(identity, port, device, medium.device_type, medium.instance_variable_get(:@raw))
session.machine.save_settings
end
true
end
def destroy
requires :identity, :machine
with_session do |session|
session.machine.remove_storage_controller(identity)
session.machine.save_settings
end
true
end
def save
requires :bus, :identity, :machine
with_session do |session|
self.raw = session.machine.add_storage_controller(identity, bus)
raw.port_count = 1
session.machine.save_settings
end
true
end
private
def raw
@raw
end
def raw=(new_raw)
@raw = new_raw
raw_attributes = {}
# TODO: pending my patches being accepted :bootable,
for key in [:bus, :controller_type, :instance, :max_devices_per_port_count, :max_port_count, :min_port_count, :port_count, :use_host_io_cache]
raw_attributes[key] = @raw.send(key)
end
merge_attributes(raw_attributes)
end
def session
::VirtualBox::Lib.lib.session
end
def with_session
raw_machine = machine.instance_variable_get(:@raw)
raw_machine.lock_machine(session, :write)
yield session
session.unlock_machine
end
end
end
end
end

View file

@ -1,38 +0,0 @@
require 'fog/core/collection'
require 'fog/virtual_box/models/compute/storage_controller'
module Fog
module Compute
class VirtualBox
class StorageControllers < Fog::Collection
model Fog::Compute::VirtualBox::StorageController
attr_accessor :machine
def all
requires :machine
data = machine.instance_variable_get(:@raw).storage_controllers.map do |storage_controller|
{:raw => storage_controller}
end
load(data)
end
def get(storage_controller_name)
requires :machine
all.detect do |storage_controller|
storage_controller.name == storage_controller_name
end
end
def new(attributes = {})
requires :machine
super({ :machine => machine }.merge!(attributes))
end
end
end
end
end

View file

@ -18,7 +18,7 @@ end
all_providers = Fog.registered_providers.map {|provider| provider.downcase}
# Manually remove these providers since they are local applications, not lacking credentials
all_providers = all_providers - ["libvirt", "virtualbox", "vmfusion"]
all_providers = all_providers - ["libvirt", "vmfusion"]
available_providers = Fog.available_providers.map {|provider| provider.downcase}