Class: VagrantPlugins::Packet::Action::StopInstance
- Inherits:
-
Object
- Object
- VagrantPlugins::Packet::Action::StopInstance
- Defined in:
- lib/vagrant-packet/action/stop_instance.rb
Overview
This stops the running instance.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, _env) ⇒ StopInstance
constructor
A new instance of StopInstance.
Constructor Details
#initialize(app, _env) ⇒ StopInstance
Returns a new instance of StopInstance.
10 11 12 13 |
# File 'lib/vagrant-packet/action/stop_instance.rb', line 10 def initialize(app, _env) @app = app @logger = Log4r::Logger.new('vagrant_packet::action::stop_instance') end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vagrant-packet/action/stop_instance.rb', line 15 def call(env) server = env[:packet_compute].devices.get(env[:machine].id) if env[:machine].state.id == :inactive env[:ui].info(I18n.t('vagrant_packet.already_status', status: env[:machine].state.id)) else env[:ui].info(I18n.t('vagrant_packet.stopping')) server.stop end @app.call(env) end |