Class: Chef::Utils::LicensingHandler
- Inherits:
-
Object
- Object
- Chef::Utils::LicensingHandler
- Defined in:
- lib/chef/utils/licensing_handler.rb
Constant Summary collapse
- DOWNLOAD_URLS =
Omnitruck URLs are no longer used. Updated to new download URLs.
{ "free" => "https://chefdownload-trial.chef.io", "trial" => "https://chefdownload-trial.chef.io", "commercial" => "https://chefdownload-commercial.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.
15 16 17 18 |
# File 'lib/chef/utils/licensing_handler.rb', line 15 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.
13 14 15 |
# File 'lib/chef/utils/licensing_handler.rb', line 13 def license_key @license_key end |
#license_type ⇒ Object (readonly)
Returns the value of attribute license_type.
13 14 15 |
# File 'lib/chef/utils/licensing_handler.rb', line 13 def license_type @license_type end |
Class Method Details
.check_software_entitlement!(ui) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/chef/utils/licensing_handler.rb', line 50 def check_software_entitlement!(ui) ChefLicensing.check_software_entitlement! rescue ChefLicensing::SoftwareNotEntitled ui.error "License is not entitled to use Workstation." exit 1 rescue ChefLicensing::Error => e ui.error e. exit 1 end |
.validate! ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/chef/utils/licensing_handler.rb', line 31 def validate! license_keys = begin ChefLicensing.fetch_and_persist # 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
26 27 28 |
# File 'lib/chef/utils/licensing_handler.rb', line 26 def install_sh_url format(omnitruck_url, "install.sh") end |
#omnitruck_url ⇒ Object
20 21 22 23 24 |
# File 'lib/chef/utils/licensing_handler.rb', line 20 def omnitruck_url url = DOWNLOAD_URLS[license_type] "#{url}/%s?license_id=#{license_key}" end |