Class: VagrantPlugins::OCI::Action::StartInstance
- Inherits:
-
Object
- Object
- VagrantPlugins::OCI::Action::StartInstance
- Defined in:
- lib/vagrant-oci/action/start_instance.rb
Overview
This stops the running instance.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ StartInstance
constructor
A new instance of StartInstance.
Constructor Details
#initialize(app, env) ⇒ StartInstance
Returns a new instance of StartInstance.
8 9 10 11 |
# File 'lib/vagrant-oci/action/start_instance.rb', line 8 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_oci::action::start_instance") end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vagrant-oci/action/start_instance.rb', line 13 def call(env) return :not_created if env[:machine].id.nil? begin server = env[:oci_compute].get_instance(env[:machine].id) rescue OCI::Errors::ServiceError return :not_created end lifecycle_state = server.data.lifecycle_state.upcase if %w[STARTING RUNNING].include?(lifecycle_state) env[:ui].info(I18n.t("vagrant_oci.already_status", :status => lifecycle_state)) else env[:ui].info(I18n.t("vagrant_oci.starting")) env[:oci_compute].instance_action(env[:machine].id, 'START') end @app.call(env) end |