summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2022-04-05 17:48:01 +0100
committerStephen Finucane <stephenfin@redhat.com>2022-04-06 14:17:59 +0100
commit0fb7190c062a08a3969a71955c014e3a572cdc9e (patch)
tree3001530e3c0741f2bec3d563cf64c1dd4511e8d5
parentcd08a847179d144fea03a7ffd8f92b06c387b966 (diff)
downloadpython-novaclient-0fb7190c062a08a3969a71955c014e3a572cdc9e.tar.gz
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] https://github.com/openstack/python-neutronclient/commit/3a64a7a166be25d40436fd40c8351a79267bd3c4 Change-Id: Ib80548e104a751179f36f2a6ebff9916d38fdf1e Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
-rw-r--r--novaclient/shell.py15
-rw-r--r--novaclient/tests/unit/test_shell.py26
-rw-r--r--releasenotes/notes/deprecate-cli-75074850847a8452.yaml9
3 files changed, 41 insertions, 9 deletions
diff --git a/novaclient/shell.py b/novaclient/shell.py
index 7762be9b..468e889b 100644
--- a/novaclient/shell.py
+++ b/novaclient/shell.py
@@ -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)
diff --git a/novaclient/tests/unit/test_shell.py b/novaclient/tests/unit/test_shell.py
index 64195291..b6b708a8 100644
--- a/novaclient/tests/unit/test_shell.py
+++ b/novaclient/tests/unit/test_shell.py
@@ -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):
diff --git a/releasenotes/notes/deprecate-cli-75074850847a8452.yaml b/releasenotes/notes/deprecate-cli-75074850847a8452.yaml
new file mode 100644
index 00000000..6d51ce03
--- /dev/null
+++ b/releasenotes/notes/deprecate-cli-75074850847a8452.yaml
@@ -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.