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, Hook, 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
212 213 214 |
# File 'lib/opennebula/pool_element.rb', line 212 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
218 219 220 |
# File 'lib/opennebula/pool_element.rb', line 218 def id @pe_id end |
#name ⇒ Object
Gets element name
- return
-
String the PoolElement name
224 225 226 |
# File 'lib/opennebula/pool_element.rb', line 224 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
243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/opennebula/pool_element.rb', line 243 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
229 230 231 232 233 234 |
# File 'lib/opennebula/pool_element.rb', line 229 def to_str str = "" REXML::Formatters::Pretty.new(1).write(@xml,str) return str end |