예제 #1
0
 def _create_legacy_bucket_obj(self, bucket_objects, region, test):
     new = False
     object_acl = (
         self.config.project.s3_object_acl
         if self.config.project.s3_object_acl
         else "private"
     )
     sigv4 = not self.config.project.s3_enable_sig_v2
     if not test.s3_bucket and not bucket_objects.get(region.account_id):
         name = generate_bucket_name(self.config.project.name)
         auto_generated = True
         new = True
     elif bucket_objects.get(region.account_id):
         name = bucket_objects[region.account_id].name
         auto_generated = bucket_objects[region.account_id].auto_generated
     else:
         name = test.s3_bucket
         auto_generated = False
     bucket_region = self._get_bucket_region_for_partition(region.partition)
     bucket_obj = S3BucketObj(
         name=name,
         region=bucket_region,
         account_id=region.account_id,
         s3_client=region.session.client("s3", region_name=bucket_region),
         auto_generated=auto_generated,
         object_acl=object_acl,
         sigv4=sigv4,
         taskcat_id=self.uid,
         partition=region.partition,
         regional_buckets=test.s3_regional_buckets,
     )
     if new:
         bucket_obj.create()
     return bucket_obj
예제 #2
0
파일: _config.py 프로젝트: tbulding/taskcat
    def _create_regional_bucket_obj(self, bucket_objects, region, test):
        _bucket_obj_key = f"{region.account_id}{region.name}"
        new = False
        object_acl = (
            self.config.project.s3_object_acl
            if self.config.project.s3_object_acl
            else "private"
        )

        sigv4 = not self.config.project.s3_enable_sig_v2

        org_id = self.config.project.org_id

        if not test.s3_bucket and not bucket_objects.get(_bucket_obj_key):
            name = generate_regional_bucket_name(region)
            auto_generated = True
            new = True
        elif bucket_objects.get(_bucket_obj_key):
            name = bucket_objects[_bucket_obj_key].name
            auto_generated = bucket_objects[_bucket_obj_key].auto_generated
        else:
            name = f"{test.s3_bucket}-{region.name}"
            auto_generated = False
            try:
                region.client("s3").head_bucket(Bucket=name)
            except ClientError as e:
                if "(404)" in str(e):
                    new = True
                else:
                    raise
        bucket_obj = S3BucketObj(
            name=name,
            region=region.name,
            account_id=region.account_id,
            s3_client=region.session.client("s3", region_name=region.name),
            auto_generated=auto_generated,
            object_acl=object_acl,
            sigv4=sigv4,
            taskcat_id=self.uid,
            partition=region.partition,
            regional_buckets=test.s3_regional_buckets,
            org_id=org_id,
        )
        if new:
            bucket_obj.create()
        return bucket_obj