This repository has been archived by the owner on Nov 17, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added VIF example
- Loading branch information
Sergio Rubio
committed
Apr 2, 2009
1 parent
76432f3
commit 2db9f1b
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |