Exemplo n.º 1
0
 def test_delete_ingest_policy(self, boss_util_fixtures):
     self._setup(boss_util_fixtures)
     BossUtil.generate_ingest_policy(
         self.job_id,
         self.upload_queue,
         self.tile_index_queue,
         self.tile_bucket.bucket.name,
     )
     assert BossUtil.delete_ingest_policy(self.job_id)
Exemplo n.º 2
0
    def test_create_ingest_policy_volumetric(self, boss_util_fixtures):
        self._setup(boss_util_fixtures)
        policy = BossUtil.generate_ingest_policy(
            self.job_id,
            self.upload_queue,
            self.tile_index_queue,
            self.tile_bucket.bucket.name,
            ingest_type=VOLUMETRIC_INGEST,
        )
        from ndingest.ndbucket.tilebucket import TileBucket

        try:
            assert settings.IAM_POLICY_PATH == policy.path
            assert policy.default_version is not None
            statements = policy.default_version.document["Statement"]
            assert 2 == len(statements)
            for stmt in statements:
                if stmt["Sid"] == "ClientUploadQueuePolicy":
                    for perm in [
                            "sqs:ReceiveMessage",
                            "sqs:GetQueueAttributes",
                            "sqs:DeleteMessage",
                    ]:
                        assert perm in stmt["Action"]
                    assert 3 == len(stmt["Action"])
                    assert self.upload_queue.arn == stmt["Resource"]
                elif stmt["Sid"] == "ClientTileBucketPolicy":
                    assert "s3:PutObject" in stmt["Action"]
                    assert len(stmt["Action"]) == 1
                    assert (TileBucket.buildArn(
                        self.tile_bucket.bucket.name) == stmt["Resource"])
        finally:
            policy.delete()
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    def create_ingest_credentials(self, upload_queue, tile_bucket):
        """

        Returns:

        """
        # Generate credentials for the ingest_job
        # Create the credentials for the job
        ingest_creds = IngestCredentials()
        policy = BossUtil.generate_ingest_policy(self.job.id, upload_queue,
                                                 tile_bucket)
        ingest_creds.generate_credentials(self.job.id, policy.arn)
Exemplo n.º 5
0
    def create_ingest_credentials(self, upload_queue, tile_bucket):
        """
        Create new ingest credentials for a job
        Args:
            upload_queue : Upload queue for the job
            tile_bucket : Name of the tile bucket for the job
        Returns:
            None

        """
        # Generate credentials for the ingest_job
        # Create the credentials for the job
        ingest_creds = IngestCredentials()
        policy = BossUtil.generate_ingest_policy(self.job.id, upload_queue,
                                                 tile_bucket)
        ingest_creds.generate_credentials(self.job.id, policy.arn)
Exemplo n.º 6
0
    def generate_ingest_credentials(self, ingest_job):
        """
        Create new ingest credentials for a job
        Args:
            upload_queue : Upload queue for the job
            tile_bucket : Name of the tile bucket for the job
        Returns:
            None

        """
        # Generate credentials for the ingest_job
        # Create the credentials for the job
        tile_bucket = TileBucket(ingest_job.collection + '&' +
                                 ingest_job.experiment)
        upload_queue = self.get_ingest_job_upload_queue(ingest_job)
        ingest_creds = IngestCredentials()
        policy = BossUtil.generate_ingest_policy(ingest_job.id, upload_queue,
                                                 tile_bucket)
        ingest_creds.generate_credentials(ingest_job.id, policy.arn)
Exemplo n.º 7
0
    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)