Skip to content

Commit 042be7c

Browse files
Dmitriy Rabotyagovemonty
authored andcommitted
Don't look up project by id if given id
There is a much deeper and systemic issue going on here, but let's start with fixing the immediate issue which is that adding a project to an image fails trying to look up project information even if the user passes the project id by id. _is_uuid_like from sdk isn't perfect, but it'll be good enough for this. Change-Id: I541416d737b961c56aa2f584c172528632fd5537
1 parent 768a64a commit 042be7c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

openstackclient/image/v2/image.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import os
2222
import sys
2323

24+
import openstack.cloud._utils
2425
from openstack.image import image_signer
2526
from osc_lib.api import utils as api_utils
2627
from osc_lib.cli import format_columns
@@ -158,9 +159,13 @@ def take_action(self, parsed_args):
158159
image_client = self.app.client_manager.image
159160
identity_client = self.app.client_manager.identity
160161

161-
project_id = common.find_project(identity_client,
162-
parsed_args.project,
163-
parsed_args.project_domain).id
162+
if openstack.cloud._utils._is_uuid_like(parsed_args.project):
163+
project_id = parsed_args.project
164+
else:
165+
project_id = common.find_project(
166+
identity_client,
167+
parsed_args.project,
168+
parsed_args.project_domain).id
164169

165170
image = image_client.find_image(parsed_args.image,
166171
ignore_missing=False)

0 commit comments

Comments
 (0)