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

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

Change-Id: I726eb86bfa3df3a9911f45770e6641264dbc1e0b
Implements: blueprint cmd-with-multi-servers
This commit is contained in:
Tang Chen 2015-11-24 18:54:03 +08:00
parent 4955117dff
commit bfa223f615
3 changed files with 12 additions and 10 deletions

View File

@ -483,17 +483,17 @@ a revert to release the new server and restart the old one.
server resume
-------------
Resume server
Resume server(s)
.. program:: server resume
.. code:: bash
os server resume
<server>
<server> [<server> ...]
.. describe:: <server>
Server (name or ID)
Server(s) to resume (name or ID)
server set
----------

View File

@ -178,7 +178,7 @@ Those actions with an opposite action are noted in parens if applicable.
* ``remove`` (``add``) - remove an object from a group of objects
* ``rescue`` (``unrescue``) - reboot a server in a special rescue mode allowing access to the original disks
* ``resize`` - change a server's flavor
* ``resume`` (``suspend``) - return a suspended server to running state
* ``resume`` (``suspend``) - return one or more suspended servers to running state
* ``revoke`` (``issue``) - revoke a token
* ``save`` - download an object locally
* ``set`` (``unset``) - set a property on the object, formerly called metadata

View File

@ -1268,7 +1268,7 @@ class ResizeServer(command.Command):
class ResumeServer(command.Command):
"""Resume server"""
"""Resume server(s)"""
log = logging.getLogger(__name__ + '.ResumeServer')
@ -1277,7 +1277,8 @@ class ResumeServer(command.Command):
parser.add_argument(
'server',
metavar='<server>',
help=_('Server (name or ID)'),
nargs='+',
help=_('Server(s) to resume (name or ID)'),
)
return parser
@ -1285,10 +1286,11 @@ class ResumeServer(command.Command):
def take_action(self, parsed_args):
compute_client = self.app.client_manager.compute
utils.find_resource(
compute_client.servers,
parsed_args.server,
) .resume()
for server in parsed_args.server:
utils.find_resource(
compute_client.servers,
server,
).resume()
class SetServer(command.Command):