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.
Files changed (81) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +3 -2
  3. data/.gitignore +2 -0
  4. data/.travis.yml +5 -35
  5. data/Gemfile +4 -2
  6. data/README.md +12 -3
  7. data/Rakefile +6 -3
  8. data/Vagrantfile +12 -3
  9. data/gemfiles/vagrant_1.5.gemfile +3 -1
  10. data/gemfiles/vagrant_1.6.gemfile +5 -3
  11. data/gemfiles/vagrant_1.7.gemfile +10 -8
  12. data/lib/vagrant-rimu.rb +10 -0
  13. data/lib/vagrant-rimu/actions.rb +117 -89
  14. data/lib/vagrant-rimu/actions/abstract_action.rb +20 -0
  15. data/lib/vagrant-rimu/actions/billing_methods.rb +13 -7
  16. data/lib/vagrant-rimu/actions/connect_to_rimu.rb +12 -6
  17. data/lib/vagrant-rimu/actions/create.rb +25 -6
  18. data/lib/vagrant-rimu/actions/is_created.rb +4 -2
  19. data/lib/vagrant-rimu/actions/is_stopped.rb +5 -3
  20. data/lib/vagrant-rimu/actions/list_distributions.rb +13 -7
  21. data/lib/vagrant-rimu/actions/list_servers.rb +13 -7
  22. data/lib/vagrant-rimu/actions/message_action_not_supported.rb +19 -0
  23. data/lib/vagrant-rimu/actions/message_already_created.rb +4 -2
  24. data/lib/vagrant-rimu/actions/message_already_off.rb +4 -2
  25. data/lib/vagrant-rimu/actions/message_not_created.rb +4 -2
  26. data/lib/vagrant-rimu/actions/message_will_not_destroy.rb +4 -2
  27. data/lib/vagrant-rimu/actions/message_will_not_stop.rb +19 -0
  28. data/lib/vagrant-rimu/actions/modify_provision_path.rb +5 -3
  29. data/lib/vagrant-rimu/actions/move.rb +32 -5
  30. data/lib/vagrant-rimu/actions/read_ssh_info.rb +10 -7
  31. data/lib/vagrant-rimu/actions/read_state.rb +14 -6
  32. data/lib/vagrant-rimu/actions/rebuild.rb +34 -6
  33. data/lib/vagrant-rimu/actions/reload.rb +11 -4
  34. data/lib/vagrant-rimu/actions/setup_sudo.rb +15 -8
  35. data/lib/vagrant-rimu/actions/setup_user.rb +45 -25
  36. data/lib/vagrant-rimu/actions/ssh_utils.rb +44 -0
  37. data/lib/vagrant-rimu/actions/start_instance.rb +6 -4
  38. data/lib/vagrant-rimu/actions/stop_instance.rb +18 -7
  39. data/lib/vagrant-rimu/actions/terminate_instance.rb +12 -6
  40. data/lib/vagrant-rimu/commands/abstract_command.rb +47 -0
  41. data/lib/vagrant-rimu/commands/billing_methods.rb +10 -10
  42. data/lib/vagrant-rimu/commands/distributions.rb +10 -10
  43. data/lib/vagrant-rimu/commands/list_servers.rb +10 -10
  44. data/lib/vagrant-rimu/commands/move.rb +10 -10
  45. data/lib/vagrant-rimu/commands/rebuild.rb +5 -7
  46. data/lib/vagrant-rimu/commands/rimu_command.rb +13 -0
  47. data/lib/vagrant-rimu/commands/root.rb +26 -43
  48. data/lib/vagrant-rimu/commands/utils.rb +22 -0
  49. data/lib/vagrant-rimu/config.rb +5 -2
  50. data/lib/vagrant-rimu/errors.rb +6 -0
  51. data/lib/vagrant-rimu/logging.rb +28 -0
  52. data/lib/vagrant-rimu/plugin.rb +11 -37
  53. data/lib/vagrant-rimu/provider.rb +4 -2
  54. data/lib/vagrant-rimu/version.rb +1 -1
  55. data/locales/en.yml +70 -19
  56. data/spec/spec_helper.rb +13 -6
  57. data/spec/vagrant-rimu/actions/billing_methods_spec.rb +49 -0
  58. data/spec/vagrant-rimu/actions/connect_to_rimu_spec.rb +2 -1
  59. data/spec/vagrant-rimu/actions/create_spec.rb +167 -0
  60. data/spec/vagrant-rimu/actions/is_created_spec.rb +49 -0
  61. data/spec/vagrant-rimu/actions/is_stopped_spec.rb +49 -0
  62. data/spec/vagrant-rimu/actions/list_distributions_spec.rb +49 -0
  63. data/spec/vagrant-rimu/actions/list_servers_spec.rb +51 -0
  64. data/spec/vagrant-rimu/actions/message_action_not_supported_spec.rb +30 -0
  65. data/spec/vagrant-rimu/actions/message_already_created_spec.rb +1 -4
  66. data/spec/vagrant-rimu/actions/message_will_not_destroy_spec.rb +1 -2
  67. data/spec/vagrant-rimu/actions/message_will_not_stop_spec.rb +35 -0
  68. data/spec/vagrant-rimu/actions/modify_provision_path_spec.rb +2 -7
  69. data/spec/vagrant-rimu/actions/move_spec.rb +75 -0
  70. data/spec/vagrant-rimu/actions/read_ssh_info_spec.rb +21 -0
  71. data/spec/vagrant-rimu/actions/rebuild_spec.rb +7 -1
  72. data/spec/vagrant-rimu/actions/stop_instance_spec.rb +4 -4
  73. data/spec/vagrant-rimu/commands/billing_methods_spec.rb +17 -0
  74. data/spec/vagrant-rimu/commands/distributions_spec.rb +17 -0
  75. data/spec/vagrant-rimu/commands/list_servers_spec.rb +17 -0
  76. data/spec/vagrant-rimu/commands/move_spec.rb +17 -0
  77. data/spec/vagrant-rimu/commands/rebuild_spec.rb +20 -0
  78. data/spec/vagrant-rimu/config_spec.rb +1 -1
  79. data/test/Vagrantfile +4 -2
  80. data/vagrant-rimu.gemspec +5 -1
  81. metadata +81 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6c675f9671332b0e50e5fd18569609f0b24798f7
