Class: VagrantPlugins::OpenStack::Action::ResumeServer
- Inherits:
-
Object
- Object
- VagrantPlugins::OpenStack::Action::ResumeServer
- Defined in:
- lib/vagrant-openstack-plugin/action/resume_server.rb
Overview
This starts a suspended server, if there is one.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ResumeServer
constructor
A new instance of ResumeServer.
Constructor Details
#initialize(app, env) ⇒ ResumeServer
Returns a new instance of ResumeServer.
8 9 10 11 |
# File 'lib/vagrant-openstack-plugin/action/resume_server.rb', line 8 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_openstack::action::resume_server") end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vagrant-openstack-plugin/action/resume_server.rb', line 13 def call(env) if env[:machine].id env[:ui].info(I18n.t("vagrant_openstack.resuming_server")) # TODO: Validate the fact that we get a server back from the API. server = env[:openstack_compute].servers.get(env[:machine].id) if server.state == 'PAUSED' env[:openstack_compute].unpause_server(server.id) elsif server.state == 'SUSPENDED' env[:openstack_compute].resume_server(server.id) end end @app.call(env) end |