Class: VagrantPlugins::OpenStack::Action::IsSnapshoting

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

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ IsSnapshoting

Returns a new instance of IsSnapshoting.



5
6
7
# File 'lib/vagrant-openstack-plugin/action/is_snapshoting.rb', line 5

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vagrant-openstack-plugin/action/is_snapshoting.rb', line 9

def call(env)
  if env[:machine].id
    infos = env[:openstack_compute].get_server_details(env[:machine].id)
    task = infos.body['server']['OS-EXT-STS:task_state']
    if task == 'image_snapshot' || task == 'image_pending_upload'
      env[:result] = true
    else
      env[:result] = false
    end
  end
  @app.call(env)
end