Class: Cloudkeeper::One::CoreConnector

Constant Summary collapse

STATUS_CODES =
Hash.new(CloudkeeperGrpc::Constants::STATUS_CODE_UNKNOWN).update(
  Cloudkeeper::One::Errors::Actions::ListingError => CloudkeeperGrpc::Constants::STATUS_CODE_APPLIANCE_NOT_FOUND,
  Cloudkeeper::One::Errors::Actions::UpdateError => CloudkeeperGrpc::Constants::STATUS_CODE_APPLIANCE_NOT_FOUND,
  Cloudkeeper::One::Errors::NetworkConnectionError => CloudkeeperGrpc::Constants::STATUS_CODE_FAILED_APPLIANCE_TRANSFER,
  Cloudkeeper::One::Errors::Opennebula::AuthenticationError => CloudkeeperGrpc::Constants::STATUS_CODE_UNAUTHENTICATED,
  Cloudkeeper::One::Errors::Opennebula::UserNotAuthorizedError => CloudkeeperGrpc::Constants::STATUS_CODE_PERMISSION_DENIED,
  Cloudkeeper::One::Errors::Opennebula::ResourceNotFoundError => CloudkeeperGrpc::Constants::STATUS_CODE_RESOURCE_NOT_FOUND,
  Cloudkeeper::One::Errors::Actions::RegistrationError => CloudkeeperGrpc::Constants::STATUS_CODE_RESOURCE_NOT_FOUND,
  Cloudkeeper::One::Errors::Opennebula::ResourceRetrievalError => CloudkeeperGrpc::Constants::STATUS_CODE_FAILED_RESOURCE_RETRIEVAL,
  Cloudkeeper::One::Errors::Opennebula::ResourceStateError => CloudkeeperGrpc::Constants::STATUS_CODE_INVALID_RESOURCE_STATE,
  Cloudkeeper::One::Errors::Opennebula::ApiCallTimeoutError => CloudkeeperGrpc::Constants::STATUS_CODE_INVALID_RESOURCE_STATE
).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ApplianceActions::List

#list_appliances, #list_image_lists

Methods included from ApplianceActions::Update

#update_image, #update_metadata, #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

#register_or_update_appliance

Methods included from ApplianceActions::Utils::ImageDownload

#download_image

Constructor Details

#initializeCoreConnector

Returns a new instance of CoreConnector.



24
25
26
27
28
29
30
# 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
end

Instance Attribute Details

#datastore_handlerObject (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

#image_handlerObject (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_handlerObject (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



42
43
44
45
# File 'lib/cloudkeeper/one/core_connector.rb', line 42

def add_appliance(appliance, _call)
  logger.debug "Registering appliance #{appliance.identifier.inspect}"
  call_backend { register_or_update_appliance appliance }
end

#appliances(image_list_identifier, _call) ⇒ Object



72
73
74
75
76
# File 'lib/cloudkeeper/one/core_connector.rb', line 72

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(use_return_value: true) { list_appliances(image_list_identifier.image_list_identifier).each }
end

#image_lists(_empty, _call) ⇒ Object



67
68
69
70
# File 'lib/cloudkeeper/one/core_connector.rb', line 67

def image_lists(_empty, _call)
  logger.debug 'Retrieving image lists registered in OpenNebula'
  call_backend(use_return_value: true) { list_image_lists.each }
end

#post_action(_empty, _call) ⇒ Object



37
38
39
40
# File 'lib/cloudkeeper/one/core_connector.rb', line 37

def post_action(_empty, _call)
  logger.debug 'Running \'post-action\'...'
  Google::Protobuf::Empty.new
end

#pre_action(_empty, _call) ⇒ Object



32
33
34
35
# File 'lib/cloudkeeper/one/core_connector.rb', line 32

def pre_action(_empty, _call)
  logger.debug 'Running \'pre-action\'...'
  Google::Protobuf::Empty.new
end

#remove_appliance(appliance, _call) ⇒ Object



57
58
59
60
# File 'lib/cloudkeeper/one/core_connector.rb', line 57

def remove_appliance(appliance, _call)
  logger.debug "Removing appliance #{appliance.identifier.inspect}"
  call_backend { discard_appliance appliance.identifier }
end

#remove_expired_appliances(_empty, _call) ⇒ Object



78
79
80
81
82
# File 'lib/cloudkeeper/one/core_connector.rb', line 78

def remove_expired_appliances(_empty, _call)
  logger.debug 'Removing expired appliances'

  call_backend { discard_expired }
end

#remove_image_list(image_list_identifier, _call) ⇒ Object



62
63
64
65
# File 'lib/cloudkeeper/one/core_connector.rb', line 62

def remove_image_list(image_list_identifier, _call)
  logger.debug "Removing appliances from image list #{image_list_identifier.image_list_identifier.inspect}"
  call_backend { discard_image_list image_list_identifier.image_list_identifier }
end

#update_appliance(appliance, _call) ⇒ Object



47
48
49
50
# File 'lib/cloudkeeper/one/core_connector.rb', line 47

def update_appliance(appliance, _call)
  logger.debug "Updating appliance #{appliance.identifier.inspect}"
  call_backend { register_or_update_appliance appliance }
end

#update_appliance_metadata(appliance, _call) ⇒ Object



52
53
54
55
# File 'lib/cloudkeeper/one/core_connector.rb', line 52

def (appliance, _call)
  logger.debug "Updating appliance metadata of #{appliance.identifier.inspect}"
  call_backend {  appliance }
end