From b7742b59371b9e0b2e417547eb2cdaa80954b50d Mon Sep 17 00:00:00 2001
From: Sean McGinnis <sean.mcginnis@gmail.com>
Date: Tue, 23 Oct 2018 14:02:49 -0500
Subject: [PATCH] Remove deprecated compute commands

The following were deprecated over two years ago and can now be removed:

* ``ip fixed add|remove`` in favor of ``server add|remove fixed ip``
* ``ip floating add|remove`` in favor of ``server add|remove floating ip``

These are backwards incompatible changes and will require a major
version bump after they are merged.

Change-Id: I10c4d32a3c0b55ad41a02afd3b14249bafcb55a9
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
---
 doc/source/cli/backwards-incompatible.rst     |  17 ++-
 .../cli/command-objects/floating-ip-pool.rst  |   2 +-
 .../cli/command-objects/floating-ip.rst       |   2 +-
 doc/source/cli/command-objects/ip-fixed.rst   |  47 --------
 doc/source/cli/commands.rst                   |   9 +-
 openstackclient/compute/v2/fixedip.py         | 100 ------------------
 openstackclient/compute/v2/floatingip.py      |  97 -----------------
 .../notes/osc4-compute-09246008eff260cb.yaml  |   8 ++
 setup.cfg                                     |   6 --
 9 files changed, 27 insertions(+), 261 deletions(-)
 delete mode 100644 doc/source/cli/command-objects/ip-fixed.rst
 delete mode 100644 openstackclient/compute/v2/fixedip.py
 delete mode 100644 openstackclient/compute/v2/floatingip.py
 create mode 100644 releasenotes/notes/osc4-compute-09246008eff260cb.yaml

diff --git a/doc/source/cli/backwards-incompatible.rst b/doc/source/cli/backwards-incompatible.rst
index fcb68684bf..a86ce35977 100644
--- a/doc/source/cli/backwards-incompatible.rst
+++ b/doc/source/cli/backwards-incompatible.rst
@@ -16,9 +16,20 @@ from this backwards incompatible change handling.
 Backwards Incompatible Changes
 ==============================
 
-.. Carry this section as comments until 4.0 release
-.. Release 4.0
-.. -----------
+Release 4.0
+-----------
+
+1. Remove ``ip fixed add|remove`` commands.
+   Use ``server add|remove fixed ip`` commands instead.
+
+  * Removed in: 4.0
+  * Commit: https://review.opendev.org/612781
+
+2. Remove ``ip floating add|remove`` commands.
+   Use ``server add|remove floating ip`` commands instead.
+
+  * Removed in: 4.0
+  * Commit: https://review.opendev.org/612781
 
 .. 1. Change ``volume transfer request accept`` to use new option ``--auth-key``
 ..    rather than a second positional argument.
diff --git a/doc/source/cli/command-objects/floating-ip-pool.rst b/doc/source/cli/command-objects/floating-ip-pool.rst
index 9213b86dd0..5c8f3aa13d 100644
--- a/doc/source/cli/command-objects/floating-ip-pool.rst
+++ b/doc/source/cli/command-objects/floating-ip-pool.rst
@@ -2,7 +2,7 @@
 floating ip pool
 ================
 
-Compute v2, Network v2
+Network v2
 
 floating ip pool list
 ---------------------
diff --git a/doc/source/cli/command-objects/floating-ip.rst b/doc/source/cli/command-objects/floating-ip.rst
index 749c32d6b8..d122ccbea3 100644
--- a/doc/source/cli/command-objects/floating-ip.rst
+++ b/doc/source/cli/command-objects/floating-ip.rst
@@ -2,7 +2,7 @@
 floating ip
 ===========
 
-Compute v2, Network v2
+Network v2
 
 floating ip create
 ------------------
diff --git a/doc/source/cli/command-objects/ip-fixed.rst b/doc/source/cli/command-objects/ip-fixed.rst
deleted file mode 100644
index f5b11dc61b..0000000000
--- a/doc/source/cli/command-objects/ip-fixed.rst
+++ /dev/null
@@ -1,47 +0,0 @@
-========
-ip fixed
-========
-
-Compute v2
-
-ip fixed add
-------------
-
-Add fixed IP address to server
-(Deprecated, please use ``server add fixed ip`` instead)
-
-.. program:: ip fixed add
-.. code:: bash
-
-    openstack ip fixed add
-        <network>
-        <server>
-
-.. describe:: <network>
-
-    Network to fetch an IP address from (name or ID)
-
-.. describe:: <server>
-
-    Server to receive the IP address (name or ID)
-
-ip fixed remove
----------------
-
-Remove fixed IP address from server
-(Deprecated, please use ``server remove fixed ip`` instead)
-
-.. program:: ip fixed remove
-.. code:: bash
-
-    openstack ip fixed remove
-        <ip-address>
-        <server>
-
-.. describe:: <ip-address>
-
-    IP address to remove from server (name only)
-
-.. describe:: <server>
-
-    Server to remove the IP address from (name or ID)
diff --git a/doc/source/cli/commands.rst b/doc/source/cli/commands.rst
index e302fdad05..7c38aa5b5c 100644
--- a/doc/source/cli/commands.rst
+++ b/doc/source/cli/commands.rst
@@ -95,9 +95,9 @@ referring to both Compute and Volume quotas.
 * ``extension``: (**Compute**, **Identity**, **Network**, **Volume**) OpenStack server API extensions
 * ``federation protocol``: (**Identity**) the underlying protocol used while federating identities
 * ``flavor``: (**Compute**) predefined server configurations: ram, root disk and so on
