vagrant-rimu 0.0.1 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.codeclimate.yml +3 -2
- data/.gitignore +2 -0
- data/.travis.yml +5 -35
- data/Gemfile +4 -2
- data/README.md +12 -3
- data/Rakefile +6 -3
- data/Vagrantfile +12 -3
- data/gemfiles/vagrant_1.5.gemfile +3 -1
- data/gemfiles/vagrant_1.6.gemfile +5 -3
- data/gemfiles/vagrant_1.7.gemfile +10 -8
- data/lib/vagrant-rimu.rb +10 -0
- data/lib/vagrant-rimu/actions.rb +117 -89
- data/lib/vagrant-rimu/actions/abstract_action.rb +20 -0
- data/lib/vagrant-rimu/actions/billing_methods.rb +13 -7
- data/lib/vagrant-rimu/actions/connect_to_rimu.rb +12 -6
- data/lib/vagrant-rimu/actions/create.rb +25 -6
- data/lib/vagrant-rimu/actions/is_created.rb +4 -2
- data/lib/vagrant-rimu/actions/is_stopped.rb +5 -3
- data/lib/vagrant-rimu/actions/list_distributions.rb +13 -7
- data/lib/vagrant-rimu/actions/list_servers.rb +13 -7
- data/lib/vagrant-rimu/actions/message_action_not_supported.rb +19 -0
- data/lib/vagrant-rimu/actions/message_already_created.rb +4 -2
- data/lib/vagrant-rimu/actions/message_already_off.rb +4 -2
- data/lib/vagrant-rimu/actions/message_not_created.rb +4 -2
- data/lib/vagrant-rimu/actions/message_will_not_destroy.rb +4 -2
- data/lib/vagrant-rimu/actions/message_will_not_stop.rb +19 -0
- data/lib/vagrant-rimu/actions/modify_provision_path.rb +5 -3
- data/lib/vagrant-rimu/actions/move.rb +32 -5
- data/lib/vagrant-rimu/actions/read_ssh_info.rb +10 -7
- data/lib/vagrant-rimu/actions/read_state.rb +14 -6
- data/lib/vagrant-rimu/actions/rebuild.rb +34 -6
- data/lib/vagrant-rimu/actions/reload.rb +11 -4
- data/lib/vagrant-rimu/actions/setup_sudo.rb +15 -8
- data/lib/vagrant-rimu/actions/setup_user.rb +45 -25
- data/lib/vagrant-rimu/actions/ssh_utils.rb +44 -0
- data/lib/vagrant-rimu/actions/start_instance.rb +6 -4
- data/lib/vagrant-rimu/actions/stop_instance.rb +18 -7
- data/lib/vagrant-rimu/actions/terminate_instance.rb +12 -6
- data/lib/vagrant-rimu/commands/abstract_command.rb +47 -0
- data/lib/vagrant-rimu/commands/billing_methods.rb +10 -10
- data/lib/vagrant-rimu/commands/distributions.rb +10 -10
- data/lib/vagrant-rimu/commands/list_servers.rb +10 -10
- data/lib/vagrant-rimu/commands/move.rb +10 -10
- data/lib/vagrant-rimu/commands/rebuild.rb +5 -7
- data/lib/vagrant-rimu/commands/rimu_command.rb +13 -0
- data/lib/vagrant-rimu/commands/root.rb +26 -43
- data/lib/vagrant-rimu/commands/utils.rb +22 -0
- data/lib/vagrant-rimu/config.rb +5 -2
- data/lib/vagrant-rimu/errors.rb +6 -0
- data/lib/vagrant-rimu/logging.rb +28 -0
- data/lib/vagrant-rimu/plugin.rb +11 -37
- data/lib/vagrant-rimu/provider.rb +4 -2
- data/lib/vagrant-rimu/version.rb +1 -1
- data/locales/en.yml +70 -19
- data/spec/spec_helper.rb +13 -6
- data/spec/vagrant-rimu/actions/billing_methods_spec.rb +49 -0
- data/spec/vagrant-rimu/actions/connect_to_rimu_spec.rb +2 -1
- data/spec/vagrant-rimu/actions/create_spec.rb +167 -0
- data/spec/vagrant-rimu/actions/is_created_spec.rb +49 -0
- data/spec/vagrant-rimu/actions/is_stopped_spec.rb +49 -0
- data/spec/vagrant-rimu/actions/list_distributions_spec.rb +49 -0
- data/spec/vagrant-rimu/actions/list_servers_spec.rb +51 -0
- data/spec/vagrant-rimu/actions/message_action_not_supported_spec.rb +30 -0
- data/spec/vagrant-rimu/actions/message_already_created_spec.rb +1 -4
- data/spec/vagrant-rimu/actions/message_will_not_destroy_spec.rb +1 -2
- data/spec/vagrant-rimu/actions/message_will_not_stop_spec.rb +35 -0
- data/spec/vagrant-rimu/actions/modify_provision_path_spec.rb +2 -7
- data/spec/vagrant-rimu/actions/move_spec.rb +75 -0
- data/spec/vagrant-rimu/actions/read_ssh_info_spec.rb +21 -0
- data/spec/vagrant-rimu/actions/rebuild_spec.rb +7 -1
- data/spec/vagrant-rimu/actions/stop_instance_spec.rb +4 -4
- data/spec/vagrant-rimu/commands/billing_methods_spec.rb +17 -0
- data/spec/vagrant-rimu/commands/distributions_spec.rb +17 -0
- data/spec/vagrant-rimu/commands/list_servers_spec.rb +17 -0
- data/spec/vagrant-rimu/commands/move_spec.rb +17 -0
- data/spec/vagrant-rimu/commands/rebuild_spec.rb +20 -0
- data/spec/vagrant-rimu/config_spec.rb +1 -1
- data/test/Vagrantfile +4 -2
- data/vagrant-rimu.gemspec +5 -1
- metadata +81 -27
@@ -1,21 +1,27 @@
|
|
1
1
|
require 'log4r'
|
2
2
|
|
3
|
+
require 'vagrant-rimu/actions/abstract_action'
|
4
|
+
|
3
5
|
module VagrantPlugins
|
4
6
|
module Rimu
|
5
7
|
module Actions
|
6
8
|
# This terminates the running server, if there is one.
|
7
|
-
class TerminateInstance
|
8
|
-
def initialize(app,
|
9
|
+
class TerminateInstance < AbstractAction
|
10
|
+
def initialize(app, _env)
|
9
11
|
@app = app
|
10
|
-
@client = env[:rimu_api]
|
11
12
|
@logger = Log4r::Logger.new("vagrant_rimu::action::terminate_instance")
|
12
13
|
end
|
13
14
|
|
14
|
-
def
|
15
|
+
def execute(env)
|
15
16
|
if env[:machine].id
|
16
17
|
env[:ui].info(I18n.t("vagrant_rimu.terminating"))
|
17
|
-
|
18
|
-
|
18
|
+
client = env[:rimu_api]
|
19
|
+
begin
|
20
|
+
client.servers.cancel(env[:machine].id.to_i)
|
21
|
+
env[:machine].id = nil
|
22
|
+
rescue ::Rimu::RimuAPI::RimuRequestError, ::Rimu::RimuAPI::RimuResponseError => e
|
23
|
+
raise Errors::ApiError, {:stderr=>e}
|
24
|
+
end
|
19
25
|
end
|
20
26
|
|
21
27
|
@app.call(env)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Rimu
|
5
|
+
module Commands
|
6
|
+
class AbstractCommand < Vagrant.plugin('2', :command)
|
7
|
+
def initialize(argv, env)
|
8
|
+
@env = env
|
9
|
+
super(normalize_args(argv), env)
|
10
|
+
end
|
11
|
+
|
12
|
+
def execute(name)
|
13
|
+
env = {}
|
14
|
+
with_target_vms(nil, provider: :rimu) do |machine|
|
15
|
+
env[:machine] = machine
|
16
|
+
env[:ui] = @env.ui
|
17
|
+
end
|
18
|
+
|
19
|
+
before_cmd(name, @argv, env)
|
20
|
+
|
21
|
+
cmd(name, @argv, env)
|
22
|
+
@env.ui.info('')
|
23
|
+
# rubocop:disable Lint/RescueException
|
24
|
+
rescue Errors::RimuError, SystemExit, Interrupt => e
|
25
|
+
raise e
|
26
|
+
rescue Exception => e
|
27
|
+
puts I18n.t('vagrant_rimu.errors.global_error').red unless e.message
|
28
|
+
raise e
|
29
|
+
end
|
30
|
+
# rubocop:enable Lint/RescueException
|
31
|
+
|
32
|
+
def normalize_args(args)
|
33
|
+
return args if args.nil?
|
34
|
+
args.pop if args.size > 0 && args.last == '--'
|
35
|
+
args
|
36
|
+
end
|
37
|
+
|
38
|
+
def before_cmd(_name, _argv, _env)
|
39
|
+
end
|
40
|
+
|
41
|
+
def cmd(_name, _argv, _env)
|
42
|
+
fail 'Command not implemented. \'cmd\' method must be overridden in all subclasses'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,16 +1,16 @@
|
|
1
|
+
require 'vagrant-rimu/commands/rimu_command'
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module Rimu
|
3
5
|
module Commands
|
4
|
-
class BillingMethods <
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
machine.action('billing_methods')
|
13
|
-
end
|
6
|
+
class BillingMethods < RimuCommand
|
7
|
+
def self.synopsis
|
8
|
+
I18n.t('vagrant_rimu.commands.billing_methods')
|
9
|
+
end
|
10
|
+
|
11
|
+
def cmd(name, argv, env)
|
12
|
+
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0
|
13
|
+
env[:machine].action('billing_methods')
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
+
require 'vagrant-rimu/commands/rimu_command'
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module Rimu
|
3
5
|
module Commands
|
4
|
-
class Distributions <
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
machine.action('list_distributions')
|
13
|
-
end
|
6
|
+
class Distributions < RimuCommand
|
7
|
+
def self.synopsis
|
8
|
+
I18n.t('vagrant_rimu.commands.list_distributions')
|
9
|
+
end
|
10
|
+
|
11
|
+
def cmd(name, argv, env)
|
12
|
+
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0
|
13
|
+
env[:machine].action('list_distributions')
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
+
require 'vagrant-rimu/commands/rimu_command'
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module Rimu
|
3
5
|
module Commands
|
4
|
-
class ListServers <
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
machine.action('list_servers')
|
13
|
-
end
|
6
|
+
class ListServers < RimuCommand
|
7
|
+
def self.synopsis
|
8
|
+
I18n.t('vagrant_rimu.commands.list_servers')
|
9
|
+
end
|
10
|
+
|
11
|
+
def cmd(name, argv, env)
|
12
|
+
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0
|
13
|
+
env[:machine].action('list_servers')
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
+
require 'vagrant-rimu/commands/abstract_command'
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module Rimu
|
3
5
|
module Commands
|
4
|
-
class Move <
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
machine.action('move')
|
13
|
-
end
|
6
|
+
class Move < AbstractCommand
|
7
|
+
def self.synopsis
|
8
|
+
I18n.t('vagrant_rimu.commands.move')
|
9
|
+
end
|
10
|
+
|
11
|
+
def cmd(name, argv, env)
|
12
|
+
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0
|
13
|
+
env[:machine].action('move')
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -1,15 +1,13 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
|
3
1
|
module VagrantPlugins
|
4
2
|
module Rimu
|
5
3
|
module Commands
|
6
4
|
class Rebuild < Vagrant.plugin('2', :command)
|
5
|
+
def self.synopsis
|
6
|
+
I18n.t('vagrant_rimu.commands.rebuild')
|
7
|
+
end
|
8
|
+
|
7
9
|
def execute
|
8
|
-
|
9
|
-
o.banner = 'Usage: vagrant rebuild [vm-name]'
|
10
|
-
end
|
11
|
-
argv = parse_options(opts)
|
12
|
-
with_target_vms(argv) do |machine|
|
10
|
+
with_target_vms(nil, provider: :rimu) do |machine|
|
13
11
|
machine.action(:rebuild)
|
14
12
|
end
|
15
13
|
0
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'vagrant-rimu/commands/abstract_command'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Rimu
|
5
|
+
module Commands
|
6
|
+
class RimuCommand < AbstractCommand
|
7
|
+
def before_cmd(_name, _argv, env)
|
8
|
+
VagrantPlugins::Rimu::Actions::ConnectToRimu.new(nil, env).call(env)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,65 +1,48 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
|
3
1
|
module VagrantPlugins
|
4
2
|
module Rimu
|
5
3
|
module Commands
|
4
|
+
COMMANDS = [
|
5
|
+
{ name: :'billing-methods', file: 'billing_methods', clazz: 'BillingMethods' },
|
6
|
+
{ name: :'distributions', file: 'distributions', clazz: 'Distributions' },
|
7
|
+
{ name: :'servers', file: 'list_servers', clazz: 'ListServers' },
|
8
|
+
{ name: :'move-vps', file: 'move', clazz: 'Move' },
|
9
|
+
# { name: :'rebuild', file: 'rebuild', clazz: 'Rebuild' },
|
10
|
+
]
|
11
|
+
|
6
12
|
class Root < Vagrant.plugin('2', :command)
|
7
13
|
def self.synopsis
|
8
|
-
'
|
14
|
+
I18n.t('vagrant_rimu.commands.root_synopsis')
|
9
15
|
end
|
10
16
|
|
11
17
|
def initialize(argv, env)
|
18
|
+
@env = env
|
12
19
|
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
|
20
|
+
@commands = Vagrant::Registry.new
|
13
21
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
@subcommands.register(:move) do
|
22
|
-
require File.expand_path('../move', __FILE__)
|
23
|
-
Move
|
24
|
-
end
|
25
|
-
|
26
|
-
@subcommands.register(:billing_methods) do
|
27
|
-
require File.expand_path('../billing_methods', __FILE__)
|
28
|
-
BillingMethods
|
29
|
-
end
|
30
|
-
|
31
|
-
@subcommands.register(:servers) do
|
32
|
-
require File.expand_path('../list_servers', __FILE__)
|
33
|
-
ListServers
|
22
|
+
COMMANDS.each do |cmd|
|
23
|
+
@commands.register(cmd[:name]) do
|
24
|
+
require_relative cmd[:file]
|
25
|
+
Commands.const_get(cmd[:clazz])
|
26
|
+
end
|
34
27
|
end
|
35
28
|
|
36
29
|
super(argv, env)
|
37
30
|
end
|
38
31
|
|
39
32
|
def execute
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
|
44
|
-
return help if !command_class || !@sub_command
|
45
|
-
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
|
46
|
-
command_class.new(@sub_args, @env).execute
|
33
|
+
command_class = @commands.get(@sub_command.to_sym) if @sub_command
|
34
|
+
return usage unless command_class && @sub_command
|
35
|
+
command_class.new(@sub_args, @env).execute(@sub_command)
|
47
36
|
end
|
48
37
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
@subcommands.each { |key, _value| keys << key.to_s }
|
56
|
-
keys.sort.each do |key|
|
57
|
-
o.separator " #{key}"
|
58
|
-
end
|
59
|
-
o.separator ''
|
60
|
-
o.separator 'For help on any individual subcommand run `vagrant rimu <subcommand> -h`'
|
38
|
+
def usage
|
39
|
+
@env.ui.info I18n.t('vagrant_rimu.commands.root_usage')
|
40
|
+
@env.ui.info ''
|
41
|
+
@env.ui.info I18n.t('vagrant_rimu.commands.available_subcommands')
|
42
|
+
@commands.each do |key, value|
|
43
|
+
@env.ui.info " #{key.to_s.ljust(20)} #{value.synopsis}"
|
61
44
|
end
|
62
|
-
@env.ui.info
|
45
|
+
@env.ui.info ''
|
63
46
|
end
|
64
47
|
end
|
65
48
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'terminal-table'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Rimu
|
5
|
+
module Commands
|
6
|
+
module Utils
|
7
|
+
# def display_item_list(env, items)
|
8
|
+
# rows = []
|
9
|
+
# items.each do |item|
|
10
|
+
# rows << [item.id, item.name]
|
11
|
+
# end
|
12
|
+
# display_table(env, %w(ID Name), rows)
|
13
|
+
# end
|
14
|
+
|
15
|
+
def display_table(env, headers, rows)
|
16
|
+
table = Terminal::Table.new headings: headers, rows: rows
|
17
|
+
env[:ui].info("\n#{table}")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/vagrant-rimu/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module Rimu
|
3
5
|
class Config < Vagrant.plugin('2', :config)
|
@@ -135,6 +137,7 @@ module VagrantPlugins
|
|
135
137
|
@data_centre = UNSET_VALUE
|
136
138
|
end
|
137
139
|
|
140
|
+
# rubocop:disable Metrics/AbcSize
|
138
141
|
def finalize!
|
139
142
|
@api_key = ENV['RIMU_API_KEY'] if @api_key == UNSET_VALUE
|
140
143
|
@api_url = ENV['RIMU_URL'] if @api_url == UNSET_VALUE
|
@@ -162,8 +165,8 @@ module VagrantPlugins
|
|
162
165
|
|
163
166
|
def validate(machine)
|
164
167
|
errors = []
|
165
|
-
errors << I18n.t('vagrant_rimu.config.api_key')
|
166
|
-
errors << I18n.t('vagrant_rimu.config.host_name')
|
168
|
+
errors << I18n.t('vagrant_rimu.config.api_key') unless @api_key
|
169
|
+
errors << I18n.t('vagrant_rimu.config.host_name') unless @host_name
|
167
170
|
if @host_name
|
168
171
|
errors << I18n.t('vagrant_rimu.config.invalid_host_name', {:host_name => @host_name}) \
|
169
172
|
unless @host_name.match(/\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/)
|
data/lib/vagrant-rimu/errors.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
|
1
3
|
module VagrantPlugins
|
2
4
|
module Rimu
|
3
5
|
module Errors
|
@@ -16,6 +18,10 @@ module VagrantPlugins
|
|
16
18
|
class ApiError < RimuError
|
17
19
|
error_key(:api_error)
|
18
20
|
end
|
21
|
+
|
22
|
+
class NoArgRequiredForCommand < RimuError
|
23
|
+
error_key(:no_args)
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
21
27
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Rimu
|
3
|
+
module Logging
|
4
|
+
def self.init
|
5
|
+
level = nil
|
6
|
+
begin
|
7
|
+
level = Log4r.const_get(ENV['VAGRANT_LOG'].upcase)
|
8
|
+
rescue NameError
|
9
|
+
begin
|
10
|
+
level = Log4r.const_get(ENV['VAGRANT_RIMU_LOG'].upcase)
|
11
|
+
rescue NameError
|
12
|
+
level = nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
level = nil unless level.is_a?(Integer)
|
17
|
+
|
18
|
+
if level
|
19
|
+
logger = Log4r::Logger.new('vagrant_rimu')
|
20
|
+
out = Log4r::Outputter.stdout
|
21
|
+
out.formatter = Log4r::PatternFormatter.new(pattern: '%d | %5l | %m', date_pattern: '%Y-%m-%d %H:%M')
|
22
|
+
logger.outputters = out
|
23
|
+
logger.level = level
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/vagrant-rimu/plugin.rb
CHANGED
@@ -24,57 +24,31 @@ module VagrantPlugins
|
|
24
24
|
|
25
25
|
provider(:rimu, {:box_optional => true, :parallel => true}) do
|
26
26
|
# Setup logging and i18n
|
27
|
-
|
28
|
-
|
27
|
+
Rimu.init_i18n
|
28
|
+
Rimu.init_logging
|
29
|
+
|
29
30
|
# Return the provider
|
30
31
|
require_relative "provider"
|
31
32
|
Provider
|
32
33
|
end
|
33
34
|
|
34
35
|
command(:rimu) do
|
36
|
+
# Setup logging and i18n
|
37
|
+
Rimu.init_i18n
|
38
|
+
Rimu.init_logging
|
39
|
+
|
35
40
|
require_relative "commands/root"
|
36
41
|
Commands::Root
|
37
42
|
end
|
38
43
|
|
39
44
|
command(:rebuild) do
|
45
|
+
# Setup logging and i18n
|
46
|
+
Rimu.init_i18n
|
47
|
+
Rimu.init_logging
|
48
|
+
|
40
49
|
require_relative "commands/rebuild"
|
41
50
|
Commands::Rebuild
|
42
51
|
end
|
43
|
-
|
44
|
-
# This initializes the internationalization strings.
|
45
|
-
def self.setup_i18n
|
46
|
-
I18n.load_path << File.expand_path("locales/en.yml", Rimu.source_root)
|
47
|
-
I18n.reload!
|
48
|
-
end
|
49
|
-
|
50
|
-
# This sets up our log level to be whatever VAGRANT_LOG is.
|
51
|
-
def self.setup_logging
|
52
|
-
require "log4r"
|
53
|
-
|
54
|
-
level = nil
|
55
|
-
begin
|
56
|
-
level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
|
57
|
-
rescue NameError
|
58
|
-
# This means that the logging constant wasn't found,
|
59
|
-
# which is fine. We just keep `level` as `nil`. But
|
60
|
-
# we tell the user.
|
61
|
-
level = nil
|
62
|
-
end
|
63
|
-
|
64
|
-
# Some constants, such as "true" resolve to booleans, so the
|
65
|
-
# above error checking doesn't catch it. This will check to make
|
66
|
-
# sure that the log level is an integer, as Log4r requires.
|
67
|
-
level = nil if !level.is_a?(Integer)
|
68
|
-
|
69
|
-
# Set the logging level on all "vagrant" namespaced
|
70
|
-
# logs as long as we have a valid level.
|
71
|
-
if level
|
72
|
-
logger = Log4r::Logger.new("vagrant_rimu")
|
73
|
-
logger.outputters = Log4r::Outputter.stderr
|
74
|
-
logger.level = level
|
75
|
-
logger = nil
|
76
|
-
end
|
77
|
-
end
|
78
52
|
end
|
79
53
|
end
|
80
54
|
end
|