Class: Chef::Server
- Inherits:
-
Object
- Object
- Chef::Server
- Defined in:
- lib/chef/server.rb
Instance Attribute Summary collapse
-
#root_url ⇒ Object
Returns the value of attribute root_url.
Class Method Summary collapse
Instance Method Summary collapse
- #direct_account_access? ⇒ Boolean
-
#initialize(root_url) ⇒ Server
constructor
A new instance of Server.
- #parse_server_version(line) ⇒ Object
- #supports_defaulting_to_pivotal? ⇒ Boolean
- #supports_public_key_read_access? ⇒ Boolean
- #supports_user_acls? ⇒ Boolean
- #version ⇒ Object
Constructor Details
#initialize(root_url) ⇒ Server
Returns a new instance of Server.
9 10 11 |
# File 'lib/chef/server.rb', line 9 def initialize(root_url) @root_url = root_url end |
Instance Attribute Details
#root_url ⇒ Object
Returns the value of attribute root_url.
8 9 10 |
# File 'lib/chef/server.rb', line 8 def root_url @root_url end |
Class Method Details
Instance Method Details
#direct_account_access? ⇒ Boolean
35 36 37 38 39 40 |
# File 'lib/chef/server.rb', line 35 def direct_account_access? Chef::ServerAPI.new("http://127.0.0.1:9465").get("users") true rescue false end |
#parse_server_version(line) ⇒ Object
18 19 20 21 22 |
# File 'lib/chef/server.rb', line 18 def parse_server_version(line) # first line from the /version endpoint will either be this format "chef-server 12.17.5\n" # or, when habitat, this format "Package: chef-server/chef-server-nginx/12.17.42/20180413212943\n" Gem::Version.new(line.include?('/') ? line.split('/')[2] : line.split(' ').last.gsub(/\+.*$/, '')) end |
#supports_defaulting_to_pivotal? ⇒ Boolean
42 43 44 |
# File 'lib/chef/server.rb', line 42 def supports_defaulting_to_pivotal? version >= Gem::Version.new('12.1.0') end |
#supports_public_key_read_access? ⇒ Boolean
46 47 48 |
# File 'lib/chef/server.rb', line 46 def supports_public_key_read_access? version >= Gem::Version.new('12.5.0') end |
#supports_user_acls? ⇒ Boolean
31 32 33 |
# File 'lib/chef/server.rb', line 31 def supports_user_acls? version >= Gem::Version.new("11.0.1") end |
#version ⇒ Object
24 25 26 27 28 29 |
# File 'lib/chef/server.rb', line 24 def version @version ||= begin ver_line = Chef::ServerAPI.new(root_url).get('version').each_line.first parse_server_version(ver_line) end end |