Class: ChefLicensing::Config
- Inherits:
-
Object
- Object
- ChefLicensing::Config
- Defined in:
- lib/chef-licensing/config.rb
Class Attribute Summary collapse
-
.chef_entitlement_id ⇒ Object
is_local_license_service is used by context class.
-
.chef_executable_name ⇒ Object
is_local_license_service is used by context class.
-
.chef_product_name ⇒ Object
is_local_license_service is used by context class.
-
.is_local_license_service ⇒ Object
is_local_license_service is used by context class.
- .license_add_command ⇒ Object
- .license_list_command ⇒ Object
- .license_server_url(opts = {}) ⇒ Object
-
.license_server_url_check_in_file ⇒ Object
writeonly
Sets the attribute license_server_url_check_in_file.
- .logger ⇒ Object
- .make_licensing_optional ⇒ Object
- .output ⇒ Object
-
.persist_license_data ⇒ Object
is_local_license_service is used by context class.
Class Method Summary collapse
Class Attribute Details
.chef_entitlement_id ⇒ Object
is_local_license_service is used by context class
20 21 22 |
# File 'lib/chef-licensing/config.rb', line 20 def chef_entitlement_id @chef_entitlement_id end |
.chef_executable_name ⇒ Object
is_local_license_service is used by context class
20 21 22 |
# File 'lib/chef-licensing/config.rb', line 20 def chef_executable_name @chef_executable_name end |
.chef_product_name ⇒ Object
is_local_license_service is used by context class
20 21 22 |
# File 'lib/chef-licensing/config.rb', line 20 def chef_product_name @chef_product_name end |
.is_local_license_service ⇒ Object
is_local_license_service is used by context class
20 21 22 |
# File 'lib/chef-licensing/config.rb', line 20 def is_local_license_service @is_local_license_service end |
.license_add_command ⇒ Object
61 62 63 |
# File 'lib/chef-licensing/config.rb', line 61 def license_add_command @license_add_command ||= "license add" end |
.license_list_command ⇒ Object
65 66 67 |
# File 'lib/chef-licensing/config.rb', line 65 def license_list_command @license_list_command ||= "license list" end |
.license_server_url(opts = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/chef-licensing/config.rb', line 22 def license_server_url(opts = {}) return @license_server_url if @license_server_url && @license_server_url_check_in_file license_server_url_from_system = ChefLicensing::ArgFetcher.fetch_value("--chef-license-server", :string) || ChefLicensing::EnvFetcher.fetch_value("CHEF_LICENSE_SERVER", :string) # Default persist to true for backward compatibility, but respect the config setting if set persist = @persist_license_data.nil? || @persist_license_data @license_server_url = ChefLicensing::LicenseKeyFetcher::File.fetch_or_persist_url(@license_server_url, license_server_url_from_system, opts.merge(persist: persist)) @license_server_url_check_in_file = true @license_server_url end |
.license_server_url_check_in_file=(value) ⇒ Object (writeonly)
Sets the attribute license_server_url_check_in_file
17 18 19 |
# File 'lib/chef-licensing/config.rb', line 17 def license_server_url_check_in_file=(value) @license_server_url_check_in_file = value end |
.logger ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/chef-licensing/config.rb', line 33 def logger # If no log level flags are set and we have a cached logger (like Inspec::Log), use it as-is return @logger if @logger && !log_level_flags_present? # If log level flags are present, configure the logger with determined level @logger = ChefLicensing::Log @logger.level = determine_log_level @logger end |
.make_licensing_optional ⇒ Object
69 70 71 |
# File 'lib/chef-licensing/config.rb', line 69 def make_licensing_optional @make_licensing_optional ||= false end |
.output ⇒ Object
57 58 59 |
# File 'lib/chef-licensing/config.rb', line 57 def output @output ||= STDOUT end |
.persist_license_data ⇒ Object
is_local_license_service is used by context class
20 21 22 |
# File 'lib/chef-licensing/config.rb', line 20 def persist_license_data @persist_license_data end |
Class Method Details
.determine_log_level ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/chef-licensing/config.rb', line 43 def determine_log_level log_level_string = get_log_level_from_flags valid = %w{trace debug info warn error fatal} if valid.include?(log_level_string) log_level = log_level_string else log_level = "info" end Mixlib::Log.const_get(log_level.upcase) end |
.require_license_for ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/chef-licensing/config.rb', line 77 def require_license_for return unless block_given? require_license_mutex.synchronize do # Store the original value by calling the method, not accessing the instance variable original_value = make_licensing_optional begin # Temporarily set licensing as required (not optional) @make_licensing_optional = false yield ensure # Always restore the original value, even if an exception occurs @make_licensing_optional = original_value end end end |
.require_license_mutex ⇒ Object
73 74 75 |
# File 'lib/chef-licensing/config.rb', line 73 def require_license_mutex @require_license_mutex ||= Mutex.new end |