2.44: Deprecate multinic/floatingIP actions and os-virtual-interfaces

The 2.44 microversion deprecates the addFixedIP, removeFixedIP,
addFloatingIP, removeFloatingIP server action APIs and
os-virtual-interfaces API.

This change deprecates the CLIs and python API bindings in novaclient.

Implements blueprint deprecate-multinic-proxy-api

Change-Id: Ie76283962c375b735f30ccb3053db07cf2330de2
This commit is contained in:
Matt Riedemann 2017-04-25 16:24:50 -04:00
parent ea3b9f7fef
commit e303cf11bf
7 changed files with 106 additions and 22 deletions

View File

@ -25,4 +25,4 @@ API_MIN_VERSION = api_versions.APIVersion("2.1")
# when client supported the max version, and bumped sequentially, otherwise # when client supported the max version, and bumped sequentially, otherwise
# the client may break due to server side new version may include some # the client may break due to server side new version may include some
# backward incompatible change. # backward incompatible change.
API_MAX_VERSION = api_versions.APIVersion("2.43") API_MAX_VERSION = api_versions.APIVersion("2.44")

View File

@ -556,27 +556,33 @@ class ServersTest(utils.FixturedTestCase):
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST) self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
self.assert_called('POST', '/servers/1234/action') self.assert_called('POST', '/servers/1234/action')
def test_add_fixed_ip(self): @mock.patch('warnings.warn')
def test_add_fixed_ip(self, mock_warn):
s = self.cs.servers.get(1234) s = self.cs.servers.get(1234)
fip = s.add_fixed_ip(1) fip = s.add_fixed_ip(1)
mock_warn.assert_called_once()
self.assert_request_id(fip, fakes.FAKE_REQUEST_ID_LIST) self.assert_request_id(fip, fakes.FAKE_REQUEST_ID_LIST)
self.assert_called('POST', '/servers/1234/action') self.assert_called('POST', '/servers/1234/action')
fip = self.cs.servers.add_fixed_ip(s, 1) fip = self.cs.servers.add_fixed_ip(s, 1)
self.assert_request_id(fip, fakes.FAKE_REQUEST_ID_LIST) self.assert_request_id(fip, fakes.FAKE_REQUEST_ID_LIST)
self.assert_called('POST', '/servers/1234/action') self.assert_called('POST', '/servers/1234/action')
def test_remove_fixed_ip(self): @mock.patch('warnings.warn')
def test_remove_fixed_ip(self, mock_warn):
s = self.cs.servers.get(1234) s = self.cs.servers.get(1234)
ret = s.remove_fixed_ip('10.0.0.1') ret = s.remove_fixed_ip('10.0.0.1')
mock_warn.assert_called_once()
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST) self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
self.assert_called('POST', '/servers/1234/action') self.assert_called('POST', '/servers/1234/action')
ret = self.cs.servers.remove_fixed_ip(s, '10.0.0.1') ret = self.cs.servers.remove_fixed_ip(s, '10.0.0.1')
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST) self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
self.assert_called('POST', '/servers/1234/action') self.assert_called('POST', '/servers/1234/action')
def test_add_floating_ip(self): @mock.patch('warnings.warn')
def test_add_floating_ip(self, mock_warn):
s = self.cs.servers.get(1234) s = self.cs.servers.get(1234)
fip = s.add_floating_ip('11.0.0.1') fip = s.add_floating_ip('11.0.0.1')
mock_warn.assert_called_once()
self.assert_request_id(fip, fakes.FAKE_REQUEST_ID_LIST) self.assert_request_id(fip, fakes.FAKE_REQUEST_ID_LIST)
self.assert_called('POST', '/servers/1234/action') self.assert_called('POST', '/servers/1234/action')
fip = self.cs.servers.add_floating_ip(s, '11.0.0.1') fip = self.cs.servers.add_floating_ip(s, '11.0.0.1')
@ -607,9 +613,11 @@ class ServersTest(utils.FixturedTestCase):
self.assert_request_id(fip, fakes.FAKE_REQUEST_ID_LIST) self.assert_request_id(fip, fakes.FAKE_REQUEST_ID_LIST)
self.assert_called('POST', '/servers/1234/action') self.assert_called('POST', '/servers/1234/action')
def test_remove_floating_ip(self): @mock.patch('warnings.warn')
def test_remove_floating_ip(self, mock_warn):
s = self.cs.servers.get(1234) s = self.cs.servers.get(1234)
ret = s.remove_floating_ip('11.0.0.1') ret = s.remove_floating_ip('11.0.0.1')
mock_warn.assert_called_once()
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST) self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
self.assert_called('POST', '/servers/1234/action') self.assert_called('POST', '/servers/1234/action')
ret = self.cs.servers.remove_floating_ip(s, '11.0.0.1') ret = self.cs.servers.remove_floating_ip(s, '11.0.0.1')

