Class: OpenNebula::History
- Inherits:
-
Object
- Object
- OpenNebula::History
- Defined in:
- service/objects/history.rb
Overview
VMs History Records representation class(linked to VM)
Defined Under Namespace
Classes: NoRecordsError
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
-
#info ⇒ Object
(also: #info!)
Getting history records from DB[table :history] and parsing them(from XML).
-
#initialize(id, client) ⇒ History
constructor
A new instance of History.
Constructor Details
#initialize(id, client) ⇒ History
Returns a new instance of History.
9 10 11 12 13 |
# File 'service/objects/history.rb', line 9 def initialize id, client @client = client @id = id @parser = Nori.new end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'service/objects/history.rb', line 5 def id @id end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
5 6 7 |
# File 'service/objects/history.rb', line 5 def records @records end |
Instance Method Details
#info ⇒ Object Also known as: info!
Getting history records from DB[table :history] and parsing them(from XML)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'service/objects/history.rb', line 16 def info rc = System.new(@client).sql_query_command("SELECT body FROM history WHERE vid=#{@id}") rc = @parser.parse rc records = rc['SQL_COMMAND']['RESULT']['ROW'] if records.class == Array then records.map! { |record| @parser.parse(Base64.decode64(record['body64'])) } else records = [@parser.parse(Base64.decode64(records['body64']))] end @records = records nil rescue NoRecordsError.new "Error occurred while parsing" end |