Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: OpenStack: Dev

Suspend/Stop VM

 

 

OpenStack dev RSS feed   Index | Next | Previous | View Threaded


george.reese at enstratus

Jul 30, 2012, 8:50 AM

Post #1 of 11 (345 views)
Permalink
Suspend/Stop VM

I must be missing something, but I can't find any docs on how to suspend or stop a VM via API.

Any pointers, please? :)

-George

--
George Reese - Chief Technology Officer, enStratus
e: george.reese [at] enstratus Skype: nspollution t: @GeorgeReese p: +1.207.956.0217
enStratus: Enterprise Cloud Management - @enStratus - http://www.enstratus.com
To schedule a meeting with me: http://tungle.me/GeorgeReese


panpengjun at gmail

Jul 30, 2012, 9:11 AM

Post #2 of 11 (338 views)
Permalink
Re: Suspend/Stop VM [In reply to]

I never tried to stop a VM using api. But run a "nova help", it has
pause, reboot, resume, etc.

To bypass nova api, you can use virsh to stop instances. Do a "sudo
virsh list --all", it will list all the running instances even if nova
cannot see it for some reason. And then you can kill all the "ghost"
instances by "sudo virsh shutdown <id>".

Hope this helps.

PJ


On Mon, Jul 30, 2012 at 10:50 AM, George Reese
<george.reese [at] enstratus> wrote:
> I must be missing something, but I can't find any docs on how to suspend or
> stop a VM via API.
>
> Any pointers, please? :)
>
> -George
>
> --
> George Reese - Chief Technology Officer, enStratus
> e: george.reese [at] enstratus Skype: nspollution t: @GeorgeReese p:
> +1.207.956.0217
> enStratus: Enterprise Cloud Management - @enStratus -
> http://www.enstratus.com
> To schedule a meeting with me: http://tungle.me/GeorgeReese
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openstack
> Post to : openstack [at] lists
> Unsubscribe : https://launchpad.net/~openstack
> More help : https://help.launchpad.net/ListHelp
>

_______________________________________________
Mailing list: https://launchpad.net/~openstack
Post to : openstack [at] lists
Unsubscribe : https://launchpad.net/~openstack
More help : https://help.launchpad.net/ListHelp


george.reese at enstratus

Jul 30, 2012, 9:13 AM

Post #3 of 11 (337 views)
Permalink
Re: Suspend/Stop VM [In reply to]

Thanks, but I am looking for how this is done via API.

-George

On Jul 30, 2012, at 11:11 AM, Pengjun Pan <panpengjun [at] gmail> wrote:

> I never tried to stop a VM using api. But run a "nova help", it has
> pause, reboot, resume, etc.
>
> To bypass nova api, you can use virsh to stop instances. Do a "sudo
> virsh list --all", it will list all the running instances even if nova
> cannot see it for some reason. And then you can kill all the "ghost"
> instances by "sudo virsh shutdown <id>".
>
> Hope this helps.
>
> PJ
>
>
> On Mon, Jul 30, 2012 at 10:50 AM, George Reese
> <george.reese [at] enstratus> wrote:
>> I must be missing something, but I can't find any docs on how to suspend or
>> stop a VM via API.
>>
>> Any pointers, please? :)
>>
>> -George
>>
>> --
>> George Reese - Chief Technology Officer, enStratus
>> e: george.reese [at] enstratus Skype: nspollution t: @GeorgeReese p:
>> +1.207.956.0217
>> enStratus: Enterprise Cloud Management - @enStratus -
>> http://www.enstratus.com
>> To schedule a meeting with me: http://tungle.me/GeorgeReese
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~openstack
>> Post to : openstack [at] lists
>> Unsubscribe : https://launchpad.net/~openstack
>> More help : https://help.launchpad.net/ListHelp
>>

--
George Reese - Chief Technology Officer, enStratus
e: george.reese [at] enstratus Skype: nspollution t: @GeorgeReese p: +1.207.956.0217
enStratus: Enterprise Cloud Management - @enStratus - http://www.enstratus.com
To schedule a meeting with me: http://tungle.me/GeorgeReese


moseleymark at gmail

Jul 30, 2012, 9:26 AM

Post #4 of 11 (337 views)
Permalink
Re: Suspend/Stop VM [In reply to]

