Class: Nifty::Events::Opennebula::RegistrationEvent

Inherits:
Event
  • Object
show all
Includes:
Utils::EventsCommon
Defined in:
lib/nifty/events/opennebula/registration_event.rb

Overview

OpenNebula registration event

Author:

  • Michal Kimle

Instance Attribute Summary collapse

Attributes inherited from Event

#client, #datastores, #parameters

Attributes inherited from Event

#appliance, #transfer_method

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::EventsCommon

#expire_appliance, #groups

Constructor Details

#initialize(appliance, transfer_method, client, datastores, parameters) ⇒ RegistrationEvent

Returns a new instance of RegistrationEvent.

See Also:



21
22
23
24
25
26
27
28
# File 'lib/nifty/events/opennebula/registration_event.rb', line 21

def initialize(appliance, transfer_method, client, datastores, parameters)
  super(appliance, transfer_method, client, datastores, parameters)

  @image_handler = Nifty::Backends::Utils::Opennebula::ImageHandler.new(client)
  @template_handler = Nifty::Backends::Utils::Opennebula::TemplateHandler.new(client)
  @group_handler = Nifty::Backends::Utils::Opennebula::GroupHandler.new(client)
  @original_disks = []
end

Instance Attribute Details

#group_handlerObject

Returns the value of attribute group_handler.



14
15
16
# File 'lib/nifty/events/opennebula/registration_event.rb', line 14

def group_handler
  @group_handler
end

#image_handlerObject

Returns the value of attribute image_handler.



14
15
16
# File 'lib/nifty/events/opennebula/registration_event.rb', line 14

def image_handler
  @image_handler
end

#original_disksObject

Returns the value of attribute original_disks.



14
15
16
# File 'lib/nifty/events/opennebula/registration_event.rb', line 14

def original_disks
  @original_disks
end

#template_handlerObject

Returns the value of attribute template_handler.



14
15
16
# File 'lib/nifty/events/opennebula/registration_event.rb', line 14

def template_handler
  @template_handler
end

Class Method Details

.event?Boolean

Returns:

  • (Boolean)

See Also:

  • Event#event?


10
11
12
# File 'lib/nifty/events/opennebula/registration_event.rb', line 10

def self.event?
  true
end

Instance Method Details

#runObject

See Also:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/nifty/events/opennebula/registration_event.rb', line 31

def run
  logger.debug("Runnig event #{self.inspect}")
  transfer_disks

  expire_appliance(template_handler, image_handler, appliance, parameters)

  groups = groups(group_handler, appliance, parameters[:groups])
  # due to OpenNebula restrictions appliances have to be registered separately for each datastore and each group
  datastores.each do |datastore|
    groups.each do |group|
      image_data = register_disks(group, datastore)
      register_appliance(image_data, group, datastore)
    end
  end

  clean_original_disks
rescue Nifty::Errors::Backends::OpennebulaError, Nifty::Errors::TransferMethodError, Nifty::Errors::ApiCallTimeoutError => ex
  fail Nifty::Errors::Events::EventError, ex
ensure
  clean_copied_disks
end