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

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

Change-Id: Ibf57b2021a504da950a491d63139a438087aed0b
Implements: blueprint cmd-with-multi-servers
This commit is contained in:
Tang Chen 2015-11-13 11:02:01 +08:00
parent c1f0ad6d71
commit 91fbb0e136
3 changed files with 12 additions and 10 deletions
doc/source
command-objects
commands.rst
openstackclient/compute/v2

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

@ -186,7 +186,7 @@ Those actions with an opposite action are noted in parens if applicable.
* ``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
* ``unlock`` (``lock``) - unlock one or more servers
* ``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

@ -1561,7 +1561,7 @@ class SuspendServer(command.Command):
class UnlockServer(command.Command):
"""Unlock server"""
"""Unlock server(s)"""
log = logging.getLogger(__name__ + '.UnlockServer')
@ -1570,7 +1570,8 @@ class UnlockServer(command.Command):
parser.add_argument(
'server',
metavar='<server>',
help=_('Server (name or ID)'),
nargs='+',
help=_('Server(s) to unlock (name or ID)'),
)
return parser
@ -1578,10 +1579,11 @@ class UnlockServer(command.Command):
def take_action(self, parsed_args):
compute_client = self.app.client_manager.compute
utils.find_resource(
compute_client.servers,
parsed_args.server,
).unlock()
for server in parsed_args.server:
utils.find_resource(
compute_client.servers,
server,
).unlock()
class UnpauseServer(command.Command):