Skip to content

Commit 91fbb0e

Browse files
committed
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
1 parent c1f0ad6 commit 91fbb0e

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

doc/source/command-objects/server.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,17 +643,17 @@ Suspend server
643643
server unlock
644644
-------------
645645
646-
Unlock server
646+
Unlock server(s)
647647
648648
.. program:: server unlock
649649
.. code:: bash
650650
651651
os server unlock
652-
<server>
652+
<server> [<server> ...]
653653
654654
.. describe:: <server>
655655
656-
Server (name or ID)
656+
Server(s) to unlock (name or ID)
657657
658658
server unpause
659659
--------------

doc/source/commands.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Those actions with an opposite action are noted in parens if applicable.
186186
* ``start`` (``stop``) - start one or more servers
187187
* ``stop`` (``start``) - stop one or more servers
188188
* ``suspend`` (``resume``) - stop a server and save to disk freeing memory
189-
* ``unlock`` (``lock``) - unlock a server
189+
* ``unlock`` (``lock``) - unlock one or more servers
190190
* ``unpause`` (``pause``) - return one or more paused servers to running state
191191
* ``unrescue`` (``rescue``) - return a server to normal boot mode
192192
* ``unset`` (``set``) - remove an attribute of the object

openstackclient/compute/v2/server.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ def take_action(self, parsed_args):
15611561

15621562

15631563
class UnlockServer(command.Command):
1564-
"""Unlock server"""
1564+
"""Unlock server(s)"""
15651565

15661566
log = logging.getLogger(__name__ + '.UnlockServer')
15671567

@@ -1570,18 +1570,20 @@ def get_parser(self, prog_name):
15701570
parser.add_argument(
15711571
'server',
15721572
metavar='<server>',
1573-
help=_('Server (name or ID)'),
1573+
nargs='+',
1574+
help=_('Server(s) to unlock (name or ID)'),
15741575
)
15751576
return parser
15761577

15771578
@utils.log_method(log)
15781579
def take_action(self, parsed_args):
15791580

15801581
compute_client = self.app.client_manager.compute
1581-
utils.find_resource(
1582-
compute_client.servers,
1583-
parsed_args.server,
1584-
).unlock()
1582+
for server in parsed_args.server:
1583+
utils.find_resource(
1584+
compute_client.servers,
1585+
server,
1586+
).unlock()
15851587

15861588

15871589
class UnpauseServer(command.Command):

0 commit comments

Comments
 (0)