Module: Facter::Util::Xendomains

Defined in:
lib/facter/util/xendomains.rb

Overview

A module to gather running Xen Domains

Constant Summary collapse

XEN_COMMANDS =
['/usr/sbin/xl', '/usr/sbin/xm']

Class Method Summary collapse

Class Method Details

.get_domainsObject



10
11
12
13
14
15
16
17
18
# File 'lib/facter/util/xendomains.rb', line 10

def self.get_domains
  command = self.xen_command
  if command
    if domains_list = Facter::Util::Resolution.exec("#{command} list 2>/dev/null")
      domains = domains_list.split("\n").reject { |line| line =~ /^(Name|Domain-0)/ }
      domains.map { |line| line.split(/\s/)[0] }.join(',')
    end
  end
end

.xen_commandObject



6
7
8
# File 'lib/facter/util/xendomains.rb', line 6

def self.xen_command
  XEN_COMMANDS.find { |cmd| Facter::Util::Resolution.which(cmd) }
end