Class: OVIRT::Template

Inherits:
BaseObject show all
Defined in:
lib/ovirt/template.rb

Instance Attribute Summary collapse

Attributes inherited from BaseObject

#client, #href, #id, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseObject

#parse_bool, #parse_version

Constructor Details

#initialize(client, xml) ⇒ Template

Returns a new instance of Template.



6
7
8
9
10
# 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

Instance Attribute Details

#clusterObject (readonly)

Returns the value of attribute cluster.



3
4
5
# File 'lib/ovirt/template.rb', line 3

def cluster
  @cluster
end

#commentObject

Returns the value of attribute comment.



4
5
6
# File 'lib/ovirt/template.rb', line 4

def comment
  @comment
end

#creation_timeObject (readonly)

Returns the value of attribute creation_time.



3
4
5
# File 'lib/ovirt/template.rb', line 3

def creation_time
  @creation_time
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/ovirt/template.rb', line 3

def description
  @description
end

#displayObject (readonly)

Returns the value of attribute display.



3
4
5
# File 'lib/ovirt/template.rb', line 3

def display
  @display
end

#memoryObject (readonly)

Returns the value of attribute memory.



3
4
5
# File 'lib/ovirt/template.rb', line 3

def memory
  @memory
end

#osObject (readonly)

Returns the value of attribute os.



3
4
5
# File 'lib/ovirt/template.rb', line 3

def os
  @os
end

#profileObject (readonly)

Returns the value of attribute profile.



3
4
5
# File 'lib/ovirt/template.rb', line 3

def profile
  @profile
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/ovirt/template.rb', line 3

def status
  @status
end

#storageObject (readonly)

Returns the value of attribute storage.



3
4
5
# File 'lib/ovirt/template.rb', line 3

def storage
  @storage
end

#versionObject (readonly)

Returns the value of attribute version.



3
4
5
# File 'lib/ovirt/template.rb', line 3

def version
  @version
end

Class Method Details

.to_xml(opts = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# 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

Instance Method Details

#interfacesObject



24
25
26
# File 'lib/ovirt/template.rb', line 24

def interfaces
  @interfaces ||= @client.template_interfaces(id)
end

#volumesObject



28
29
30
# File 'lib/ovirt/template.rb', line 28

def volumes
  @volumes ||= @client.template_volumes(id)
end