Class: Xen::Host
- Inherits:
-
Object
- Object
- Xen::Host
- Defined in:
- lib/xen/host.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
-
#nr_cpus ⇒ Object
readonly
Returns the value of attribute nr_cpus.
-
#total_memory ⇒ Object
readonly
Returns the value of attribute total_memory.
Class Method Summary collapse
Instance Method Summary collapse
- #domu_memory ⇒ Object
- #free_memory ⇒ Object
-
#initialize(detail_hash = {}) ⇒ Host
constructor
A new instance of Host.
Constructor Details
#initialize(detail_hash = {}) ⇒ Host
Returns a new instance of Host.
5 6 7 |
# File 'lib/xen/host.rb', line 5 def initialize(detail_hash={}) detail_hash.each { |i,j| instance_variable_set("@#{i}", j) } end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/xen/host.rb', line 3 def host @host end |
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
3 4 5 |
# File 'lib/xen/host.rb', line 3 def machine @machine end |
#nr_cpus ⇒ Object (readonly)
Returns the value of attribute nr_cpus.
3 4 5 |
# File 'lib/xen/host.rb', line 3 def nr_cpus @nr_cpus end |
#total_memory ⇒ Object (readonly)
Returns the value of attribute total_memory.
3 4 5 |
# File 'lib/xen/host.rb', line 3 def total_memory @total_memory end |
Class Method Details
Instance Method Details
#domu_memory ⇒ Object
21 22 23 |
# File 'lib/xen/host.rb', line 21 def domu_memory Xen::Slice.find(:running).inject(0){|m, slice| m += slice.instance.memory.to_i; m} end |
#free_memory ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/xen/host.rb', line 13 def free_memory if f = `free -m` if (m = f.match /buffers\/cache.*\s+(\w+)\n/) m[1].to_i end end end |