Merge "[compute] Support restore server"

This commit is contained in:
Jenkins 2016-03-04 23:41:42 +00:00 committed by Gerrit Code Review
commit fa3a34322c
6 changed files with 63 additions and 1 deletions

View File

@ -514,6 +514,21 @@ process for the user: the first is to perform the resize, the second is
to either confirm (verify) success and release the old server, or to declare
a revert to release the new server and restart the old one.
server restore
--------------
Restore server(s) from soft-deleted state
.. program:: server restore
.. code:: bash
os server restore
<server> [<server> ...]
.. describe:: <server>
Server(s) to restore (name or ID)
server resume
-------------

View File

@ -201,7 +201,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
* ``restore`` - restore a heat stack snapshot
* ``restore`` - restore a heat stack snapshot or restore a server in soft-deleted state
* ``resume`` (``suspend``) - return one or more suspended servers to running state
* ``revoke`` (``issue``) - revoke a token
* ``save`` - download an object locally

View File

@ -1273,6 +1273,28 @@ class ResizeServer(command.Command):
compute_client.servers.revert_resize(server)
class RestoreServer(command.Command):
"""Restore server(s)"""
def get_parser(self, prog_name):
parser = super(RestoreServer, self).get_parser(prog_name)
parser.add_argument(
'server',
metavar='<server>',
nargs='+',
help=_('Server(s) to restore (name or ID)'),
)
return parser
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
).restore()
class ResumeServer(command.Command):
"""Resume server(s)"""

View File

@ -1171,6 +1171,26 @@ class TestServerResize(TestServer):
)
class TestServerRestore(TestServer):
def setUp(self):
super(TestServerRestore, self).setUp()
# Get the command object to test
self.cmd = server.RestoreServer(self.app, None)
# Set methods to be tested.
self.methods = {
'restore': None,
}
def test_server_restore_one_server(self):
self.run_method_with_servers('restore', 1)
def test_server_restore_multi_servers(self):
self.run_method_with_servers('restore', 3)
class TestServerResume(TestServer):
def setUp(self):

View File

@ -0,0 +1,4 @@
---
features:
- |
Add support for the ``server restore`` command.

View File

@ -120,6 +120,7 @@ openstack.compute.v2 =
server_remove_volume = openstackclient.compute.v2.server:RemoveServerVolume
server_rescue = openstackclient.compute.v2.server:RescueServer
server_resize = openstackclient.compute.v2.server:ResizeServer
server_restore = openstackclient.compute.v2.server:RestoreServer
server_resume = openstackclient.compute.v2.server:ResumeServer
server_set = openstackclient.compute.v2.server:SetServer
server_shelve = openstackclient.compute.v2.server:ShelveServer