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, BackupJob, Cluster, Datastore, Document, Group, Hook, Host, Image, MarketPlace, MarketPlaceApp, SecurityGroup, Template, User, VMGroup, VNTemplate, Vdc, VirtualMachine, VirtualNetwork, VirtualRouter, Zone
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Gets element name [return] String the PoolElement name.
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.
-
#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?
Instance Attribute Details
#name ⇒ Object (readonly)
Gets element name
- return
-
String the PoolElement name
224 225 226 |
# File 'lib/opennebula/pool_element.rb', line 224 def name @name end |
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
212 213 214 |
# File 'lib/opennebula/pool_element.rb', line 212 def self.new_with_id(id, client = nil) new(build_xml(id), client) end |
Instance Method Details
#id ⇒ Object
Returns element identifier
- return
-
Integer the PoolElement ID
218 219 220 |
# File 'lib/opennebula/pool_element.rb', line 218 def id @pe_id 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
241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/opennebula/pool_element.rb', line 241 def replace(opts, xpath = 'TEMPLATE') return unless 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 |
#to_str ⇒ Object
DO NOT USE - ONLY REXML BACKEND
227 228 229 230 231 232 |
# File 'lib/opennebula/pool_element.rb', line 227 def to_str str = '' REXML::Formatters::Pretty.new(1).write(@xml, str) str end |