Revert "Don't look up project by id if given id"

This reverts commit 042be7c7fe89f5a1a190af90d5980205d995941b. This
solution worked but it was confusing. The issue that the author was
seeing was presumably due to users not being able to list projects but in
theory the 'openstackclient.image.common.find_project' function that was
being called here should have already handle this. It transpires however
that there was a bug in this and we weren't correctly handling HTTP 403
errors correctly. This bug has since been fixed in change
I2ea2def607ec5be112e42d53a1e660fef0cdd69c meaning this change is no
longer necessary. Remove it and simplify the code somewhat.

Change-Id: I108efec2c8deda50fcb9cc84f313602bed2ac15c
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2022-11-30 12:32:50 +00:00
parent 6cd72f6182
commit 85254fbeb4

@ -29,7 +29,6 @@ from osc_lib.cli import parseractions
from osc_lib.command import command
from osc_lib import exceptions
from osc_lib import utils
from oslo_utils import uuidutils
from openstackclient.common import progressbar
from openstackclient.i18n import _
@ -184,14 +183,11 @@ class AddProjectToImage(command.ShowOne):
image_client = self.app.client_manager.image
identity_client = self.app.client_manager.identity
if uuidutils.is_uuid_like(parsed_args.project):
project_id = parsed_args.project
else:
project_id = common.find_project(
identity_client,
parsed_args.project,
parsed_args.project_domain,
).id
project_id = common.find_project(
identity_client,
parsed_args.project,
parsed_args.project_domain,
).id
image = image_client.find_image(
parsed_args.image, ignore_missing=False