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
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
59 60 61 |
# File 'lib/chef-licensing/config.rb', line 59 def license_add_command @license_add_command ||= "license add" end |
.license_list_command ⇒ Object
63 64 65 |
# File 'lib/chef-licensing/config.rb', line 63 def license_list_command @license_list_command ||= "license list" end |
.license_server_url(opts = {}) ⇒ Object
22 23 24 25 26 27 28 29 |
# 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) @license_server_url = ChefLicensing::LicenseKeyFetcher::File.fetch_or_persist_url(@license_server_url, license_server_url_from_system, opts) @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
31 32 33 34 35 36 37 38 39 |
# File 'lib/chef-licensing/config.rb', line 31 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
67 68 69 |
# File 'lib/chef-licensing/config.rb', line 67 def make_licensing_optional @make_licensing_optional ||= false end |
.output ⇒ Object
55 56 57 |
# File 'lib/chef-licensing/config.rb', line 55 def output @output ||= STDOUT end |
Class Method Details
.determine_log_level ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/chef-licensing/config.rb', line 41 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
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/chef-licensing/config.rb', line 75 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
71 72 73 |
# File 'lib/chef-licensing/config.rb', line 71 def require_license_mutex @require_license_mutex ||= Mutex.new end |