Class: Cloudkeeper::One::CoreConnector
- Inherits:
-
CloudkeeperGrpc::Communicator::Service
- Object
- CloudkeeperGrpc::Communicator::Service
- Cloudkeeper::One::CoreConnector
- Includes:
- ApplianceActions::Discard, ApplianceActions::List, ApplianceActions::Registration, ApplianceActions::Update
- Defined in:
- lib/cloudkeeper/one/core_connector.rb
Constant Summary collapse
- ERRORS =
Hash.new(CloudkeeperGrpc::Constants::STATUS_ERROR).update( Cloudkeeper::One::Errors::Actions::ListingError => CloudkeeperGrpc::Constants::STATUS_ERROR_APPLIANCE_NOT_FOUND, Cloudkeeper::One::Errors::Actions::UpdateError => CloudkeeperGrpc::Constants::STATUS_ERROR_APPLIANCE_NOT_FOUND, Cloudkeeper::One::Errors::NetworkConnectionError => CloudkeeperGrpc::Constants::STATUS_ERROR_APPLIANCE_TRANSFER, Cloudkeeper::One::Errors::Opennebula::AuthenticationError => CloudkeeperGrpc::Constants::STATUS_ERROR_AUTHENTICATION, Cloudkeeper::One::Errors::Opennebula::UserNotAuthorizedError => CloudkeeperGrpc::Constants::STATUS_ERROR_USER_NOT_AUTHORIZED, Cloudkeeper::One::Errors::Opennebula::ResourceNotFoundError => CloudkeeperGrpc::Constants::STATUS_ERROR_RESOURCE_NOT_FOUND, Cloudkeeper::One::Errors::Actions::RegistrationError => CloudkeeperGrpc::Constants::STATUS_ERROR_RESOURCE_NOT_FOUND, Cloudkeeper::One::Errors::Opennebula::ResourceRetrievalError => CloudkeeperGrpc::Constants::STATUS_ERROR_RESOURCE_RETRIEVAL, Cloudkeeper::One::Errors::Opennebula::ResourceStateError => CloudkeeperGrpc::Constants::STATUS_ERROR_RESOURCE_STATE, Cloudkeeper::One::Errors::Opennebula::ApiCallTimeoutError => CloudkeeperGrpc::Constants::STATUS_ERROR_RESOURCE_STATE ).freeze
Instance Attribute Summary collapse
-
#datastore_handler ⇒ Object
readonly
Returns the value of attribute datastore_handler.
-
#group_handler ⇒ Object
readonly
Returns the value of attribute group_handler.
-
#image_handler ⇒ Object
readonly
Returns the value of attribute image_handler.
-
#template_handler ⇒ Object
readonly
Returns the value of attribute template_handler.
Instance Method Summary collapse
- #add_appliance(appliance, call) ⇒ Object
- #appliances(image_list_identifier, call) ⇒ Object
- #image_lists(_empty, call) ⇒ Object
-
#initialize ⇒ CoreConnector
constructor
A new instance of CoreConnector.
- #post_action(_empty, call) ⇒ Object
- #pre_action(_empty, call) ⇒ Object
- #remove_appliance(appliance, call) ⇒ Object
- #remove_image_list(image_list_identifier, call) ⇒ Object
- #update_appliance(appliance, call) ⇒ Object
Methods included from ApplianceActions::List
#list_appliances, #list_image_lists
Methods included from ApplianceActions::Update
#update_appliance_metadata, #update_image, #update_template
Methods included from ApplianceActions::Utils::TemplatePreparation
#prepare_template, #render_templates
Methods included from ApplianceActions::Discard
#discard_appliance, #discard_expired, #discard_image_list, #discard_images, #discard_templates
Methods included from ApplianceActions::Registration
Methods included from ApplianceActions::Utils::ImageDownload
Constructor Details
#initialize ⇒ CoreConnector
Returns a new instance of CoreConnector.
24 25 26 27 28 29 30 31 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 24 def initialize super @image_handler = Cloudkeeper::One::Opennebula::ImageHandler.new @template_handler = Cloudkeeper::One::Opennebula::TemplateHandler.new @datastore_handler = Cloudkeeper::One::Opennebula::DatastoreHandler.new @group_handler = Cloudkeeper::One::Opennebula::GroupHandler.new end |
Instance Attribute Details
#datastore_handler ⇒ Object (readonly)
Returns the value of attribute datastore_handler.
4 5 6 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 4 def datastore_handler @datastore_handler end |
#group_handler ⇒ Object (readonly)
Returns the value of attribute group_handler.
4 5 6 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 4 def group_handler @group_handler end |
#image_handler ⇒ Object (readonly)
Returns the value of attribute image_handler.
4 5 6 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 4 def image_handler @image_handler end |
#template_handler ⇒ Object (readonly)
Returns the value of attribute template_handler.
4 5 6 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 4 def template_handler @template_handler end |
Instance Method Details
#add_appliance(appliance, call) ⇒ Object
44 45 46 47 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 44 def add_appliance(appliance, call) logger.debug "Registering appliance #{appliance.identifier.inspect}" call_backend(call) { register_or_update_appliance appliance } end |
#appliances(image_list_identifier, call) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 69 def appliances(image_list_identifier, call) logger.debug "Retrieving appliances from image list #{image_list_identifier.image_list_identifier.inspect} " \ 'registered in OpenNebula' call_backend(call, default_return_value: [], use_return_value: true) do list_appliances(image_list_identifier.image_list_identifier).each end end |
#image_lists(_empty, call) ⇒ Object
64 65 66 67 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 64 def image_lists(_empty, call) logger.debug 'Retrieving image lists registered in OpenNebula' call_backend(call, default_return_value: [], use_return_value: true) { list_image_lists.each } end |
#post_action(_empty, call) ⇒ Object
38 39 40 41 42 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 38 def post_action(_empty, call) logger.debug 'Running \'post-action\'...' call.['status'] = 'SUCCESS' Google::Protobuf::Empty.new end |
#pre_action(_empty, call) ⇒ Object
33 34 35 36 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 33 def pre_action(_empty, call) logger.debug 'Running \'pre-action\'...' call_backend(call) { discard_expired } end |
#remove_appliance(appliance, call) ⇒ Object
54 55 56 57 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 54 def remove_appliance(appliance, call) logger.debug "Removing appliance #{appliance.identifier.inspect}" call_backend(call) { discard_appliance appliance.identifier } end |
#remove_image_list(image_list_identifier, call) ⇒ Object
59 60 61 62 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 59 def remove_image_list(image_list_identifier, call) logger.debug "Removing appliances from image list #{image_list_identifier.image_list_identifier.inspect}" call_backend(call) { discard_image_list image_list_identifier.image_list_identifier } end |
#update_appliance(appliance, call) ⇒ Object
49 50 51 52 |
# File 'lib/cloudkeeper/one/core_connector.rb', line 49 def update_appliance(appliance, call) logger.debug "Updating appliance #{appliance.identifier.inspect}" call_backend(call) { appliance.image ? register_or_update_appliance(appliance) : (appliance) } end |