mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[cloud] Handle client-error exceptions in s3_bucket (#26044)
* Handle exception when capital letter used in S3 bucket name. * Fix whitespace for PEP8
This commit is contained in:
parent
9a3f5bf1fc
commit
11b1ad0928
1 changed files with 3 additions and 3 deletions
|
@ -129,7 +129,7 @@ try:
|
||||||
import boto.ec2
|
import boto.ec2
|
||||||
from boto.s3.connection import OrdinaryCallingFormat, Location, S3Connection
|
from boto.s3.connection import OrdinaryCallingFormat, Location, S3Connection
|
||||||
from boto.s3.tagging import Tags, TagSet
|
from boto.s3.tagging import Tags, TagSet
|
||||||
from boto.exception import BotoServerError, S3CreateError, S3ResponseError
|
from boto.exception import BotoServerError, S3CreateError, S3ResponseError, BotoClientError
|
||||||
HAS_BOTO = True
|
HAS_BOTO = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_BOTO = False
|
HAS_BOTO = False
|
||||||
|
@ -255,7 +255,7 @@ def _create_or_update_bucket(connection, module, location):
|
||||||
try:
|
try:
|
||||||
bucket = connection.create_bucket(name, location=location)
|
bucket = connection.create_bucket(name, location=location)
|
||||||
changed = True
|
changed = True
|
||||||
except S3CreateError as e:
|
except (S3CreateError, BotoClientError) as e:
|
||||||
module.fail_json(msg=e.message)
|
module.fail_json(msg=e.message)
|
||||||
|
|
||||||
# Versioning
|
# Versioning
|
||||||
|
@ -390,7 +390,7 @@ def _create_or_update_bucket_ceph(connection, module, location):
|
||||||
try:
|
try:
|
||||||
bucket = connection.create_bucket(name, location=location)
|
bucket = connection.create_bucket(name, location=location)
|
||||||
changed = True
|
changed = True
|
||||||
except S3CreateError as e:
|
except (S3CreateError, BotoClientError) as e:
|
||||||
module.fail_json(msg=e.message)
|
module.fail_json(msg=e.message)
|
||||||
|
|
||||||
if bucket:
|
if bucket:
|
||||||
|
|
Loading…
Reference in a new issue