4
- data.tar.gz: f78da593a48552622d63927c7622d434c6c0ce0a
2
+ SHA256:
3
+ metadata.gz: b72c29d0587540ea39b084634d97352f70e74e2f1b1f8a3b501eaa14322db90a
4
+ data.tar.gz: 0dc31d0bb2eccd623bc34ba83be3cb574970a75477892b296e1139ab2e940c6d
5
5
  SHA512:
6
- metadata.gz: bed1ab227be52d43cadffc554a37ca9d5976686b76247ed57eb690f15d8bdaefef4cb4c2b76ccd83a2896a523b746d3ab4c7232cc79d9e8be37dd36865ff8064
7
- data.tar.gz: 4423dff4fad2fa4d33cf717613ad89a5433269da657629fb7ebf3cbb24a6742290e45945248d2479cb413cbb660994ad52632acd0a9bc33c4f0278a29624a159
6
+ metadata.gz: a150d07523a6c9b0d5e2be0aa5202fd1c7a7f71d1fdc40d44a58f8a3e852eb2b8c378b5e4ddb50f9a11ea408973c65a58e14fb093c466b99ba568a639a9e74b8
7
+ data.tar.gz: 171a02b5a4832f2fd979c276490dfeb8242e8d86ac12abb779791b4c77f8d5f59b2ec05a3a1a3bbda85ef915c5c224d586182624629e5719eeea3a28922665d7
@@ -8,5 +8,6 @@ ratings:
8
8
  paths:
9
9
  - "**.rb"
10
10
  exclude_paths:
11
- - spec/**/*
12
- - test/**/*
11
+ - "**.yml"
12
+ - spec/**/*
13
+ - test/**/*
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
  /pkg/
10
10
  /spec/reports/
11
11
  /tmp/
12
+ /.vagrant
13
+ intial.txt
@@ -1,51 +1,21 @@
1
1
  language: ruby
2
- script: bundle exec rspec spec
2
+ script: bundle exec rake
3
3
  before_install:
4
4
  - rvm @global do gem uninstall bundler --all --force --executables
5
5
  - gem uninstall bundler --all --force --executables
6
6
  - gem install bundler -v "$BUNDLER_VERSION"
7
7
  # bundler_args: --without development
8
+ install:
9
+ - travis_retry bundle install
8
10
  addons:
9
11
  code_climate:
10
12
  repo_token: 3a5d0d815b7e9bc2c6b4608f74babd935d43fa564cd9041944dfd221f593a4db
