From 0a8753dc3eaeda25554ccd769350de1e9792a62b Mon Sep 17 00:00:00 2001
From: Roger Luethi <rl@patchworkscience.org>
Date: Thu, 23 Jul 2020 13:20:09 +0200
Subject: [PATCH] Fix reverted osc-lib interface change

The patch https://review.opendev.org/#/c/673389/ introduced a regression
by changing the osc-lib interface.

Two conflicting attempts to fix the regression were launched:

1) Reverting the patch.

2) The patch https://review.opendev.org/683119 changes the exception
   from the generic CommandError back to a specific Forbidden exception.

   The patch https://review.opendev.org/683118 catches this exception
   and passes on, i.e. re-implements the same behavior as before.

The first idea was implemented, the initial patch reverted. The second
idea was partially implemented. The change in python-openstackclient
(683118) was merged. The change in osc-lib was approved but failed to
merge because the initial change had been reverted.

Now we have again a situation where the exception produced in osc-lib
does not match the exception expected by the caller.

It is unclear if the osc-lib interface will ever get a rebased version
of https://review.opendev.org/683119 merged, so the safest way to
address the issue is to also catch the exception that used to be
thrown before the inital change and is again thrown after the inital
change has been reverted.

Change-Id: I2ea2def607ec5be112e42d53a1e660fef0cdd69c
---
 openstackclient/identity/common.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/openstackclient/identity/common.py b/openstackclient/identity/common.py
index e70d87d21f..a75db4f8dd 100644
--- a/openstackclient/identity/common.py
+++ b/openstackclient/identity/common.py
@@ -207,7 +207,7 @@ def _find_identity_resource(identity_client_manager, name_or_id,
                                                 name_or_id, **kwargs)
         if identity_resource is not None:
             return identity_resource
-    except exceptions.Forbidden:
+    except (exceptions.Forbidden, identity_exc.Forbidden):
         pass
 
     return resource_type(None, {'id': name_or_id, 'name': name_or_id})