Add "server stop" command to osc.
There is no stop command in osc. Add it. Change-Id: Ia11a8f3b1245c884f7da442292009342d2ffde1e Implements: blueprint cmd-with-multi-servers
This commit is contained in:
parent
1809faaf1f
commit
7107b5536e
@ -610,6 +610,21 @@ Start server(s)
|
||||
|
||||
Server(s) to start (name or ID)
|
||||
|
||||
server stop
|
||||
-----------
|
||||
|
||||
Stop server(s)
|
||||
|
||||
.. program:: server stop
|
||||
.. code:: bash
|
||||
|
||||
os server stop
|
||||
<server> [<server> ...]
|
||||
|
||||
.. describe:: <server>
|
||||
|
||||
Server(s) to stop (name or ID)
|
||||
|
||||
server suspend
|
||||
--------------
|
||||
|
||||
|
@ -183,7 +183,8 @@ Those actions with an opposite action are noted in parens if applicable.
|
||||
* ``save`` - download an object locally
|
||||
* ``set`` (``unset``) - set a property on the object, formerly called metadata
|
||||
* ``show`` - display detailed information about the specific object
|
||||
* ``start`` - start one or more servers
|
||||
* ``start`` (``stop``) - start one or more servers
|
||||
* ``stop`` (``start``) - stop one or more servers
|
||||
* ``suspend`` (``resume``) - stop a server and save to disk freeing memory
|
||||
* ``unlock`` (``lock``) - unlock a server
|
||||
* ``unpause`` (``pause``) - return a paused server to running state
|
||||
|
@ -1508,6 +1508,31 @@ class StartServer(command.Command):
|
||||
).start()
|
||||
|
||||
|
||||
class StopServer(command.Command):
|
||||
"""Stop server(s)."""
|
||||
|
||||
log = logging.getLogger(__name__ + '.StopServer')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(StopServer, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'server',
|
||||
metavar='<server>',
|
||||
nargs="+",
|
||||
help=_('Server(s) to stop (name or ID)'),
|
||||
)
|
||||
return parser
|
||||
|
||||
@utils.log_method(log)
|
||||
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,
|
||||
).stop()
|
||||
|
||||
|
||||
class SuspendServer(command.Command):
|
||||
"""Suspend server"""
|
||||
|
||||
|
@ -134,6 +134,7 @@ openstack.compute.v2 =
|
||||
server_show = openstackclient.compute.v2.server:ShowServer
|
||||
server_ssh = openstackclient.compute.v2.server:SshServer
|
||||
server_start = openstackclient.compute.v2.server:StartServer
|
||||
server_stop = openstackclient.compute.v2.server:StopServer
|
||||
server_suspend = openstackclient.compute.v2.server:SuspendServer
|
||||
server_unlock = openstackclient.compute.v2.server:UnlockServer
|
||||
server_unpause = openstackclient.compute.v2.server:UnpauseServer
|
||||
|
Loading…
Reference in New Issue
Block a user