vagrant-rimu 0.0.1
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 +7 -0
- data/.codeclimate.yml +12 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.rubocop.yml +1170 -0
- data/.travis.yml +55 -0
- data/Gemfile +23 -0
- data/LICENSE +373 -0
- data/README.md +109 -0
- data/Rakefile +6 -0
- data/Vagrantfile +6 -0
- data/gemfiles/vagrant_1.5.gemfile +18 -0
- data/gemfiles/vagrant_1.6.gemfile +18 -0
- data/gemfiles/vagrant_1.7.gemfile +18 -0
- data/lib/vagrant-rimu/actions/billing_methods.rb +20 -0
- data/lib/vagrant-rimu/actions/connect_to_rimu.rb +23 -0
- data/lib/vagrant-rimu/actions/create.rb +91 -0
- data/lib/vagrant-rimu/actions/is_created.rb +16 -0
- data/lib/vagrant-rimu/actions/is_stopped.rb +17 -0
- data/lib/vagrant-rimu/actions/list_distributions.rb +20 -0
- data/lib/vagrant-rimu/actions/list_servers.rb +20 -0
- data/lib/vagrant-rimu/actions/message_already_created.rb +16 -0
- data/lib/vagrant-rimu/actions/message_already_off.rb +16 -0
- data/lib/vagrant-rimu/actions/message_not_created.rb +16 -0
- data/lib/vagrant-rimu/actions/message_will_not_destroy.rb +17 -0
- data/lib/vagrant-rimu/actions/modify_provision_path.rb +37 -0
- data/lib/vagrant-rimu/actions/move.rb +22 -0
- data/lib/vagrant-rimu/actions/read_ssh_info.rb +43 -0
- data/lib/vagrant-rimu/actions/read_state.rb +37 -0
- data/lib/vagrant-rimu/actions/rebuild.rb +52 -0
- data/lib/vagrant-rimu/actions/reload.rb +23 -0
- data/lib/vagrant-rimu/actions/setup_sudo.rb +43 -0
- data/lib/vagrant-rimu/actions/setup_user.rb +68 -0
- data/lib/vagrant-rimu/actions/start_instance.rb +29 -0
- data/lib/vagrant-rimu/actions/stop_instance.rb +26 -0
- data/lib/vagrant-rimu/actions/terminate_instance.rb +26 -0
- data/lib/vagrant-rimu/actions.rb +237 -0
- data/lib/vagrant-rimu/commands/billing_methods.rb +18 -0
- data/lib/vagrant-rimu/commands/distributions.rb +18 -0
- data/lib/vagrant-rimu/commands/list_servers.rb +18 -0
- data/lib/vagrant-rimu/commands/move.rb +18 -0
- data/lib/vagrant-rimu/commands/rebuild.rb +20 -0
- data/lib/vagrant-rimu/commands/root.rb +67 -0
- data/lib/vagrant-rimu/config.rb +190 -0
- data/lib/vagrant-rimu/errors.rb +21 -0
- data/lib/vagrant-rimu/plugin.rb +80 -0
- data/lib/vagrant-rimu/provider.rb +54 -0
- data/lib/vagrant-rimu/version.rb +5 -0
- data/lib/vagrant-rimu.rb +20 -0
- data/locales/en.yml +79 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/vagrant-rimu/actions/connect_to_rimu_spec.rb +38 -0
- data/spec/vagrant-rimu/actions/message_already_created_spec.rb +33 -0
- data/spec/vagrant-rimu/actions/message_already_off_spec.rb +33 -0
- data/spec/vagrant-rimu/actions/message_not_created_spec.rb +33 -0
- data/spec/vagrant-rimu/actions/message_will_not_destroy_spec.rb +36 -0
- data/spec/vagrant-rimu/actions/modify_provision_path_spec.rb +81 -0
- data/spec/vagrant-rimu/actions/read_ssh_info_spec.rb +62 -0
- data/spec/vagrant-rimu/actions/read_state_spec.rb +59 -0
- data/spec/vagrant-rimu/actions/rebuild_spec.rb +148 -0
- data/spec/vagrant-rimu/actions/reload_spec.rb +42 -0
- data/spec/vagrant-rimu/actions/setup_sudo_spec.rb +94 -0
- data/spec/vagrant-rimu/actions/setup_user_spec.rb +78 -0
- data/spec/vagrant-rimu/actions/start_instance_spec.rb +64 -0
- data/spec/vagrant-rimu/actions/stop_instance_spec.rb +57 -0
- data/spec/vagrant-rimu/actions/terminate_instance_spec.rb +54 -0
- data/spec/vagrant-rimu/actions_spec.rb +22 -0
- data/spec/vagrant-rimu/commands/billing_methods_spec.rb +4 -0
- data/spec/vagrant-rimu/commands/distributions_spec.rb +4 -0
- data/spec/vagrant-rimu/commands/list_servers_spec.rb +4 -0
- data/spec/vagrant-rimu/commands/move_spec.rb +4 -0
- data/spec/vagrant-rimu/commands/rebuild_spec.rb +4 -0
- data/spec/vagrant-rimu/commands/root_spec.rb +4 -0
- data/spec/vagrant-rimu/config_spec.rb +162 -0
- data/spec/vagrant-rimu/provider_spec.rb +13 -0
- data/test/Vagrantfile +30 -0
- data/test/scripts/provision.sh +3 -0
- data/test/test.sh +12 -0
- data/test/test_rimu_id_rsa +51 -0
- data/test/test_rimu_id_rsa.pub +1 -0
- data/vagrant-rimu.gemspec +25 -0
- metadata +238 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
require "vagrant-rimu/actions"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Rimu
|
5
|
+
class Provider < Vagrant.plugin('2', :provider)
|
6
|
+
|
7
|
+
def initialize(machine)
|
8
|
+
@machine = machine
|
9
|
+
end
|
10
|
+
|
11
|
+
def action(name)
|
12
|
+
# Attempt to get the action method from the Action class if it
|
13
|
+
# exists, otherwise return nil to show that we don't support the
|
14
|
+
# given action.
|
15
|
+
action_method = "action_#{name}"
|
16
|
+
return Actions.send(action_method) if Actions.respond_to?(action_method)
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def ssh_info
|
21
|
+
# Run a custom action called "read_ssh_info" which does what it
|
22
|
+
# says and puts the resulting SSH info into the `:machine_ssh_info`
|
23
|
+
# key in the environment.
|
24
|
+
env = @machine.action("read_ssh_info")
|
25
|
+
env[:machine_ssh_info]
|
26
|
+
end
|
27
|
+
|
28
|
+
def state
|
29
|
+
# Run a custom action we define called "read_state" which does
|
30
|
+
# what it says. It puts the state in the `:machine_state_id`
|
31
|
+
# key in the environment.
|
32
|
+
env = @machine.action("read_state")
|
33
|
+
|
34
|
+
state_id = env[:machine_state_id]
|
35
|
+
|
36
|
+
# Get the short and long description
|
37
|
+
short = I18n.t("vagrant_rimu.states.short_#{state_id}")
|
38
|
+
long = I18n.t("vagrant_rimu.states.long_#{state_id}")
|
39
|
+
|
40
|
+
# Return the MachineState object
|
41
|
+
Vagrant::MachineState.new(state_id, short, long)
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_s
|
45
|
+
if @machine.respond_to?('id') and ! @machine.id.nil?
|
46
|
+
id = @machine.id
|
47
|
+
else
|
48
|
+
id = 'new'
|
49
|
+
end
|
50
|
+
"Rimu (#{id})"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/lib/vagrant-rimu.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
require 'vagrant-rimu/plugin'
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module Rimu
|
7
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-rimu", __FILE__))
|
8
|
+
autoload :Errors, lib_path.join('errors')
|
9
|
+
|
10
|
+
def self.source_root
|
11
|
+
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.public_key(private_key_path)
|
15
|
+
File.read("#{private_key_path}.pub")
|
16
|
+
rescue
|
17
|
+
raise Errors::PublicKeyError, :path => "#{private_key_path}.pub"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
en:
|
2
|
+
vagrant_rimu:
|
3
|
+
off: |-
|
4
|
+
VPS is off
|
5
|
+
creating: |-
|
6
|
+
Creating a new VPS...
|
7
|
+
ready: |-
|
8
|
+
Machine is booted and ready for use!
|
9
|
+
not_created: |-
|
10
|
+
The VPS is not created. Please run `vagrant up` first.
|
11
|
+
already_status: |-
|
12
|
+
The VPS is already %{status}.
|
13
|
+
starting: |-
|
14
|
+
Starting the VPS...
|
15
|
+
stopping: |-
|
16
|
+
Stopping the VPS...
|
17
|
+
terminating: |-
|
18
|
+
Terminating the VPS...
|
19
|
+
waiting_for_ready: |-
|
20
|
+
Waiting for VPS to become "ready"...
|
21
|
+
will_not_destroy: |-
|
22
|
+
The VPS '%{name}' will not be destroyed, since the confirmation
|
23
|
+
was declined.
|
24
|
+
ip_address: |-
|
25
|
+
Assigned IP address: %{ip}
|
26
|
+
creating_user: "Creating user account: %{user}..."
|
27
|
+
modifying_sudo: "Modifying sudoers file to remove tty requirement..."
|
28
|
+
reloading: "Rebooting the VPS..."
|
29
|
+
rebuilding: "Rebuilding the VPS..."
|
30
|
+
config:
|
31
|
+
api_key: "The RIMU API Key option: [api_key] is required"
|
32
|
+
host_name: "The Host name option: [host_name] is required"
|
33
|
+
invalid_host_name: |-
|
34
|
+
Host name: %{host_name} is not a fully qualified domain name (FQDN)
|
35
|
+
private_key: "A valid SSH private key path option: [private_key_path] is required"
|
36
|
+
missing_private_key: "SSH private key not found: %{key}"
|
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
|
+
states:
|
58
|
+
short_not_created: |-
|
59
|
+
not created
|
60
|
+
long_not_created: |-
|
61
|
+
The VPS is not created. Run `vagrant up` to create it.
|
62
|
+
short_starting: |-
|
63
|
+
starting
|
64
|
+
long_starting: |-
|
65
|
+
The VPS is starting.
|
66
|
+
short_stopped: |-
|
67
|
+
stopped
|
68
|
+
long_stopped: |-
|
69
|
+
The VPS is stopped. Run `vagrant up` to start it.
|
70
|
+
short_stopping: |-
|
71
|
+
stopping
|
72
|
+
long_stopping: |-
|
73
|
+
The VPS is stopping. Wait until is completely stopped to
|
74
|
+
run `vagrant up` and start it.
|
75
|
+
short_running: |-
|
76
|
+
running
|
77
|
+
long_running: |-
|
78
|
+
The VPS is running. To stop this machine, you can run
|
79
|
+
`vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
require 'codeclimate-test-reporter'
|
4
|
+
|
5
|
+
SimpleCov.start
|
6
|
+
if ENV['CI']=='true'
|
7
|
+
require 'codecov'
|
8
|
+
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
9
|
+
Coveralls.wear!
|
10
|
+
CodeClimate::TestReporter.start
|
11
|
+
end
|
12
|
+
|
13
|
+
Dir['lib/**/*.rb'].each do|file|
|
14
|
+
require_string = file.match(/lib\/(.*)\.rb/)[1]
|
15
|
+
require require_string
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'rspec/its'
|
19
|
+
|
20
|
+
I18n.load_path << File.expand_path('locales/en.yml', Pathname.new(File.expand_path('../../', __FILE__)))
|
21
|
+
|
22
|
+
RSpec.configure do |config|
|
23
|
+
config.mock_with :rspec do |c|
|
24
|
+
c.syntax = [:should, :expect]
|
25
|
+
end
|
26
|
+
config.expect_with :rspec do |c|
|
27
|
+
c.syntax = [:should, :expect]
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VagrantPlugins::Rimu::Actions::ConnectToRimu do
|
4
|
+
let(:app) do
|
5
|
+
double.tap do |app|
|
6
|
+
app.stub(:call)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:config) do
|
11
|
+
double.tap do |config|
|
12
|
+
config.stub(:api_url) { nil }
|
13
|
+
config.stub(:api_key) { 'foo' }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:env) do
|
18
|
+
{}.tap do |env|
|
19
|
+
env[:ui] = double
|
20
|
+
env[:ui].stub(:info).with(anything)
|
21
|
+
env[:ui].stub(:warn).with(anything)
|
22
|
+
env[:machine] = double('machine')
|
23
|
+
env[:machine].stub(:provider_config) { config }
|
24
|
+
env[:rimu_api] = double('rimu_api')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
before :each do
|
29
|
+
@action = VagrantPlugins::Rimu::Actions::ConnectToRimu.new(app, env)
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'ConnectToRimu' do
|
33
|
+
it 'set the correct api_key' do
|
34
|
+
@action.call(env)
|
35
|
+
expect(env[:rimu_api].api_key).to eq('foo')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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::MessageAlreadyCreated do
|
10
|
+
let(:env) do
|
11
|
+
{}.tap do |env|
|
12
|
+
env[:ui] = double('ui').tap do |ui|
|
13
|
+
ui.stub(:info).with(anything)
|
14
|
+
ui.stub(:error).with(anything)
|
15
|
+
end
|
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
|
+
expect(I18n).to receive(:t).with('vagrant_rimu.already_status', :status => 'created')
|
28
|
+
expect(app).to receive(:call)
|
29
|
+
@action = VagrantPlugins::Rimu::Actions::MessageAlreadyCreated.new(app, env)
|
30
|
+
@action.call(env)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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::MessageAlreadyOff do
|
10
|
+
let(:env) do
|
11
|
+
{}.tap do |env|
|
12
|
+
env[:ui] = double('ui').tap do |ui|
|
13
|
+
ui.stub(:info).with(anything)
|
14
|
+
ui.stub(:error).with(anything)
|
15
|
+
end
|
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
|
+
expect(I18n).to receive(:t).with('vagrant_rimu.already_status', :status => :off)
|
28
|
+
expect(app).to receive(:call)
|
29
|
+
@action = VagrantPlugins::Rimu::Actions::MessageAlreadyOff.new(app, env)
|
30
|
+
@action.call(env)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
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::MessageNotCreated do
|
10
|
+
let(:env) do
|
11
|
+
{}.tap do |env|
|
12
|
+
env[:ui] = double('ui').tap do |ui|
|
13
|
+
ui.stub(:info).with(anything)
|
14
|
+
ui.stub(:error).with(anything)
|
15
|
+
end
|
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
|
+
expect(I18n).to receive(:t).with('vagrant_rimu.not_created')
|
28
|
+
expect(app).to receive(:call)
|
29
|
+
@action = VagrantPlugins::Rimu::Actions::MessageNotCreated.new(app, env)
|
30
|
+
@action.call(env)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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::MessageWillNotDestroy do
|
10
|
+
let(:env) do
|
11
|
+
{}.tap do |env|
|
12
|
+
env[:ui] = double('ui').tap do |ui|
|
13
|
+
ui.stub(:info).with(anything)
|
14
|
+
ui.stub(:error).with(anything)
|
15
|
+
end
|
16
|
+
env[:machine] = OpenStruct.new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
let(:app) do
|
21
|
+
double('app').tap do |app|
|
22
|
+
app.stub(:call).with(anything)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'call' do
|
27
|
+
it 'sets info variable' do
|
28
|
+
name = 'rimu.example.com'
|
29
|
+
env[:machine].name = name
|
30
|
+
expect(I18n).to receive(:t).with('vagrant_rimu.will_not_destroy', {:name => name})
|
31
|
+
expect(app).to receive(:call)
|
32
|
+
@action = VagrantPlugins::Rimu::Actions::MessageWillNotDestroy.new(app, env)
|
33
|
+
@action.call(env)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,81 @@
|
|
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::ModifyProvisionPath do
|
8
|
+
let(:communicate) { double('communicate') }
|
9
|
+
let(:sudo) { double('sudo') }
|
10
|
+
let(:machine) { double('machine') }
|
11
|
+
let(:ssh_info) { double('ssh_info') }
|
12
|
+
let(:vm) { double('vm') }
|
13
|
+
let(:provisioners) { double('provisioners') }
|
14
|
+
|
15
|
+
let(:provisioner) do
|
16
|
+
double.tap do |p|
|
17
|
+
p.stub(:config) {{:upload_path => '/tmp'}}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:config) do
|
22
|
+
double.tap do |config|
|
23
|
+
provisioners.stub(:each) {
|
24
|
+
[
|
25
|
+
provisioner,
|
26
|
+
provisioner,
|
27
|
+
]
|
28
|
+
}
|
29
|
+
vm.stub(:provisioners) { provisioners }
|
30
|
+
config.stub(:vm) { vm }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:env) do
|
35
|
+
{}.tap do |env|
|
36
|
+
env[:ui] = double('ui').tap do |ui|
|
37
|
+
ui.stub(:info).with(anything)
|
38
|
+
ui.stub(:error).with(anything)
|
39
|
+
end
|
40
|
+
communicate.stub(:sudo) { sudo }
|
41
|
+
machine.stub(:config) { config }
|
42
|
+
ssh_info.stub(:[]) { {:username=>'rimu'} }
|
43
|
+
machine.stub(:ssh_info) { ssh_info }
|
44
|
+
machine.stub(:communicate) { communicate }
|
45
|
+
env[:machine] = machine
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
let(:app) do
|
50
|
+
double('app').tap do |app|
|
51
|
+
app.stub(:call).with(anything)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'call' do
|
56
|
+
context 'when provisioning is not enabled' do
|
57
|
+
it 'should not call provisioners' do
|
58
|
+
env.stub(:has_key?).with(:provision_enabled) { true }
|
59
|
+
expect(env).to receive(:has_key?).with(:provision_enabled)
|
60
|
+
expect(env[:machine]).not_to receive(:ssh_info)
|
61
|
+
expect(env[:machine].config.vm.provisioners).not_to receive(:each)
|
62
|
+
expect(env[:machine].communicate).not_to receive(:sudo)
|
63
|
+
expect(app).to receive(:call)
|
64
|
+
@action = VagrantPlugins::Rimu::Actions::ModifyProvisionPath.new(app, env)
|
65
|
+
@action.call(env)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'when provisioning is enabled' do
|
70
|
+
it 'should call provisioners' do
|
71
|
+
env.stub(:has_key?).with(:provision_enabled) { false }
|
72
|
+
expect(env).to receive(:has_key?).with(:provision_enabled)
|
73
|
+
expect(env[:machine]).to receive(:ssh_info)
|
74
|
+
expect(env[:machine].config.vm.provisioners).to receive(:each)
|
75
|
+
# expect(env[:machine].communicate).to receive(:sudo)
|
76
|
+
@action = VagrantPlugins::Rimu::Actions::ModifyProvisionPath.new(app, env)
|
77
|
+
@action.call(env)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,62 @@
|
|
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::ReadSSHInfo do
|
8
|
+
let(:orders) { double('orders') }
|
9
|
+
let(:machine) { double('machine') }
|
10
|
+
let(:order) { double('order') }
|
11
|
+
let(:allocated_ips) { {:primary_ip=>'192.168.1.1'} }
|
12
|
+
let(:id) { '200' }
|
13
|
+
|
14
|
+
|
15
|
+
let(:env) do
|
16
|
+
{}.tap do |env|
|
17
|
+
env[:ui] = double('ui').tap do |ui|
|
18
|
+
ui.stub(:info).with(anything)
|
19
|
+
ui.stub(:error).with(anything)
|
20
|
+
end
|
21
|
+
env[:rimu_api] = double('rimu_api').tap do |os|
|
22
|
+
order.stub(:allocated_ips) { allocated_ips }
|
23
|
+
orders.stub(:order) { order }
|
24
|
+
os.stub(:orders) { orders }
|
25
|
+
end
|
26
|
+
machine.stub(:id) { id }
|
27
|
+
env[:machine] = machine
|
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
|
+
context 'when machine id is nil' do
|
39
|
+
it 'should not call order' do
|
40
|
+
env[:machine].id.stub(:nil?) { true }
|
41
|
+
expect(env[:machine].id).to receive(:nil?)
|
42
|
+
expect(order).not_to receive(:allocated_ips)
|
43
|
+
expect(env[:rimu_api].orders).not_to receive(:order).with(id.to_i)
|
44
|
+
expect(app).to receive(:call)
|
45
|
+
@action = VagrantPlugins::Rimu::Actions::ReadSSHInfo.new(app, env)
|
46
|
+
@action.call(env)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when machine id is not nil' do
|
51
|
+
it 'should call orders' do
|
52
|
+
env[:machine].id.stub(:nil?) { false }
|
53
|
+
expect(env[:machine].id).to receive(:nil?)
|
54
|
+
expect(order).to receive(:allocated_ips)
|
55
|
+
expect(env[:rimu_api].orders).to receive(:order).with(id.to_i)
|
56
|
+
expect(app).to receive(:call)
|
57
|
+
@action = VagrantPlugins::Rimu::Actions::ReadSSHInfo.new(app, env)
|
58
|
+
@action.call(env)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,59 @@
|
|
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::ReadState do
|
8
|
+
let(:servers) { double('servers') }
|
9
|
+
let(:machine) { double('machine') }
|
10
|
+
let(:status) { double('status') }
|
11
|
+
let(:id) { '200' }
|
12
|
+
|
13
|
+
|
14
|
+
let(:env) do
|
15
|
+
{}.tap do |env|
|
16
|
+
env[:ui] = double('ui').tap do |ui|
|
17
|
+
ui.stub(:info).with(anything)
|
18
|
+
ui.stub(:error).with(anything)
|
19
|
+
end
|
20
|
+
env[:rimu_api] = double('rimu_api').tap do |os|
|
21
|
+
status.stub(:running_state) { 'RUNNING' }
|
22
|
+
servers.stub(:status) { status }
|
23
|
+
os.stub(:servers) { servers }
|
24
|
+
end
|
25
|
+
machine.stub(:id) { id }
|
26
|
+
env[:machine] = machine
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:app) do
|
31
|
+
double('app').tap do |app|
|
32
|
+
app.stub(:call).with(anything)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe 'call' do
|
37
|
+
context 'when machine id is nil' do
|
38
|
+
it 'should not call status' do
|
39
|
+
env[:machine].id.stub(:nil?) { true }
|
40
|
+
expect(env[:machine].id).to receive(:nil?)
|
41
|
+
expect(env[:rimu_api].servers).not_to receive(:status).with(id.to_i)
|
42
|
+
expect(app).to receive(:call)
|
43
|
+
@action = VagrantPlugins::Rimu::Actions::ReadState.new(app, env)
|
44
|
+
@action.call(env)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when machine id is not nil' do
|
49
|
+
it 'should call status' do
|
50
|
+
env[:machine].id.stub(:nil?) { false }
|
51
|
+
expect(env[:machine].id).to receive(:nil?)
|
52
|
+
expect(env[:rimu_api].servers).to receive(:status).with(id.to_i)
|
53
|
+
expect(app).to receive(:call)
|
54
|
+
@action = VagrantPlugins::Rimu::Actions::ReadState.new(app, env)
|
55
|
+
@action.call(env)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|