diff --git a/novaclient/client.py b/novaclient/client.py index 9ca9658c7..aac0e8eb2 100644 --- a/novaclient/client.py +++ b/novaclient/client.py @@ -206,8 +206,7 @@ def _discover_via_python_path(): def _discover_via_contrib_path(version): if version.ver_major == 2: - modules = {"baremetal": "novaclient.v2.contrib.baremetal", - "tenant_networks": "novaclient.v2.contrib.tenant_networks"} + modules = {"tenant_networks": "novaclient.v2.contrib.tenant_networks"} for name, module_name in modules.items(): module_loader = pkgutil.get_loader(module_name) diff --git a/novaclient/tests/unit/v2/contrib/test_baremetal.py b/novaclient/tests/unit/v2/contrib/test_baremetal.py deleted file mode 100644 index 512245402..000000000 --- a/novaclient/tests/unit/v2/contrib/test_baremetal.py +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2013 Hewlett-Packard Development Company, L.P. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -import warnings - -import mock - -from novaclient import api_versions -from novaclient import extension -from novaclient.tests.unit import utils -from novaclient.tests.unit.v2 import fakes -from novaclient.v2.contrib import baremetal - - -@mock.patch.object(warnings, 'warn') -class BaremetalExtensionTest(utils.TestCase): - def setUp(self): - super(BaremetalExtensionTest, self).setUp() - extensions = [ - extension.Extension(baremetal.__name__.split(".")[-1], baremetal), - ] - self.cs = fakes.FakeClient(api_versions.APIVersion("2.0"), - extensions=extensions) - - 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, 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, 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/tests/unit/v2/fakes.py b/novaclient/tests/unit/v2/fakes.py index 4f75c2a28..ef5c6014b 100644 --- a/novaclient/tests/unit/v2/fakes.py +++ b/novaclient/tests/unit/v2/fakes.py @@ -2350,50 +2350,6 @@ class FakeSessionClient(base_client.SessionClient): def delete_os_tenant_networks_1(self, **kw): return (204, FAKE_RESPONSE_HEADERS, None) - def get_os_baremetal_nodes(self, **kw): - return ( - 200, FAKE_RESPONSE_HEADERS, { - 'nodes': [ - { - "id": 1, - "instance_uuid": None, - "interfaces": [], - "cpus": 2, - "local_gb": 10, - "memory_mb": 5, - "pm_address": "2.3.4.5", - "pm_user": "pmuser", - "pm_password": "pmpass", - "prov_mac_address": "aa:bb:cc:dd:ee:ff", - "prov_vlan_id": 1, - "service_host": "somehost", - "terminal_port": 8080, - } - ] - } - ) - - def get_os_baremetal_nodes_1(self, **kw): - return ( - 200, FAKE_RESPONSE_HEADERS, { - 'node': { - "id": 1, - "instance_uuid": None, - "pm_address": "1.2.3.4", - "interfaces": [], - "cpus": 2, - "local_gb": 10, - "memory_mb": 5, - "pm_user": "pmuser", - "pm_password": "pmpass", - "prov_mac_address": "aa:bb:cc:dd:ee:ff", - "prov_vlan_id": 1, - "service_host": "somehost", - "terminal_port": 8080, - } - } - ) - def post_os_assisted_volume_snapshots(self, **kw): return (202, FAKE_RESPONSE_HEADERS, {'snapshot': {'id': 'blah', 'volumeId': '1'}}) diff --git a/novaclient/v2/client.py b/novaclient/v2/client.py index 2db2f221e..d216a94ae 100644 --- a/novaclient/v2/client.py +++ b/novaclient/v2/client.py @@ -196,8 +196,8 @@ class Client(object): server_migrations.ServerMigrationsManager(self) # V2.0 extensions: - # NOTE(andreykurilin): baremetal and tenant_networks extensions are - # deprecated now, which is why they are not initialized by default. + # NOTE(andreykurilin): tenant_networks extension is + # deprecated now, which is why it is not initialized by default. self.assisted_volume_snapshots = \ assisted_volume_snapshots.AssistedSnapshotManager(self) self.cells = cells.CellsManager(self) diff --git a/novaclient/v2/contrib/__init__.py b/novaclient/v2/contrib/__init__.py index 80acf65f5..eb225b881 100644 --- a/novaclient/v2/contrib/__init__.py +++ b/novaclient/v2/contrib/__init__.py @@ -15,9 +15,9 @@ import warnings from novaclient.i18n import _LW -# NOTE(andreykurilin): "baremetal" and "tenant_networks" extensions excluded -# here deliberately. They were deprecated separately from deprecation -# extension mechanism and I prefer to not auto-load them by default +# NOTE(andreykurilin): "tenant_networks" extension excluded +# here deliberately. It was deprecated separately from deprecation +# extension mechanism and I prefer to not auto-load it by default # (V2_0_EXTENSIONS is designed for such behaviour). V2_0_EXTENSIONS = { 'assisted_volume_snapshots': diff --git a/novaclient/v2/contrib/baremetal.py b/novaclient/v2/contrib/baremetal.py deleted file mode 100644 index 57933891d..000000000 --- a/novaclient/v2/contrib/baremetal.py +++ /dev/null @@ -1,196 +0,0 @@ -# Copyright 2013 Hewlett-Packard Development Company, L.P. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -Baremetal interface (v2 extension). -""" - -from __future__ import print_function - -import sys -import warnings - -from novaclient import api_versions -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): - """ - DEPRECATED: A baremetal node (typically a physical server or an - empty VM). - """ - - def __repr__(self): - return "" % self.id - - -class BareMetalNodeInterface(base.Resource): - """ - An interface belonging to a baremetal node. - """ - - def __repr__(self): - return "" % self.id - - -class BareMetalNodeManager(base.ManagerWithFind): - """ - DEPRECATED: Manage :class:`BareMetalNode` resources. - """ - resource_class = BareMetalNode - - @api_versions.wraps('2.0', '2.35') - def get(self, node_id): - """ - 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') - - @api_versions.wraps('2.0', '2.35') - def list(self): - """ - 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') - - @api_versions.wraps('2.0', '2.35') - def list_interfaces(self, node_id): - """ - 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) - for interface in node.interfaces: - interface_object = BareMetalNodeInterface(self, interface) - interfaces.append(interface_object) - return interfaces - - -def _translate_baremetal_node_keys(collection): - convert = [('service_host', 'host'), - ('local_gb', 'disk_gb'), - ('prov_mac_address', 'mac_address'), - ('pm_address', 'pm_address'), - ('pm_user', 'pm_username'), - ('pm_password', 'pm_password'), - ('terminal_port', 'terminal_port'), - ] - for item in collection: - keys = item.__dict__.keys() - for from_key, to_key in convert: - if from_key in keys and to_key not in keys: - setattr(item, to_key, item._info[from_key]) - - -def _print_baremetal_nodes_list(nodes): - """Print the list of baremetal nodes.""" - - def _parse_address(fields): - macs = [] - for interface in fields.interfaces: - macs.append(interface['address']) - return ', '.join("%s" % i for i in macs) - - formatters = { - 'MAC Address': _parse_address - } - - _translate_baremetal_node_keys(nodes) - utils.print_list(nodes, [ - 'ID', - 'Host', - 'Task State', - 'CPUs', - 'Memory_MB', - 'Disk_GB', - 'MAC Address', - 'PM Address', - 'PM Username', - 'PM Password', - 'Terminal Port', - ], formatters=formatters) - - -def do_baremetal_node_list(cs, _args): - """DEPRECATED: Print list of available baremetal nodes.""" - _emit_deprecation_warning('baremetal-node-list') - nodes = cs.baremetal.list() - _print_baremetal_nodes_list(nodes) - - -def _find_baremetal_node(cs, node): - """Get a node by ID.""" - return utils.find_resource(cs.baremetal, node) - - -def _print_baremetal_resource(resource): - """Print details of a baremetal resource.""" - info = resource._info.copy() - utils.print_dict(info) - - -def _print_baremetal_node_interfaces(interfaces): - """Print interfaces of a baremetal node.""" - utils.print_list(interfaces, [ - 'ID', - 'Datapath_ID', - 'Port_No', - 'Address', - ]) - - -@utils.arg( - 'node', - metavar='', - help=_("ID of node")) -def do_baremetal_node_show(cs, args): - """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='', help=_("ID of node")) -def do_baremetal_interface_list(cs, args): - """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/rm-baremetal-cli-api-fbc8c242d48cd2fb.yaml b/releasenotes/notes/rm-baremetal-cli-api-fbc8c242d48cd2fb.yaml new file mode 100644 index 000000000..d35a7349c --- /dev/null +++ b/releasenotes/notes/rm-baremetal-cli-api-fbc8c242d48cd2fb.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - | + The baremetal CLIs and python API bindings were deprecated in the Newton + release and have been removed. Use python-openstackclient or + python-ironicclient for CLIs. Use python-ironicclient or openstacksdk for + python API bindings \ No newline at end of file