vagrant-rimu 0.0.1 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
# action_root = Pathname.new(File.expand_path('../../../../lib/vagrant-rimu/actions', __FILE__))
|
5
|
+
# autoload :StopInstance, action_root.join('stop_instance')
|
6
|
+
|
7
|
+
describe VagrantPlugins::Rimu::Actions::IsStopped do
|
8
|
+
let(:state) { double('state') }
|
9
|
+
let(:machine) { double('machine') }
|
10
|
+
|
11
|
+
let(:env) do
|
12
|
+
{}.tap do |env|
|
13
|
+
env[:ui] = double('ui').tap do |ui|
|
14
|
+
ui.stub(:info).with(anything)
|
15
|
+
ui.stub(:error).with(anything)
|
16
|
+
end
|
17
|
+
machine.stub(:state) { state }
|
18
|
+
env[:machine] = machine
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:app) do
|
23
|
+
double('app').tap do |app|
|
24
|
+
app.stub(:call).with(anything)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'call' do
|
29
|
+
context 'when server is stopped' do
|
30
|
+
it 'returns true' do
|
31
|
+
env[:machine].state.stub(:id) { :off }
|
32
|
+
expect(app).to receive(:call)
|
33
|
+
@action = VagrantPlugins::Rimu::Actions::IsStopped.new(app, env)
|
34
|
+
@action.call(env)
|
35
|
+
env[:result].should == true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when server is running' do
|
40
|
+
it 'returns false' do
|
41
|
+
env[:machine].state.stub(:id) { :active }
|
42
|
+
expect(app).to receive(:call)
|
43
|
+
@action = VagrantPlugins::Rimu::Actions::IsStopped.new(app, env)
|
44
|
+
@action.call(env)
|
45
|
+
env[:result].should == false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
# action_root = Pathname.new(File.expand_path('../../../../lib/vagrant-rimu/actions', __FILE__))
|
7
|
+
# autoload :StopInstance, action_root.join('stop_instance')
|
8
|
+
|
9
|
+
describe VagrantPlugins::Rimu::Actions::ListDistributions do
|
10
|
+
let(:distributions) { double('distributions') }
|
11
|
+
let(:machine) { double('machine') }
|
12
|
+
let(:distro1) { OpenStruct.new({:distro_code => 'jessie.64', :distro_description => 'Debian 8.0 64-bit (aka Jessie, RimuHosting recommended distro)'}) }
|
13
|
+
let(:distro2) { OpenStruct.new({:distro_code => 'centos6.64', :distro_description => 'Centos6 64-bit'}) }
|
14
|
+
|
15
|
+
|
16
|
+
let(:env) do
|
17
|
+
{}.tap do |env|
|
18
|
+
env[:ui] = double('ui').tap do |ui|
|
19
|
+
ui.stub(:info).with(anything)
|
20
|
+
ui.stub(:error).with(anything)
|
21
|
+
end
|
22
|
+
env[:rimu_api] = double('rimu_api').tap do |os|
|
23
|
+
distributions.stub(:each).and_yield(distro1).and_yield(distro2)
|
24
|
+
os.stub(:distributions) { distributions }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:app) do
|
30
|
+
double('app').tap do |app|
|
31
|
+
app.stub(:call).with(anything)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'call' do
|
36
|
+
it 'return a distribution listing' do
|
37
|
+
expect(env[:rimu_api].distributions).to receive(:each)
|
38
|
+
rows = []
|
39
|
+
[distro1, distro2].each do |o|
|
40
|
+
rows << [o.distro_code, o.distro_description]
|
41
|
+
end
|
42
|
+
table = Terminal::Table.new headings: ['Distro Code', 'Distro Description'], rows: rows
|
43
|
+
expect(env[:ui]).to receive(:info).with("\n#{table}")
|
44
|
+
expect(app).to receive(:call)
|
45
|
+
@action = VagrantPlugins::Rimu::Actions::ListDistributions.new(app, env)
|
46
|
+
@action.call(env)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
# action_root = Pathname.new(File.expand_path('../../../../lib/vagrant-rimu/actions', __FILE__))
|
7
|
+
# autoload :StopInstance, action_root.join('stop_instance')
|
8
|
+
|
9
|
+
describe VagrantPlugins::Rimu::Actions::ListServers do
|
10
|
+
let(:orders) { double('orders') }
|
11
|
+
let(:ordersm) { double('ordersm') }
|
12
|
+
let(:machine) { double('machine') }
|
13
|
+
let(:server1) { OpenStruct.new({:order_oid => 1, :domain_name => 'rimu01.example.com', :location => {:data_center_location_code => 'DCDALLAS'}, :host_server_oid => 200, :running_state => 'RUNNING'}) }
|
14
|
+
let(:server2) { OpenStruct.new({:order_oid => 2, :domain_name => 'rimu02.example.com', :location => {:data_center_location_code => 'DCDALLAS'}, :host_server_oid => 200, :running_state => 'NOTRUNNING'}) }
|
15
|
+
|
16
|
+
|
17
|
+
let(:env) do
|
18
|
+
{}.tap do |env|
|
19
|
+
env[:ui] = double('ui').tap do |ui|
|
20
|
+
ui.stub(:info).with(anything)
|
21
|
+
ui.stub(:error).with(anything)
|
22
|
+
end
|
23
|
+
env[:rimu_api] = double('rimu_api').tap do |os|
|
24
|
+
orders.stub(:each).and_yield(server1).and_yield(server2)
|
25
|
+
ordersm.stub(:orders) { orders }
|
26
|
+
os.stub(:orders) { ordersm }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:app) do
|
32
|
+
double('app').tap do |app|
|
33
|
+
app.stub(:call).with(anything)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'call' do
|
38
|
+
it 'return a server listing' do
|
39
|
+
expect(env[:rimu_api].orders.orders).to receive(:each)
|
40
|
+
rows = []
|
41
|
+
[server1, server2].each do |o|
|
42
|
+
rows << [o.order_oid, o.domain_name, o.location["data_center_location_code"], o.host_server_oid, o.running_state]
|
43
|
+
end
|
44
|
+
table = Terminal::Table.new headings: ['ID', 'Hostname', 'Data Centre', 'Host Server', 'Status'], rows: rows
|
45
|
+
expect(env[:ui]).to receive(:info).with("\n#{table}")
|
46
|
+
expect(app).to receive(:call)
|
47
|
+
@action = VagrantPlugins::Rimu::Actions::ListServers.new(app, env)
|
48
|
+
@action.call(env)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# action_root = Pathname.new(File.expand_path('../../../../lib/vagrant-rimu/actions', __FILE__))
|
4
|
+
# autoload :StopInstance, action_root.join('stop_instance')
|
5
|
+
|
6
|
+
describe VagrantPlugins::Rimu::Actions::MessageActionNotSupported do
|
7
|
+
let(:env) do
|
8
|
+
{}.tap do |env|
|
9
|
+
env[:ui] = double('ui').tap do |ui|
|
10
|
+
ui.stub(:info).with(anything)
|
11
|
+
ui.stub(:error).with(anything)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:app) do
|
17
|
+
double('app').tap do |app|
|
18
|
+
app.stub(:call).with(anything)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'call' do
|
23
|
+
it 'sets info variable' do
|
24
|
+
expect(I18n).to receive(:t).with('vagrant_rimu.action_not_supported')
|
25
|
+
expect(app).to receive(:call)
|
26
|
+
@action = VagrantPlugins::Rimu::Actions::MessageActionNotSupported.new(app, env)
|
27
|
+
@action.call(env)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
require 'pathname'
|
3
|
-
|
4
1
|
require 'spec_helper'
|
5
2
|
|
6
3
|
# action_root = Pathname.new(File.expand_path('../../../../lib/vagrant-rimu/actions', __FILE__))
|
@@ -30,4 +27,4 @@ describe VagrantPlugins::Rimu::Actions::MessageAlreadyCreated do
|
|
30
27
|
@action.call(env)
|
31
28
|
end
|
32
29
|
end
|
33
|
-
end
|
30
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
# action_root = Pathname.new(File.expand_path('../../../../lib/vagrant-rimu/actions', __FILE__))
|
6
|
+
# autoload :StopInstance, action_root.join('stop_instance')
|
7
|
+
|
8
|
+
describe VagrantPlugins::Rimu::Actions::MessageWillNotStop do
|
9
|
+
let(:env) do
|
10
|
+
{}.tap do |env|
|
11
|
+
env[:ui] = double('ui').tap do |ui|
|
12
|
+
ui.stub(:info).with(anything)
|
13
|
+
ui.stub(:error).with(anything)
|
14
|
+
end
|
15
|
+
env[:machine] = OpenStruct.new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:app) do
|
20
|
+
double('app').tap do |app|
|
21
|
+
app.stub(:call).with(anything)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'call' do
|
26
|
+
it 'sets info variable' do
|
27
|
+
name = 'rimu.example.com'
|
28
|
+
env[:machine].name = name
|
29
|
+
expect(I18n).to receive(:t).with('vagrant_rimu.will_not_stop', {:name => name})
|
30
|
+
expect(app).to receive(:call)
|
31
|
+
@action = VagrantPlugins::Rimu::Actions::MessageWillNotStop.new(app, env)
|
32
|
+
@action.call(env)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -20,12 +20,7 @@ describe VagrantPlugins::Rimu::Actions::ModifyProvisionPath do
|
|
20
20
|
|
21
21
|
let(:config) do
|
22
22
|
double.tap do |config|
|
23
|
-
provisioners.stub(:each)
|
24
|
-
[
|
25
|
-
provisioner,
|
26
|
-
provisioner,
|
27
|
-
]
|
28
|
-
}
|
23
|
+
provisioners.stub(:each).and_yield(provisioner).and_yield(provisioner)
|
29
24
|
vm.stub(:provisioners) { provisioners }
|
30
25
|
config.stub(:vm) { vm }
|
31
26
|
end
|
@@ -72,7 +67,7 @@ describe VagrantPlugins::Rimu::Actions::ModifyProvisionPath do
|
|
72
67
|
expect(env).to receive(:has_key?).with(:provision_enabled)
|
73
68
|
expect(env[:machine]).to receive(:ssh_info)
|
74
69
|
expect(env[:machine].config.vm.provisioners).to receive(:each)
|
75
|
-
|
70
|
+
expect(env[:machine].communicate).to receive(:sudo)
|
76
71
|
@action = VagrantPlugins::Rimu::Actions::ModifyProvisionPath.new(app, env)
|
77
72
|
@action.call(env)
|
78
73
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
# action_root = Pathname.new(File.expand_path('../../../../lib/vagrant-rimu/actions', __FILE__))
|
5
|
+
# autoload :StopInstance, action_root.join('stop_instance')
|
6
|
+
|
7
|
+
describe VagrantPlugins::Rimu::Actions::Move do
|
8
|
+
let(:ssh) { double('ssh') }
|
9
|
+
let(:servers) { double('servers') }
|
10
|
+
let(:machine) { double('machine') }
|
11
|
+
let(:move) { double('move') }
|
12
|
+
let(:communicate) { double('communicate') }
|
13
|
+
let(:id) { '200' }
|
14
|
+
|
15
|
+
let(:config) do
|
16
|
+
double.tap do |config|
|
17
|
+
config.stub(:api_url) { nil }
|
18
|
+
config.stub(:api_key) { 'foo' }
|
19
|
+
# config.stub(:host_name) { 'rimu.example.com' }
|
20
|
+
# config.stub(:root_password) { nil }
|
21
|
+
# config.stub(:distro_code) { nil }
|
22
|
+
# config.stub(:control_panel) { nil }
|
23
|
+
# config.stub(:vps_to_clone) { nil }
|
24
|
+
# config.stub(:minimal_init) { nil }
|
25
|
+
# config.stub(:disk_space_mb) { nil }
|
26
|
+
# config.stub(:memory_mb) { nil }
|
27
|
+
# config.stub(:disk_space_2_mb) { nil }
|
28
|
+
config.stub(:setup?) { true }
|
29
|
+
ssh.stub(:username) { 'rimu' }
|
30
|
+
ssh.stub(:username=) { 'rimu' }
|
31
|
+
ssh.stub(:private_key_path) { 'test/test_rimu_id_rsa' }
|
32
|
+
config.stub(:ssh) { ssh }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
let(:env) do
|
37
|
+
{}.tap do |env|
|
38
|
+
env[:ui] = double('ui').tap do |ui|
|
39
|
+
ui.stub(:info).with(anything)
|
40
|
+
ui.stub(:error).with(anything)
|
41
|
+
end
|
42
|
+
env[:rimu_api] = double('rimu_api').tap do |os|
|
43
|
+
move.stub(:order_oid) { id }
|
44
|
+
move.stub(:allocated_ips) { {:primary_ip => '192.168.1.10'} }
|
45
|
+
servers.stub(:move) { move }
|
46
|
+
os.stub(:servers) { servers }
|
47
|
+
end
|
48
|
+
machine.stub(:id) { id }
|
49
|
+
machine.stub(:id=) { id }
|
50
|
+
env[:machine] = machine
|
51
|
+
env[:machine].stub(:config) { config }
|
52
|
+
env[:machine].stub(:provider_config) { config }
|
53
|
+
communicate.stub(:ready?) { true }
|
54
|
+
env[:machine].stub(:communicate) { communicate }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
let(:app) do
|
59
|
+
double('app').tap do |app|
|
60
|
+
app.stub(:call).with(anything)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'call' do
|
65
|
+
it 'moves server to different host' do
|
66
|
+
expect(env[:machine].provider_config).to receive(:setup?)
|
67
|
+
expect(env[:machine].communicate).to receive(:ready?)
|
68
|
+
expect(env[:machine].config.ssh).to receive(:username=).with(ssh.username)
|
69
|
+
expect(env[:rimu_api].servers).to receive(:move)
|
70
|
+
expect(app).to receive(:call)
|
71
|
+
@action = VagrantPlugins::Rimu::Actions::Move.new(app, env)
|
72
|
+
@action.call(env)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -5,12 +5,19 @@ require 'spec_helper'
|
|
5
5
|
# autoload :StopInstance, action_root.join('stop_instance')
|
6
6
|
|
7
7
|
describe VagrantPlugins::Rimu::Actions::ReadSSHInfo do
|
8
|
+
let(:ssh) { double('ssh') }
|
8
9
|
let(:orders) { double('orders') }
|
9
10
|
let(:machine) { double('machine') }
|
10
11
|
let(:order) { double('order') }
|
11
12
|
let(:allocated_ips) { {:primary_ip=>'192.168.1.1'} }
|
12
13
|
let(:id) { '200' }
|
13
14
|
|
15
|
+
let(:config) do
|
16
|
+
double.tap do |config|
|
17
|
+
ssh.stub(:private_key_path) { 'test/test_rimu_id_rsa' }
|
18
|
+
config.stub(:ssh) { ssh }
|
19
|
+
end
|
20
|
+
end
|
14
21
|
|
15
22
|
let(:env) do
|
16
23
|
{}.tap do |env|
|
@@ -24,6 +31,7 @@ describe VagrantPlugins::Rimu::Actions::ReadSSHInfo do
|
|
24
31
|
os.stub(:orders) { orders }
|
25
32
|
end
|
26
33
|
machine.stub(:id) { id }
|
34
|
+
machine.stub(:config) { config }
|
27
35
|
env[:machine] = machine
|
28
36
|
end
|
29
37
|
end
|
@@ -58,5 +66,18 @@ describe VagrantPlugins::Rimu::Actions::ReadSSHInfo do
|
|
58
66
|
@action.call(env)
|
59
67
|
end
|
60
68
|
end
|
69
|
+
|
70
|
+
context 'when api call returns nil' do
|
71
|
+
it 'should return nil machine id' do
|
72
|
+
env[:machine].id.stub(:nil?) { false }
|
73
|
+
expect(env[:machine].id).to receive(:nil?)
|
74
|
+
expect(order).not_to receive(:allocated_ips)
|
75
|
+
expect(env[:rimu_api].orders).to receive(:order).with(id.to_i).and_return(nil)
|
76
|
+
expect(env[:machine]).to receive(:id=).with(nil)
|
77
|
+
expect(app).to receive(:call)
|
78
|
+
@action = VagrantPlugins::Rimu::Actions::ReadSSHInfo.new(app, env)
|
79
|
+
@action.call(env)
|
80
|
+
end
|
81
|
+
end
|
61
82
|
end
|
62
83
|
end
|
@@ -6,6 +6,7 @@ require 'spec_helper'
|
|
6
6
|
|
7
7
|
describe VagrantPlugins::Rimu::Actions::Rebuild do
|
8
8
|
let(:ssh) { double('ssh') }
|
9
|
+
let(:root_path) { '.' }
|
9
10
|
let(:servers) { double('servers') }
|
10
11
|
let(:machine) { double('machine') }
|
11
12
|
let(:reinstall) { double('reinstall') }
|
@@ -28,6 +29,7 @@ describe VagrantPlugins::Rimu::Actions::Rebuild do
|
|
28
29
|
config.stub(:setup?) { true }
|
29
30
|
ssh.stub(:username) { 'rimu' }
|
30
31
|
ssh.stub(:username=) { 'rimu' }
|
32
|
+
ssh.stub(:password=).with(anything)
|
31
33
|
ssh.stub(:private_key_path) { 'test/test_rimu_id_rsa' }
|
32
34
|
config.stub(:ssh) { ssh }
|
33
35
|
end
|
@@ -43,10 +45,13 @@ describe VagrantPlugins::Rimu::Actions::Rebuild do
|
|
43
45
|
servers.stub(:reinstall) { reinstall }
|
44
46
|
os.stub(:servers) { servers }
|
45
47
|
end
|
48
|
+
env.stub(:root_path) { root_path }
|
46
49
|
machine.stub(:id) { id }
|
50
|
+
machine.stub(:env) { env }
|
47
51
|
env[:machine] = machine
|
48
52
|
env[:machine].stub(:config) { config }
|
49
53
|
env[:machine].stub(:provider_config) { config }
|
54
|
+
communicate.stub(:execute).with(anything)
|
50
55
|
communicate.stub(:ready?) { true }
|
51
56
|
env[:machine].stub(:communicate) { communicate }
|
52
57
|
end
|
@@ -62,6 +67,7 @@ describe VagrantPlugins::Rimu::Actions::Rebuild do
|
|
62
67
|
context 'when vps_to_clone option is not set' do
|
63
68
|
it 'reinstall the server using instantiation_options' do
|
64
69
|
# env.stub(:interrupted) { false }
|
70
|
+
root_passwd = Digest::SHA2.new.update('foo').to_s
|
65
71
|
expect(env[:machine].provider_config).to receive(:setup?)
|
66
72
|
expect(env[:machine].communicate).to receive(:ready?)
|
67
73
|
expect(env[:machine].config.ssh).to receive(:username=).with(ssh.username)
|
@@ -70,7 +76,7 @@ describe VagrantPlugins::Rimu::Actions::Rebuild do
|
|
70
76
|
{
|
71
77
|
:instantiation_options=> {
|
72
78
|
:domain_name=>config.host_name,
|
73
|
-
:password=>
|
79
|
+
:password=>root_passwd,
|
74
80
|
:distro=>nil,
|
75
81
|
:control_panel=>nil
|
76
82
|
},
|
@@ -33,9 +33,9 @@ describe VagrantPlugins::Rimu::Actions::StopInstance do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
describe 'call' do
|
36
|
-
context 'when server state id is not :
|
36
|
+
context 'when server state id is not :off' do
|
37
37
|
it 'stops the server' do
|
38
|
-
state.stub(:id) { :
|
38
|
+
state.stub(:id) { :active }
|
39
39
|
env[:machine].stub(:state) { state }
|
40
40
|
expect(env[:rimu_api].servers).to receive(:shutdown).with(id.to_i)
|
41
41
|
expect(app).to receive(:call)
|
@@ -43,9 +43,9 @@ describe VagrantPlugins::Rimu::Actions::StopInstance do
|
|
43
43
|
@action.call(env)
|
44
44
|
end
|
45
45
|
end
|
46
|
-
context 'when server id is :
|
46
|
+
context 'when server id is :off' do
|
47
47
|
it 'does nothing' do
|
48
|
-
state.stub(:id) { :
|
48
|
+
state.stub(:id) { :off }
|
49
49
|
env[:machine].stub(:state) { state }
|
50
50
|
expect(env[:rimu_api].servers).to_not receive(:shutdown)
|
51
51
|
expect(app).to receive(:call)
|