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,4 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require 'vagrant'
|
2
|
+
|
3
|
+
require 'vagrant-rimu/actions'
|
2
4
|
|
3
5
|
module VagrantPlugins
|
4
6
|
module Rimu
|
@@ -31,7 +33,7 @@ module VagrantPlugins
|
|
31
33
|
# key in the environment.
|
32
34
|
env = @machine.action("read_state")
|
33
35
|
|
34
|
-
state_id = env[:
|
36
|
+
state_id = env[:machine_state]
|
35
37
|
|
36
38
|
# Get the short and long description
|
37
39
|
short = I18n.t("vagrant_rimu.states.short_#{state_id}")
|
data/lib/vagrant-rimu/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -14,6 +14,8 @@ en:
|
|
14
14
|
Starting the VPS...
|
15
15
|
stopping: |-
|
16
16
|
Stopping the VPS...
|
17
|
+
moving: |-
|
18
|
+
Moving the VPS to different host...
|
17
19
|
terminating: |-
|
18
20
|
Terminating the VPS...
|
19
21
|
waiting_for_ready: |-
|
@@ -21,10 +23,15 @@ en:
|
|
21
23
|
will_not_destroy: |-
|
22
24
|
The VPS '%{name}' will not be destroyed, since the confirmation
|
23
25
|
was declined.
|
26
|
+
will_not_stop: |-
|
27
|
+
The VPS '%{name}' will not be stopped, as the Rimu API does not
|
28
|
+
support this action. To stop your VPS run `vagrant ssh` and then
|
29
|
+
`halt` on the VPS console.
|
24
30
|
ip_address: |-
|
25
31
|
Assigned IP address: %{ip}
|
26
32
|
creating_user: "Creating user account: %{user}..."
|
27
33
|
modifying_sudo: "Modifying sudoers file to remove tty requirement..."
|
34
|
+
action_not_supported: "The requested command is not supported by this provider"
|
28
35
|
reloading: "Rebooting the VPS..."
|
29
36
|
rebuilding: "Rebuilding the VPS..."
|
30
37
|
config:
|
@@ -35,25 +42,6 @@ en:
|
|
35
42
|
private_key: "A valid SSH private key path option: [private_key_path] is required"
|
36
43
|
missing_private_key: "SSH private key not found: %{key}"
|
37
44
|
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
45
|
states:
|
58
46
|
short_not_created: |-
|
59
47
|
not created
|
@@ -65,8 +53,12 @@ en:
|
|
65
53
|
The VPS is starting.
|
66
54
|
short_stopped: |-
|
67
55
|
stopped
|
56
|
+
short_off: |-
|
57
|
+
stopped
|
68
58
|
long_stopped: |-
|
69
59
|
The VPS is stopped. Run `vagrant up` to start it.
|
60
|
+
long_off: |-
|
61
|
+
The VPS is stopped. Run `vagrant up` to start it.
|
70
62
|
short_stopping: |-
|
71
63
|
stopping
|
72
64
|
long_stopping: |-
|
@@ -74,6 +66,65 @@ en:
|
|
74
66
|
run `vagrant up` and start it.
|
75
67
|
short_running: |-
|
76
68
|
running
|
69
|
+
short_active: |-
|
70
|
+
running
|
77
71
|
long_running: |-
|
78
72
|
The VPS is running. To stop this machine, you can run
|
79
73
|
`vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
|
74
|
+
long_active: |-
|
75
|
+
The VPS is running. To stop this machine, you can run
|
76
|
+
`vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
|
77
|
+
current_state: |-
|
78
|
+
Machine state is `%{state}`
|
79
|
+
commands:
|
80
|
+
root_synopsis: |-
|
81
|
+
Rimu provider specific commands
|
82
|
+
root_usage: |-
|
83
|
+
Usage: vagrant rimu <subcommand> [<args>]
|
84
|
+
rebuild_usage: |-
|
85
|
+
Usage: vagrant rebuild [vm-name]
|
86
|
+
available_subcommands: |-
|
87
|
+
Available subcommands:
|
88
|
+
billing_methods: |-
|
89
|
+
List billing methods
|
90
|
+
list_distributions: |-
|
91
|
+
List Distributions
|
92
|
+
list_servers: |-
|
93
|
+
List servers
|
94
|
+
move: |-
|
95
|
+
Moves server to different host
|
96
|
+
rebuild: |-
|
97
|
+
Rebuilds the server, retaining the current IP address
|
98
|
+
errors:
|
99
|
+
global_error: |-
|
100
|
+
An unknown error happened in Vagrant Rimu provider
|
101
|
+
|
102
|
+
To easily debug what happened, we recommend to set the environment
|
103
|
+
variable VAGRANT_RIMU_LOG to debug
|
104
|
+
|
105
|
+
$ export VAGRANT_RIMU_LOG=debug
|
106
|
+
|
107
|
+
If doing this does not help fixing your issue, there may be a bug
|
108
|
+
in the provider. Please submit an issue on Github at
|
109
|
+
https://github.com/akissa/vagrant-rimu
|
110
|
+
with the stracktrace and the logs.
|
111
|
+
no_args: |-
|
112
|
+
Command '%{cmd}' does not required any argument.
|
113
|
+
api_error: |-
|
114
|
+
The API request failed. Please inspect the error message
|
115
|
+
below for more info.
|
116
|
+
|
117
|
+
Error: %{stderr}
|
118
|
+
public_key: |-
|
119
|
+
There was an issue reading the public key at:
|
120
|
+
|
121
|
+
Path: %{path}
|
122
|
+
|
123
|
+
Please check the file permissions.
|
124
|
+
rsync: |-
|
125
|
+
There was an error when attemping to rsync a share folder.
|
126
|
+
Please inspect the error message below for more info.
|
127
|
+
|
128
|
+
Host path: %{hostpath}
|
129
|
+
Guest path: %{guestpath}
|
130
|
+
Error: %{stderr}
|
data/spec/spec_helper.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
require 'simplecov'
|
2
|
-
require 'coveralls'
|
3
|
-
require 'codeclimate-test-reporter'
|
4
2
|
|
5
|
-
SimpleCov.start
|
6
3
|
if ENV['CI']=='true'
|
7
4
|
require 'codecov'
|
8
|
-
|
5
|
+
require 'coveralls'
|
6
|
+
require 'codeclimate-test-reporter'
|
7
|
+
SimpleCov.formatters = [
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
9
|
+
Coveralls::SimpleCov::Formatter,
|
10
|
+
SimpleCov::Formatter::Codecov,
|
11
|
+
CodeClimate::TestReporter::Formatter,
|
12
|
+
]
|
9
13
|
Coveralls.wear!
|
10
14
|
CodeClimate::TestReporter.start
|
11
15
|
end
|
16
|
+
SimpleCov.start
|
12
17
|
|
13
18
|
Dir['lib/**/*.rb'].each do|file|
|
14
19
|
require_string = file.match(/lib\/(.*)\.rb/)[1]
|
@@ -17,8 +22,6 @@ end
|
|
17
22
|
|
18
23
|
require 'rspec/its'
|
19
24
|
|
20
|
-
I18n.load_path << File.expand_path('locales/en.yml', Pathname.new(File.expand_path('../../', __FILE__)))
|
21
|
-
|
22
25
|
RSpec.configure do |config|
|
23
26
|
config.mock_with :rspec do |c|
|
24
27
|
c.syntax = [:should, :expect]
|
@@ -27,3 +30,7 @@ RSpec.configure do |config|
|
|
27
30
|
c.syntax = [:should, :expect]
|
28
31
|
end
|
29
32
|
end
|
33
|
+
|
34
|
+
I18n.load_path << File.expand_path('locales/en.yml', Pathname.new(File.expand_path('../../', __FILE__)))
|
35
|
+
|
36
|
+
VagrantPlugins::Rimu::Logging.init
|
@@ -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::BillingMethods do
|
10
|
+
let(:billing_methods) { double('billing_methods') }
|
11
|
+
let(:machine) { double('machine') }
|
12
|
+
let(:method1) { OpenStruct.new({:billing_oid => 1012, :billing_method_type => 'TS_WIRE', :description => 'Wire Transfer'}) }
|
13
|
+
let(:method2) { OpenStruct.new({:billing_oid => 2000, :billing_method_type => 'TS_CARD', :description => 'Credit Card'}) }
|
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
|
+
billing_methods.stub(:each).and_yield(method1).and_yield(method2)
|
24
|
+
os.stub(:billing_methods) { billing_methods }
|
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 billing_methods listing' do
|
37
|
+
expect(env[:rimu_api].billing_methods).to receive(:each)
|
38
|
+
rows = []
|
39
|
+
[method1, method2].each do |b|
|
40
|
+
rows << [b.billing_oid, b.billing_method_type, b.description]
|
41
|
+
end
|
42
|
+
table = Terminal::Table.new headings: ['ID', 'Type', 'Description'], rows: rows
|
43
|
+
expect(env[:ui]).to receive(:info).with("\n#{table}")
|
44
|
+
expect(app).to receive(:call)
|
45
|
+
@action = VagrantPlugins::Rimu::Actions::BillingMethods.new(app, env)
|
46
|
+
@action.call(env)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -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
|
@@ -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::IsCreated 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 created' do
|
30
|
+
it 'returns true' do
|
31
|
+
env[:machine].state.stub(:id) { :off }
|
32
|
+
expect(app).to receive(:call)
|
33
|
+
@action = VagrantPlugins::Rimu::Actions::IsCreated.new(app, env)
|
34
|
+
@action.call(env)
|
35
|
+
env[:result].should == true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when server is not created' do
|
40
|
+
it 'returns false' do
|
41
|
+
env[:machine].state.stub(:id) { :not_created }
|
42
|
+
expect(app).to receive(:call)
|
43
|
+
@action = VagrantPlugins::Rimu::Actions::IsCreated.new(app, env)
|
44
|
+
@action.call(env)
|
45
|
+
env[:result].should == false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|