vagrant-rimu 0.0.2 → 0.0.7
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 +13 -4
- data/Rakefile +6 -3
- data/Vagrantfile +5 -0
- 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.rb +102 -80
- 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 +12 -6
- data/lib/vagrant-rimu/actions/create.rb +24 -5
- 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 +11 -4
- data/lib/vagrant-rimu/actions/list_servers.rb +11 -6
- 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 +31 -4
- data/lib/vagrant-rimu/actions/read_ssh_info.rb +8 -5
- data/lib/vagrant-rimu/actions/read_state.rb +12 -4
- data/lib/vagrant-rimu/actions/rebuild.rb +33 -5
- data/lib/vagrant-rimu/actions/reload.rb +10 -3
- data/lib/vagrant-rimu/actions/setup_sudo.rb +15 -8
- data/lib/vagrant-rimu/actions/setup_user.rb +44 -30
- data/lib/vagrant-rimu/actions/ssh_utils.rb +44 -0
- data/lib/vagrant-rimu/actions/start_instance.rb +4 -2
- data/lib/vagrant-rimu/actions/stop_instance.rb +16 -6
- data/lib/vagrant-rimu/actions/terminate_instance.rb +10 -4
- 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 +3 -2
- data/lib/vagrant-rimu/errors.rb +4 -0
- data/lib/vagrant-rimu/plugin.rb +1 -1
- data/lib/vagrant-rimu/provider.rb +1 -1
- data/lib/vagrant-rimu/version.rb +1 -1
- data/locales/en.yml +70 -19
- data/spec/spec_helper.rb +1 -1
- data/spec/vagrant-rimu/actions/billing_methods_spec.rb +4 -4
- 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 +1 -1
- data/spec/vagrant-rimu/actions/is_stopped_spec.rb +2 -2
- 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/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/move_spec.rb +75 -0
- data/spec/vagrant-rimu/actions/read_ssh_info_spec.rb +8 -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/test/Vagrantfile +4 -2
- data/vagrant-rimu.gemspec +3 -1
- metadata +48 -6
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,7 @@ if ENV['CI']=='true'
|
|
4
4
|
require 'codecov'
|
5
5
|
require 'coveralls'
|
6
6
|
require 'codeclimate-test-reporter'
|
7
|
-
SimpleCov.
|
7
|
+
SimpleCov.formatters = [
|
8
8
|
SimpleCov::Formatter::HTMLFormatter,
|
9
9
|
Coveralls::SimpleCov::Formatter,
|
10
10
|
SimpleCov::Formatter::Codecov,
|
@@ -35,12 +35,12 @@ describe VagrantPlugins::Rimu::Actions::BillingMethods do
|
|
35
35
|
describe 'call' do
|
36
36
|
it 'return a billing_methods listing' do
|
37
37
|
expect(env[:rimu_api].billing_methods).to receive(:each)
|
38
|
-
|
39
|
-
expect(env[:ui]).to receive(:info).with(heading)
|
38
|
+
rows = []
|
40
39
|
[method1, method2].each do |b|
|
41
|
-
|
42
|
-
expect(env[:ui]).to receive(:info).with(row)
|
40
|
+
rows << [b.billing_oid, b.billing_method_type, b.description]
|
43
41
|
end
|
42
|
+
table = Terminal::Table.new headings: ['ID', 'Type', 'Description'], rows: rows
|
43
|
+
expect(env[:ui]).to receive(:info).with("\n#{table}")
|
44
44
|
expect(app).to receive(:call)
|
45
45
|
@action = VagrantPlugins::Rimu::Actions::BillingMethods.new(app, env)
|
46
46
|
@action.call(env)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe VagrantPlugins::Rimu::Actions::ConnectToRimu do
|
4
|
+
let(:rimu_api) { double('rimu_api') }
|
4
5
|
let(:app) do
|
5
6
|
double.tap do |app|
|
6
7
|
app.stub(:call)
|
@@ -21,7 +22,7 @@ describe VagrantPlugins::Rimu::Actions::ConnectToRimu do
|
|
21
22
|
env[:ui].stub(:warn).with(anything)
|
22
23
|
env[:machine] = double('machine')
|
23
24
|
env[:machine].stub(:provider_config) { config }
|
24
|
-
env[:rimu_api] =
|
25
|
+
env[:rimu_api] = rimu_api
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
@@ -0,0 +1,167 @@
|
|
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::Create do
|
8
|
+
let(:dup) { double('dup') }
|
9
|
+
let(:ssh) { double('ssh') }
|
10
|
+
let(:root_path) { '.' }
|
11
|
+
let(:servers) { double('servers') }
|
12
|
+
let(:machine) { double('machine') }
|
13
|
+
let(:create) { double('create') }
|
14
|
+
let(:communicate) { double('communicate') }
|
15
|
+
let(:id) { '200' }
|
16
|
+
|
17
|
+
let(:config) do
|
18
|
+
double.tap do |config|
|
19
|
+
config.stub(:api_url) { nil }
|
20
|
+
config.stub(:api_key) { 'foo' }
|
21
|
+
config.stub(:host_name) { 'rimu.example.com' }
|
22
|
+
config.stub(:root_password) { 'P455w0rd' }
|
23
|
+
config.stub(:distro_code) { nil }
|
24
|
+
config.stub(:control_panel) { nil }
|
25
|
+
config.stub(:vps_to_clone) { nil }
|
26
|
+
config.stub(:minimal_init) { nil }
|
27
|
+
config.stub(:disk_space_mb) { nil }
|
28
|
+
config.stub(:memory_mb) { nil }
|
29
|
+
config.stub(:disk_space_2_mb) { nil }
|
30
|
+
config.stub(:billing_id) { nil }
|
31
|
+
config.stub(:data_centre) { nil }
|
32
|
+
config.stub(:host_server_id) { nil }
|
33
|
+
config.stub(:extra_ip_reason) { nil }
|
34
|
+
config.stub(:num_ips) { nil }
|
35
|
+
config.stub(:private_ips) { nil }
|
36
|
+
config.stub(:vps_type) { nil }
|
37
|
+
config.stub(:setup?) { true }
|
38
|
+
ssh.stub(:username) { 'rimu' }
|
39
|
+
ssh.stub(:username=) { 'rimu' }
|
40
|
+
ssh.stub(:password=).with(anything)
|
41
|
+
ssh.stub(:private_key_path) { 'test/test_rimu_id_rsa' }
|
42
|
+
config.stub(:ssh) { ssh }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
let(:env) do
|
47
|
+
{}.tap do |env|
|
48
|
+
env[:ui] = double('ui').tap do |ui|
|
49
|
+
ui.stub(:info).with(anything)
|
50
|
+
ui.stub(:error).with(anything)
|
51
|
+
end
|
52
|
+
env[:rimu_api] = double('rimu_api').tap do |os|
|
53
|
+
create.stub(:order_oid) { id }
|
54
|
+
create.stub(:allocated_ips) { {:primary_ip => '192.168.1.10'} }
|
55
|
+
servers.stub(:create) { create }
|
56
|
+
os.stub(:servers) { servers }
|
57
|
+
end
|
58
|
+
env.stub(:root_path) { root_path }
|
59
|
+
machine.stub(:id) { id }
|
60
|
+
machine.stub(:id=) { id }
|
61
|
+
machine.stub(:env) { env }
|
62
|
+
env[:machine] = machine
|
63
|
+
env[:machine].stub(:config) { config }
|
64
|
+
env[:machine].stub(:provider_config) { config }
|
65
|
+
communicate.stub(:execute).with(anything)
|
66
|
+
communicate.stub(:ready?) { true }
|
67
|
+
env[:machine].stub(:communicate) { communicate }
|
68
|
+
# dup.stub(:delete) { double('delete') }
|
69
|
+
# dup.stub(:[]=) { double('[]=') }
|
70
|
+
# env.stub(:dup) { dup }
|
71
|
+
# action_runner.stub(:run) { double('run') }
|
72
|
+
# env[:action_runner] = action_runner
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
let(:app) do
|
77
|
+
double('app').tap do |app|
|
78
|
+
app.stub(:call).with(anything)
|
79
|
+
# app.stub(:terminate).with(anything)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe 'call' do
|
84
|
+
context 'when vps_to_clone option is not set' do
|
85
|
+
it 'should install the server using instantiation_options' do
|
86
|
+
expect(env[:machine].provider_config).to receive(:setup?)
|
87
|
+
expect(env[:machine].communicate).to receive(:ready?)
|
88
|
+
expect(env[:machine].config.ssh).to receive(:username=).with(ssh.username)
|
89
|
+
expect(env[:rimu_api].servers).to receive(:create).with(
|
90
|
+
{
|
91
|
+
:billing_oid => config.billing_id,
|
92
|
+
:dc_location => config.data_centre,
|
93
|
+
:host_server_oid => config.host_server_id,
|
94
|
+
:instantiation_options=> {
|
95
|
+
:domain_name=>config.host_name,
|
96
|
+
:password=>config.root_password,
|
97
|
+
:distro=>config.distro_code,
|
98
|
+
:control_panel=>config.control_panel
|
99
|
+
},
|
100
|
+
:ip_request => {
|
101
|
+
:extra_ip_reason => config.extra_ip_reason,
|
102
|
+
:num_ips => config.num_ips,
|
103
|
+
:requested_ips => config.private_ips,
|
104
|
+
},
|
105
|
+
:is_just_minimal_init=>nil,
|
106
|
+
:vps_parameters=>{
|
107
|
+
:disk_space_mb=>nil,
|
108
|
+
:memory_mb=>nil,
|
109
|
+
:disk_space_2_mb=>nil
|
110
|
+
},
|
111
|
+
:vps_type => config.vps_type,
|
112
|
+
}
|
113
|
+
)
|
114
|
+
expect(app).to receive(:call)
|
115
|
+
@action = VagrantPlugins::Rimu::Actions::Create.new(app, env)
|
116
|
+
@action.call(env)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'when vps_to_clone option is set' do
|
121
|
+
it 'should install the server using instantiation_via_clone_options' do
|
122
|
+
vps_clone = 9999
|
123
|
+
env[:machine].provider_config.stub(:vps_to_clone) { vps_clone }
|
124
|
+
expect(env[:machine].provider_config).to receive(:setup?)
|
125
|
+
expect(env[:machine].communicate).not_to receive(:ready?)
|
126
|
+
expect(env[:machine].config.ssh).to receive(:username=).with(ssh.username)
|
127
|
+
expect(env[:rimu_api].servers).to receive(:create).with(
|
128
|
+
{
|
129
|
+
:billing_oid => config.billing_id,
|
130
|
+
:dc_location => config.data_centre,
|
131
|
+
:host_server_oid => config.host_server_id,
|
132
|
+
:instantiation_via_clone_options=> {
|
133
|
+
:domain_name=>config.host_name,
|
134
|
+
:vps_order_oid_to_clone => vps_clone,
|
135
|
+
},
|
136
|
+
:ip_request => {
|
137
|
+
:extra_ip_reason => config.extra_ip_reason,
|
138
|
+
:num_ips => config.num_ips,
|
139
|
+
:requested_ips => config.private_ips,
|
140
|
+
},
|
141
|
+
:is_just_minimal_init=>nil,
|
142
|
+
:vps_parameters=>{
|
143
|
+
:disk_space_mb=>nil,
|
144
|
+
:memory_mb=>nil,
|
145
|
+
:disk_space_2_mb=>nil
|
146
|
+
},
|
147
|
+
:vps_type => config.vps_type,
|
148
|
+
}
|
149
|
+
)
|
150
|
+
expect(app).to receive(:call)
|
151
|
+
@action = VagrantPlugins::Rimu::Actions::Create.new(app, env)
|
152
|
+
@action.call(env)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# context 'when terminate is run' do
|
157
|
+
# it 'should call the destroy action' do
|
158
|
+
# expect(app.dup).to receive(:[]=).with(:config_validate, false)
|
159
|
+
# expect(app.dup).to receive(:[]=).with(:force_confirm_destroy, true)
|
160
|
+
# expect(env[:action_runner]).to receive(:run)
|
161
|
+
# expect(app).to receive(:terminate)
|
162
|
+
# @action = VagrantPlugins::Rimu::Actions::Create.new(app, env)
|
163
|
+
# @action.terminate(env)
|
164
|
+
# end
|
165
|
+
# end
|
166
|
+
end
|
167
|
+
end
|
@@ -28,7 +28,7 @@ describe VagrantPlugins::Rimu::Actions::IsCreated do
|
|
28
28
|
describe 'call' do
|
29
29
|
context 'when server is created' do
|
30
30
|
it 'returns true' do
|
31
|
-
env[:machine].state.stub(:id) { :
|
31
|
+
env[:machine].state.stub(:id) { :off }
|
32
32
|
expect(app).to receive(:call)
|
33
33
|
@action = VagrantPlugins::Rimu::Actions::IsCreated.new(app, env)
|
34
34
|
@action.call(env)
|
@@ -28,7 +28,7 @@ describe VagrantPlugins::Rimu::Actions::IsStopped do
|
|
28
28
|
describe 'call' do
|
29
29
|
context 'when server is stopped' do
|
30
30
|
it 'returns true' do
|
31
|
-
env[:machine].state.stub(:id) { :
|
31
|
+
env[:machine].state.stub(:id) { :off }
|
32
32
|
expect(app).to receive(:call)
|
33
33
|
@action = VagrantPlugins::Rimu::Actions::IsStopped.new(app, env)
|
34
34
|
@action.call(env)
|
@@ -38,7 +38,7 @@ describe VagrantPlugins::Rimu::Actions::IsStopped do
|
|
38
38
|
|
39
39
|
context 'when server is running' do
|
40
40
|
it 'returns false' do
|
41
|
-
env[:machine].state.stub(:id) { :
|
41
|
+
env[:machine].state.stub(:id) { :active }
|
42
42
|
expect(app).to receive(:call)
|
43
43
|
@action = VagrantPlugins::Rimu::Actions::IsStopped.new(app, env)
|
44
44
|
@action.call(env)
|
@@ -35,12 +35,12 @@ describe VagrantPlugins::Rimu::Actions::ListDistributions do
|
|
35
35
|
describe 'call' do
|
36
36
|
it 'return a distribution listing' do
|
37
37
|
expect(env[:rimu_api].distributions).to receive(:each)
|
38
|
-
|
39
|
-
expect(env[:ui]).to receive(:info).with(heading)
|
38
|
+
rows = []
|
40
39
|
[distro1, distro2].each do |o|
|
41
|
-
|
42
|
-
expect(env[:ui]).to receive(:info).with(row)
|
40
|
+
rows << [o.distro_code, o.distro_description]
|
43
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
44
|
expect(app).to receive(:call)
|
45
45
|
@action = VagrantPlugins::Rimu::Actions::ListDistributions.new(app, env)
|
46
46
|
@action.call(env)
|
@@ -37,12 +37,12 @@ describe VagrantPlugins::Rimu::Actions::ListServers do
|
|
37
37
|
describe 'call' do
|
38
38
|
it 'return a server listing' do
|
39
39
|
expect(env[:rimu_api].orders.orders).to receive(:each)
|
40
|
-
|
41
|
-
expect(env[:ui]).to receive(:info).with(heading)
|
40
|
+
rows = []
|
42
41
|
[server1, server2].each do |o|
|
43
|
-
|
44
|
-
expect(env[:ui]).to receive(:info).with(row)
|
42
|
+
rows << [o.order_oid, o.domain_name, o.location["data_center_location_code"], o.host_server_oid, o.running_state]
|
45
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
46
|
expect(app).to receive(:call)
|
47
47
|
@action = VagrantPlugins::Rimu::Actions::ListServers.new(app, env)
|
48
48
|
@action.call(env)
|
@@ -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
|
@@ -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
|