def get_tile_bucket(self): """ Returns: """ return TileBucket.getBucketName()
def test_createPolicy_with_folder(self): """Test policy creation with a folder""" statements = [{ 'Sid': 'WriteAccess', 'Effect': 'Allow', 'Action': ['s3:PutObject'] }] expName = 'ndingest_test_tile_bucket_policy' folder = 'some/folder' actual = self.tile_bucket.createPolicy(statements, expName, folder) try: assert(expName == actual.policy_name) assert(settings.IAM_POLICY_PATH == actual.path) assert(actual.default_version is not None) # Test that the statements' resource set to this bucket and folder. statements = actual.default_version.document['Statement'] bucket_name = TileBucket.getBucketName() arn = 'arn:aws:s3:::{}/{}/*'.format(bucket_name, folder) for stmt in statements: assert(stmt['Resource'] == arn) finally: actual.delete()
def test_createPolicy_with_folder(tile_bucket): """Test policy creation with a folder""" from ndingest.ndbucket.tilebucket import TileBucket statements = [{ "Sid": "WriteAccess", "Effect": "Allow", "Action": ["s3:PutObject"] }] expName = "ndingest_test_tile_bucket_policy" folder = "some/folder" actual = tile_bucket.createPolicy(statements, expName, folder) try: assert expName == actual.policy_name assert settings.IAM_POLICY_PATH == actual.path assert actual.default_version is not None # Test that the statements' resource set to this bucket and folder. statements = actual.default_version.document["Statement"] bucket_name = TileBucket.getBucketName() arn = "arn:aws:s3:::{}/{}/*".format(bucket_name, folder) for stmt in statements: assert stmt["Resource"] == arn finally: actual.delete()
def generate_ingest_credentials(self, ingest_job): """ Create new ingest credentials for a job Args: ingest_job: Ingest job model Returns: None Raises: (ValueError): On bad ingest_type """ # Generate credentials for the ingest_job upload_queue = self.get_ingest_job_upload_queue(ingest_job) ingest_creds = IngestCredentials() if ingest_job.ingest_type == IngestJob.TILE_INGEST: bucket_name = TileBucket.getBucketName() elif ingest_job.ingest_type == IngestJob.VOLUMETRIC_INGEST: bucket_name = INGEST_BUCKET else: raise ValueError('Unknown ingest_type: {}'.format( ingest_job.ingest_type)) policy = BossUtil.generate_ingest_policy( ingest_job.id, upload_queue, bucket_name, ingest_type=ingest_job.ingest_type) ingest_creds.generate_credentials(ingest_job.id, policy.arn)
def get_tile_bucket(self): """ Get the name of the ingest tile bucket Returns: Str: Name of the Tile bucket """ return TileBucket.getBucketName()
def get_tile_bucket(self): """ Get the name of the ingest tile bucket Returns: Str: Name of the Tile bucket """ return TileBucket.getBucketName()
def generate_ingest_credentials(self, ingest_job): """ Create new ingest credentials for a job Args: ingest_job: Ingest job model Returns: None Raises: (ValueError): On bad ingest_type """ # Generate credentials for the ingest_job upload_queue = self.get_ingest_job_upload_queue(ingest_job) tile_index_queue = None ingest_creds = IngestCredentials() if ingest_job.ingest_type == IngestJob.TILE_INGEST: bucket_name = TileBucket.getBucketName() tile_index_queue = self.get_ingest_job_tile_index_queue(ingest_job) elif ingest_job.ingest_type == IngestJob.VOLUMETRIC_INGEST: bucket_name = INGEST_BUCKET else: raise ValueError('Unknown ingest_type: {}'.format(ingest_job.ingest_type)) policy = BossUtil.generate_ingest_policy(ingest_job.id, upload_queue, tile_index_queue, bucket_name, ingest_type=ingest_job.ingest_type) ingest_creds.generate_credentials(ingest_job.id, policy.arn)