On Mon, Jul 30, 2012 at 8:50 AM, George Reese
<george.reese [at] enstratus> wrote:
> I must be missing something, but I can't find any docs on how to suspend or
> stop a VM via API.
>
> Any pointers, please? :)

I think this works (see http://api.openstack.org/) but haven't tested
it in a while:

Stop: Encode this python dict with json.dumps:

params = { "suspend": None, }

and POST it as the body to v2/{tenant_id}/servers/{server_id}/action

The None really needs to be a None. To start back up, use "resume"
instead of "suspend".

_______________________________________________
Mailing list: https://launchpad.net/~openstack
Post to : openstack [at] lists
Unsubscribe : https://launchpad.net/~openstack
More help : https://help.launchpad.net/ListHelp


ayoung at redhat

Jul 30, 2012, 9:29 AM

Post #5 of 11 (348 views)
Permalink
Re: Suspend/Stop VM [In reply to]

On 07/30/2012 12:13 PM, George Reese wrote:
> Thanks, but I am looking for how this is done via API.

You can determine from the CLI what APIs are called by running with
--debug. For example:

nova --debug list

You will see:

send: u'GET /v2/cdc204424fdf4f428ca27cc3d65ea583/servers/detail
HTTP/1.1\r\nHost: 10.16.184.54:8774\r\nx-auth-project-id:
demo\r\nx-auth-token:..."

REQ: curl -i
http://10.16.184.54:8774/v2/cdc204424fdf4f428ca27cc3d65ea583/servers/detail
-X GET -H "X-Auth-Project-Id: demo" -H "User-Agent: python-novaclient"
-H "Accept: application/json" -H "X-Auth-Token:...."



>
> -George
>
> On Jul 30, 2012, at 11:11 AM, Pengjun Pan <panpengjun [at] gmail
> <mailto:panpengjun [at] gmail>> wrote:
>
>> I never tried to stop a VM using api. But run a "nova help", it has
>> pause, reboot, resume, etc.
>>
>> To bypass nova api, you can use virsh to stop instances. Do a "sudo
>> virsh list --all", it will list all the running instances even if nova
>> cannot see it for some reason. And then you can kill all the "ghost"
>> instances by "sudo virsh shutdown <id>".
>>
>> Hope this helps.
>>
>> PJ
>>
>>
>> On Mon, Jul 30, 2012 at 10:50 AM, George Reese
>> <george.reese [at] enstratus <mailto:george.reese [at] enstratus>> wrote:
>>> I must be missing something, but I can't find any docs on how to
>>> suspend or
>>> stop a VM via API.
>>>
>>> Any pointers, please? :)
>>>
>>> -George
>>>
>>> --
>>> George Reese - Chief Technology Officer, enStratus
>>> e: george.reese [at] enstratus <mailto:george.reese [at] enstratus>
>>> Skype: nspollution t: @GeorgeReese p:
>>> +1.207.956.0217
>>> enStratus: Enterprise Cloud Management - @enStratus -
>>> http://www.enstratus.com
>>> To schedule a meeting with me: http://tungle.me/GeorgeReese
>>>
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~openstack
>>> Post to : openstack [at] lists
>>> Unsubscribe : https://launchpad.net/~openstack
>>> More help : https://help.launchpad.net/ListHelp
>>>
>
> --
> George Reese - Chief Technology Officer, enStratus
> e: george.reese [at] enstratus <mailto:george.reese [at] enstratus>
> Skype: nspollution t: @GeorgeReese p: +1.207.956.0217
> enStratus: Enterprise Cloud Management - @enStratus -
> http://www.enstratus.com <http://www.enstratus.com/>
> To schedule a meeting with me: http://tungle.me/GeorgeReese
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openstack
> Post to : openstack [at] lists
> Unsubscribe : https://launchpad.net/~openstack
> More help : https://help.launchpad.net/ListHelp


markmc at redhat

Jul 30, 2012, 9:32 AM

Post #6 of 11 (330 views)
Permalink
Re: Suspend/Stop VM [In reply to]

On Mon, 2012-07-30 at 10:50 -0500, George Reese wrote:
> I must be missing something, but I can't find any docs on how to suspend or stop a VM via API.
>
> Any pointers, please? :)

Try 'nova --debug pause $instance'

Shows e.g.

POST /v2/$tenant/servers/$instance/action HTTP/1.1
Host: $host:8774
Accept: application/json
Content-Length: application/json
Content-Type: text/html
x-auth-project-id: demo
x-auth-token: $token

