Skip to content

Instantly share code, notes, and snippets.

@geemus
Created March 14, 2011 21:08
Show Gist options
  • Save geemus/869891 to your computer and use it in GitHub Desktop.
Save geemus/869891 to your computer and use it in GitHub Desktop.
simple example of using virtualbox
require 'fog'
compute = Fog::Compute.new(:provider => 'VirtualBox')
server = compute.servers.create(:name => 'lucid', :os => 'Ubuntu')
medium = compute.mediums.create(:device_type => :hard_disk, :location => '/Users/geemus/geemus/virtualbox_poc/lucid.vmdk', :read_only => false)
storage_controller = server.storage_controllers.create(:bus => :sata, :name => 'sata')
storage_controller.attach(medium, 0)
network_adapter = server.network_adapters.first
network_adapter.mac_address = '080027D8E375'
network_adapter.save
nat_driver = network_adapter.nat_driver
nat_driver.redirects.create(:guest_port => 22, :host_port => 2222)
server.start
Formatador.display('Press return to shutdown/cleanup...')
STDIN.getc
server.destroy
medium.destroy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment