Class: Cloudkeeper::BackendConnector
- Inherits:
-
Object
- Object
- Cloudkeeper::BackendConnector
- Includes:
- Entities::Conversions
- Defined in:
- lib/cloudkeeper/backend_connector.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#grpc_client ⇒ Object
readonly
Returns the value of attribute grpc_client.
-
#nginx ⇒ Object
readonly
Returns the value of attribute nginx.
Instance Method Summary collapse
- #add_appliance(appliance) ⇒ Object
- #appliances(image_list_identifier) ⇒ Object
- #image_lists ⇒ Object
-
#initialize ⇒ BackendConnector
constructor
A new instance of BackendConnector.
- #post_action ⇒ Object
- #pre_action ⇒ Object
- #remove_appliance(appliance) ⇒ Object
- #remove_expired_appliances ⇒ Object
- #remove_image_list(image_list_identifier) ⇒ Object
- #update_appliance(appliance) ⇒ Object
- #update_appliance_metadata(appliance) ⇒ Object
Constructor Details
#initialize ⇒ BackendConnector
Returns a new instance of BackendConnector.
7 8 9 10 11 |
# File 'lib/cloudkeeper/backend_connector.rb', line 7 def initialize @grpc_client = CloudkeeperGrpc::Communicator::Stub.new(Cloudkeeper::Settings[:'backend-endpoint'], credentials) @nginx = Cloudkeeper::Nginx::HttpServer.new @errors = false end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/cloudkeeper/backend_connector.rb', line 5 def errors @errors end |
#grpc_client ⇒ Object (readonly)
Returns the value of attribute grpc_client.
5 6 7 |
# File 'lib/cloudkeeper/backend_connector.rb', line 5 def grpc_client @grpc_client end |
#nginx ⇒ Object (readonly)
Returns the value of attribute nginx.
5 6 7 |
# File 'lib/cloudkeeper/backend_connector.rb', line 5 def nginx @nginx end |
Instance Method Details
#add_appliance(appliance) ⇒ Object
23 24 25 26 |
# File 'lib/cloudkeeper/backend_connector.rb', line 23 def add_appliance(appliance) logger.debug "'add_appliance' gRPC method call (appliance.identifier: #{appliance.identifier})" manage_appliance appliance, :add_appliance end |
#appliances(image_list_identifier) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cloudkeeper/backend_connector.rb', line 58 def appliances(image_list_identifier) logger.debug "'appliances' gRPC method call" response = handle_errors(exception: true) do grpc_client.appliances(CloudkeeperGrpc::ImageListIdentifier.new(image_list_identifier: image_list_identifier)) end response.inject({}) do |acc, elem| image = convert_image_proto(elem.image) appliance = convert_appliance_proto elem, image acc.merge appliance.identifier => appliance end end |
#image_lists ⇒ Object
52 53 54 55 56 |
# File 'lib/cloudkeeper/backend_connector.rb', line 52 def image_lists logger.debug "'image_lists' gRPC method call" response = handle_errors(exception: true) { grpc_client.image_lists(Google::Protobuf::Empty.new) } response.map(&:image_list_identifier) end |
#post_action ⇒ Object
18 19 20 21 |
# File 'lib/cloudkeeper/backend_connector.rb', line 18 def post_action logger.debug "'post_action' gRPC method call" handle_errors { grpc_client.post_action(Google::Protobuf::Empty.new) } end |
#pre_action ⇒ Object
13 14 15 16 |
# File 'lib/cloudkeeper/backend_connector.rb', line 13 def pre_action logger.debug "'pre_action' gRPC method call" handle_errors(exception: true) { grpc_client.pre_action(Google::Protobuf::Empty.new) } end |
#remove_appliance(appliance) ⇒ Object
39 40 41 42 43 |
# File 'lib/cloudkeeper/backend_connector.rb', line 39 def remove_appliance(appliance) logger.debug "'remove_appliance' gRPC method call (appliance.identifier: #{appliance.identifier})" appliance.image = nil manage_appliance appliance, :remove_appliance end |
#remove_expired_appliances ⇒ Object
71 72 73 74 |
# File 'lib/cloudkeeper/backend_connector.rb', line 71 def remove_expired_appliances logger.debug "'remove_expired_appliances' gRPC method call" handle_errors { grpc_client.remove_expired_appliances(Google::Protobuf::Empty.new) } end |
#remove_image_list(image_list_identifier) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/cloudkeeper/backend_connector.rb', line 45 def remove_image_list(image_list_identifier) logger.debug "'remove_image_list' gRPC method call (image_list_identifier: #{image_list_identifier})" handle_errors do grpc_client.remove_image_list(CloudkeeperGrpc::ImageListIdentifier.new(image_list_identifier: image_list_identifier)) end end |
#update_appliance(appliance) ⇒ Object
28 29 30 31 |
# File 'lib/cloudkeeper/backend_connector.rb', line 28 def update_appliance(appliance) logger.debug "'update_appliance' gRPC method call (appliance.identifier: #{appliance.identifier})" manage_appliance appliance, :update_appliance end |
#update_appliance_metadata(appliance) ⇒ Object
33 34 35 36 37 |
# File 'lib/cloudkeeper/backend_connector.rb', line 33 def (appliance) logger.debug "'update_appliance_metadata' gRPC method call (appliance.identifier: #{appliance.identifier})" appliance.image = nil manage_appliance appliance, :update_appliance_metadata end |