diff options
author | John Keiser <jkeiser@opscode.com> | 2014-06-30 10:33:48 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2014-07-07 10:04:59 -0700 |
commit | c5956378e9035af7f05e1be1c7741b50de7eb84c (patch) | |
tree | 33feaf826e9dd3126b7515d5b4a7b9cd339dc1c5 /lib/chef/application.rb | |
parent | b536215ece2183584188c3a304c2322de2f2a4ff (diff) | |
download | chef-c5956378e9035af7f05e1be1c7741b50de7eb84c.tar.gz |
Support --chef-zero-port=A-B,C,D-E syntax for finding ports
Diffstat (limited to 'lib/chef/application.rb')
-rw-r--r-- | lib/chef/application.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb index ca610480d0..c77fcd5ee7 100644 --- a/lib/chef/application.rb +++ b/lib/chef/application.rb @@ -199,10 +199,11 @@ class Chef::Application server_options[:data_store] = data_store server_options[:log_level] = Chef::Log.level server_options[:host] = Chef::Config.chef_zero.host - server_options[:port] = Chef::Config.chef_zero.port + server_options[:port] = Chef::Application.parse_port(Chef::Config.chef_zero.port) Chef::Log.info("Starting chef-zero on host #{Chef::Config.chef_zero.host}, port #{Chef::Config.chef_zero.port} with repository at #{chef_fs.fs_description}") @chef_zero_server = ChefZero::Server.new(server_options) @chef_zero_server.start_background + Chef::Log.info("chef-zero started at #{@chef_zero_server.url}") Chef::Config.chef_server_url = @chef_zero_server.url end end @@ -240,6 +241,28 @@ class Chef::Application Chef::Application.destroy_server_connectivity end + def self.parse_port(port) + if port.is_a?(String) + parts = port.split(',') + if parts.size == 1 + a,b = parts[0].split('-',2) + if b + a.to_i.upto(b.to_i) + else + [ a.to_i ] + end + else + array = [] + parts.each do |part| + array += parse_port(part).to_a + end + array + end + else + port + end + end + private def apply_config(config_content, config_file_path) |