diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-07-15 00:40:25 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-07-15 00:40:26 +0000 |
commit | 5eb7b65f0d1aca4f62b5d5f451a99a43fd4265fc (patch) | |
tree | 5f1e840adffdc9986f65c2cf17ee95ffabc62a95 | |
parent | e39665f3363ee5ad4d88fb6c610cab9a6c72706e (diff) | |
parent | 87c1b5311b2e641564305a4753b989b6498775b1 (diff) | |
download | python-novaclient-5.0.0.tar.gz |
Merge "Deprecate baremetal API and CLI interfaces"5.0.0
-rw-r--r-- | novaclient/tests/unit/v2/contrib/test_baremetal.py | 13 | ||||
-rw-r--r-- | novaclient/v2/contrib/baremetal.py | 40 | ||||
-rw-r--r-- | releasenotes/notes/deprecate-baremetal-d67f58a2986b3565.yaml | 13 |
3 files changed, 55 insertions, 11 deletions
diff --git a/novaclient/tests/unit/v2/contrib/test_baremetal.py b/novaclient/tests/unit/v2/contrib/test_baremetal.py index fdcd4f5f..c892acb9 100644 --- a/novaclient/tests/unit/v2/contrib/test_baremetal.py +++ b/novaclient/tests/unit/v2/contrib/test_baremetal.py @@ -14,12 +14,16 @@ # under the License. +import mock +import warnings + from novaclient import extension from novaclient.tests.unit import utils from novaclient.tests.unit.v2.contrib import fakes from novaclient.v2.contrib import baremetal +@mock.patch.object(warnings, 'warn') class BaremetalExtensionTest(utils.TestCase): def setUp(self): super(BaremetalExtensionTest, self).setUp() @@ -28,20 +32,23 @@ class BaremetalExtensionTest(utils.TestCase): ] self.cs = fakes.FakeClient(extensions=extensions) - def test_list_nodes(self): + def test_list_nodes(self, mock_warn): nl = self.cs.baremetal.list() self.assert_request_id(nl, fakes.FAKE_REQUEST_ID_LIST) self.cs.assert_called('GET', '/os-baremetal-nodes') for n in nl: self.assertIsInstance(n, baremetal.BareMetalNode) + self.assertEqual(1, mock_warn.call_count) - def test_get_node(self): + def test_get_node(self, mock_warn): n = self.cs.baremetal.get(1) self.assert_request_id(n, fakes.FAKE_REQUEST_ID_LIST) self.cs.assert_called('GET', '/os-baremetal-nodes/1') self.assertIsInstance(n, baremetal.BareMetalNode) + self.assertEqual(1, mock_warn.call_count) - def test_node_list_interfaces(self): + def test_node_list_interfaces(self, mock_warn): il = self.cs.baremetal.list_interfaces(1) self.assert_request_id(il, fakes.FAKE_REQUEST_ID_LIST) self.cs.assert_called('GET', '/os-baremetal-nodes/1') + self.assertEqual(1, mock_warn.call_count) diff --git a/novaclient/v2/contrib/baremetal.py b/novaclient/v2/contrib/baremetal.py index 4307d6cc..7f013881 100644 --- a/novaclient/v2/contrib/baremetal.py +++ b/novaclient/v2/contrib/baremetal.py @@ -17,14 +17,32 @@ Baremetal interface (v2 extension). """ +from __future__ import print_function + +import sys +import warnings + from novaclient import base from novaclient.i18n import _ from novaclient import utils +DEPRECATION_WARNING = ( + 'The novaclient.v2.contrib.baremetal module is deprecated and ' + 'will be removed after Nova 15.0.0 is released. Use ' + 'python-ironicclient or openstacksdk instead.') + + +def _emit_deprecation_warning(command_name): + print('WARNING: Command %s is deprecated and will be removed after Nova ' + '15.0.0 is released. Use python-ironicclient or ' + 'python-openstackclient instead.' % command_name, file=sys.stderr) + + class BareMetalNode(base.Resource): """ - A baremetal node (typically a physical server or an empty VM). + DEPRECATED: A baremetal node (typically a physical server or an + empty VM). """ def __repr__(self): @@ -42,34 +60,37 @@ class BareMetalNodeInterface(base.Resource): class BareMetalNodeManager(base.ManagerWithFind): """ - Manage :class:`BareMetalNode` resources. + DEPRECATED: Manage :class:`BareMetalNode` resources. """ resource_class = BareMetalNode def get(self, node_id): """ - Get a baremetal node. + DEPRECATED: Get a baremetal node. :param node_id: The ID of the node to delete. :rtype: :class:`BareMetalNode` """ + warnings.warn(DEPRECATION_WARNING, DeprecationWarning) return self._get("/os-baremetal-nodes/%s" % node_id, 'node') def list(self): """ - Get a list of all baremetal nodes. + DEPRECATED: Get a list of all baremetal nodes. :rtype: list of :class:`BareMetalNode` """ + warnings.warn(DEPRECATION_WARNING, DeprecationWarning) return self._list('/os-baremetal-nodes', 'nodes') def list_interfaces(self, node_id): """ - List the interfaces on a baremetal node. + DEPRECATED: List the interfaces on a baremetal node. :param node_id: The ID of the node to list. :rtype: novaclient.base.ListWithMeta """ + warnings.warn(DEPRECATION_WARNING, DeprecationWarning) interfaces = base.ListWithMeta([], None) node = self._get("/os-baremetal-nodes/%s" % node_id, 'node') interfaces.append_request_ids(node.request_ids) @@ -125,7 +146,8 @@ def _print_baremetal_nodes_list(nodes): def do_baremetal_node_list(cs, _args): - """Print list of available baremetal nodes.""" + """DEPRECATED: Print list of available baremetal nodes.""" + _emit_deprecation_warning('baremetal-node-list') nodes = cs.baremetal.list() _print_baremetal_nodes_list(nodes) @@ -156,13 +178,15 @@ def _print_baremetal_node_interfaces(interfaces): metavar='<node>', help=_("ID of node")) def do_baremetal_node_show(cs, args): - """Show information about a baremetal node.""" + """DEPRECATED: Show information about a baremetal node.""" + _emit_deprecation_warning('baremetal-node-show') node = _find_baremetal_node(cs, args.node) _print_baremetal_resource(node) @utils.arg('node', metavar='<node>', help=_("ID of node")) def do_baremetal_interface_list(cs, args): - """List network interfaces associated with a baremetal node.""" + """DEPRECATED: List network interfaces associated with a baremetal node.""" + _emit_deprecation_warning('baremetal-interface-list') interfaces = cs.baremetal.list_interfaces(args.node) _print_baremetal_node_interfaces(interfaces) diff --git a/releasenotes/notes/deprecate-baremetal-d67f58a2986b3565.yaml b/releasenotes/notes/deprecate-baremetal-d67f58a2986b3565.yaml new file mode 100644 index 00000000..12333467 --- /dev/null +++ b/releasenotes/notes/deprecate-baremetal-d67f58a2986b3565.yaml @@ -0,0 +1,13 @@ +--- +deprecations: + - | + The following CLIs and python API bindings are now deprecated for removal: + + * nova baremetal-node-list + * nova baremetal-node-show + * nova baremetal-interface-list + + These will be removed in the first major python-novaclient release after + the Nova 15.0.0 Ocata release. Use python-ironicclient or + python-openstackclient for CLI and python-ironicclient or openstacksdk + for python API bindings. |