vagrant-rimu 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +3 -2
  3. data/.travis.yml +3 -1
  4. data/Gemfile +3 -1
  5. data/README.md +1 -2
  6. data/Rakefile +6 -3
  7. data/gemfiles/vagrant_1.5.gemfile +3 -1
  8. data/gemfiles/vagrant_1.6.gemfile +5 -3
  9. data/gemfiles/vagrant_1.7.gemfile +10 -8
  10. data/lib/vagrant-rimu/actions/abstract_action.rb +20 -0
  11. data/lib/vagrant-rimu/actions/billing_methods.rb +11 -4
  12. data/lib/vagrant-rimu/actions/connect_to_rimu.rb +5 -3
  13. data/lib/vagrant-rimu/actions/create.rb +8 -3
  14. data/lib/vagrant-rimu/actions/is_created.rb +4 -2
  15. data/lib/vagrant-rimu/actions/is_stopped.rb +4 -2
  16. data/lib/vagrant-rimu/actions/list_distributions.rb +11 -4
  17. data/lib/vagrant-rimu/actions/list_servers.rb +11 -6
  18. data/lib/vagrant-rimu/actions/message_already_created.rb +4 -2
  19. data/lib/vagrant-rimu/actions/message_already_off.rb +4 -2
  20. data/lib/vagrant-rimu/actions/message_not_created.rb +4 -2
  21. data/lib/vagrant-rimu/actions/message_will_not_destroy.rb +4 -2
  22. data/lib/vagrant-rimu/actions/modify_provision_path.rb +4 -2
  23. data/lib/vagrant-rimu/actions/move.rb +26 -3
  24. data/lib/vagrant-rimu/actions/read_ssh_info.rb +4 -2
  25. data/lib/vagrant-rimu/actions/read_state.rb +4 -2
  26. data/lib/vagrant-rimu/actions/rebuild.rb +7 -2
  27. data/lib/vagrant-rimu/actions/reload.rb +4 -2
  28. data/lib/vagrant-rimu/actions/setup_sudo.rb +15 -8
  29. data/lib/vagrant-rimu/actions/setup_user.rb +35 -24
  30. data/lib/vagrant-rimu/actions/start_instance.rb +4 -2
  31. data/lib/vagrant-rimu/actions/stop_instance.rb +11 -5
  32. data/lib/vagrant-rimu/actions/terminate_instance.rb +4 -2
  33. data/lib/vagrant-rimu/actions.rb +1 -0
  34. data/lib/vagrant-rimu/commands/abstract_command.rb +47 -0
  35. data/lib/vagrant-rimu/commands/billing_methods.rb +10 -10
  36. data/lib/vagrant-rimu/commands/distributions.rb +10 -10
  37. data/lib/vagrant-rimu/commands/list_servers.rb +10 -10
  38. data/lib/vagrant-rimu/commands/move.rb +10 -10
  39. data/lib/vagrant-rimu/commands/rebuild.rb +9 -10
  40. data/lib/vagrant-rimu/commands/rimu_command.rb +13 -0
  41. data/lib/vagrant-rimu/commands/root.rb +26 -43
  42. data/lib/vagrant-rimu/commands/utils.rb +22 -0
  43. data/lib/vagrant-rimu/config.rb +1 -0
  44. data/lib/vagrant-rimu/errors.rb +4 -0
  45. data/lib/vagrant-rimu/version.rb +1 -1
  46. data/locales/en.yml +50 -19
  47. data/spec/vagrant-rimu/actions/billing_methods_spec.rb +4 -4
  48. data/spec/vagrant-rimu/actions/create_spec.rb +164 -0
  49. data/spec/vagrant-rimu/actions/list_distributions_spec.rb +4 -4
  50. data/spec/vagrant-rimu/actions/list_servers_spec.rb +4 -4
  51. data/spec/vagrant-rimu/actions/move_spec.rb +75 -0
  52. data/spec/vagrant-rimu/commands/billing_methods_spec.rb +17 -0
  53. data/spec/vagrant-rimu/commands/distributions_spec.rb +17 -0
  54. data/spec/vagrant-rimu/commands/list_servers_spec.rb +17 -0
  55. data/spec/vagrant-rimu/commands/move_spec.rb +17 -0
  56. data/spec/vagrant-rimu/commands/rebuild_spec.rb +17 -0
  57. data/test/Vagrantfile +1 -1
  58. data/vagrant-rimu.gemspec +2 -0
  59. metadata +58 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a03f01ba13d87cf66c51b6708cfee445ea83faf
