Enable "openstack server unpause" command to take multiple servers.

Current "openstack server unpause" command could only unpause one server.
Improve it to be able to handle more than one servers. Also improve the
doc to reflect the new feature.

Change-Id: I069ebdd6dcd121f6e55c2bf40d42197f93830e0c
Implements: blueprint cmd-with-multi-servers
This commit is contained in:
Tang Chen 2015-11-12 23:50:36 +08:00
parent 6611f3781b
commit 90d86ef01c
3 changed files with 12 additions and 10 deletions

View File

@ -658,17 +658,17 @@ Unlock server
server unpause
--------------
Unpause server
Unpause server(s)
.. program:: server unpause
.. code:: bash
os server unpause
<server>
<server> [<server> ...]
.. describe:: <server>
Server (name or ID)
Server(s) to unpause (name or ID)
server unrescue
---------------

View File

@ -187,7 +187,7 @@ Those actions with an opposite action are noted in parens if applicable.
* ``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
* ``unpause`` (``pause``) - return one or more paused servers to running state
* ``unrescue`` (``rescue``) - return a server to normal boot mode
* ``unset`` (``set``) - remove an attribute of the object

View File

@ -1583,7 +1583,7 @@ class UnlockServer(command.Command):
class UnpauseServer(command.Command):
"""Unpause server"""
"""Unpause server(s)"""
log = logging.getLogger(__name__ + '.UnpauseServer')
@ -1592,7 +1592,8 @@ class UnpauseServer(command.Command):
parser.add_argument(
'server',
metavar='<server>',
help=_('Server (name or ID)'),
nargs='+',
help=_('Server(s) to unpause (name or ID)'),
)
return parser
@ -1600,10 +1601,11 @@ class UnpauseServer(command.Command):
def take_action(self, parsed_args):
compute_client = self.app.client_manager.compute
utils.find_resource(
compute_client.servers,
parsed_args.server,
).unpause()
for server in parsed_args.server:
utils.find_resource(
compute_client.servers,
server,
).unpause()
class UnrescueServer(command.Command):