From a9ca9148323314310a3e6433e8610eb4e0c2ca52 Mon Sep 17 00:00:00 2001 From: "kirby@puppetlabs.com" Date: Fri, 25 May 2018 11:54:46 -0700 Subject: [PATCH] Add support for setting redis port and password This commit adds options for setting redis port and password. Without this change it is not possible to specify the redis port or password. --- lib/vmpooler.rb | 4 ++-- vmpooler | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/vmpooler.rb b/lib/vmpooler.rb index 6a7c12f29..a1c757bc2 100644 --- a/lib/vmpooler.rb +++ b/lib/vmpooler.rb @@ -86,8 +86,8 @@ def self.config(filepath = 'vmpooler.yaml') parsed_config end - def self.new_redis(host = 'localhost') - Redis.new(host: host) + def self.new_redis(host = 'localhost', port = nil, password = nil) + Redis.new(host: host, port: port, password: password) end def self.new_logger(logfile) diff --git a/vmpooler b/vmpooler index 7b2e82010..57478f9da 100755 --- a/vmpooler +++ b/vmpooler @@ -7,13 +7,15 @@ require 'lib/vmpooler' config = Vmpooler.config redis_host = config[:redis]['server'] +redis_port = config[:redis]['port'] +redis_password = config[:redis]['password'] logger_file = config[:config]['logfile'] metrics = Vmpooler.new_metrics(config) api = Thread.new do thr = Vmpooler::API.new - thr.helpers.configure(config, Vmpooler.new_redis(redis_host), metrics) + thr.helpers.configure(config, Vmpooler.new_redis(redis_host, redis_port, redis_password), metrics) thr.helpers.execute! end @@ -21,7 +23,7 @@ manager = Thread.new do Vmpooler::PoolManager.new( config, Vmpooler.new_logger(logger_file), - Vmpooler.new_redis(redis_host), + Vmpooler.new_redis(redis_host, redis_port, redis_password), metrics ).execute! end