Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
* Updated examples
Browse files Browse the repository at this point in the history
* added VIF example
  • Loading branch information
Sergio Rubio committed Apr 2, 2009
1 parent 76432f3 commit 2db9f1b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions examples/base.rb
@@ -0,0 +1,11 @@
def ask_host
host_url = ARGV[0]

if host_url.nil? or host_url !~ /http:\/\/.*$/
puts "Usage: #{$0} <xen-api server url>"
puts
puts "Example: #{$0} http://xen.example.net:9363"
exit
end
return host_url
end
26 changes: 26 additions & 0 deletions examples/vif.rb
@@ -0,0 +1,26 @@
require 'rubygems'
begin
require '../lib/pangea'
rescue
require 'pangea'
end
# cmdline helper
require "#{File.join(File.dirname(__FILE__), 'base.rb')}"
# from base.rb
host_url = ask_host

host = Pangea::Host.connect(host_url, 'foo', 'bar')

# skip if only one VM available (Dom0)
if host.resident_vms.size > 1
vm = host.resident_vms[1]
puts "VM Label: #{vm.label}"
vm.vifs.each do |vif|
puts "Device: #{vif.device}"
puts "MAC Address: " + vif.mac
metrics = vif.metrics
puts "Kbs Out: #{metrics.io_write_kbs}"
puts "Kbs In: #{metrics.io_read_kbs}"
puts "----"
end
end

0 comments on commit 2db9f1b

Please sign in to comment.