-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow user to specify a configuration file in VMPOOLER_CONFIG_FILE
variable Previously, there were two ways to configure Vmpooler, either by changing the contents of vmpooler.yaml or by assigning the raw YAML to the VMPOOLER_CONFIG environment variable. This commit adds a new environment variable called VMPOOLER_CONFIG_FILE that can be assigned the name of a config file to use. Also fixes #240 by whitelisting the Symbol class when calling YAML.safe_load in Vmpooler.config.
- Loading branch information
adamdav
committed
Jan 23, 2018
1 parent
28922df
commit de26c86
Showing
8 changed files
with
152 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
Gemfile.lock | ||
Gemfile.local | ||
vendor | ||
vmpooler.yaml | ||
/vmpooler.yaml | ||
.bundle | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
:providers: | ||
:dummy: | ||
|
||
:redis: | ||
server: 'localhost' | ||
|
||
:auth: | ||
provider: dummy | ||
|
||
:tagfilter: | ||
url: '(.*)\/' | ||
|
||
:config: | ||
site_name: 'vmpooler' | ||
# Need to change this on Windows | ||
logfile: '/var/log/vmpooler.log' | ||
task_limit: 10 | ||
timeout: 15 | ||
vm_checktime: 15 | ||
vm_lifetime: 12 | ||
vm_lifetime_auth: 24 | ||
allowed_tags: | ||
- 'created_by' | ||
- 'project' | ||
domain: 'company.com' | ||
prefix: 'poolvm-' | ||
|
||
# Uncomment the lines below to suppress metrics to STDOUT | ||
# :statsd: | ||
# server: 'localhost' | ||
# prefix: 'vmpooler' | ||
# port: 8125 | ||
|
||
:pools: | ||
- name: 'pool01' | ||
size: 5 | ||
provider: dummy | ||
- name: 'pool02' | ||
size: 5 | ||
provider: dummy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
:providers: | ||
:dummy: | ||
|
||
:redis: | ||
server: 'localhost' | ||
|
||
:auth: | ||
provider: dummy | ||
|
||
:tagfilter: | ||
url: '(.*)\/' | ||
|
||
:config: | ||
site_name: 'vmpooler' | ||
# Need to change this on Windows | ||
logfile: '/var/log/vmpooler.log' | ||
task_limit: 10 | ||
timeout: 15 | ||
vm_checktime: 15 | ||
vm_lifetime: 12 | ||
vm_lifetime_auth: 24 | ||
allowed_tags: | ||
- 'created_by' | ||
- 'project' | ||
domain: 'company.com' | ||
prefix: 'poolvm-' | ||
|
||
# Uncomment the lines below to suppress metrics to STDOUT | ||
# :statsd: | ||
# server: 'localhost' | ||
# prefix: 'vmpooler' | ||
# port: 8125 | ||
|
||
:pools: | ||
- name: 'pool03' | ||
size: 5 | ||
provider: dummy | ||
- name: 'pool04' | ||
size: 5 | ||
provider: dummy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Vmpooler' do | ||
describe '.config' do | ||
let(:config_file) { File.join(fixtures_dir, 'vmpooler2.yaml') } | ||
let(:config) { YAML.load_file(config_file) } | ||
|
||
before(:each) do | ||
ENV['VMPOOLER_DEBUG'] = 'true' | ||
ENV['VMPOOLER_CONFIG_FILE'] = nil | ||
ENV['VMPOOLER_CONFIG'] = nil | ||
end | ||
|
||
context 'when no config is given' do | ||
it 'defaults to vmpooler.yaml' do | ||
default_config_file = File.join(fixtures_dir, 'vmpooler.yaml') | ||
default_config = YAML.load_file(default_config_file) | ||
|
||
Dir.chdir(fixtures_dir) do | ||
expect(Vmpooler.config[:pools]).to eq(default_config[:pools]) | ||
end | ||
end | ||
end | ||
|
||
context 'when config variable is set' do | ||
it 'should use the config' do | ||
ENV['VMPOOLER_CONFIG'] = config.to_yaml | ||
expect(Vmpooler.config[:pools]).to eq(config[:pools]) | ||
end | ||
end | ||
|
||
context 'when config file is set' do | ||
it 'should use the file' do | ||
ENV['VMPOOLER_CONFIG_FILE'] = config_file | ||
expect(Vmpooler.config[:pools]).to eq(config[:pools]) | ||
end | ||
end | ||
end | ||
end |