Class: Berta::EntityHandler
- Inherits:
-
Object
- Object
- Berta::EntityHandler
- Defined in:
- lib/berta/entity_handler.rb
Overview
Class for handeling entities in OpenNebula
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(handle) ⇒ EntityHandler
constructor
A new instance of EntityHandler.
- #notify(vms) ⇒ Object
Constructor Details
#initialize(handle) ⇒ EntityHandler
Returns a new instance of EntityHandler.
6 7 8 9 10 11 12 |
# File 'lib/berta/entity_handler.rb', line 6 def initialize(handle) @handle = handle @type = handle.class.name.split('::').last @name = handle['NAME'] @email = handle['TEMPLATE/EMAIL'] @id = handle['ID'] end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
4 5 6 |
# File 'lib/berta/entity_handler.rb', line 4 def email @email end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
4 5 6 |
# File 'lib/berta/entity_handler.rb', line 4 def handle @handle end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/berta/entity_handler.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/berta/entity_handler.rb', line 4 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/berta/entity_handler.rb', line 4 def type @type end |
Instance Method Details
#notify(vms) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/berta/entity_handler.rb', line 14 def notify(vms) notification = Berta::Notification.new(name, email, type) to_notify = vms.keep_if(&:should_notify?) if to_notify.empty? logger.debug { "No notifications for #{type} #{name} with id #{id}" } return end notification.notify(to_notify) to_notify.each(&:update_notified) rescue Berta::Errors::Entities::NoEmailError logger.debug { "#{type} #{id} has no email, skipping" } end |