Class: TopologicalInventory::Providers::Common::Operations::Source

Inherits:
Object
  • Object
show all
Includes:
Logging, Mixins::SourcesApi, Mixins::Statuses, Mixins::XRhHeaders
Defined in:
lib/topological_inventory/providers/common/operations/source.rb

Constant Summary collapse

EVENT_AVAILABILITY_STATUS =
"availability_status".freeze
SERVICE_NAME =
"platform.sources.status".freeze
ERROR_MESSAGES =
{
  :authentication_not_found          => "Authentication not found in Sources API",
  :endpoint_or_application_not_found => "Endpoint or Application not found in Sources API",
}.freeze
LAST_CHECKED_AT_THRESHOLD =
5.minutes.freeze
AUTH_NOT_NECESSARY =
"n/a".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Statuses

#operation_status

Methods included from Mixins::XRhHeaders

#account_number_by_identity, #identity_by_account_number

Methods included from Mixins::SourcesApi

#application, #authentication, #endpoint, #full_hostname, #on_premise?, #sources_api, #verify_ssl_mode

Methods included from Logging

#logger

Constructor Details

#initialize(params = {}, request_context = nil, metrics = nil) ⇒ Source

Returns a new instance of Source.



32
33
34
35
36
37
38
39
40
41
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 32

def initialize(params = {}, request_context = nil, metrics = nil)
  self.metrics           = metrics
  self.operation         = 'Source'
  self.params            = params
  self.request_context   = request_context
  self.source_id         = params['source_id']
  self.    = params['external_tenant']
  self.updates_via_kafka = ENV['UPDATE_SOURCES_VIA_API'].blank?
  self.identity          = ()
end

Instance Attribute Details

#account_numberObject

Returns the value of attribute account_number.



30
31
32
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 30

def 
  @account_number
end

#identityObject

Returns the value of attribute identity.



30
31
32
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 30

def identity
  @identity
end

#operationObject

Returns the value of attribute operation.



30
31
32
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 30

def operation
  @operation
end

#paramsObject

Returns the value of attribute params.



30
31
32
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 30

def params
  @params
end

#request_contextObject

Returns the value of attribute request_context.



30
31
32
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 30

def request_context
  @request_context
end

#source_idObject

Returns the value of attribute source_id.



30
31
32
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 30

def source_id
  @source_id
end

Instance Method Details

#availability_checkObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/topological_inventory/providers/common/operations/source.rb', line 43

def availability_check
  self.operation += '#availability_check'

  return operation_status[:error] if params_missing?

  return operation_status[:skipped] if checked_recently?

  status, error_message = connection_status

  update_source_and_subresources(status, error_message)

  logger.availability_check("Completed: Source #{source_id} is #{status}")

  operation_status[:success]
end