View File

@ -1671,12 +1671,18 @@ class ShellTest(utils.TestCase):
self.assert_called('DELETE', '/servers/uuid2/metadata/key1', pos=2) self.assert_called('DELETE', '/servers/uuid2/metadata/key1', pos=2)
def test_server_floating_ip_associate(self): def test_server_floating_ip_associate(self):
self.run_command('floating-ip-associate sample-server 11.0.0.1') _, err = self.run_command(
'floating-ip-associate sample-server 11.0.0.1')
self.assertIn('WARNING: Command floating-ip-associate is deprecated',
err)
self.assert_called('POST', '/servers/1234/action', self.assert_called('POST', '/servers/1234/action',
{'addFloatingIp': {'address': '11.0.0.1'}}) {'addFloatingIp': {'address': '11.0.0.1'}})
def test_server_floating_ip_disassociate(self): def test_server_floating_ip_disassociate(self):
self.run_command('floating-ip-disassociate sample-server 11.0.0.1') _, err = self.run_command(
'floating-ip-disassociate sample-server 11.0.0.1')
self.assertIn(
'WARNING: Command floating-ip-disassociate is deprecated', err)
self.assert_called('POST', '/servers/1234/action', self.assert_called('POST', '/servers/1234/action',
{'removeFloatingIp': {'address': '11.0.0.1'}}) {'removeFloatingIp': {'address': '11.0.0.1'}})
@ -2500,12 +2506,14 @@ class ShellTest(utils.TestCase):
self.assert_called('PUT', '/os-cloudpipe/configure-project', body) self.assert_called('PUT', '/os-cloudpipe/configure-project', body)
def test_add_fixed_ip(self): def test_add_fixed_ip(self):
self.run_command('add-fixed-ip sample-server 1') _, err = self.run_command('add-fixed-ip sample-server 1')
self.assertIn('WARNING: Command add-fixed-ip is deprecated', err)
self.assert_called('POST', '/servers/1234/action', self.assert_called('POST', '/servers/1234/action',
{'addFixedIp': {'networkId': '1'}}) {'addFixedIp': {'networkId': '1'}})
def test_remove_fixed_ip(self): def test_remove_fixed_ip(self):
self.run_command('remove-fixed-ip sample-server 10.0.0.10') _, err = self.run_command('remove-fixed-ip sample-server 10.0.0.10')
self.assertIn('WARNING: Command remove-fixed-ip is deprecated', err)
self.assert_called('POST', '/servers/1234/action', self.assert_called('POST', '/servers/1234/action',
{'removeFixedIp': {'address': '10.0.0.10'}}) {'removeFixedIp': {'address': '10.0.0.10'}})
@ -2867,7 +2875,9 @@ class ShellTest(utils.TestCase):
self.assert_called('GET', '/os-server-groups?limit=20&offset=5') self.assert_called('GET', '/os-server-groups?limit=20&offset=5')
def test_list_server_os_virtual_interfaces(self): def test_list_server_os_virtual_interfaces(self):
self.run_command('virtual-interface-list 1234') _, err = self.run_command('virtual-interface-list 1234')
self.assertIn('WARNING: Command virtual-interface-list is deprecated',
err)
self.assert_called('GET', '/servers/1234/os-virtual-interfaces') self.assert_called('GET', '/servers/1234/os-virtual-interfaces')
def test_versions(self): def test_versions(self):
@ -2903,6 +2913,7 @@ class ShellTest(utils.TestCase):
41, # There are no version-wrapped shell method changes for this. 41, # There are no version-wrapped shell method changes for this.
42, # There are no version-wrapped shell method changes for this. 42, # There are no version-wrapped shell method changes for this.
43, # There are no version-wrapped shell method changes for this. 43, # There are no version-wrapped shell method changes for this.
44, # There are no version-wrapped shell method changes for this.
]) ])
versions_supported = set(range(0, versions_supported = set(range(0,
novaclient.API_MAX_VERSION.ver_minor + 1)) novaclient.API_MAX_VERSION.ver_minor + 1))