4
- data.tar.gz: 967f4fcc6e0f8461e71c3f6509e3378f828407b1
3
+ metadata.gz: 7bb71155b1d915e134acd0b54427600466968a24
4
+ data.tar.gz: 92fea11036f014aa61159e4c5f5e56c359835d9a
5
5
  SHA512:
6
- metadata.gz: ed69f66bd9f6b912a169bf4305ac603eca49ed073f370a81158023b9b48aa8fa0095870d9d018618317888fa01116a9f7f784bdd74d22d8bf32ce119ccb0a12f
7
- data.tar.gz: b8b5f0bac476789a3d08759ce1c1911d379b77cfa767e4298e8dda445e4d8f0a65dfd7c7d6b0b99db3085fa33bc2a9ce1cb61c5a71300131f95a415fc3b37a1f
6
+ metadata.gz: 45df36e60c52b926b9885d6df23764ae3fd33cb43a1bd99c56562327229d70180afd361bcae4aa77bd88f2025bbb9b93a4081326ad769f43fc7d0c426cf8d48c
7
+ data.tar.gz: 6f2502345025c5c978ee3cf89f42b3b20cdbddf7cf040df3fc5891e0314909934cbd84dd003ea049da267713fedfdff1762304c86f9b516bc0300e555b2b2555
data/.codeclimate.yml CHANGED
@@ -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/.travis.yml CHANGED
@@ -1,10 +1,12 @@
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
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.29.0', :require => false
17
20
  end
18
21
 
19
22
  group :plugins do
20
23
  gem 'bundler', '>= 1.5.2', '< 1.8.0'
21
24
  gem 'vagrant-rimu', :path => '.'
22
- gemspec
23
25
  end
