module Fog::Libvirt::Compute::Shared
Private Instance Methods
Source
# File lib/fog/libvirt/requests/compute/list_domains.rb, line 51 def boot_order xml xml_elements(xml, "domain/os/boot", "dev") end
Source
# File lib/fog/libvirt/requests/compute/list_domains.rb, line 33 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
Source
# File lib/fog/libvirt/requests/compute/list_domains.rb, line 55 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
Source
# File lib/fog/libvirt/requests/compute/list_domains.rb, line 68 def domain_to_attributes(dom) states= %w(nostate running blocked paused shutting-down shutoff crashed) begin { :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] } rescue ::Libvirt::RetrieveError, ::Libvirt::Error # Catch libvirt exceptions to avoid race conditions involving # concurrent libvirt operations (like from another process) return nil end end
Source
# File lib/fog/libvirt/requests/compute/list_domains.rb, line 41 def domain_volumes xml vols_by_file = xml_elements(xml, "domain/devices/disk/source", "file") vols_by_name = xml_elements(xml, "domain/devices/disk/source", "name") vols = [] vols_by_file.zip(vols_by_name).each do |by_file,by_name| vols.push(by_file.nil? ? by_name : by_file) end vols end