Deprecate baremetal API and CLI interfaces

Nova has a very bad read only baremetal proxy, which we will be
deprecating and removing. This signals this in our client.

Co-Authored-By: Jim Rollenhagen <jim@jimrollenhagen.com>
Change-Id: Icf479c29c0c43d91871f49fe4b71266954b0c3f7
This commit is contained in:
Sean Dague 2016-06-24 15:20:16 -04:00 committed by Matt Riedemann
parent 78a04ef4b2
commit 87c1b5311b
3 changed files with 55 additions and 11 deletions

View File

@ -14,12 +14,16 @@
# under the License. # under the License.
import mock
import warnings
from novaclient import extension from novaclient import extension
from novaclient.tests.unit import utils from novaclient.tests.unit import utils
from novaclient.tests.unit.v2.contrib import fakes from novaclient.tests.unit.v2.contrib import fakes
from novaclient.v2.contrib import baremetal from novaclient.v2.contrib import baremetal
@mock.patch.object(warnings, 'warn')
class BaremetalExtensionTest(utils.TestCase): class BaremetalExtensionTest(utils.TestCase):
def setUp(self): def setUp(self):
super(BaremetalExtensionTest, self).setUp() super(BaremetalExtensionTest, self).setUp()
@ -28,20 +32,23 @@ class BaremetalExtensionTest(utils.TestCase):
] ]
self.cs = fakes.FakeClient(extensions=extensions) self.cs = fakes.FakeClient(extensions=extensions)
def test_list_nodes(self): def test_list_nodes(self, mock_warn):
nl = self.cs.baremetal.list() nl = self.cs.baremetal.list()
self.assert_request_id(nl, fakes.FAKE_REQUEST_ID_LIST) self.assert_request_id(nl, fakes.FAKE_REQUEST_ID_LIST)
self.cs.assert_called('GET', '/os-baremetal-nodes') self.cs.assert_called('GET', '/os-baremetal-nodes')
for n in nl: for n in nl:
self.assertIsInstance(n, baremetal.BareMetalNode) 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) n = self.cs.baremetal.get(1)
self.assert_request_id(n, fakes.FAKE_REQUEST_ID_LIST) self.assert_request_id(n, fakes.FAKE_REQUEST_ID_LIST)
self.cs.assert_called('GET', '/os-baremetal-nodes/1') self.cs.assert_called('GET', '/os-baremetal-nodes/1')
self.assertIsInstance(n, baremetal.BareMetalNode) 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) il = self.cs.baremetal.list_interfaces(1)
self.assert_request_id(il, fakes.FAKE_REQUEST_ID_LIST) self.assert_request_id(il, fakes.FAKE_REQUEST_ID_LIST)
self.cs.assert_called('GET', '/os-baremetal-nodes/1') self.cs.assert_called('GET', '/os-baremetal-nodes/1')
self.assertEqual(1, mock_warn.call_count)

View File

@ -17,14 +17,32 @@
Baremetal interface (v2 extension). Baremetal interface (v2 extension).
""" """
from __future__ import print_function
import sys
import warnings
from novaclient import base from novaclient import base
from novaclient.i18n import _ from novaclient.i18n import _
from novaclient import utils 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): 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): def __repr__(self):
@ -42,34 +60,37 @@ class BareMetalNodeInterface(base.Resource):
class BareMetalNodeManager(base.ManagerWithFind): class BareMetalNodeManager(base.ManagerWithFind):
""" """
Manage :class:`BareMetalNode` resources. DEPRECATED: Manage :class:`BareMetalNode` resources.
""" """
resource_class = BareMetalNode resource_class = BareMetalNode
def get(self, node_id): def get(self, node_id):
""" """
Get a baremetal node. DEPRECATED: Get a baremetal node.
:param node_id: The ID of the node to delete. :param node_id: The ID of the node to delete.
:rtype: :class:`BareMetalNode` :rtype: :class:`BareMetalNode`
""" """
warnings.warn(DEPRECATION_WARNING, DeprecationWarning)
return self._get("/os-baremetal-nodes/%s" % node_id, 'node') return self._get("/os-baremetal-nodes/%s" % node_id, 'node')
def list(self): def list(self):
""" """
Get a list of all baremetal nodes. DEPRECATED: Get a list of all baremetal nodes.
:rtype: list of :class:`BareMetalNode` :rtype: list of :class:`BareMetalNode`
""" """
warnings.warn(DEPRECATION_WARNING, DeprecationWarning)
return self._list('/os-baremetal-nodes', 'nodes') return self._list('/os-baremetal-nodes', 'nodes')
def list_interfaces(self, node_id): 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. :param node_id: The ID of the node to list.
:rtype: novaclient.base.ListWithMeta :rtype: novaclient.base.ListWithMeta
""" """
warnings.warn(DEPRECATION_WARNING, DeprecationWarning)
interfaces = base.ListWithMeta([], None) interfaces = base.ListWithMeta([], None)
node = self._get("/os-baremetal-nodes/%s" % node_id, 'node') node = self._get("/os-baremetal-nodes/%s" % node_id, 'node')
interfaces.append_request_ids(node.request_ids) interfaces.append_request_ids(node.request_ids)
@ -125,7 +146,8 @@ def _print_baremetal_nodes_list(nodes):
def do_baremetal_node_list(cs, _args): 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() nodes = cs.baremetal.list()
_print_baremetal_nodes_list(nodes) _print_baremetal_nodes_list(nodes)
@ -156,13 +178,15 @@ def _print_baremetal_node_interfaces(interfaces):
metavar='<node>', metavar='<node>',
help=_("ID of node")) help=_("ID of node"))
def do_baremetal_node_show(cs, args): 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) node = _find_baremetal_node(cs, args.node)
_print_baremetal_resource(node) _print_baremetal_resource(node)
@utils.arg('node', metavar='<node>', help=_("ID of node")) @utils.arg('node', metavar='<node>', help=_("ID of node"))
def do_baremetal_interface_list(cs, args): 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) interfaces = cs.baremetal.list_interfaces(args.node)
_print_baremetal_node_interfaces(interfaces) _print_baremetal_node_interfaces(interfaces)

View File

@ -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.