Class: VagrantPlugins::Rimu::Actions::Move
- Inherits:
-
AbstractAction
- Object
- AbstractAction
- VagrantPlugins::Rimu::Actions::Move
- Includes:
- Vagrant::Util::Retryable
- Defined in:
- lib/vagrant-rimu/actions/move.rb
Instance Method Summary collapse
-
#execute(env) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize(app, env) ⇒ Move
constructor
A new instance of Move.
Methods inherited from AbstractAction
Constructor Details
#initialize(app, env) ⇒ Move
Returns a new instance of Move.
12 13 14 15 16 |
# File 'lib/vagrant-rimu/actions/move.rb', line 12 def initialize(app, env) @app = app @machine = env[:machine] @logger = Log4r::Logger.new('vagrant::rimu::move') end |
Instance Method Details
#execute(env) ⇒ Object
rubocop:disable Metrics/AbcSize
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vagrant-rimu/actions/move.rb', line 19 def execute(env) client = env[:rimu_api] env[:ui].info I18n.t('vagrant_rimu.moving') begin result = client.servers.move(@machine.id.to_i) rescue ::Rimu::RimuAPI::RimuRequestError, ::Rimu::RimuAPI::RimuResponseError => e raise Errors::ApiError, {:stderr=>e} end @machine.id = result.order_oid env[:ui].info I18n.t('vagrant_rimu.ip_address', {:ip => result.allocated_ips["primary_ip"]}) switch_user = @machine.provider_config.setup? user = @machine.config.ssh.username @machine.config.ssh.username = 'root' if switch_user retryable(:tries => 120, :sleep => 10) do next if env[:interrupted] raise 'not ready' unless @machine.communicate.ready? end @machine.config.ssh.username = user @app.call(env) end |