Class: VagrantPlugins::OpenStack::Action::PauseServer

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-openstack-plugin/action/pause_server.rb

Overview

This pauses a running server, if there is one.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ PauseServer

Returns a new instance of PauseServer.



8
9
10
11
# File 'lib/vagrant-openstack-plugin/action/pause_server.rb', line 8

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new("vagrant_openstack::action::pause_server")
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/vagrant-openstack-plugin/action/pause_server.rb', line 13

def call(env)
  if env[:machine].id
    env[:ui].info(I18n.t("vagrant_openstack.pausing_server"))

    # TODO: Validate the fact that we get a server back from the API.
    server = env[:openstack_compute].servers.get(env[:machine].id)
    env[:openstack_compute].pause_server(server.id)
  end

  @app.call(env)
end