Deprecate nova CLI
It is time to signal that we're fully committed to delivering a pure
OSC experience.
Based on the neutron change from 6 (!!) years ago [1]
[1] 3a64a7a166
Change-Id: Ib80548e104a751179f36f2a6ebff9916d38fdf1e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
cd08a84717
commit
0fb7190c06
@ -20,6 +20,7 @@ Command-line interface to the OpenStack Nova API.
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from keystoneauth1 import loading
|
||||
@ -816,9 +817,19 @@ class OpenStackHelpFormatter(argparse.HelpFormatter):
|
||||
super(OpenStackHelpFormatter, self).start_section(heading)
|
||||
|
||||
|
||||
def main():
|
||||
def main(argv=sys.argv[1:]):
|
||||
try:
|
||||
argv = [encodeutils.safe_decode(a) for a in sys.argv[1:]]
|
||||
# Special dansmith envvar to hide the warning. Don't rely on this
|
||||
# because we will eventually remove all this stuff.
|
||||
if os.environ.get("NOVACLIENT_ISHOULDNTBEDOINGTHIS") != "1":
|
||||
print(
|
||||
_(
|
||||
"nova CLI is deprecated and will be a removed in a future "
|
||||
"release"
|
||||
),
|
||||
file=sys.stderr,
|
||||
)
|
||||
argv = [encodeutils.safe_decode(a) for a in argv]
|
||||
OpenStackComputeShell().main(argv)
|
||||
except Exception as exc:
|
||||
logger.debug(exc, exc_info=1)
|
||||
|
@ -624,26 +624,32 @@ class ShellTest(utils.TestCase):
|
||||
self._test_service_type,
|
||||
'unknown', 'compute', self.mock_client)
|
||||
|
||||
@mock.patch('sys.argv', ['nova'])
|
||||
@mock.patch('sys.stdout', io.StringIO())
|
||||
@mock.patch('sys.stderr', io.StringIO())
|
||||
def test_main_noargs(self):
|
||||
# Ensure that main works with no command-line arguments
|
||||
try:
|
||||
novaclient.shell.main()
|
||||
novaclient.shell.main([])
|
||||
except SystemExit:
|
||||
self.fail('Unexpected SystemExit')
|
||||
|
||||
# We expect the normal usage as a result
|
||||
self.assertIn('Command-line interface to the OpenStack Nova API',
|
||||
sys.stdout.getvalue())
|
||||
self.assertIn(
|
||||
'Command-line interface to the OpenStack Nova API',
|
||||
sys.stdout.getvalue(),
|
||||
)
|
||||
# We also expect to see the deprecation warning
|
||||
self.assertIn(
|
||||
'nova CLI is deprecated and will be a removed in a future release',
|
||||
sys.stderr.getvalue(),
|
||||
)
|
||||
|
||||
@mock.patch.object(novaclient.shell.OpenStackComputeShell, 'main')
|
||||
def test_main_keyboard_interrupt(self, mock_compute_shell):
|
||||
# Ensure that exit code is 130 for KeyboardInterrupt
|
||||
mock_compute_shell.side_effect = KeyboardInterrupt()
|
||||
try:
|
||||
novaclient.shell.main()
|
||||
novaclient.shell.main([])
|
||||
except SystemExit as ex:
|
||||
self.assertEqual(ex.code, 130)
|
||||
|
||||
@ -766,9 +772,15 @@ class ShellTest(utils.TestCase):
|
||||
pass
|
||||
with mock.patch('sys.stderr', io.StringIO()):
|
||||
mock_compute_shell.side_effect = MyException('message')
|
||||
self.assertRaises(SystemExit, novaclient.shell.main)
|
||||
self.assertRaises(SystemExit, novaclient.shell.main, [])
|
||||
err = sys.stderr.getvalue()
|
||||
self.assertEqual(err, 'ERROR (MyException): message\n')
|
||||
# We expect to see the error propagated
|
||||
self.assertIn('ERROR (MyException): message\n', err)
|
||||
# We also expect to see the deprecation warning
|
||||
self.assertIn(
|
||||
'nova CLI is deprecated and will be a removed in a future release',
|
||||
err,
|
||||
)
|
||||
|
||||
|
||||
class TestLoadVersionedActions(utils.TestCase):
|
||||
|
9
releasenotes/notes/deprecate-cli-75074850847a8452.yaml
Normal file
9
releasenotes/notes/deprecate-cli-75074850847a8452.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
deprecations:
|
||||
- |
|
||||
The ``nova`` CLI is now deprecated. This is the signal that it is
|
||||
time to start using the openstack CLI. No new features will be
|
||||
added to the ``nova`` CLI, though fixes to the CLI will be assessed
|
||||
on a case by case basis. Fixes to the API bindings, development of
|
||||
new API bindings, and changes to the compute commands in the openstack
|
||||
CLI are exempt from this deprecation.
|
Loading…
Reference in New Issue
Block a user