Class: OpenNebula::DiskRecords
- Inherits:
-
RecordsSource
- Object
- RecordsSource
- OpenNebula::DiskRecords
- Defined in:
- service/records/disk_records.rb
Overview
(Disk)Records source class for fullfilling Timeline
Instance Attribute Summary
Attributes inherited from RecordsSource
Instance Method Summary collapse
-
#find(stime, etime) ⇒ Object
Returns all needed records for given timerange.
-
#init_state(stime) ⇒ Object
Gets All of the DiskRecords before stime and with deletion time greater than stime or nil and counts(which is initial quantity of disks).
-
#initialize(id) ⇒ DiskRecords
constructor
inits RecordsSource class with DiskRecord class as base.
-
#key ⇒ Object
Overrides key for db queries.
Methods inherited from RecordsSource
check_source, #records, tl_filter
Constructor Details
#initialize(id) ⇒ DiskRecords
inits RecordsSource class with DiskRecord class as base
77 78 79 |
# File 'service/records/disk_records.rb', line 77 def initialize id super(DiskRecord, id) end |
Instance Method Details
#find(stime, etime) ⇒ Object
Returns all needed records for given timerange
82 83 84 |
# File 'service/records/disk_records.rb', line 82 def find stime, etime @records.where(crt: stime..etime).or(del: stime..etime) end |
#init_state(stime) ⇒ Object
Gets All of the DiskRecords before stime and with deletion time greater than stime or nil and counts(which is initial quantity of disks)
87 88 89 90 91 92 93 94 95 |
# File 'service/records/disk_records.rb', line 87 def init_state stime state = {} @records.where { crt < stime }.where(del: nil).all.each do | rec | key = rec.type_sym state[key] = [] if state[key].nil? state[key] << { size: rec.size, img: rec.img } end state end |
#key ⇒ Object
Overrides key for db queries
72 73 74 |
# File 'service/records/disk_records.rb', line 72 def key :vm end |