Class: OpenNebula::History

Inherits:
Object
  • Object
show all
Defined in:
service/objects/history.rb

Overview

VMs History Records representation class(linked to VM)

Defined Under Namespace

Classes: NoRecordsError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, client) ⇒ History

Returns a new instance of History.

Parameters:



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

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'service/objects/history.rb', line 5

def id
  @id
end

#recordsObject (readonly)

Returns the value of attribute records.



5
6
7
# File 'service/objects/history.rb', line 5

def records
  @records
end

Instance Method Details

#infoObject 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