Merge "Add support for triggering an crash dump"

This commit is contained in:
Jenkins 2016-02-05 22:49:36 +00:00 committed by Gerrit Code Review
commit fb4240a4b5
6 changed files with 74 additions and 0 deletions

View File

@ -168,6 +168,25 @@ Delete server(s)
Server(s) to delete (name or ID)
server dump create
------------------
Create a dump file in server(s)
Trigger crash dump in server(s) with features like kdump in Linux. It will
create a dump file in the server(s) dumping the server(s)' memory, and also
crash the server(s). OSC sees the dump file (server dump) as a kind of
resource.
.. program:: server dump create
.. code:: bash
os server dump create
<server> [<server> ...]
.. describe:: <server>
Server(s) to create dump file (name or ID)
server list
-----------

View File

@ -112,6 +112,7 @@ referring to both Compute and Volume quotas.
* ``security group``: (**Compute**, **Network**) - groups of network access rules
* ``security group rule``: (**Compute**, **Network**) - the individual rules that define protocol/IP/port access
* ``server``: (**Compute**) virtual machine instance
* ``server dump``: (**Compute**) a dump file of a server created by features like kdump
* ``server image``: (**Compute**) saved server disk image
* ``service``: (**Identity**) a cloud service
* ``service provider``: (**Identity**) a resource that consumes assertions from an ``identity provider``

View File

@ -542,6 +542,34 @@ class CreateServer(command.ShowOne):
return zip(*sorted(six.iteritems(details)))
class CreateServerDump(command.Command):
"""Create a dump file in server(s)
Trigger crash dump in server(s) with features like kdump in Linux.
It will create a dump file in the server(s) dumping the server(s)'
memory, and also crash the server(s). OSC sees the dump file
(server dump) as a kind of resource.
"""
def get_parser(self, prog_name):
parser = super(CreateServerDump, self).get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
nargs='+',
help=_('Server(s) to create dump file (name or ID)'),
)
return parser
def take_action(self, parsed_args):
compute_client = self.app.client_manager.compute
for server in parsed_args.server:
utils.find_resource(
compute_client.servers,
server,
).trigger_crash_dump()
class CreateServerImage(command.ShowOne):
"""Create a new disk image from a running server"""

View File

@ -490,6 +490,26 @@ class TestServerDelete(TestServer):
)
class TestServerDumpCreate(TestServer):
def setUp(self):
super(TestServerDumpCreate, self).setUp()
# Get the command object to test
self.cmd = server.CreateServerDump(self.app, None)
# Set methods to be tested.
self.methods = {
'trigger_crash_dump': None,
}
def test_server_dump_one_server(self):
self.run_method_with_servers('trigger_crash_dump', 1)
def test_server_dump_multi_servers(self):
self.run_method_with_servers('trigger_crash_dump', 3)
class TestServerImageCreate(TestServer):
columns = (

View File

@ -0,0 +1,5 @@
---
features:
- |
Add support for the `server dump create` command
[Bug `1538372 <https://bugs.launchpad.net/python-openstackclient/+bug/1538372>`_]

View File

@ -133,6 +133,7 @@ openstack.compute.v2 =
server_start = openstackclient.compute.v2.server:StartServer
server_stop = openstackclient.compute.v2.server:StopServer
server_suspend = openstackclient.compute.v2.server:SuspendServer
server_dump_create = openstackclient.compute.v2.server:CreateServerDump
server_unlock = openstackclient.compute.v2.server:UnlockServer
server_unpause = openstackclient.compute.v2.server:UnpauseServer
server_unrescue = openstackclient.compute.v2.server:UnrescueServer