Class: OpenNebula::PoolElement
- Inherits:
-
XMLElement
- Object
- XMLElement
- OpenNebula::PoolElement
- Defined in:
- lib/opennebula/pool_element.rb
Overview
The PoolElement Class represents a generic element of a Pool in XML format
Direct Known Subclasses
Acl, Cluster, Datastore, Document, Group, Host, Image, MarketPlace, MarketPlaceApp, SecurityGroup, Template, User, VMGroup, VNTemplate, Vdc, VirtualMachine, VirtualNetwork, VirtualRouter, Zone
Class Method Summary collapse
-
.new_with_id(id, client = nil) ⇒ Object
- Creates new element specifying its id id
- identifyier of the element client
-
initialized OpenNebula::Client object.
Instance Method Summary collapse
-
#id ⇒ Object
Returns element identifier [return] Integer the PoolElement ID.
-
#name ⇒ Object
Gets element name [return] String the PoolElement name.
-
#replace(opts, xpath = "TEMPLATE") ⇒ Object
Replace the xml pointed by xpath using a Hash object one object will be modified taking hash object pairs.
-
#to_str ⇒ Object
DO NOT USE - ONLY REXML BACKEND.
Methods inherited from XMLElement
#[], #add_element, #attr, build_xml, #delete_element, #each, #each_xpath, #element_xml, #has_elements?, #initialize_xml, #retrieve_elements, #retrieve_xmlelements, #set_content, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml, #xml_nil?
Class Method Details
.new_with_id(id, client = nil) ⇒ Object
Creates new element specifying its id
- id
-
identifyier of the element
- client
-
initialized OpenNebula::Client object
216 217 218 |
# File 'lib/opennebula/pool_element.rb', line 216 def self.new_with_id(id, client=nil) self.new(self.build_xml(id), client) end |
Instance Method Details
#id ⇒ Object
Returns element identifier
- return
-
Integer the PoolElement ID
222 223 224 |
# File 'lib/opennebula/pool_element.rb', line 222 def id @pe_id end |
#name ⇒ Object
Gets element name
- return
-
String the PoolElement name
228 229 230 |
# File 'lib/opennebula/pool_element.rb', line 228 def name @name end |
#replace(opts, xpath = "TEMPLATE") ⇒ Object
Replace the xml pointed by xpath using a Hash object one object will be modified taking hash object pairs
247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/opennebula/pool_element.rb', line 247 def replace(opts, xpath = "TEMPLATE") if self[xpath] opts.each do |att, value| xpath_u = xpath+"/#{att}" docs = retrieve_xmlelements(xpath_u) if docs.size == 1 docs[0].set_content(value) end end update(template_like_str(xpath)) end end |
#to_str ⇒ Object
DO NOT USE - ONLY REXML BACKEND
233 234 235 236 237 238 |
# File 'lib/opennebula/pool_element.rb', line 233 def to_str str = "" REXML::Formatters::Pretty.new(1).write(@xml,str) return str end |