{"pause": null}'

HTTP/1.1 202 Accepted

It's an API extension, not part of the core API, and AFAIK they're not
so well documented.

Mark.


_______________________________________________
Mailing list: https://launchpad.net/~openstack
Post to : openstack [at] lists
Unsubscribe : https://launchpad.net/~openstack
More help : https://help.launchpad.net/ListHelp


george.reese at enstratus

Jul 30, 2012, 9:48 AM

Post #7 of 11 (330 views)
Permalink
Re: Suspend/Stop VM [In reply to]

Thanks for this and a number of other suggestions. I am giving them a try.

Just a note though: some of the things that appear to work are inconsistent with other server actions in structure (os-stop vs. pause vs. os-start vs. reboot).

-George

On Jul 30, 2012, at 11:32 AM, Mark McLoughlin <markmc [at] redhat> wrote:

> On Mon, 2012-07-30 at 10:50 -0500, George Reese wrote:
>> I must be missing something, but I can't find any docs on how to suspend or stop a VM via API.
>>
>> Any pointers, please? :)
>
> Try 'nova --debug pause $instance'
>
> Shows e.g.
>
> POST /v2/$tenant/servers/$instance/action HTTP/1.1
> Host: $host:8774
> Accept: application/json
> Content-Length: application/json
> Content-Type: text/html
> x-auth-project-id: demo
> x-auth-token: $token
>
> {"pause": null}'
>
> HTTP/1.1 202 Accepted
>
> It's an API extension, not part of the core API, and AFAIK they're not
> so well documented.
>
> Mark.
>

--
George Reese - Chief Technology Officer, enStratus
e: george.reese [at] enstratus Skype: nspollution t: @GeorgeReese p: +1.207.956.0217
enStratus: Enterprise Cloud Management - @enStratus - http://www.enstratus.com
To schedule a meeting with me: http://tungle.me/GeorgeReese


eric at cloudscaling

Jul 30, 2012, 9:57 AM

Post #8 of 11 (329 views)
Permalink
Re: Suspend/Stop VM [In reply to]

I'm not sure where the actions are documented, but you can infer them from here:
https://github.com/openstack/python-novaclient/blob/master/novaclient/v1_1/servers.py

Below, I've pasted a few of the methods related to this thread. These are POST'ed to the action URI, as Mark suggested.

Regards,
Eric Windisch

def stop(self, server):
"""
Stop the server.
"""
return self._action('os-stop', server, None)

def start(self, server):
"""
Start the server.
"""
self._action('os-start', server, None)

def pause(self, server):
"""
Pause the server.
"""
self._action('pause', server, None)

def unpause(self, server):
"""
Unpause the server.
"""
self._action('unpause', server, None)

def lock(self, server):
"""
Lock the server.
"""
self._action('lock', server, None)

def unlock(self, server):
"""
Unlock the server.
"""
self._action('unlock', server, None)

def suspend(self, server):
"""
Suspend the server.
"""
self._action('suspend', server, None)

def resume(self, server):
"""
Resume the server.
"""
self._action('resume', server, None)


anne at openstack

Jul 30, 2012, 10:06 AM

Post #9 of 11 (334 views)
Permalink
Re: Suspend/Stop VM [In reply to]

As I noted on Twitter, there's an open doc bug at
https://bugs.launchpad.net/openstack-manuals/+bug/1029560 noting this
gap. Thanks George for clicking through to say it impacts you.

I'm sending a second email to the mailing list next to discuss this
unfortunate gap in reality in the API docs, what I believe the causes
to be, and how I'd like to move forward.

Thanks,
Anne



