From 5152fd273bb36bba20f969949cb2a51b5ecfd503 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Sun, 16 Dec 2012 22:35:51 +0100 Subject: [PATCH] [xenserver|docs] added some color!, minor format fixes --- .../examples/storage_repositories.md | 106 ++++++++++-------- 1 file changed, 60 insertions(+), 46 deletions(-) diff --git a/lib/fog/xenserver/examples/storage_repositories.md b/lib/fog/xenserver/examples/storage_repositories.md index c24eec924..28b641d2d 100644 --- a/lib/fog/xenserver/examples/storage_repositories.md +++ b/lib/fog/xenserver/examples/storage_repositories.md @@ -6,75 +6,89 @@ http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=SR Create the XenServer connection first, as usual: - require 'fog' - require 'net/scp' - require 'pp' - - xenserver = Fog::Compute.new({ - :provider => 'XenServer', - :xenserver_url => 'xenserver-test', - :xenserver_username => 'root', - :xenserver_password => 'secret', - }) +```ruby +require 'fog' +require 'net/scp' +require 'pp' +xenserver = Fog::Compute.new({ + :provider => 'XenServer', + :xenserver_url => 'xenserver-test', + :xenserver_username => 'root', + :xenserver_password => 'secret', +}) +``` -Listing the available storage repositories +Listing the available storage repositories: - xenserver.storage_repositories +```ruby +xenserver.storage_repositories +``` Filter storage repositories by content type: - xenserver.storage_repositories.select { |sr| sr.content_type == 'iso' } +```ruby +xenserver.storage_repositories.select { |sr| sr.content_type == 'iso' } +``` Filter storage repositories by allowed operations: - rw_srs = xenserver.storage_repositories.select do |sr| - # Are we allowed to create a VDI here? - sr.allowed_operations.include? 'vdi_create' - end +```ruby +rw_srs = xenserver.storage_repositories.select do |sr| + # Are we allowed to create a VDI here? + sr.allowed_operations.include? 'vdi_create' +end +``` Print some attributes of the first SR found: - sr = rw_srs.first - puts sr.name - puts sr.description - puts sr.type - puts sr.tags - # in bytes - puts sr.physical_size - puts sr.physical_utilisation - # sum of virtual_sizes of all VDIs in this storage repository (in bytes) - puts sr.virtual_allocation +```ruby +sr = rw_srs.first +puts sr.name +puts sr.description +puts sr.type +puts sr.tags +# in bytes +puts sr.physical_size +puts sr.physical_utilisation +# sum of virtual_sizes of all VDIs in this storage repository (in bytes) +puts sr.virtual_allocation +``` - List virtual disk images available and print some VDI's attributes: - sr.vdis.each do |vdi| - # http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=VDI - puts vdi.uuid - puts vdi.is_a_snapshot - puts vdi.name - # in bytes - puts vdi.physical_utilisation - puts vdi.virtual_size - puts vdi.read_only - # ["update", "resize", "destroy", "clone", "copy", "snapshot"], - puts vdi.allowed_operations - end +```ruby +sr.vdis.each do |vdi| + # http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/?c=VDI + puts vdi.uuid + puts vdi.is_a_snapshot + puts vdi.name + # in bytes + puts vdi.physical_utilisation + puts vdi.virtual_size + puts vdi.read_only + # ["update", "resize", "destroy", "clone", "copy", "snapshot"], + puts vdi.allowed_operations +end +``` Create a new VDI in this storage repository: - vdi = xenserver.vdis.create :name => 'super-vdi', - :storage_repository => sr, - :description => 'my super-vdi', - :virtual_size => '1073741824' # 1 GB +```ruby +vdi = xenserver.vdis.create :name => 'super-vdi', + :storage_repository => sr, + :description => 'my super-vdi', + :virtual_size => '1073741824' # 1 GB +``` I have an ext3 storage repository and this creates a 1GB VHD file there: [root@xenserver ~]# vhd-util query -v -n /var/run/sr-mount/6edd263a-2da1-7533-840c-768417b5be25/4050057d-a3a8-4c00-8f2e-cf5531232921.vhd 1024 -Destroy it +Destroy the VDI: - vdi.destroy +```ruby +vdi.destroy +```