Remove deprecated baremetal CLIs and APIs

These were all deprecated in Newton with change:

87c1b5311b

So now we can remove them.

Change-Id: Ic74a989b8a6565cc52ab82440fab8605a4b78e6b
This commit is contained in:
Matt Riedemann 2017-03-20 15:26:09 -04:00
parent ba24847cbe
commit dee51a0163
7 changed files with 13 additions and 304 deletions

View File

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

View File

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

View File

@ -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'}})

View File

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

View File

@ -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':

View File

@ -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 "<BareMetalNode: %s>" % self.id
class BareMetalNodeInterface(base.Resource):
"""
An interface belonging to a baremetal node.
"""
def __repr__(self):
return "<BareMetalNodeInterface: %s>" % 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='<node>',
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='<node>', 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)

View File

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