Class: ChefLicensing::LicensingService::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/chef-licensing/licensing_service/local.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



8
9
10
# File 'lib/chef-licensing/licensing_service/local.rb', line 8

def logger
  @logger
end

Class Method Details

.detected?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/chef-licensing/licensing_service/local.rb', line 11

def detected?
  new.detected?
end

Instance Method Details

#detected?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/chef-licensing/licensing_service/local.rb', line 16

def detected?
  return ChefLicensing::Config.is_local_license_service if ChefLicensing::Config.is_local_license_service

  ChefLicensing::Api::ListLicenses.info
  true
rescue ChefLicensing::ListLicensesError => e
  # If API call returns 404, it is a global licensing service
  return false if e.status_code == 404

  raise(ChefLicensing::ListLicensesError.new("Error occured while fetching licenses #{e.message}", e.status_code))
end