Class: VagrantPlugins::OneAndOne::Action::Reload
- Inherits:
-
Object
- Object
- VagrantPlugins::OneAndOne::Action::Reload
- Defined in:
- lib/vagrant-oneandone/action/reload.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Reload
constructor
A new instance of Reload.
Constructor Details
#initialize(app, env) ⇒ Reload
Returns a new instance of Reload.
6 7 8 9 10 |
# File 'lib/vagrant-oneandone/action/reload.rb', line 6 def initialize(app, env) @app = app @logger = Log4r::Logger.new('vagrant_1and1::action::reload') @machine = env[:machine] end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 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 |
# File 'lib/vagrant-oneandone/action/reload.rb', line 12 def call(env) compute = env[:oneandone_compute] server = begin compute.servers.get(@machine.id) rescue nil end if server.nil? @logger.warn "Unable to find server #{env[:machine].id}..." env[:ui].warn(I18n.t('vagrant_1and1.errors.instance_not_found')) env[:machine].id = nil else @logger.info "Restarting server #{env[:machine].id}..." env[:ui].info(I18n.t('vagrant_1and1.reloading_server')) # if needed, wait until the server is ready server.wait_for { ready? } if env[:force_halt] compute.change_status(server_id: server.id, action: 'REBOOT', method: 'HARDWARE') else server.reboot end server.wait_for { ready? } env[:ui].info(I18n.t('vagrant_1and1.rebooted')) end @app.call(env) end |