View File

@ -20,6 +20,7 @@ Server interface.
""" """
import base64 import base64
import warnings
from oslo_utils import encodeutils from oslo_utils import encodeutils
import six import six
@ -51,6 +52,12 @@ CONSOLE_TYPE_PROTOCOL_MAPPING = {
'webmks': 'mks' 'webmks': 'mks'
} }
ADD_REMOVE_FIXED_FLOATING_DEPRECATION_WARNING = _(
'The %s server action API is deprecated as of the 2.44 microversion. This '
'API binding will be removed in the first major release after the Nova '
'16.0.0 Pike release. Use python-neutronclient or openstacksdk instead.'
)
class Server(base.Resource): class Server(base.Resource):
HUMAN_ID = True HUMAN_ID = True
@ -871,29 +878,36 @@ class ServerManager(base.BootingManagerWithFind):
marker = result[-1].id marker = result[-1].id
return result return result
@api_versions.wraps('2.0', '2.43')
def add_fixed_ip(self, server, network_id): def add_fixed_ip(self, server, network_id):
""" """
Add an IP address on a network. DEPRECATED Add an IP address on a network.
:param server: The :class:`Server` (or its ID) to add an IP to. :param server: The :class:`Server` (or its ID) to add an IP to.
:param network_id: The ID of the network the IP should be on. :param network_id: The ID of the network the IP should be on.
:returns: An instance of novaclient.base.TupleWithMeta :returns: An instance of novaclient.base.TupleWithMeta
""" """
warnings.warn(ADD_REMOVE_FIXED_FLOATING_DEPRECATION_WARNING %
'addFixedIP', DeprecationWarning)
return self._action('addFixedIp', server, {'networkId': network_id}) return self._action('addFixedIp', server, {'networkId': network_id})
@api_versions.wraps('2.0', '2.43')
def remove_fixed_ip(self, server, address): def remove_fixed_ip(self, server, address):
""" """
Remove an IP address. DEPRECATED Remove an IP address.
:param server: The :class:`Server` (or its ID) to add an IP to. :param server: The :class:`Server` (or its ID) to add an IP to.
:param address: The IP address to remove. :param address: The IP address to remove.
:returns: An instance of novaclient.base.TupleWithMeta :returns: An instance of novaclient.base.TupleWithMeta
""" """
warnings.warn(ADD_REMOVE_FIXED_FLOATING_DEPRECATION_WARNING %
'removeFixedIP', DeprecationWarning)
return self._action('removeFixedIp', server, {'address': address}) return self._action('removeFixedIp', server, {'address': address})
@api_versions.wraps('2.0', '2.43')
def add_floating_ip(self, server, address, fixed_address=None): def add_floating_ip(self, server, address, fixed_address=None):
""" """
Add a floating IP to an instance DEPRECATED Add a floating IP to an instance
:param server: The :class:`Server` (or its ID) to add an IP to. :param server: The :class:`Server` (or its ID) to add an IP to.
:param address: The FloatingIP or string floating address to add. :param address: The FloatingIP or string floating address to add.
@ -901,7 +915,8 @@ class ServerManager(base.BootingManagerWithFind):
associated with (optional) associated with (optional)
:returns: An instance of novaclient.base.TupleWithMeta :returns: An instance of novaclient.base.TupleWithMeta
""" """
warnings.warn(ADD_REMOVE_FIXED_FLOATING_DEPRECATION_WARNING %
'addFloatingIP', DeprecationWarning)
address = address.ip if hasattr(address, 'ip') else address address = address.ip if hasattr(address, 'ip') else address
if fixed_address: if fixed_address:
if hasattr(fixed_address, 'ip'): if hasattr(fixed_address, 'ip'):
@ -912,15 +927,17 @@ class ServerManager(base.BootingManagerWithFind):
else: else:
return self._action('addFloatingIp', server, {'address': address}) return self._action('addFloatingIp', server, {'address': address})
@api_versions.wraps('2.0', '2.43')
def remove_floating_ip(self, server, address): def remove_floating_ip(self, server, address):
""" """
Remove a floating IP address. DEPRECATED Remove a floating IP address.
:param server: The :class:`Server` (or its ID) to remove an IP from. :param server: The :class:`Server` (or its ID) to remove an IP from.
:param address: The FloatingIP or string floating address to remove. :param address: The FloatingIP or string floating address to remove.
:returns: An instance of novaclient.base.TupleWithMeta :returns: An instance of novaclient.base.TupleWithMeta
""" """
warnings.warn(ADD_REMOVE_FIXED_FLOATING_DEPRECATION_WARNING %
'removeFloatingIP', DeprecationWarning)
address = address.ip if hasattr(address, 'ip') else address address = address.ip if hasattr(address, 'ip') else address
return self._action('removeFloatingIp', server, {'address': address}) return self._action('removeFloatingIp', server, {'address': address})

