module Fog::Compute::Libvirt::Shared
Private Instance Methods
boot_order(xml)
click to toggle source
# File lib/fog/libvirt/requests/compute/list_domains.rb, line 35 def boot_order xml xml_elements(xml, "domain/os/boot", "dev") end
domain_display(xml)
click to toggle source
# File lib/fog/libvirt/requests/compute/list_domains.rb, line 23 def domain_display xml attrs = {} [:type, :port, :password, :listen].each do |element| attrs[element] = xml_element(xml, "domain/devices/graphics",element.to_s) rescue nil end attrs.reject{|k,v| v.nil? or v == ""} end
domain_interfaces(xml)
click to toggle source
# File lib/fog/libvirt/requests/compute/list_domains.rb, line 39 def domain_interfaces xml ifs = xml_elements(xml, "domain/devices/interface") ifs.map { |i| nics.new({ :type => i['type'], :mac => (i/'mac').first[:address], :network => ((i/'source').first[:network] rescue nil), :bridge => ((i/'source').first[:bridge] rescue nil), :model => ((i/'model').first[:type] rescue nil), }.reject{|k,v| v.nil?}) } end
domain_to_attributes(dom)
click to toggle source
# File lib/fog/libvirt/requests/compute/list_domains.rb, line 52 def domain_to_attributes(dom) states= %w(nostate running blocked paused shutting-down shutoff crashed) { :id => dom.uuid, :uuid => dom.uuid, :name => dom.name, :max_memory_size => dom.info.max_mem, :cputime => dom.info.cpu_time, :memory_size => dom.info.memory, :cpus => dom.info.nr_virt_cpu, :autostart => dom.autostart?, :os_type => dom.os_type, :active => dom.active?, :display => domain_display(dom.xml_desc), :boot_order => boot_order(dom.xml_desc), :nics => domain_interfaces(dom.xml_desc), :volumes_path => domain_volumes(dom.xml_desc), :state => states[dom.info.state] } end
domain_volumes(xml)
click to toggle source
# File lib/fog/libvirt/requests/compute/list_domains.rb, line 31 def domain_volumes xml xml_elements(xml, "domain/devices/disk/source", "file") end