-* ``fixed ip``: (**Compute**, **Network**) - an internal IP address assigned to a server
-* ``floating ip``: (**Compute**, **Network**) - a public IP address that can be mapped to a server
-* ``floating ip pool``: (**Compute**, **Network**) - a pool of public IP addresses
+* ``fixed ip``: (**Compute**) - an internal IP address assigned to a server
+* ``floating ip``: (**Network**) - a public IP address that can be mapped to a server
+* ``floating ip pool``: (**Network**) - a pool of public IP addresses
 * ``group``: (**Identity**) a grouping of users
 * ``host``: (**Compute**) - the physical computer running compute services
 * ``hypervisor``: (**Compute**) the virtual machine manager
@@ -106,9 +106,6 @@ referring to both Compute and Volume quotas.
 * ``image``: (**Image**) a disk image
 * ``image member``: (**Image**) a project that is a member of an Image
 * ``ip availability``: (**Network**) - details of IP usage of a network
-* ``ip fixed``: (**Compute**, **Network**) - an internal IP address assigned to a server
-* ``ip floating``: (**Compute**, **Network**) - a public IP address that can be mapped to a server
-* ``ip floating pool``: (**Compute**, **Network**) - a pool of public IP addresses
 * ``keypair``: (**Compute**) an SSH public key
 * ``limits``: (**Compute**, **Volume**) resource usage limits
 * ``mapping``: (**Identity**) a definition to translate identity provider attributes to Identity concepts
