Class: Chef::Utils::LicensingHandler
- Inherits:
-
Object
- Object
- Chef::Utils::LicensingHandler
- Defined in:
- lib/chef/utils/licensing_handler.rb
Constant Summary collapse
- LEGACY_OMNITRUCK_URL =
"https://omnitruck.chef.io".freeze
- OMNITRUCK_URLS =
{ "free" => "https://chefdownload-trial.chef.io", "trial" => "https://chefdownload-trial.chef.io", "commercial" => "https://chefdownload-commerical.chef.io", }.freeze
Instance Attribute Summary collapse
-
#license_key ⇒ Object
readonly
Returns the value of attribute license_key.
-
#license_type ⇒ Object
readonly
Returns the value of attribute license_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, type) ⇒ LicensingHandler
constructor
A new instance of LicensingHandler.
- #install_sh_url ⇒ Object
- #omnitruck_url ⇒ Object
Constructor Details
#initialize(key, type) ⇒ LicensingHandler
Returns a new instance of LicensingHandler.
33 34 35 36 |
# File 'lib/chef/utils/licensing_handler.rb', line 33 def initialize(key, type) @license_key = key @license_type = type end |
Instance Attribute Details
#license_key ⇒ Object (readonly)
Returns the value of attribute license_key.
31 32 33 |
# File 'lib/chef/utils/licensing_handler.rb', line 31 def license_key @license_key end |
#license_type ⇒ Object (readonly)
Returns the value of attribute license_type.
31 32 33 |
# File 'lib/chef/utils/licensing_handler.rb', line 31 def license_type @license_type end |
Class Method Details
.validate! ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/chef/utils/licensing_handler.rb', line 51 def validate! license_keys = begin ChefLicensing::LicenseKeyFetcher.fetch # If the env is airgapped or the local licensing service is unreachable, # the licensing gem will raise ChefLicensing::RestfulClientConnectionError. # In such cases, we are assuming the license is not available. rescue ChefLicensing::RestfulClientConnectionError [] end return new(nil, nil) if license_keys&.empty? = ChefLicensing::Api::Describe.list({ license_keys: license_keys, }) new(.last.id, .last.license_type) end |
Instance Method Details
#install_sh_url ⇒ Object
46 47 48 |
# File 'lib/chef/utils/licensing_handler.rb', line 46 def install_sh_url format(omnitruck_url, "install.sh") end |
#omnitruck_url ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/chef/utils/licensing_handler.rb', line 38 def omnitruck_url url = OMNITRUCK_URLS[license_type] is_legacy = url.nil? url ||= LEGACY_OMNITRUCK_URL "#{url}/%s#{is_legacy ? "" : "?license_id=#{license_key}"}" end |