From 62bb88f621140670c1c2f26397f97cd87fd66b18 Mon Sep 17 00:00:00 2001
From: TerryHowe <terrylhowe@gmail.com>
Date: Fri, 1 May 2015 12:21:08 -0600
Subject: [PATCH] Security group rule delete broken

Nova client was changed to take a rule id for security group
rule delete.

https://github.com/openstack/python-novaclient/blob/master/novaclient/v2/security_group_rules.py#L72

Change-Id: I0a69f3f196a36f267ee85a651b09aa8d3c328121
Closes-Bug: #1450872
---
 doc/source/backwards-incompatible.rst        | 12 ++++++
 openstackclient/compute/v2/security_group.py | 39 ++------------------
 2 files changed, 16 insertions(+), 35 deletions(-)

diff --git a/doc/source/backwards-incompatible.rst b/doc/source/backwards-incompatible.rst
index 817f2a3097..437f9324bb 100644
--- a/doc/source/backwards-incompatible.rst
+++ b/doc/source/backwards-incompatible.rst
@@ -35,6 +35,18 @@ List of Backwards Incompatible Changes
   * Bug: https://bugs.launchpad.net/python-openstackclient/+bug/1404073
   * Commit: https://review.openstack.org/#/c/143242/
 
+3. Command `openstack security group rule delete` now requires rule id
+
+  Previously, the command was `openstack security group rule delete --proto
+  <proto> [--src-ip <ip-address> --dst-port <port-range>] <group>`,
+  whereas now it is: `openstack security group rule delete <rule>`.
+
+  * In favor of: Using `openstack security group rule delete <rule>`.
+  * As of: 1.2.1
+  * Removed in: NA
+  * Bug: https://bugs.launchpad.net/python-openstackclient/+bug/1450872
+  * Commit: https://review.openstack.org/#/c/179446/
+
 For Developers
 ==============
 
diff --git a/openstackclient/compute/v2/security_group.py b/openstackclient/compute/v2/security_group.py
index 55405810d2..d860bf808e 100644
--- a/openstackclient/compute/v2/security_group.py
+++ b/openstackclient/compute/v2/security_group.py
@@ -328,28 +328,9 @@ class DeleteSecurityGroupRule(command.Command):
     def get_parser(self, prog_name):
         parser = super(DeleteSecurityGroupRule, self).get_parser(prog_name)
         parser.add_argument(
-            'group',
-            metavar='<group>',
-            help='Security group rule to delete (name or ID)',
-        )
-        parser.add_argument(
-            "--proto",
-            metavar="<proto>",
-            default="tcp",
-            help="IP protocol (icmp, tcp, udp; default: tcp)",
-        )
-        parser.add_argument(
-            "--src-ip",
-            metavar="<ip-address>",
-            default="0.0.0.0/0",
-            help="Source IP (may use CIDR notation; default: 0.0.0.0/0)",
-        )
-        parser.add_argument(
-            "--dst-port",
-            metavar="<port-range>",
-            action=parseractions.RangeAction,
-            help="Destination port, may be a range: 137:139 (default: 0; "
-                 "only required for proto tcp and udp)",
+            'rule',
+            metavar='<rule>',
+            help='Security group rule ID to delete',
         )
         return parser
 
@@ -357,19 +338,7 @@ class DeleteSecurityGroupRule(command.Command):
         self.log.debug('take_action(%s)', parsed_args)
 
         compute_client = self.app.client_manager.compute
-        group = utils.find_resource(
-            compute_client.security_groups,
-            parsed_args.group,
-        )
-        from_port, to_port = parsed_args.dst_port
-        # sigh...delete by ID?
-        compute_client.security_group_rules.delete(
-            group.id,
-            parsed_args.proto,
-            from_port,
-            to_port,
-            parsed_args.src_ip,
-        )
+        compute_client.security_group_rules.delete(parsed_args.rule)
         return