Closed Tiboris closed 3 years ago
To you have a traceback for the original issue?
Do I understand it correctly that when user doesn't have rights for certain image:
aws_image = self.ec2.Image(req_img)
Results in aws_image
being None
and thus following:
logger.info(
f"{self.dsp_name}: Requested provisioning of {aws_image.name} image"
)
Throws attribute error because it is basically: None.name
. Is it correct?
If so, would it be better to handle it in a following way?
aws_image = self.ec2.Image(req_img)
if not aws_image:
raise ValidationError(
f"{self.dsp_name}: Used credentials for user who is "
f"not authorized to use image: {req_img}"
)
Also what is the error/behaviour if there is no image with the desired name?
Results in aws_image being None and thus following:
Yes thats correct this would work
if not aws_image:
raise ValidationError(
f"{self.dsp_name}: Used credentials for user who is "
f"not authorized to use image: {req_img}"
)
Also what is the error/behaviour if there is no image with the desired name?
except ClientError as image_err: err_msg = ( f"{self.dsp_name}: Requested image " f"'{req_img}' can not be provisioned" ) logger.error(err_msg) err_resp = image_err.response["Error"]["Message"] raise ValidationError(f"{err_msg} Request failed with {err_resp}")
With https://github.com/neoave/mrack/pull/66/commits/ca82c4604a2e9eefdd2ebbc1884b07384e567f5a i try to fix overcomplicated code I created.
There was an issue when reading image.name for image for which user did not have proper read rights and is not authorised to use it - Nonetype has no attribute name
refactor overcomplicated code in openstack in second commit
Signed-off-by: Tibor Dudlák tdudlak@redhat.com