Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 19th, 2012  |  syntax: None  |  size: 0.65 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. require 'fog'
  2. require 'pp'
  3.  
  4. conn = Fog::Compute.new({
  5.   :provider => 'XenServer',
  6.   :xenserver_url => 'xenserver-test',
  7.   :xenserver_username => 'root',
  8.   :xenserver_password => 'changeme',
  9. })
  10.  
  11.  
  12. # Find a storage repository (SR)
  13. sr = conn.storage_repositories.find { |sr| sr.name == 'Local storage' }
  14.  
  15. # Create a ~17GB VDI in storage repository 'Local Storage'
  16. vdi = conn.vdis.create :name => 'foovdi',
  17.                        :storage_repository => sr,
  18.                        :description => 'my foovdi',
  19.                        :virtual_size => '18589934592' # ~17GB in bytes
  20.  
  21.  
  22. # List all VDIs
  23. conn.vdis.each { |vdi| puts vdi.name }
  24.  
  25. # Destroy the VDI
  26. vdi.destroy