Class: Cloudkeeper::Aws::CoreConnector

Inherits:
CloudkeeperGrpc::Communicator::Service show all
Includes:
BackendExecutor
Defined in:
lib/cloudkeeper/aws/core_connector.rb

Overview

Class implementing GRPC procedures

Constant Summary collapse

ERRORS =
{
  Cloudkeeper::Aws::Errors::Backend::ApplianceNotFoundError \
    => CloudkeeperGrpc::Constants::STATUS_CODE_APPLIANCE_NOT_FOUND,
  Cloudkeeper::Aws::Errors::Backend::MultipleAppliancesFoundError \
    => CloudkeeperGrpc::Constants::STATUS_CODE_INVALID_RESOURCE_STATE,
  Cloudkeeper::Aws::Errors::Backend::ImageImportError \
    => CloudkeeperGrpc::Constants::STATUS_CODE_FAILED_APPLIANCE_TRANSFER,
  Cloudkeeper::Aws::Errors::Backend::TimeoutError \
    => CloudkeeperGrpc::Constants::STATUS_CODE_FAILED_APPLIANCE_TRANSFER,
  Cloudkeeper::Aws::Errors::Backend::BackendError \
    => CloudkeeperGrpc::Constants::STATUS_CODE_UNKNOWN,
  Cloudkeeper::Aws::Errors::ImageDownloadError \
    => CloudkeeperGrpc::Constants::STATUS_CODE_UNKNOWN
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BackendExecutor

#change_tags, #deregister_expired_appliances, #deregister_image, #deregister_image_list, #fetch_appliances, #list_image_lists, #modify_appliance, #register_appliance, #upload_appliance, #upload_local_appliance, #upload_remote_appliance

Constructor Details

#initialize(cloud) ⇒ CoreConnector

Returns a new instance of CoreConnector.



24
25
26
27
# File 'lib/cloudkeeper/aws/core_connector.rb', line 24

def initialize(cloud)
  @cloud = cloud
  super()
end

Instance Attribute Details

#cloudObject

Returns the value of attribute cloud.



5
6
7
# File 'lib/cloudkeeper/aws/core_connector.rb', line 5

def cloud
  @cloud
end

Instance Method Details

#add_appliance(appliance, _call) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/cloudkeeper/aws/core_connector.rb', line 49

def add_appliance(appliance, _call)
  logger.debug { "GRPC add appliance #{appliance.identifier}" }
  handle_error do
    register_appliance(appliance)
    Google::Protobuf::Empty.new
  end
end

#appliances(image_list_identifier, _call) ⇒ Object



94
95
96
97
# File 'lib/cloudkeeper/aws/core_connector.rb', line 94

def appliances(image_list_identifier, _call)
  logger.debug { "GRPC appliances for: #{image_list_identifier.image_list_identifier}" }
  handle_error { fetch_appliances(image_list_identifier).each }
end

#handle_errorObject



29
30
31
32
33
34
35
36
37
# File 'lib/cloudkeeper/aws/core_connector.rb', line 29

def handle_error
  yield
rescue Cloudkeeper::Aws::Errors::StandardError => e
  logger.error { "Error #{e.class} with message #{e.message}" }
  raise GRPC::BadStatus.new(ERRORS[e.class], e.message)
rescue ::StandardError => e
  logger.error { "Standard error #{e.class} with message #{e.message}" }
  raise GRPC::BadStatus.new(CloudkeeperGrpc::Constants::STATUS_CODE_UNKNOWN, e.message)
end

#image_lists(_empty, _call) ⇒ Object



89
90
91
92
# File 'lib/cloudkeeper/aws/core_connector.rb', line 89

def image_lists(_empty, _call)
  logger.debug { 'GRPC image lists' }
  handle_error { list_image_lists.each }
end

#post_action(_empty, _call) ⇒ Object



44
45
46
47
# File 'lib/cloudkeeper/aws/core_connector.rb', line 44

def post_action(_empty, _call)
  logger.debug { 'GRPC post action' }
  Google::Protobuf::Empty.new
end

#pre_action(_empty, _call) ⇒ Object



39
40
41
42
# File 'lib/cloudkeeper/aws/core_connector.rb', line 39

def pre_action(_empty, _call)
  logger.debug { 'GRPC pre action' }
  Google::Protobuf::Empty.new
end

#remove_appliance(appliance, _call) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/cloudkeeper/aws/core_connector.rb', line 73

def remove_appliance(appliance, _call)
  logger.debug { "GRPC remove appliance #{appliance.identifier}" }
  handle_error do
    deregister_image(appliance)
    Google::Protobuf::Empty.new
  end
end

#remove_expired_appliances(_empty, _call) ⇒ Object



99
100
101
102
103
104
105
# File 'lib/cloudkeeper/aws/core_connector.rb', line 99

def remove_expired_appliances(_empty, _call)
  logger.debug { 'GRPC remove expired appliances' }
  handle_error do
    deregister_expired_appliances
    Google::Protobuf::Empty.new
  end
end

#remove_image_list(image_list_identifier, _call) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/cloudkeeper/aws/core_connector.rb', line 81

def remove_image_list(image_list_identifier, _call)
  logger.debug { "GRPC remove image list with id: #{image_list_identifier.image_list_identifier}" }
  handle_error do
    deregister_image_list(image_list_identifier)
    Google::Protobuf::Empty.new
  end
end

#update_appliance(appliance, _call) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/cloudkeeper/aws/core_connector.rb', line 57

def update_appliance(appliance, _call)
  logger.debug { "GRPC update appliance #{appliance.identifier}" }
  handle_error do
    modify_appliance(appliance)
    Google::Protobuf::Empty.new
  end
end

#update_appliance_metadata(appliance, _call) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/cloudkeeper/aws/core_connector.rb', line 65

def (appliance, _call)
  logger.debug { "GRPC update appliance metadata #{appliance.identifier}" }
  handle_error do
    change_tags(appliance)
    Google::Protobuf::Empty.new
  end
end