Microversion 2.77: Support Specifying AZ to unshelve
This patch adds a new parameter ``--availability-zone`` to ``openstack server unshelve`` command. This can help users to specify an ``availability_zone`` to unshelve a shelve offloaded server from 2.77 microversion. Depends-On: https://review.opendev.org/679295 Implements: blueprint support-specifying-az-when-restore-shelved-server Change-Id: Ia431e27c2a17fe16466707cc362532860ecf22df
This commit is contained in:
parent
7549d260aa
commit
fcd46acb69
@ -99,7 +99,7 @@ python-mimeparse==1.6.0
|
|||||||
python-mistralclient==3.1.0
|
python-mistralclient==3.1.0
|
||||||
python-muranoclient==0.8.2
|
python-muranoclient==0.8.2
|
||||||
python-neutronclient==6.7.0
|
python-neutronclient==6.7.0
|
||||||
python-novaclient==14.2.0
|
python-novaclient==15.0.0
|
||||||
python-octaviaclient==1.3.0
|
python-octaviaclient==1.3.0
|
||||||
python-rsdclient==0.1.0
|
python-rsdclient==0.1.0
|
||||||
python-saharaclient==1.4.0
|
python-saharaclient==1.4.0
|
||||||
|
@ -2811,12 +2811,32 @@ class UnshelveServer(command.Command):
|
|||||||
nargs='+',
|
nargs='+',
|
||||||
help=_('Server(s) to unshelve (name or ID)'),
|
help=_('Server(s) to unshelve (name or ID)'),
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--availability-zone',
|
||||||
|
default=None,
|
||||||
|
help=_('Name of the availability zone in which to unshelve a '
|
||||||
|
'SHELVED_OFFLOADED server (supported by '
|
||||||
|
'--os-compute-api-version 2.77 or above)'),
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
compute_client = self.app.client_manager.compute
|
compute_client = self.app.client_manager.compute
|
||||||
|
support_az = compute_client.api_version >= api_versions.APIVersion(
|
||||||
|
'2.77')
|
||||||
|
if not support_az and parsed_args.availability_zone:
|
||||||
|
msg = _("--os-compute-api-version 2.77 or greater is required "
|
||||||
|
"to support the '--availability-zone' option.")
|
||||||
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
for server in parsed_args.server:
|
for server in parsed_args.server:
|
||||||
utils.find_resource(
|
if support_az:
|
||||||
compute_client.servers,
|
utils.find_resource(
|
||||||
server,
|
compute_client.servers,
|
||||||
).unshelve()
|
server
|
||||||
|
).unshelve(availability_zone=parsed_args.availability_zone)
|
||||||
|
else:
|
||||||
|
utils.find_resource(
|
||||||
|
compute_client.servers,
|
||||||
|
server,
|
||||||
|
).unshelve()
|
||||||
|
@ -109,6 +109,10 @@ class TestServer(compute_fakes.TestComputev2):
|
|||||||
version = self.app.client_manager.compute.api_version
|
version = self.app.client_manager.compute.api_version
|
||||||
if version >= api_versions.APIVersion('2.73'):
|
if version >= api_versions.APIVersion('2.73'):
|
||||||
method.assert_called_with(reason=None)
|
method.assert_called_with(reason=None)
|
||||||
|
elif method_name == 'unshelve':
|
||||||
|
version = self.app.client_manager.compute.api_version
|
||||||
|
if version >= api_versions.APIVersion('2.77'):
|
||||||
|
method.assert_called_with(availability_zone=None)
|
||||||
else:
|
else:
|
||||||
method.assert_called_with()
|
method.assert_called_with()
|
||||||
else:
|
else:
|
||||||
@ -4777,6 +4781,56 @@ class TestServerUnshelve(TestServer):
|
|||||||
def test_unshelve_multi_servers(self):
|
def test_unshelve_multi_servers(self):
|
||||||
self.run_method_with_servers('unshelve', 3)
|
self.run_method_with_servers('unshelve', 3)
|
||||||
|
|
||||||
|
def test_unshelve_server_with_specified_az(self):
|
||||||
|
server = compute_fakes.FakeServer.create_one_server()
|
||||||
|
arglist = [
|
||||||
|
server.id,
|
||||||
|
'--availability-zone', "foo-az",
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('availability_zone', "foo-az"),
|
||||||
|
('server', [server.id])
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
ex = self.assertRaises(exceptions.CommandError,
|
||||||
|
self.cmd.take_action,
|
||||||
|
parsed_args)
|
||||||
|
self.assertIn(
|
||||||
|
'--os-compute-api-version 2.77 or greater is required', str(ex))
|
||||||
|
|
||||||
|
|
||||||
|
class TestServerUnshelveV277(TestServerUnshelve):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestServerUnshelveV277, self).setUp()
|
||||||
|
|
||||||
|
self.server = compute_fakes.FakeServer.create_one_server(
|
||||||
|
methods=self.methods)
|
||||||
|
|
||||||
|
# This is the return value for utils.find_resource()
|
||||||
|
self.servers_mock.get.return_value = self.server
|
||||||
|
|
||||||
|
# Get the command object to test
|
||||||
|
self.cmd = server.UnshelveServer(self.app, None)
|
||||||
|
|
||||||
|
def test_specified_az_to_unshelve_with_v277(self):
|
||||||
|
self.app.client_manager.compute.api_version = api_versions.APIVersion(
|
||||||
|
'2.77')
|
||||||
|
|
||||||
|
arglist = [
|
||||||
|
'--availability-zone', "foo-az",
|
||||||
|
self.server.id,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('availability_zone', "foo-az"),
|
||||||
|
('server', [self.server.id])
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
self.cmd.take_action(parsed_args)
|
||||||
|
self.servers_mock.get.assert_called_with(self.server.id)
|
||||||
|
self.server.unshelve.assert_called_with(availability_zone="foo-az")
|
||||||
|
|
||||||
|
|
||||||
class TestServerGeneral(TestServer):
|
class TestServerGeneral(TestServer):
|
||||||
OLD = {
|
OLD = {
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Add ``--availability-zone`` option to ``server unshelve``
|
||||||
|
command to enable users to specify an availability zone during
|
||||||
|
unshelve of a shelved offloaded server. Note that it requires
|
||||||
|
``--os-compute-api-version 2.77`` or greater.
|
||||||
|
[Blueprint ` <https://blueprints.launchpad.net/nova/+spec/support-specifying-az-when-restore-shelved-server`_]
|
@ -13,5 +13,5 @@ oslo.i18n>=3.15.3 # Apache-2.0
|
|||||||
oslo.utils>=3.33.0 # Apache-2.0
|
oslo.utils>=3.33.0 # Apache-2.0
|
||||||
python-glanceclient>=2.8.0 # Apache-2.0
|
python-glanceclient>=2.8.0 # Apache-2.0
|
||||||
python-keystoneclient>=3.17.0 # Apache-2.0
|
python-keystoneclient>=3.17.0 # Apache-2.0
|
||||||
python-novaclient>=14.2.0 # Apache-2.0
|
python-novaclient>=15.0.0 # Apache-2.0
|
||||||
python-cinderclient>=3.3.0 # Apache-2.0
|
python-cinderclient>=3.3.0 # Apache-2.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user