Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot 'resume' while instance is in vm_state active #91

Closed
f2brossi opened this issue Sep 5, 2014 · 2 comments
Closed

Cannot 'resume' while instance is in vm_state active #91

f2brossi opened this issue Sep 5, 2014 · 2 comments
Milestone

Comments

@f2brossi
Copy link
Contributor

f2brossi commented Sep 5, 2014

after > vagrant suspend

try quickly > vagrant resume

Then actually vagrant return
==> test: Resuming suspended VM...
Cannot 'resume' while instance is in vm_state active

Would be nice to indicate that the vm is suspending and so the action cannot be performed.

@f2brossi
Copy link
Contributor Author

With nova api v2 extensions and v2.1 ( experimental ) we have the transition task_state to suspending and so we indicate to the user that the action cannot be performed.

see issue #89

@f2brossi
Copy link
Contributor Author

f2brossi commented Nov 8, 2014

Proposal for methods resume/suspend in action.rb, according to http://docs.openstack.org/developer/nova/devref/vmstates.html

     # This is the action that is primarily responsible for suspending
      # the virtual machine..
      # When machine_state_id != "active" there are two cases:
      #  - A task is ongoing  and so the vm can not be suspended.
      #  - No task is ongoing and vm_state is not "active". In that case
      # the vm can not be suspended except when vm_state == "resumed".
      def self.action_suspend
        new_builder.tap do |b|
          b.use ConfigValidate
          b.use ConnectOpenstack
          b.use Call, ReadState do |env, b2|
            if env[:machine_state_id] == :not_created
              b2.use Message, I18n.t('vagrant_openstack.not_created')
            elsif env[:machine_state_id] == :suspended
              b2.use Message, I18n.t('vagrant_openstack.already_suspended')
            elsif env[:machine_state_id] != :active && env[:machine_state_id] != :resumed
              b2.use Message, I18n.t('vagrant_openstack.ongoing_task_or_not_resumed')
            else
              b2.use Suspend
            end
          end
        end
      end

      # This is the action that is primarily responsible for resuming
      # suspended machines.
      # When machine_state_id != "active" there are two cases:
      #  - A task is ongoing  and so the vm can not be suspended.
      #  - No task is ongoing and vm_state is not "active". In that case
      # the vm can not be suspended except when vm_state == "suspended".
      def self.action_resume
        new_builder.tap do |b|
          b.use ConfigValidate
          b.use ConnectOpenstack
          b.use Call, ReadState do |env, b2|
            if env[:machine_state_id] == :not_created
              b2.use Message, I18n.t('vagrant_openstack.not_created')
            elsif env[:machine_state_id] == :resumed
              b2.use Message, I18n.t('vagrant_openstack.already_resumed')
            elsif  ! ( env[:machine_state_id] == :active  || env[:machine_state_id] == :suspended )
              b2.use Message, I18n.t('vagrant_openstack.ongoing_task_or_not_suspended')
            else
              b2.use Resume
            end
          end
        end
      end

@ggiamarchi ggiamarchi added this to the 0.6 milestone Nov 21, 2014
Sharpie pushed a commit to Sharpie/vagrant-openstack-provider that referenced this issue Jan 18, 2016
issue91: do not accept resume/suspend when a task is ongoing.

Fix ggiamarchi#91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants