vagrant-rimu 0.0.2 → 0.0.3
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 +4 -4
- data/.codeclimate.yml +3 -2
- data/.travis.yml +3 -1
- data/Gemfile +3 -1
- data/README.md +1 -2
- data/Rakefile +6 -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/actions/abstract_action.rb +20 -0
- data/lib/vagrant-rimu/actions/billing_methods.rb +11 -4
- data/lib/vagrant-rimu/actions/connect_to_rimu.rb +5 -3
- data/lib/vagrant-rimu/actions/create.rb +8 -3
- data/lib/vagrant-rimu/actions/is_created.rb +4 -2
- data/lib/vagrant-rimu/actions/is_stopped.rb +4 -2
- data/lib/vagrant-rimu/actions/list_distributions.rb +11 -4
- data/lib/vagrant-rimu/actions/list_servers.rb +11 -6
- 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/modify_provision_path.rb +4 -2
- data/lib/vagrant-rimu/actions/move.rb +26 -3
- data/lib/vagrant-rimu/actions/read_ssh_info.rb +4 -2
- data/lib/vagrant-rimu/actions/read_state.rb +4 -2
- data/lib/vagrant-rimu/actions/rebuild.rb +7 -2
- data/lib/vagrant-rimu/actions/reload.rb +4 -2
- data/lib/vagrant-rimu/actions/setup_sudo.rb +15 -8
- data/lib/vagrant-rimu/actions/setup_user.rb +35 -24
- data/lib/vagrant-rimu/actions/start_instance.rb +4 -2
- data/lib/vagrant-rimu/actions/stop_instance.rb +11 -5
- data/lib/vagrant-rimu/actions/terminate_instance.rb +4 -2
- data/lib/vagrant-rimu/actions.rb +1 -0
- 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 +9 -10
- 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 +1 -0
- data/lib/vagrant-rimu/errors.rb +4 -0
- data/lib/vagrant-rimu/version.rb +1 -1
- data/locales/en.yml +50 -19
- data/spec/vagrant-rimu/actions/billing_methods_spec.rb +4 -4
- data/spec/vagrant-rimu/actions/create_spec.rb +164 -0
- data/spec/vagrant-rimu/actions/list_distributions_spec.rb +4 -4
- data/spec/vagrant-rimu/actions/list_servers_spec.rb +4 -4
- data/spec/vagrant-rimu/actions/move_spec.rb +75 -0
- 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 +17 -0
- data/test/Vagrantfile +1 -1
- data/vagrant-rimu.gemspec +2 -0
- metadata +58 -22
@@ -1,16 +1,18 @@
|
|
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
|
-
class SetupSudo
|
8
|
+
class SetupSudo < AbstractAction
|
7
9
|
def initialize(app, env)
|
8
10
|
@app = app
|
9
11
|
@machine = env[:machine]
|
10
12
|
@logger = Log4r::Logger.new('vagrant::rimu::setup_sudo')
|
11
13
|
end
|
12
14
|
|
13
|
-
def
|
15
|
+
def execute(env)
|
14
16
|
# check if setup is enabled
|
15
17
|
return @app.call(env) unless @machine.provider_config.setup?
|
16
18
|
|
@@ -18,10 +20,20 @@ module VagrantPlugins
|
|
18
20
|
user = @machine.config.ssh.username
|
19
21
|
@machine.config.ssh.username = 'root'
|
20
22
|
|
23
|
+
# modify the sudoers file
|
24
|
+
modify_sudo(env)
|
25
|
+
|
26
|
+
# reset ssh username
|
27
|
+
@machine.config.ssh.username = user
|
28
|
+
|
29
|
+
@app.call(env)
|
30
|
+
end
|
31
|
+
|
32
|
+
def modify_sudo(env)
|
21
33
|
# check for guest name available in Vagrant 1.2 first
|
22
34
|
guest_name = @machine.guest.name if @machine.guest.respond_to?(:name)
|
23
35
|
guest_name ||= @machine.guest.to_s.downcase
|
24
|
-
|
36
|
+
|
25
37
|
case guest_name
|
26
38
|
when /redhat/
|
27
39
|
env[:ui].info I18n.t('vagrant_rimu.modifying_sudo')
|
@@ -31,11 +43,6 @@ module VagrantPlugins
|
|
31
43
|
sed -i'.bk' -e 's/\(Defaults\s\+requiretty\)/# \1/' /etc/sudoers
|
32
44
|
BASH
|
33
45
|
end
|
34
|
-
|
35
|
-
# reset ssh username
|
36
|
-
@machine.config.ssh.username = user
|
37
|
-
|
38
|
-
@app.call(env)
|
39
46
|
end
|
40
47
|
end
|
41
48
|
end
|
@@ -1,16 +1,19 @@
|
|
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
|
-
class SetupUser
|
8
|
+
class SetupUser < AbstractAction
|
7
9
|
def initialize(app, env)
|
8
10
|
@app = app
|
9
11
|
@machine = env[:machine]
|
10
12
|
@logger = Log4r::Logger.new('vagrant::rimu::setup_user')
|
11
13
|
end
|
12
14
|
|
13
|
-
|
15
|
+
# rubocop:disable Metrics/AbcSize
|
16
|
+
def execute(env)
|
14
17
|
# check if setup is enabled
|
15
18
|
return @app.call(env) unless @machine.provider_config.setup?
|
16
19
|
|
@@ -21,30 +24,22 @@ module VagrantPlugins
|
|
21
24
|
user = @machine.config.ssh.username
|
22
25
|
@machine.config.ssh.username = 'root'
|
23
26
|
|
24
|
-
env[:ui].info I18n.t('vagrant_rimu.creating_user', {
|
25
|
-
:user => user
|
26
|
-
})
|
27
|
-
|
28
27
|
# create user account
|
29
|
-
|
30
|
-
if ! (grep ^#{user}: /etc/passwd); then
|
31
|
-
useradd -m -s /bin/bash #{user};
|
32
|
-
fi
|
33
|
-
BASH
|
34
|
-
|
35
|
-
# grant user sudo access with no password requirement
|
36
|
-
@machine.communicate.execute(<<-BASH)
|
37
|
-
if ! (grep #{user} /etc/sudoers); then
|
38
|
-
echo "#{user} ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers;
|
39
|
-
else
|
40
|
-
sed -i -e "/#{user}/ s/=.*/=(ALL:ALL) NOPASSWD: ALL/" /etc/sudoers;
|
41
|
-
fi
|
42
|
-
BASH
|
28
|
+
create_user(env, user)
|
43
29
|
|
44
30
|
# create the .ssh directory in the users home
|
45
31
|
@machine.communicate.execute("su #{user} -c 'mkdir -p ~/.ssh'")
|
46
32
|
|
47
33
|
# add the specified key to the authorized keys file
|
34
|
+
upload_key(user)
|
35
|
+
|
36
|
+
# reset username
|
37
|
+
@machine.config.ssh.username = user
|
38
|
+
|
39
|
+
@app.call(env)
|
40
|
+
end
|
41
|
+
|
42
|
+
def upload_key(user)
|
48
43
|
path = @machine.config.ssh.private_key_path
|
49
44
|
path = path[0] if path.is_a?(Array)
|
50
45
|
path = File.expand_path(path, @machine.env.root_path)
|
@@ -56,11 +51,27 @@ module VagrantPlugins
|
|
56
51
|
|
57
52
|
chown -R #{user} /home/#{user}/.ssh;
|
58
53
|
BASH
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_user(env, user)
|
57
|
+
env[:ui].info I18n.t('vagrant_rimu.creating_user', {
|
58
|
+
:user => user
|
59
|
+
})
|
60
|
+
|
61
|
+
@machine.communicate.execute(<<-BASH)
|
62
|
+
if ! (grep ^#{user}: /etc/passwd); then
|
63
|
+
useradd -m -s /bin/bash #{user};
|
64
|
+
fi
|
65
|
+
BASH
|
59
66
|
|
60
|
-
#
|
61
|
-
@machine.
|
62
|
-
|
63
|
-
|
67
|
+
# grant user sudo access with no password requirement
|
68
|
+
@machine.communicate.execute(<<-BASH)
|
69
|
+
if ! (grep #{user} /etc/sudoers); then
|
70
|
+
echo "#{user} ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers;
|
71
|
+
else
|
72
|
+
sed -i -e "/#{user}/ s/=.*/=(ALL:ALL) NOPASSWD: ALL/" /etc/sudoers;
|
73
|
+
fi
|
74
|
+
BASH
|
64
75
|
end
|
65
76
|
|
66
77
|
def public_key(private_key_path)
|
@@ -1,16 +1,18 @@
|
|
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
|
-
class StartInstance
|
8
|
+
class StartInstance < AbstractAction
|
7
9
|
def initialize(app, env)
|
8
10
|
@app = app
|
9
11
|
@machine = env[:machine]
|
10
12
|
@logger = Log4r::Logger.new("vagrant_rimu::action::start_instance")
|
11
13
|
end
|
12
14
|
|
13
|
-
def
|
15
|
+
def execute(env)
|
14
16
|
client = env[:rimu_api]
|
15
17
|
env[:ui].info I18n.t('vagrant_rimu.starting')
|
16
18
|
begin
|
@@ -1,26 +1,32 @@
|
|
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 stops the running instance.
|
7
|
-
class StopInstance
|
9
|
+
class StopInstance < AbstractAction
|
8
10
|
def initialize(app, _env)
|
9
11
|
@app = app
|
10
12
|
@logger = Log4r::Logger.new('vagrant_rimu::action::stop_instance')
|
11
13
|
end
|
12
14
|
|
13
|
-
def
|
15
|
+
def execute(env)
|
14
16
|
if env[:machine].state.id == :stopped
|
15
17
|
env[:ui].info(I18n.t('vagrant_rimu.already_status', :status => env[:machine].state.id))
|
16
18
|
else
|
17
|
-
env
|
18
|
-
client = env[:rimu_api]
|
19
|
-
client.servers.shutdown(env[:machine].id.to_i)
|
19
|
+
shutdown(env)
|
20
20
|
end
|
21
21
|
|
22
22
|
@app.call(env)
|
23
23
|
end
|
24
|
+
|
25
|
+
def shutdown(env)
|
26
|
+
env[:ui].info(I18n.t('vagrant_rimu.stopping'))
|
27
|
+
client = env[:rimu_api]
|
28
|
+
client.servers.shutdown(env[:machine].id.to_i)
|
29
|
+
end
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
@@ -1,16 +1,18 @@
|
|
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
|
9
|
+
class TerminateInstance < AbstractAction
|
8
10
|
def initialize(app, _env)
|
9
11
|
@app = app
|
10
12
|
@logger = Log4r::Logger.new("vagrant_rimu::action::terminate_instance")
|
11
13
|
end
|
12
14
|
|
13
|
-
def
|
15
|
+
def execute(env)
|
14
16
|
if env[:machine].id
|
15
17
|
env[:ui].info(I18n.t("vagrant_rimu.terminating"))
|
16
18
|
client = env[:rimu_api]
|
data/lib/vagrant-rimu/actions.rb
CHANGED
@@ -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::ApiError, SystemExit, Interrupt => e
|
25
|
+
raise e
|
26
|
+
rescue Exception => e
|
27
|
+
puts I18n.t('vagrant_rimu.errors.global_error').red unless e.message && e.message.start_with?('Catched Error:')
|
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,18 +1,17 @@
|
|
1
1
|
require 'optparse'
|
2
|
+
require 'vagrant-rimu/commands/abstract_command'
|
2
3
|
|
3
4
|
module VagrantPlugins
|
4
5
|
module Rimu
|
5
6
|
module Commands
|
6
|
-
class Rebuild <
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
0
|
7
|
+
class Rebuild < AbstractCommand
|
8
|
+
def self.synopsis
|
9
|
+
I18n.t('vagrant_rimu.commands.rebuild')
|
10
|
+
end
|
11
|
+
|
12
|
+
def cmd(name, argv, env)
|
13
|
+
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0
|
14
|
+
env[:machine].action('rebuild')
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -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.command.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
data/lib/vagrant-rimu/errors.rb
CHANGED
data/lib/vagrant-rimu/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -35,25 +35,6 @@ en:
|
|
35
35
|
private_key: "A valid SSH private key path option: [private_key_path] is required"
|
36
36
|
missing_private_key: "SSH private key not found: %{key}"
|
37
37
|
public_key: "SSH public key not found: %{key}"
|
38
|
-
errors:
|
39
|
-
api_error: |-
|
40
|
-
The API request failed. Please inspect the error message
|
41
|
-
below for more info.
|
42
|
-
|
43
|
-
Error: %{stderr}
|
44
|
-
public_key: |-
|
45
|
-
There was an issue reading the public key at:
|
46
|
-
|
47
|
-
Path: %{path}
|
48
|
-
|
49
|
-
Please check the file's permissions.
|
50
|
-
rsync: |-
|
51
|
-
There was an error when attemping to rsync a share folder.
|
52
|
-
Please inspect the error message below for more info.
|
53
|
-
|
54
|
-
Host path: %{hostpath}
|
55
|
-
Guest path: %{guestpath}
|
56
|
-
Error: %{stderr}
|
57
38
|
states:
|
58
39
|
short_not_created: |-
|
59
40
|
not created
|
@@ -77,3 +58,53 @@ en:
|
|
77
58
|
long_running: |-
|
78
59
|
The VPS is running. To stop this machine, you can run
|
79
60
|
`vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
|
61
|
+
commands:
|
62
|
+
root_synopsis: |-
|
63
|
+
Rimu provider specific commands
|
64
|
+
root_usage: |-
|
65
|
+
Usage: vagrant rimu <subcommand> [<args>]
|
66
|
+
available_subcommands: |-
|
67
|
+
Available subcommands:
|
68
|
+
billing_methods: |-
|
69
|
+
List billing methods
|
70
|
+
list_distributions: |-
|
71
|
+
List Distributions
|
72
|
+
list_servers: |-
|
73
|
+
List servers
|
74
|
+
move: |-
|
75
|
+
Moves server to different host
|
76
|
+
rebuild: |-
|
77
|
+
Rebuilds the server, retaining the current IP address
|
78
|
+
errors:
|
79
|
+
global_error: |-
|
80
|
+
An unknown error happened in Vagrant Rimu provider
|
81
|
+
|
82
|
+
To easily debug what happened, we recommend to set the environment
|
83
|
+
variable VAGRANT_RIMU_LOG to debug
|
84
|
+
|
85
|
+
$ export VAGRANT_RIMU_LOG=debug
|
86
|
+
|
87
|
+
If doing this does not help fixing your issue, there may be a bug
|
88
|
+
in the provider. Please submit an issue on Github at
|
89
|
+
https://github.com/akissa/vagrant-rimu
|
90
|
+
with the stracktrace and the logs.
|
91
|
+
no_args: |-
|
92
|
+
Command '%{cmd}' does not required any argument.
|
93
|
+
api_error: |-
|
94
|
+
The API request failed. Please inspect the error message
|
95
|
+
below for more info.
|
96
|
+
|
97
|
+
Error: %{stderr}
|
98
|
+
public_key: |-
|
99
|
+
There was an issue reading the public key at:
|
100
|
+
|
101
|
+
Path: %{path}
|
102
|
+
|
103
|
+
Please check the file permissions.
|
104
|
+
rsync: |-
|
105
|
+
There was an error when attemping to rsync a share folder.
|
106
|
+
Please inspect the error message below for more info.
|
107
|
+
|
108
|
+
Host path: %{hostpath}
|
109
|
+
Guest path: %{guestpath}
|
110
|
+
Error: %{stderr}
|