diff --git a/openstackclient/compute/v2/fixedip.py b/openstackclient/compute/v2/fixedip.py
deleted file mode 100644
index 0c0b619e8e..0000000000
--- a/openstackclient/compute/v2/fixedip.py
+++ /dev/null
@@ -1,100 +0,0 @@
-#   Copyright 2013 OpenStack Foundation
-#
-#   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.
-#
-
-"""Fixed IP action implementations"""
-
-import logging
-
-from osc_lib.command import command
-from osc_lib import utils
-
-from openstackclient.i18n import _
-
-
-class AddFixedIP(command.Command):
-    _description = _("Add fixed IP address to server")
-
-    # TODO(tangchen): Remove this class and ``ip fixed add`` command
-    #                 two cycles after Mitaka.
-
-    # This notifies cliff to not display the help for this command
-    deprecated = True
-
-    log = logging.getLogger('deprecated')
-
-    def get_parser(self, prog_name):
-        parser = super(AddFixedIP, self).get_parser(prog_name)
-        parser.add_argument(
-            "network",
-            metavar="<network>",
-            help=_("Network to fetch an IP address from (name or ID)"),
-        )
-        parser.add_argument(
-            "server",
-            metavar="<server>",
-            help=_("Server to receive the IP address (name or ID)"),
-        )
-        return parser
-
-    def take_action(self, parsed_args):
-        self.log.warning(_('This command has been deprecated. '
-                           'Please use "server add fixed ip" instead.'))
-
-        compute_client = self.app.client_manager.compute
-
-        network = utils.find_resource(
-            compute_client.networks, parsed_args.network)
-
-        server = utils.find_resource(
-            compute_client.servers, parsed_args.server)
-
-        server.add_fixed_ip(network.id)
-
-
-class RemoveFixedIP(command.Command):
-    _description = _("Remove fixed IP address from server")
-
-    # TODO(tangchen): Remove this class and ``ip fixed remove`` command
-    #                 two cycles after Mitaka.
-
-    # This notifies cliff to not display the help for this command
-    deprecated = True
-
-    log = logging.getLogger('deprecated')
-
-    def get_parser(self, prog_name):
-        parser = super(RemoveFixedIP, self).get_parser(prog_name)
-        parser.add_argument(
-            "ip_address",
-            metavar="<ip-address>",
-            help=_("IP address to remove from server (name only)"),
-        )
-        parser.add_argument(
-            "server",
-            metavar="<server>",
-            help=_("Server to remove the IP address from (name or ID)"),
-        )
-        return parser
-
-    def take_action(self, parsed_args):
-        self.log.warning(_('This command has been deprecated. '
-                           'Please use "server remove fixed ip" instead.'))
-
-        compute_client = self.app.client_manager.compute
-
-        server = utils.find_resource(
-            compute_client.servers, parsed_args.server)
-
-        server.remove_fixed_ip(parsed_args.ip_address)
diff --git a/openstackclient/compute/v2/floatingip.py b/openstackclient/compute/v2/floatingip.py
deleted file mode 100644
index 69595bed2f..0000000000
--- a/openstackclient/compute/v2/floatingip.py
+++ /dev/null
@@ -1,97 +0,0 @@
-#   Copyright 2013 OpenStack Foundation
-#
-#   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.
-#
-
-"""Floating IP action implementations"""
-
-import logging
-
-from osc_lib.command import command
-from osc_lib import utils
-
-from openstackclient.i18n import _
-
-
-class AddFloatingIP(command.Command):
-    _description = _("Add floating IP address to server")
-
-    # TODO(tangchen): Remove this class and ``ip floating add`` command
-    #                 two cycles after Mitaka.
-
-    # This notifies cliff to not display the help for this command
-    deprecated = True
-
-    log = logging.getLogger('deprecated')
-
-    def get_parser(self, prog_name):
-        parser = super(AddFloatingIP, self).get_parser(prog_name)
-        parser.add_argument(
-            "ip_address",
-            metavar="<ip-address>",
-            help=_("IP address to add to server (name only)"),
-        )
-        parser.add_argument(
-            "server",
-            metavar="<server>",
-            help=_("Server to receive the IP address (name or ID)"),
-        )
-        return parser
-
-    def take_action(self, parsed_args):
-        self.log.warning(_('This command has been deprecated. '
-                           'Please use "server add floating ip" instead.'))
-
-        compute_client = self.app.client_manager.compute
-
-        server = utils.find_resource(
-            compute_client.servers, parsed_args.server)
-
-        server.add_floating_ip(parsed_args.ip_address)
-
-
-class RemoveFloatingIP(command.Command):
-    _description = _("Remove floating IP address from server")
-
-    # TODO(tangchen): Remove this class and ``ip floating remove`` command
-    #                 two cycles after Mitaka.
-
-    # This notifies cliff to not display the help for this command
-    deprecated = True
-
-    log = logging.getLogger('deprecated')
-
-    def get_parser(self, prog_name):
-        parser = super(RemoveFloatingIP, self).get_parser(prog_name)
-        parser.add_argument(
-            "ip_address",
-            metavar="<ip-address>",
-            help=_("IP address to remove from server (name only)"),
-        )
-        parser.add_argument(
-            "server",
-            metavar="<server>",
-            help=_("Server to remove the IP address from (name or ID)"),
-        )
-        return parser
-
-    def take_action(self, parsed_args):
-        self.log.warning(_('This command has been deprecated. '
-                           'Please use "server remove floating ip" instead.'))
-
-        compute_client = self.app.client_manager.compute
-
-        server = utils.find_resource(
-            compute_client.servers, parsed_args.server)
-
-        server.remove_floating_ip(parsed_args.ip_address)
diff --git a/releasenotes/notes/osc4-compute-09246008eff260cb.yaml b/releasenotes/notes/osc4-compute-09246008eff260cb.yaml
new file mode 100644
index 0000000000..ab7baa67a0
--- /dev/null
+++ b/releasenotes/notes/osc4-compute-09246008eff260cb.yaml
@@ -0,0 +1,8 @@
+---
+upgrade:
+  - |
+    Remove deprecated ``ip fixed add|remove`` commands.
+    Use ``server add|remove fixed ip`` commands instead.
+  - |
+    Remove deprecated ``ip floating add|remove`` commands.
+    Use ``server add|remove floating ip`` commands instead.
diff --git a/setup.cfg b/setup.cfg
index db03c48423..031776a99d 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -91,12 +91,6 @@ openstack.compute.v2 =
 
     hypervisor_stats_show = openstackclient.compute.v2.hypervisor_stats:ShowHypervisorStats
 
-    ip_fixed_add = openstackclient.compute.v2.fixedip:AddFixedIP
-    ip_fixed_remove = openstackclient.compute.v2.fixedip:RemoveFixedIP
-
-    ip_floating_add = openstackclient.compute.v2.floatingip:AddFloatingIP
-    ip_floating_remove = openstackclient.compute.v2.floatingip:RemoveFloatingIP
-
     keypair_create = openstackclient.compute.v2.keypair:CreateKeypair
     keypair_delete = openstackclient.compute.v2.keypair:DeleteKeypair
     keypair_list = openstackclient.compute.v2.keypair:ListKeypair