11
13
  matrix:
12
14
  include:
13
15
  - gemfile: Gemfile
14
- rvm: 2.2.1
16
+ rvm: 2.3.0
15
17
  env:
16
- BUNDLER_VERSION='>= 1.5.2, < 1.8.0'
17
- - gemfile: Gemfile
18
- rvm: 2.1.4
19
- env:
20
- BUNDLER_VERSION='>= 1.5.2, < 1.8.0'
21
- - gemfile: Gemfile
22
- rvm: 2.0.0
23
- env:
24
- BUNDLER_VERSION='>= 1.5.2, < 1.8.0'
25
- - gemfile: gemfiles/vagrant_1.6.gemfile
26
- rvm: 2.2.1
27
- env:
28
- BUNDLER_VERSION='>= 1.5.2, < 1.7.0'
29
- - gemfile: gemfiles/vagrant_1.6.gemfile
30
- rvm: 2.1.4
31
- env:
32
- BUNDLER_VERSION='>= 1.5.2, < 1.7.0'
33
- - gemfile: gemfiles/vagrant_1.6.gemfile
34
- rvm: 2.0.0
35
- env:
36
- BUNDLER_VERSION='>= 1.5.2, < 1.7.0'
37
- # - gemfile: gemfiles/vagrant_1.5.gemfile
38
- # rvm: 2.2.1
39
- # env:
40
- # BUNDLER_VERSION='= 1.5.2'
41
- - gemfile: gemfiles/vagrant_1.5.gemfile
42
- rvm: 2.1.4
43
- env:
44
- BUNDLER_VERSION='= 1.5.2'
45
- - gemfile: gemfiles/vagrant_1.5.gemfile
46
- rvm: 2.0.0
47
- env:
48
- BUNDLER_VERSION='= 1.5.2'
18
+ BUNDLER_VERSION='1.7.9'
49
19
 
50
20
  notifications:
51
21
  email:
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gemspec
4
+
3
5
  group :test do
4
6
  gem 'codecov', :require => false
5
7
  gem 'simplecov', :require => false
@@ -14,10 +16,10 @@ group :development do
14
16
  else
15
17
  gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant.git'
16
18
  end
19
+ gem 'rubocop', '~> 0.49.0', :require => false
17
20
  end
18
21
 
19
22
  group :plugins do
20
- gem 'bundler', '>= 1.5.2', '< 1.8.0'
23
+ gem 'bundler', '1.7.9'
21
24
  gem 'vagrant-rimu', :path => '.'
22
- gemspec
23
25
  end