data/README.md CHANGED
@@ -4,7 +4,6 @@
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)
10
9
  [![MPLv2 License](https://img.shields.io/badge/license-MPLv2-blue.svg?style=flat-square)](https://www.mozilla.org/MPL/2.0/)
@@ -92,7 +91,7 @@ The provider supports the following Vagrant sub-commands:
92
91
  Rimu VPS.
93
92
  - `vagrant ssh` - Logs into the Rimu VPS using the configured user account.
94
93
  - `vagrant rimu` - Moves a VPS to a different host and provides info on
95
- distributions, servers and billing_methods
94
+ `distributions`, `servers` and `billing methods`
96
95
 
97
96
  ## Contributing
98
97
 
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,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
@@ -0,0 +1,20 @@
1
+ require 'colorize'
2
+
3
+ module VagrantPlugins
4
+ module Rimu
5
+ module Actions
6
+ class AbstractAction
7
+ def call(env)
8
+ execute(env)
9
+ # rubocop:disable Lint/RescueException
10
+ rescue Errors::RimuError, SystemExit, Interrupt => e
11
+ raise e
12
+ rescue Exception => e
13
+ puts I18n.t('vagrant_rimu.errors.global_error').red unless e.message && e.message.start_with?('Caught Error:')
14
+ raise $!, "Caught Error: #{$!}", $!.backtrace
15
+ end
16
+ # rubocop:enable Lint/RescueException
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,16 +1,23 @@
1
+ require 'vagrant-rimu/commands/utils'
2
+ require 'vagrant-rimu/actions/abstract_action'
3
+
1
4
  module VagrantPlugins
2
5
  module Rimu
3
6
  module Actions
4
- class BillingMethods
7
+ class BillingMethods < AbstractAction
8
+ include VagrantPlugins::Rimu::Commands::Utils
9
+
5
10
  def initialize(app, _env)
6
11
  @app = app
7
12
  end
8
13
 
9
- def call(env)
10
- env[:ui].info '%-20s %-20s %s' % ['ID', 'Type', 'Description']
14
+ def execute(env)
15
+ rows = []
11
16
  env[:rimu_api].billing_methods.each do |b|
12
- env[:ui].info '%-20s %-20s %s' % [b.billing_oid, b.billing_method_type, b.description]
17
+ rows << [b.billing_oid, b.billing_method_type, b.description]
13
18
  end
19
+ display_table(env, ['ID', 'Type', 'Description'], rows)
20
+
14
21
  @app.call(env)
15
22
  end
16
23
  end
@@ -1,21 +1,23 @@
1
1
  require 'log4r'
2
2
  require 'rimu'
3
3
 
4
+ require 'vagrant-rimu/actions/abstract_action'
5
+
4
6
  module VagrantPlugins
5
7
  module Rimu
6
8
  module Actions
7
- class ConnectToRimu
9
+ class ConnectToRimu < AbstractAction
8
10
  def initialize(app, env)
9
11
  @app = app
10
12
  @config = env[:machine].provider_config
11
13
  @logger = Log4r::Logger.new('vagrant_rimu::action::connect_to_rimu')
12
14
  end
13
15
 
14
- def call(env)
16
+ def execute(env)
15
17
  @logger.info('Connecting to Rimu api_url...')
16
18
  rimu = ::Rimu::RimuAPI.new({:api_url => @config.api_url, :api_key=> @config.api_key})
17
19
  env[:rimu_api] = rimu
18
- @app.call(env)
20
+ @app.call(env) unless @app.nil?
19
21
  end
20
22
  end
21
23
  end
@@ -1,18 +1,22 @@
1
1
  require 'log4r'
2
2
  require 'vagrant'
3
3
 
4
+ require 'vagrant-rimu/actions/abstract_action'
5
+
4
6
  module VagrantPlugins
5
7
  module Rimu
6
8
  module Actions
7
- class Create
9
+ class Create < AbstractAction
8
10
  include Vagrant::Util::Retryable
11
+
9
12
  def initialize(app, env)
10
13
  @app = app
11
14
  @machine = env[:machine]
12
15
  @logger = Log4r::Logger.new('vagrant::rimu::create')
13
16
  end
14
17
 
15
- def call(env)
18
+ # rubocop:disable Metrics/AbcSize
19
+ def execute(env)
16
20
  client = env[:rimu_api]
17
21
  env[:ui].info I18n.t('vagrant_rimu.creating')
18
22
  params = {
@@ -70,6 +74,7 @@ module VagrantPlugins
70
74
  @machine.config.ssh.username = user
71
75
  @app.call(env)
72
76
  end
77
+ # rubocop:enable Metrics/AbcSize
73
78
 
74
79
  def recover(env)
75
80
  return if env['vagrant.error'].is_a?(Vagrant::Errors::VagrantError)
@@ -83,7 +88,7 @@ module VagrantPlugins
83
88
  destroy_env.delete(:interrupted)
84
89
  destroy_env[:config_validate] = false
85
90
  destroy_env[:force_confirm_destroy] = true
86
- env[:action_runner].run(Actions.destroy, destroy_env)
91
+ env[:action_runner].run(Actions.action_destroy, destroy_env)
87
92
  end
88
93
  end
89
94
  end
@@ -1,12 +1,14 @@
1
+ require 'vagrant-rimu/actions/abstract_action'
2
+
1
3
  module VagrantPlugins
2
4
  module Rimu
3
5
  module Actions
4
- class IsCreated
6
+ class IsCreated < AbstractAction
5
7
  def initialize(app, _env)
6
8
  @app = app
7
9
  end
8
10
 
9
- def call(env)
11
+ def execute(env)
10
12
  env[:result] = env[:machine].state.id != :not_created
11
13
  @app.call(env)
12
14
  end
@@ -1,12 +1,14 @@
1
+ require 'vagrant-rimu/actions/abstract_action'
2
+
1
3
  module VagrantPlugins
2
4
  module Rimu
3
5
  module Actions
4
- class IsStopped
6
+ class IsStopped < AbstractAction
5
7
  def initialize(app, _env)
6
8
  @app = app
7
9
  end
8
10
 
9
- def call(env)
11
+ def execute(env)
10
12
  env[:result] = env[:machine].state.id == :stopped
11
13
 
12
14
  @app.call(env)
@@ -1,16 +1,23 @@
1
+ require 'vagrant-rimu/commands/utils'
2
+ require 'vagrant-rimu/actions/abstract_action'
3
+
1
4
  module VagrantPlugins
2
5
  module Rimu
3
6
  module Actions
4
- class ListDistributions
7
+ class ListDistributions < AbstractAction
8
+ include VagrantPlugins::Rimu::Commands::Utils
9
+
5
10
  def initialize(app, _env)
6
11
  @app = app
7
12
  end
8
13
 
9
- def call(env)
10
- env[:ui].info '%-15s %s' % ['Distro Code', 'Distro Description']
14
+ def execute(env)
15
+ rows = []
11
16
  env[:rimu_api].distributions.each do |dist|
12
- env[:ui].info '%-15s %s' % [dist.distro_code, dist.distro_description]
17
+ rows << [dist.distro_code, dist.distro_description]
13
18
  end
19
+ display_table(env, ['Distro Code', 'Distro Description'], rows)
20
+
14
21
  @app.call(env)
15
22
  end
16
23
  end
@@ -1,18 +1,23 @@
1
+ require 'vagrant-rimu/commands/utils'
2
+ require 'vagrant-rimu/actions/abstract_action'
3
+
1
4
  module VagrantPlugins
2
5
  module Rimu
3
6
  module Actions
4
- class ListServers
7
+ class ListServers < AbstractAction
8
+ include VagrantPlugins::Rimu::Commands::Utils
9
+
5
10
  def initialize(app, _env)
6
11
  @app = app
7
12
  end
8
13
 
9
- def call(env)
10
- heading = '%-10s %-30s %-20s %-15s %-15s' % ['ID', 'Hostname', 'Data Centre', 'Host Server', 'Status']
11
- env[:ui].info heading
14
+ def execute(env)
15
+ rows = []
12
16
  env[:rimu_api].orders.orders.each do |o|
13
- row = '%-10s %-30s %-20s %-15s %-15s' % [o.order_oid, o.domain_name, o.location["data_center_location_code"], o.host_server_oid, o.running_state]
14
- env[:ui].info row
17
+ rows << [o.order_oid, o.domain_name, o.location["data_center_location_code"], o.host_server_oid, o.running_state]
15
18
  end
19
+ display_table(env, ['ID', 'Hostname', 'Data Centre', 'Host Server', 'Status'], rows)
20
+
16
21
  @app.call(env)
17
22
  end
18
23
  end
@@ -1,12 +1,14 @@
1
+ require 'vagrant-rimu/actions/abstract_action'
2
+
1
3
  module VagrantPlugins
2
4
  module Rimu
3
5
  module Actions
4
- class MessageAlreadyCreated
6
+ class MessageAlreadyCreated < AbstractAction
5
7
  def initialize(app, _env)
6
8
  @app = app
7
9
  end
8
10
 
9
- def call(env)
11
+ def execute(env)
10
12
  env[:ui].info(I18n.t('vagrant_rimu.already_status', :status => 'created'))
11
13
  @app.call(env)
12
14
  end
@@ -1,12 +1,14 @@
1
+ require 'vagrant-rimu/actions/abstract_action'
2
+
1
3
  module VagrantPlugins
2
4
  module Rimu
3
5
  module Actions
4
- class MessageAlreadyOff
6
+ class MessageAlreadyOff < AbstractAction
5
7
  def initialize(app, _env)
6
8
  @app = app
7
9
  end
8
10
 
9
- def call(env)
11
+ def execute(env)
10
12
  env[:ui].info(I18n.t("vagrant_rimu.already_status", :status => :off))
11
13
  @app.call(env)
12
14
  end
@@ -1,12 +1,14 @@
1
+ require 'vagrant-rimu/actions/abstract_action'
2
+
1
3
  module VagrantPlugins
2
4
  module Rimu
3
5
  module Actions
4
- class MessageNotCreated
6
+ class MessageNotCreated < AbstractAction
5
7
  def initialize(app, _env)
6
8
  @app = app
7
9
  end
8
10
 
9
- def call(env)
11
+ def execute(env)
10
12
  env[:ui].info(I18n.t('vagrant_rimu.not_created'))
11
13
  @app.call(env)
12
14
  end
@@ -1,13 +1,15 @@
1
+ require 'vagrant-rimu/actions/abstract_action'
2
+
1
3
  module VagrantPlugins
2
4
  module Rimu
3
5
  module Actions
4
- class MessageWillNotDestroy
6
+ class MessageWillNotDestroy < AbstractAction
5
7
  def initialize(app, env)
6
8
  @app = app
7
9
  @machine = env[:machine]
8
10
  end
9
11
 
10
- def call(env)
12
+ def execute(env)
11
13
  env[:ui].info(I18n.t('vagrant_rimu.will_not_destroy', {:name => @machine.name}))
12
14
  @app.call(env)
13
15
  end
@@ -1,16 +1,18 @@
1
1
  require 'log4r'
2
2
 
3
+ require 'vagrant-rimu/actions/abstract_action'
4
+
3
5
  module VagrantPlugins
4
6
  module Rimu
5
7
  module Actions
6
- class ModifyProvisionPath
8
+ class ModifyProvisionPath < AbstractAction
7
9
  def initialize(app, env)
8
10
  @app = app
9
11
  @machine = env[:machine]
10
12
  @logger = Log4r::Logger.new('vagrant::rimu::modify_provision_path')
11
13
  end
12
14
 
13
- def call(env)
15
+ def execute(env)
14
16
  # check if provisioning is enabled
15
17
  enabled = true
16
18
  enabled = env[:provision_enabled] if env.has_key?(:provision_enabled)
@@ -1,19 +1,42 @@
1
1
  require 'log4r'
2
+ require 'vagrant'
3
+
4
+ require 'vagrant-rimu/actions/abstract_action'
2
5
 
3
6
  module VagrantPlugins
4
7
  module Rimu
5
8
  module Actions
6
- class Move
9
+ class Move < AbstractAction
10
+ include Vagrant::Util::Retryable
11
+
7
12
  def initialize(app, env)
8
13
  @app = app
9
14
  @machine = env[:machine]
10
15
  @logger = Log4r::Logger.new('vagrant::rimu::move')
11
16
  end
12
17
 
13
- def call(env)
18
+ # rubocop:disable Metrics/AbcSize
19
+ def execute(env)
14
20
  client = env[:rimu_api]
21
+
15
22
  env[:ui].info I18n.t('vagrant_rimu.move')
16
- fail 'not implemented'
23
+
24
+ result = client.servers.move(@machine.id.to_i)
25
+
26
+ @machine.id = result.order_oid
27
+ env[:ui].info I18n.t('vagrant_rimu.ip_address', {:ip => result.allocated_ips["primary_ip"]})
28
+
29
+ switch_user = @machine.provider_config.setup?
30
+ user = @machine.config.ssh.username
31
+ @machine.config.ssh.username = 'root' if switch_user
32
+
33
+ retryable(:tries => 120, :sleep => 10) do
34
+ next if env[:interrupted]
35
+ raise 'not ready' if !@machine.communicate.ready?
36
+ end
37
+
38
+ @machine.config.ssh.username = user
39
+
17
40
  @app.call(env)
18
41
  end
19
42
  end
@@ -1,18 +1,20 @@
1
1
  require 'log4r'
2
2
 
3
+ require 'vagrant-rimu/actions/abstract_action'
4
+
3
5
  module VagrantPlugins
4
6
  module Rimu
5
7
  module Actions
6
8
  # This action reads the SSH info for the machine and puts it into the
7
9
  # `:machine_ssh_info` key in the environment.
8
- class ReadSSHInfo
10
+ class ReadSSHInfo < AbstractAction
9
11
  def initialize(app, env)
10
12
  @app = app
11
13
  @machine = env[:machine]
12
14
  @logger = Log4r::Logger.new("vagrant_rimu::action::read_ssh_info")
13
15
  end
14
16
 
15
- def call(env)
17
+ def execute(env)
16
18
  client = env[:rimu_api]
17
19
  env[:machine_ssh_info] = read_ssh_info(client, @machine)
18
20
 
@@ -1,16 +1,18 @@
1
1
  require 'log4r'
2
2
 
3
+ require 'vagrant-rimu/actions/abstract_action'
4
+
3
5
  module VagrantPlugins
4
6
  module Rimu
5
7
  module Actions
6
- class ReadState
8
+ class ReadState < AbstractAction
7
9
  def initialize(app, env)
8
10
  @app = app
9
11
  @machine = env[:machine]
10
12
  @logger = Log4r::Logger.new('vagrant_rimu::action::read_state')
11
13
  end
12
14
 
13
- def call(env)
15
+ def execute(env)
14
16
  client = env[:rimu_api]
15
17
  env[:machine_state] = read_state(client, @machine)
16
18
  @logger.info "Machine state is '#{env[:machine_state]}'"
@@ -3,7 +3,7 @@ require 'log4r'
3
3
  module VagrantPlugins
4
4
  module Rimu
5
5
  module Actions
6
- class Rebuild
6
+ class Rebuild < AbstractAction
7
7
  include Vagrant::Util::Retryable
8
8
 
9
9
  def initialize(app, env)
@@ -12,9 +12,11 @@ module VagrantPlugins
12
12
  @logger = Log4r::Logger.new('vagrant::rimu::rebuild')
13
13
  end
14
14
 
15
- def call(env)
15
+ # rubocop:disable Metrics/AbcSize
16
+ def execute(env)
16
17
  client = env[:rimu_api]
17
18
  env[:ui].info I18n.t('vagrant_rimu.rebuilding')
19
+
18
20
  params = {
19
21
  :instantiation_options => {
20
22
  :domain_name => @machine.provider_config.host_name,
@@ -35,7 +37,9 @@ module VagrantPlugins
35
37
  }
36
38
  params.delete(:instantiation_via_clone_options) if @machine.provider_config.vps_to_clone.nil?
37
39
  params.delete(:instantiation_options) if params.has_key?(:instantiation_via_clone_options)
40
+
38
41
  client.servers.reinstall(@machine.id.to_i, params)
42
+
39
43
  switch_user = @machine.provider_config.setup?
40
44
  user = @machine.config.ssh.username
41
45
  @machine.config.ssh.username = 'root' if switch_user
@@ -44,6 +48,7 @@ module VagrantPlugins
44
48
  raise 'not ready' if !@machine.communicate.ready?
45
49
  end
46
50
  @machine.config.ssh.username = user
51
+
47
52
  @app.call(env)
48
53
  end
49
54
  end
@@ -1,16 +1,18 @@
1
1
  require 'log4r'
2
2
 
3
+ require 'vagrant-rimu/actions/abstract_action'
4
+
3
5
  module VagrantPlugins
4
6
  module Rimu
5
7
  module Actions
6
- class Reload
8
+ class Reload < AbstractAction
7
9
  def initialize(app, env)
8
10
  @app = app
9
11
  @machine = env[:machine]
10
12
  @logger = Log4r::Logger.new('vagrant::rimu::reload')
11
13
  end
12
14
 
13
- def call(env)
15
+ def execute(env)
14
16
  client = env[:rimu_api]
15
17
  env[:ui].info I18n.t('vagrant_rimu.reloading')
16
18
  client.servers.reboot(@machine.id.to_i)