Class: PoolParty::Remote::LibvirtInstance
- Inherits:
-
RemoteInstance
show all
- Includes:
- Dslify
- Defined in:
- lib/poolparty/net/remoter_bases/libvirt/libvirt_instance.rb
Instance Method Summary
collapse
#[], #[]=, #each, #elapsed_runtime, #has_key?, #keys, #load, #on_init, #pending?, #running?, #terminated?, #terminating?, #valid?, #values
Constructor Details
Returns a new instance of LibvirtInstance.
20
21
22
23
|
# File 'lib/poolparty/net/remoter_bases/libvirt/libvirt_instance.rb', line 20
def initialize(o={})
set_vars_from_options o
end
|
Instance Method Details
#description ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/poolparty/net/remoter_bases/libvirt/libvirt_instance.rb', line 47
def description
p command = "virsh dumpxml #{instance_id || image_id || name}"
xml = `#{command}`
hsh = XmlSimple.xml_in(xml, 'KeyToSymbol'=>true)
hsh[:state] = `virsh domstate #{instance_id || image_id || name}`
hsh[:mac_address] = mac_addresses( hsh ).first
dsl_options.merge! hsh
self
end
|
#keypair(*n) ⇒ Object
29
30
31
|
# File 'lib/poolparty/net/remoter_bases/libvirt/libvirt_instance.rb', line 29
def keypair(*n)
dsl_options[:keypair] ||= Key.new(keypair_name)
end
|
#mac_address ⇒ Object
TODO: this needs to be extended for selecting between multiple interfaces
34
35
36
|
# File 'lib/poolparty/net/remoter_bases/libvirt/libvirt_instance.rb', line 34
def mac_address(hsh=nil)
mac_addresses.first(hsh)
end
|
#mac_addresses(hsh = nil) ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/poolparty/net/remoter_bases/libvirt/libvirt_instance.rb', line 38
def mac_addresses(hsh=nil)
data = hsh || description
data[:devices].select{|el|
el.has_key? :interface
}.collect{|eth|
eth.interface.collect{|n| n.mac}
}.flatten.collect{|c| c.values}.flatten
end
|
25
26
27
|
# File 'lib/poolparty/net/remoter_bases/libvirt/libvirt_instance.rb', line 25
def to_hash
dsl_options
end
|