Class: Libvirt::Connect

Inherits:
Object
  • Object
show all
Defined in:
lib/libvirt-ext.rb

Instance Method Summary collapse

Instance Method Details

#active_domainsObject



49
# File 'lib/libvirt-ext.rb', line 49

def active_domains()  each_active_domain.to_a  end

#domainsObject



51
# File 'lib/libvirt-ext.rb', line 51

def domains()  each_domain.to_a  end

#each_active_domainObject



33
34
35
36
# File 'lib/libvirt-ext.rb', line 33

def each_active_domain
	return Enumerator.new( self, __callee__)  unless block_given?
	list_domains.each {|id| yield lookup_domain_by_id( id) }
end

#each_domain(&e) ⇒ Object



43
44
45
46
47
# File 'lib/libvirt-ext.rb', line 43

def each_domain &e
	return Enumerator.new( self, __callee__)  unless block_given?
	each_active_domain &e
	each_inactive_domain &e
end

#each_inactive_domainObject



38
39
40
41
# File 'lib/libvirt-ext.rb', line 38

def each_inactive_domain
	return Enumerator.new( self, __callee__)  unless block_given?
	list_defined_domains.each {|name| yield lookup_domain_by_name( name) }
end

#inactive_domainsObject



50
# File 'lib/libvirt-ext.rb', line 50

def inactive_domains()  each_inactive_domain.to_a  end

#inspectObject



69
70
71
# File 'lib/libvirt-ext.rb', line 69

def inspect
	"#<#{self.class.name} #{uri}>"
end

#lookup_domain(id_uuid_or_name) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/libvirt-ext.rb', line 52

def lookup_domain id_uuid_or_name
	case id_uuid_or_name
	when UUIDTools::UUID then lookup_domain_by_uuid id_uuid_or_name.to_s
	when Numeric then lookup_domain_by_id id_uuid_or_name
	when String
		begin UUIDTools::UUID.parse id_uuid_or_name
		rescue Object
			if id_uuid_or_name == id_uuid_or_name.to_i.to_s
				lookup_domain_by_id id_uuid_or_name
			else
				lookup_domain_by_name id_uuid_or_name
			end
		end
	else raise ArgumentError, "UUID or domain name expected."
	end
end