View File

@ -75,6 +75,17 @@ def emit_hosts_deprecation_warning(command_name, replacement=None):
file=sys.stderr) file=sys.stderr)
# NOTE(mriedem): Remove this along with the deprecated commands in the first
# major python-novaclient release AFTER the nova server 16.0.0 Pike release.
def emit_fixed_floating_deprecation_warning(command_name):
print(_('WARNING: Command %s is deprecated and will be removed '
'in the first major release after the Nova server 16.0.0 '
'Pike release. Use python-neutronclient or python-openstackclient'
'instead. Specify --os-compute-api-version less than 2.44 '
'to continue using this command until it is removed.') %
command_name, file=sys.stderr)
CLIENT_BDM2_KEYS = { CLIENT_BDM2_KEYS = {
'id': 'uuid', 'id': 'uuid',
'source': 'source_type', 'source': 'source_type',
@ -2200,7 +2211,8 @@ def _find_network_id(cs, net_name):
metavar='<network-id>', metavar='<network-id>',
help=_('Network ID.')) help=_('Network ID.'))
def do_add_fixed_ip(cs, args): def do_add_fixed_ip(cs, args):
"""Add new IP address on a network to server.""" """DEPRECATED Add new IP address on a network to server."""
emit_fixed_floating_deprecation_warning('add-fixed-ip')
server = _find_server(cs, args.server) server = _find_server(cs, args.server)
server.add_fixed_ip(args.network_id) server.add_fixed_ip(args.network_id)
@ -2208,7 +2220,8 @@ def do_add_fixed_ip(cs, args):
@utils.arg('server', metavar='<server>', help=_('Name or ID of server.')) @utils.arg('server', metavar='<server>', help=_('Name or ID of server.'))
@utils.arg('address', metavar='<address>', help=_('IP Address.')) @utils.arg('address', metavar='<address>', help=_('IP Address.'))
def do_remove_fixed_ip(cs, args): def do_remove_fixed_ip(cs, args):
"""Remove an IP address from a server.""" """DEPRECATED Remove an IP address from a server."""
emit_fixed_floating_deprecation_warning('remove-fixed-ip')
server = _find_server(cs, args.server) server = _find_server(cs, args.server)
server.remove_fixed_ip(args.address) server.remove_fixed_ip(args.address)
@ -2442,7 +2455,8 @@ def do_console_log(cs, args):
default=None, default=None,
help=_('Fixed IP Address to associate with.')) help=_('Fixed IP Address to associate with.'))
def do_floating_ip_associate(cs, args): def do_floating_ip_associate(cs, args):
"""Associate a floating IP address to a server.""" """DEPRECATED Associate a floating IP address to a server."""
emit_fixed_floating_deprecation_warning('floating-ip-associate')
_associate_floating_ip(cs, args) _associate_floating_ip(cs, args)
@ -2454,7 +2468,8 @@ def _associate_floating_ip(cs, args):
@utils.arg('server', metavar='<server>', help=_('Name or ID of server.')) @utils.arg('server', metavar='<server>', help=_('Name or ID of server.'))
@utils.arg('address', metavar='<address>', help=_('IP Address.')) @utils.arg('address', metavar='<address>', help=_('IP Address.'))
def do_floating_ip_disassociate(cs, args): def do_floating_ip_disassociate(cs, args):
"""Disassociate a floating IP address from a server.""" """DEPRECATED Disassociate a floating IP address from a server."""
emit_fixed_floating_deprecation_warning('floating-ip-disassociate')
_disassociate_floating_ip(cs, args) _disassociate_floating_ip(cs, args)
@ -4473,7 +4488,13 @@ def _print_virtual_interface_list(cs, interface_list):
@utils.arg('server', metavar='<server>', help=_('ID of server.')) @utils.arg('server', metavar='<server>', help=_('ID of server.'))
def do_virtual_interface_list(cs, args): def do_virtual_interface_list(cs, args):
"""Show virtual interface info about the given server.""" """DEPRECATED Show virtual interface info about the given server."""
print(_('WARNING: Command virtual-interface-list is deprecated and will '
'be removed in the first major release after the Nova server '
'16.0.0 Pike release. There is no replacement or alternative for '
'this command. Specify --os-compute-api-version less than 2.44 '
'to continue using this command until it is removed.'),
file=sys.stderr)
server = _find_server(cs, args.server) server = _find_server(cs, args.server)
interface_list = cs.virtual_interfaces.list(base.getid(server)) interface_list = cs.virtual_interfaces.list(base.getid(server))
_print_virtual_interface_list(cs, interface_list) _print_virtual_interface_list(cs, interface_list)

