def _put_bucket_tagging(self):
"""Add new Tags without overwriting old Tags.
Regular put_bucket_tagging sets TagSet which overwrites old tags. Below
logic keeps the old tags in place as well.
"""
try:
# Get current tags list, if no tags exist will get an exception.
result = self.s3client.get_bucket_tagging(Bucket=self.bucket)['TagSet']
except ClientError as error:
LOG.warning(error)
result = []
# Make simplified dictionary of tags from result
all_tags = {}
for tag in result:
all_tags.update({tag.get('Key'): tag.get('Value')})
all_tags.update({'app_group': self.group, 'app_name': self.app_name})
tag_set = generate_s3_tags.generated_tag_data(all_tags)
self.s3client.put_bucket_tagging(Bucket=self.bucket, Tagging={'TagSet': tag_set})
LOG.info("Adding tagging %s for Bucket", tag_set)
评论列表
文章目录