class OVIRT::Template
Attributes
cluster[R]
comment[RW]
creation_time[R]
description[R]
display[R]
memory[R]
os[R]
profile[R]
status[R]
storage[R]
version[R]
Public Class Methods
new(client, xml)
click to toggle source
Calls superclass method
OVIRT::BaseObject.new
# File lib/ovirt/template.rb, line 6 def initialize(client, xml) super(client, xml[:id], xml[:href], (xml/'name').first.text) parse_xml_attributes!(xml) self end
to_xml(opts={})
click to toggle source
# File lib/ovirt/template.rb, line 12 def self.to_xml(opts={}) builder = Nokogiri::XML::Builder.new do template_ { name_ opts[:name] || "t-#{Time.now.to_i}" description opts[:description] || '' comment opts[:comment] || '' vm(:id => opts[:vm]) } end Nokogiri::XML(builder.to_xml).root.to_s end
Public Instance Methods
interfaces()
click to toggle source
# File lib/ovirt/template.rb, line 24 def interfaces @interfaces ||= @client.template_interfaces(id) end
volumes()
click to toggle source
# File lib/ovirt/template.rb, line 28 def volumes @volumes ||= @client.template_volumes(id) end
Private Instance Methods
parse_xml_attributes!(xml)
click to toggle source
# File lib/ovirt/template.rb, line 33 def parse_xml_attributes!(xml) @description = ((xml/'description').first.text rescue '') @comment = ((xml/'comment').first.text rescue '') @version = TemplateVersion.new((xml/'version').first) @status = ((xml/'status').first.text rescue 'unknown') @memory = (xml/'memory').first.text @profile = (xml/'type').first.text if (xml/'cluster').first @cluster = Link::new(@client, (xml/'cluster').first[:id], (xml/'cluster').first[:href]) end @display = { :type => ((xml/'display/type').first.text rescue ''), :monitors => ((xml/'display/monitors').first.text rescue 0) } @cores = (xml/'cpu/topology').first[:cores].to_i @sockets = (xml/'cpu/topology').first[:sockets].to_i @storage = ((xml/'disks/disk/size').first.text rescue nil) @creation_time = (xml/'creation_time').text @os = { :type => (xml/'os').first[:type], :boot => (xml/'os/boot').collect {|boot| boot[:dev] } } end