data/README.md CHANGED
@@ -4,9 +4,9 @@
4
4
  management of [Rimuhosting](https://www.rimuhosting.com/) VPS's.
5
5
 
6
6
  [![Build Status](https://travis-ci.org/akissa/vagrant-rimu.svg?branch=master)](https://travis-ci.org/akissa/vagrant-rimu)
7
- [![codecov.io](https://codecov.io/github/akissa/vagrant-rimu/coverage.svg?branch=master)](https://codecov.io/github/akissa/vagrant-rimu?branch=master)
8
7
  [![Code Climate](https://codeclimate.com/github/akissa/vagrant-rimu/badges/gpa.svg)](https://codeclimate.com/github/akissa/vagrant-rimu)
9
8
  [![Test Coverage](https://codeclimate.com/github/akissa/vagrant-rimu/badges/coverage.svg)](https://codeclimate.com/github/akissa/vagrant-rimu/coverage)
9
+ [![Gem Version](https://badge.fury.io/rb/vagrant-rimu.svg)](https://badge.fury.io/rb/vagrant-rimu)
10
10
  [![MPLv2 License](https://img.shields.io/badge/license-MPLv2-blue.svg?style=flat-square)](https://www.mozilla.org/MPL/2.0/)
11
11
 
12
12
  Current Features include:
@@ -36,6 +36,7 @@ The most basic `Vagrantfile` to create a VPS on Rimu is shown below
36
36
  Vagrant.configure('2') do |config|
37
37
 
38
38
  config.vm.provider :rimu do |provider, override|
39
+ override.ssh.insert_key = true
39
40
  override.ssh.private_key_path = '~/.ssh/id_rsa'
40
41
 
41
42
  provider.api_key = 'YOUR RIMU API KEY'
@@ -91,8 +92,16 @@ The provider supports the following Vagrant sub-commands:
91
92
  - `vagrant status` - Outputs the status (active, off, not created) for the
92
93
  Rimu VPS.
93
94
  - `vagrant ssh` - Logs into the Rimu VPS using the configured user account.
94
- - `vagrant rimu` - Moves a VPS to a different host and provides info on
95
- distributions, servers and billing_methods
95
+ - `vagrant rimu` - Rimu provider specific commands
96
+
97
+ **Rimu Specific Commands**
98
+
99
+ The Rimu specific commands are available as sub commands of `vagrant rimu`.
100
+ The `vagrant rimu` command provides the following sub commands:
101
+ - `distributions` - Lists the distributions supported.
102
+ - `servers` - Lists the servers under your account.
103
+ - `billing methods` - Lists the billing methods setup for your account.
104
+ - `move-vps` - Moves your VPS to a different host.
96
105
 
97
106
  ## Contributing
98
107
 
data/Rakefile CHANGED
@@ -1,6 +1,9 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
6
- task :default => :spec
7
+ RuboCop::RakeTask.new
8
+
9
+ task default: %w(rubocop spec)
@@ -1,6 +1,15 @@
1
1
  REQUIRED_PLUGINS = %w(vagrant-rimu)
2
+ abort "Please set the environment variable RIMU_API_KEY in order to run vagrant with the rimu provider" unless ENV.key? 'RIMU_API_KEY'
2
3
 
3
- # Vagrant::Config.run do |config|
4
- Vagrant.configure(2) do |config|
5
- config.vm.box = "precise64"
4
+ Vagrant.configure('2') do |config|
5
+ config.ssh.insert_key = true
6
+ config.vm.synced_folder '.', '/vagrant', :disabled => true
7
+ config.vm.provider :rimu do |provider, override|
8
+ override.ssh.private_key_path = 'test/test_rimu_id_rsa'
9
+ override.ssh.insert_key = true
10
+ provider.api_key = ENV['RIMU_API_KEY']
11
+ provider.host_name = 'rimu.example.com'
12
+ provider.disk_space_mb = 4000
13
+ end
14
+ config.vm.provision "shell", inline: "echo 'done' > ~/provision"
6
15
  end
@@ -1,7 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gemspec :path => '../'
4
+
3
5
  group :development do
4
6
  gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.5.4'
7
+ gem 'rubocop', '~> 0.29.0', :require => false
5
8
  end
6
9
 
7
10
  group :test do
@@ -14,5 +17,4 @@ end
14
17
  group :plugins do
15
18
  gem 'bundler', '= 1.5.2'
16
19
  gem 'vagrant-rimu', :path => '../'
17
- gemspec :path => '../'
18
20
  end
@@ -1,7 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- group :development do
4
- gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.6.5'
3
+ gemspec :path => '../'
4
+
5
+ group :development do
6
+ gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.6.5'
7
+ gem 'rubocop', '~> 0.29.0', :require => false
5
8
  end
6
9
 
7
10
  group :test do
@@ -14,5 +17,4 @@ end
14
17
  group :plugins do
15
18
  gem 'bundler', '>= 1.5.2', '< 1.7.0'
16
19
  gem 'vagrant-rimu', :path => '../'
17
- gemspec :path => '../'
18
20
  end
@@ -1,18 +1,20 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gemspec :path => '../'
4
+
3
5
  group :development do
4
- gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.7.1'
6
+ gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.7.1'
7
+ gem 'rubocop', '~> 0.29.0', :require => false
5
8
  end
6
9
 
7
10
  group :test do
8
- gem 'codecov', :require => false
9
- gem 'simplecov', :require => false
10
- gem 'coveralls', :require => false
11
- gem 'codeclimate-test-reporter', require: false
11
+ gem 'codecov', :require => false
12
+ gem 'simplecov', :require => false
13
+ gem 'coveralls', :require => false
14
+ gem 'codeclimate-test-reporter', require: false
12
15
  end
13
16
 
14
17
  group :plugins do
15
- gem 'bundler', '>= 1.5.2', '< 1.8.0'
16
- gem 'vagrant-rimu', :path => '../'
17
- gemspec :path => '../'
18
+ gem 'bundler', '>= 1.5.2', '< 1.8.0'
19
+ gem 'vagrant-rimu', :path => '../'
18
20
  end
@@ -1,11 +1,21 @@
1
1
  require 'pathname'
2
2
 
3
3
  require 'vagrant-rimu/plugin'
4
+ require 'vagrant-rimu/logging'
4
5
 
5
6
  module VagrantPlugins
6
7
  module Rimu
7
8
  lib_path = Pathname.new(File.expand_path("../vagrant-rimu", __FILE__))
8
9
  autoload :Errors, lib_path.join('errors')
10
+
11
+ def self.init_i18n
12
+ I18n.load_path << File.expand_path('locales/en.yml', source_root)
13
+ I18n.reload!
14
+ end
15
+
16
+ def self.init_logging
17
+ Logging.init
18
+ end
9
19
 
10
20
  def self.source_root
11
21
  @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
@@ -4,25 +4,26 @@ require 'vagrant/action/builder'
4
4
 
5
5
  module VagrantPlugins
6
6
  module Rimu
7
+ # rubocop:disable Metrics/ModuleLength
7
8
  module Actions
8
9
  include Vagrant::Action::Builtin
9
10
 
10
11
  # This action is called to terminate the remote machine.
11
12
  def self.action_destroy
12
- Vagrant::Action::Builder.new.tap do |b|
13
- b.use Call, DestroyConfirm do |env, b2|
13
+ new_builder.tap do |b|
14
+ b.use Call, DestroyConfirm do |env, b1|
14
15
  if env[:result]
15
- b2.use ConfigValidate
16
- b.use Call, IsCreated do |env2, b3|
17
- if !env2[:result]
18
- b3.use MessageNotCreated
19
- next
16
+ b1.use ConfigValidate
17
+ b1.use ConnectToRimu
18
+ b1.use Call, ReadState do |env1, b2|
19
+ if env1[:machine_state] == :not_created
20
+ b2.use MessageNotCreated
21
+ else
22
+ b2.use TerminateInstance
20
23
  end
21
24
  end
22
- b2.use ConnectToRimu
23
- b2.use TerminateInstance
24
25
  else
25
- b2.use MessageWillNotDestroy
26
+ b1.use MessageWillNotDestroy
26
27
  end
27
28
  end
28
29
  end
@@ -32,7 +33,7 @@ module VagrantPlugins
32
33
  # resulting state is expected to be put into the `:machine_ssh_info`
33
34
  # key.
34
35
  def self.action_read_ssh_info
35
- Vagrant::Action::Builder.new.tap do |b|
36
+ new_builder.tap do |b|
36
37
  b.use ConfigValidate
37
38
  b.use ConnectToRimu
38
39
  b.use ReadSSHInfo
@@ -40,10 +41,10 @@ module VagrantPlugins
40
41
  end
41
42
 
42
43
  # This action is called to read the state of the machine. The
43
- # resulting state is expected to be put into the `:machine_state_id`
44
+ # resulting state is expected to be put into the `:machine_state`
44
45
  # key.
45
46
  def self.action_read_state
46
- Vagrant::Action::Builder.new.tap do |b|
47
+ new_builder.tap do |b|
47
48
  b.use ConfigValidate
48
49
  b.use ConnectToRimu
49
50
  b.use ReadState
@@ -52,69 +53,69 @@ module VagrantPlugins
52
53
 
53
54
  # This action is called to SSH into the machine.
54
55
  def self.action_ssh
55
- Vagrant::Action::Builder.new.tap do |b|
56
+ new_builder.tap do |b|
56
57
  b.use ConfigValidate
57
- b.use Call, IsCreated do |env, b2|
58
- if !env[:result]
59
- b2.use MessageNotCreated
60
- next
58
+ b.use ConnectToRimu
59
+ b.use Call, ReadState do |env, b1|
60
+ if env[:machine_state] == :not_created
61
+ b1.use MessageNotCreated
62
+ else
63
+ b1.use SSHExec
61
64
  end
62
-
63
- b2.use SSHExec
64
65
  end
65
66
  end
66
67
  end
67
68
 
68
69
  def self.action_ssh_run
69
- Vagrant::Action::Builder.new.tap do |b|
70
+ new_builder.tap do |b|
70
71
  b.use ConfigValidate
71
- b.use Call, IsCreated do |env, b2|
72
- if !env[:result]
73
- b2.use MessageNotCreated
74
- next
72
+ b.use ConnectToRimu
73
+ b.use Call, ReadState do |env, b1|
74
+ if env[:machine_state] == :not_created
75
+ b1.use MessageNotCreated
76
+ else
77
+ b1.use SSHRun
75
78
  end
76
-
77
- b2.use SSHRun
78
79
  end
79
80
  end
80
81
  end
81
82
 
82
83
  # This action is called when `vagrant provision` is called.
83
84
  def self.action_provision
84
- return Vagrant::Action::Builder.new.tap do |builder|
85
- builder.use ConfigValidate
86
- builder.use ConnectToRimu
87
- builder.use Call, IsCreated do |env, b|
85
+ new_builder.tap do |b|
86
+ b.use ConfigValidate
87
+ b.use ConnectToRimu
88
+ b.use Call, ReadState do |env, b1|
88
89
  case env[:machine_state]
89
90
  when :active
90
- b.use Provision
91
- b.use ModifyProvisionPath
92
- b.use SyncedFolders
91
+ b1.use Provision
92
+ b1.use ModifyProvisionPath
93
+ b1.use SyncedFolders
93
94
  when :off
94
95
  env[:ui].info I18n.t('vagrant_rimu.off')
95
96
  when :not_created
96
- b.use MessageNotCreated
97
+ b1.use MessageNotCreated
97
98
  end
98
99
  end
99
100
  end
100
101
  end
101
102
 
102
103
  def self.action_up
103
- return Vagrant::Action::Builder.new.tap do |builder|
104
- builder.use ConfigValidate
105
- builder.use ConnectToRimu
106
- builder.use Call, IsCreated do |env, b|
104
+ new_builder.tap do |b|
105
+ b.use ConfigValidate
106
+ b.use ConnectToRimu
107
+ b.use Call, ReadState do |env, b1|
107
108
  case env[:machine_state]
108
- when :active
109
- b.use MessageAlreadyCreated
110
- when :off
111
- b.use StartInstance
112
- b.use action_provision
113
109
  when :not_created
114
- b.use Create
115
- b.use SetupSudo
116
- b.use SetupUser
117
- b.use action_provision
110
+ b1.use Create
111
+ b1.use SetupSudo
112
+ b1.use SetupUser
113
+ b1.use action_provision
114
+ when :off
115
+ b1.use StartInstance
116
+ b1.use action_provision
117
+ else
118
+ b1.use MessageAlreadyCreated
118
119
  end
119
120
  end
120
121
  end
@@ -122,63 +123,61 @@ module VagrantPlugins
122
123
 
123
124
  # This action is called to halt the remote machine.
124
125
  def self.action_halt
125
- Vagrant::Action::Builder.new.tap do |builder|
126
- builder.use ConfigValidate
127
- builder.use Call, IsCreated do |env, b1|
128
- if env[:result]
129
- b1.use Call, IsStopped do |env2, b2|
130
- if env2[:result]
131
- b2.use MessageAlreadyOff
132
- else
133
- b2.use ConnectToRimu
134
- b2.use PowerOff
135
- end
136
- end
137
- else
138
- b1.use MessageNotCreated
139
- end
140
- end
126
+ new_builder.tap do |b|
127
+ b.use MessageWillNotStop
128
+ # b.use ConfigValidate
129
+ # b.use ConnectToRimu
130
+ # b.use Call, ReadState do |env, b1|
131
+ # case env[:machine_state]
132
+ # when :not_created
133
+ # b1.use MessageNotCreated
134
+ # when :off
135
+ # b1.use MessageAlreadyOff
136
+ # else
137
+ # b1.use StopInstance
138
+ # end
139
+ # end
141
140
  end
142
141
  end
143
142
 
144
143
  def self.action_reload
145
- return Vagrant::Action::Builder.new.tap do |builder|
146
- builder.use ConfigValidate
147
- builder.use ConnectToRimu
148
- builder.use Call, IsCreated do |env, b|
144
+ new_builder.tap do |b|
145
+ b.use ConfigValidate
146
+ b.use ConnectToRimu
147
+ b.use Call, ReadState do |env, b1|
149
148
  case env[:machine_state]
150
- when :active
151
- b.use Reload
152
- b.use action_provision
149
+ when :not_created
150
+ b1.use MessageNotCreated
153
151
  when :off
154
152
  env[:ui].info I18n.t('vagrant_rimu.off')
155
- when :not_created
156
- b.use MessageNotCreated
153
+ else
154
+ b1.use Reload
155
+ b1.use action_provision
157
156
  end
158
157
  end
159
158
  end
160
159
  end
161
160
 
162
161
  def self.action_rebuild
163
- return Vagrant::Action::Builder.new.tap do |builder|
164
- builder.use ConfigValidate
165
- builder.use ConnectToRimu
166
- builder.use Call, IsCreated do |env, b|
162
+ new_builder.tap do |b|
163
+ b.use ConfigValidate
164
+ b.use ConnectToRimu
165
+ b.use Call, ReadState do |env, b1|
167
166
  case env[:machine_state]
168
167
  when :active, :off
169
- b.use Rebuild
170
- b.use SetupSudo
171
- b.use SetupUser
172
- b.use action_provision
168
+ b1.use Rebuild
169
+ b1.use SetupSudo
170
+ b1.use SetupUser
171
+ b1.use action_provision
173
172
  when :not_created
174
- b.use MessageNotCreated
173
+ b1.use MessageNotCreated
175
174
  end
176
175
  end
177
176
  end
178
177
  end
179
178
 
180
179
  def self.action_list_distributions
181
- Vagrant::Action::Builder.new.tap do |b|
180
+ new_builder.tap do |b|
182
181
  b.use ConfigValidate
183
182
  b.use ConnectToRimu
184
183
  b.use ListDistributions
@@ -186,7 +185,7 @@ module VagrantPlugins
186
185
  end
187
186
 
188
187
  def self.action_list_servers
189
- Vagrant::Action::Builder.new.tap do |b|
188
+ new_builder.tap do |b|
190
189
  b.use ConfigValidate
191
190
  b.use ConnectToRimu
192
191
  b.use ListServers
@@ -194,7 +193,7 @@ module VagrantPlugins
194
193
  end
195
194
 
196
195
  def self.action_billing_methods
197
- Vagrant::Action::Builder.new.tap do |b|
196
+ new_builder.tap do |b|
198
197
  b.use ConfigValidate
199
198
  b.use ConnectToRimu
200
199
  b.use BillingMethods
@@ -202,10 +201,31 @@ module VagrantPlugins
202
201
  end
203
202
 
204
203
  def self.action_move
205
- Vagrant::Action::Builder.new.tap do |b|
204
+ new_builder.tap do |b|
206
205
  b.use ConfigValidate
207
206
  b.use ConnectToRimu
208
- b.use Move
207
+ b.use Call, ReadState do |env, b1|
208
+ case env[:machine_state]
209
+ when :active, :off
210
+ b1.use Move
211
+ when :not_created
212
+ b1.use MessageNotCreated
213
+ end
214
+ end
215
+ end
216
+ end
217
+
218
+ def self.action_suspend
219
+ new_builder.tap do |b|
220
+ b.use ConfigValidate
221
+ b.use MessageActionNotSupported
222
+ end
223
+ end
224
+
225
+ def self.action_resume
226
+ new_builder.tap do |b|
227
+ b.use ConfigValidate
228
+ b.use MessageActionNotSupported
209
229
  end
210
230
  end
211
231
 
@@ -213,8 +233,8 @@ module VagrantPlugins
213
233
  autoload :ConnectToRimu, action_root.join('connect_to_rimu')
214
234
  autoload :StopInstance, action_root.join('stop_instance')
215
235
  autoload :TerminateInstance, action_root.join('terminate_instance')
216
- autoload :IsCreated, action_root.join('is_created')
217
- autoload :IsStopped, action_root.join('is_stopped')
236
+ # autoload :IsCreated, action_root.join('is_created')
237
+ # autoload :IsStopped, action_root.join('is_stopped')
218
238
  autoload :ReadSSHInfo, action_root.join('read_ssh_info')
219
239
  autoload :ReadState, action_root.join('read_state')
220
240
  autoload :StartInstance, action_root.join('start_instance')
@@ -232,6 +252,14 @@ module VagrantPlugins
232
252
  autoload :MessageNotCreated, action_root.join('message_not_created')
233
253
  autoload :MessageWillNotDestroy, action_root.join('message_will_not_destroy')
234
254
  autoload :MessageAlreadyCreated, action_root.join('message_already_created')
255
+ autoload :MessageWillNotStop, action_root.join('message_will_not_stop')
256
+ autoload :MessageActionNotSupported, action_root.join('message_action_not_supported')
257
+
258
+ private
259
+
260
+ def self.new_builder
261
+ Vagrant::Action::Builder.new
262
+ end
235
263
  end
236
264
  end
237
265
  end