View File

@ -14,10 +14,14 @@
# under the License. # under the License.
""" """
Virtual Interfaces (1.1 extension). DEPRECATED Virtual Interfaces (1.1 extension).
""" """
import warnings
from novaclient import api_versions
from novaclient import base from novaclient import base
from novaclient.i18n import _
class VirtualInterface(base.Resource): class VirtualInterface(base.Resource):
@ -26,8 +30,15 @@ class VirtualInterface(base.Resource):
class VirtualInterfaceManager(base.ManagerWithFind): class VirtualInterfaceManager(base.ManagerWithFind):
"""DEPRECATED"""
resource_class = VirtualInterface resource_class = VirtualInterface
@api_versions.wraps('2.0', '2.43')
def list(self, instance_id): def list(self, instance_id):
"""DEPRECATED"""
warnings.warn(_('The os-virtual-interfaces API is deprecated. This '
'API binding will be removed in the first major '
'release after the Nova server 16.0.0 Pike release.'),
DeprecationWarning)
return self._list('/servers/%s/os-virtual-interfaces' % instance_id, return self._list('/servers/%s/os-virtual-interfaces' % instance_id,
'virtual_interfaces') 'virtual_interfaces')

View File

@ -0,0 +1,16 @@
---
deprecations:
- |
The following CLIs and their backing API bindings are deprecated and capped
at microversion 2.44:
* ``nova add-fixed-ip``: use python-neutronclient or openstacksdk
* ``nova remove-fixed-ip``: use python-neutronclient or openstacksdk
* ``nova floating-ip-associate``: use python-neutronclient or openstacksdk
* ``nova floating-ip-disassociate``: use python-neutronclient or
openstacksdk
* ``nova virtual-interface-list``: there is no replacement as this is
only implemented for nova-network which is deprecated
The CLIs and API bindings will be removed in the first major release after
Nova 16.0.0 Pike is released.