On Mon, Jul 30, 2012 at 11:13 AM, George Reese
<george.reese [at] enstratus> wrote:
> Thanks, but I am looking for how this is done via API.
>
> -George
>
> On Jul 30, 2012, at 11:11 AM, Pengjun Pan <panpengjun [at] gmail> wrote:
>
> I never tried to stop a VM using api. But run a "nova help", it has
> pause, reboot, resume, etc.
>
> To bypass nova api, you can use virsh to stop instances. Do a "sudo
> virsh list --all", it will list all the running instances even if nova
> cannot see it for some reason. And then you can kill all the "ghost"
> instances by "sudo virsh shutdown <id>".
>
> Hope this helps.
>
> PJ
>
>
> On Mon, Jul 30, 2012 at 10:50 AM, George Reese
> <george.reese [at] enstratus> wrote:
>
> I must be missing something, but I can't find any docs on how to suspend or
> stop a VM via API.
>
> Any pointers, please? :)
>
> -George
>
> --
> George Reese - Chief Technology Officer, enStratus
> e: george.reese [at] enstratus Skype: nspollution t: @GeorgeReese p:
> +1.207.956.0217
> enStratus: Enterprise Cloud Management - @enStratus -
> http://www.enstratus.com
> To schedule a meeting with me: http://tungle.me/GeorgeReese
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openstack
> Post to : openstack [at] lists
> Unsubscribe : https://launchpad.net/~openstack
> More help : https://help.launchpad.net/ListHelp
>
>
> --
> George Reese - Chief Technology Officer, enStratus
> e: george.reese [at] enstratus Skype: nspollution t: @GeorgeReese p:
> +1.207.956.0217
> enStratus: Enterprise Cloud Management - @enStratus -
> http://www.enstratus.com
> To schedule a meeting with me: http://tungle.me/GeorgeReese
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~openstack
> Post to : openstack [at] lists
> Unsubscribe : https://launchpad.net/~openstack
> More help : https://help.launchpad.net/ListHelp
>

_______________________________________________
Mailing list: https://launchpad.net/~openstack
Post to : openstack [at] lists
Unsubscribe : https://launchpad.net/~openstack
More help : https://help.launchpad.net/ListHelp


george.reese at enstratus

Jul 30, 2012, 10:36 AM

Post #10 of 11 (332 views)
Permalink
Re: Suspend/Stop VM [In reply to]

Thanks, this bit is perfect.

-George

On Jul 30, 2012, at 11:57 AM, Eric Windisch <eric [at] cloudscaling> wrote:

> I'm not sure where the actions are documented, but you can infer them from here:
> https://github.com/openstack/python-novaclient/blob/master/novaclient/v1_1/servers.py
>
> Below, I've pasted a few of the methods related to this thread. These are POST'ed to the action URI, as Mark suggested.
>
> Regards,
> Eric Windisch
>
> def stop(self, server):
> """
> Stop the server.
> """
> return self._action('os-stop', server, None)
>
> def start(self, server):
> """
> Start the server.
> """
> self._action('os-start', server, None)
>
> def pause(self, server):
> """
> Pause the server.
> """
> self._action('pause', server, None)
>
> def unpause(self, server):
> """
> Unpause the server.
> """
> self._action('unpause', server, None)
>
> def lock(self, server):
> """
> Lock the server.
> """
> self._action('lock', server, None)
>
> def unlock(self, server):
> """
> Unlock the server.
> """
> self._action('unlock', server, None)
>
> def suspend(self, server):
> """
> Suspend the server.
> """
> self._action('suspend', server, None)
>
> def resume(self, server):
> """
> Resume the server.
> """
> self._action('resume', server, None)

--
George Reese - Chief Technology Officer, enStratus
e: george.reese [at] enstratus Skype: nspollution t: @GeorgeReese p: +1.207.956.0217
enStratus: Enterprise Cloud Management - @enStratus - http://www.enstratus.com
To schedule a meeting with me: http://tungle.me/GeorgeReese


jaypipes at gmail

Jul 30, 2012, 1:41 PM

Post #11 of 11 (332 views)
Permalink
Re: Suspend/Stop VM [In reply to]

On 07/30/2012 12:48 PM, George Reese wrote:
> Thanks for this and a number of other suggestions. I am giving them a try.
>
> Just a note though: some of the things that appear to work are
> inconsistent with other server actions in structure (os-stop vs. pause
> vs. os-start vs. reboot).

Yeah, definitely. The difference is what is in the core OpenStack
Compute v2 API vs. what is an the Compute API as an extension. The idea
being that extensions get "baked" in the python-novaclient and in the
community and after some baking time will get moved into the core API.
If you see stuff that looks like "os-XXXX", that's an extension.

Agreed it needs some cleanup and this is probably a good a time as ever
to ask when the Nova community plans to "make official" some of these
oft-used extensions to the Compute API?

Best,
-jay

_______________________________________________
Mailing list: https://launchpad.net/~openstack
Post to : openstack [at] lists
Unsubscribe : https://launchpad.net/~openstack
More help : https://help.launchpad.net/ListHelp

OpenStack dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.