예제 #1
0
    def validate_configuration(self, configuration):
        """See :meth:`ingest.strike.monitors.monitor.Monitor.validate_configuration`
        """

        warnings = []
        if 'sqs_name' not in configuration:
            raise InvalidMonitorConfiguration(
                'sqs_name is required for s3 monitor')
        if not isinstance(configuration['sqs_name'], basestring):
            raise InvalidMonitorConfiguration('sqs_name must be a string')
        if not configuration['sqs_name']:
            raise InvalidMonitorConfiguration(
                'sqs_name must be a non-empty string')

        # If credentials exist, validate them.
        credentials = AWSClient.instantiate_credentials_from_config(
            configuration)

        region_name = configuration.get('region_name')

        # Check whether the bucket can actually be accessed
        with SQSClient(credentials, region_name) as client:
            try:
                client.get_queue_by_name(configuration['sqs_name'])
            except ClientError:
                warnings.append(
                    ValidationWarning(
                        'sqs_access',
                        'Unable to access SQS. Check the name, region and credentials.'
                    ))

        return warnings
예제 #2
0
    def validate_configuration(self, configuration):
        """See :meth:`ingest.strike.monitors.monitor.Monitor.validate_configuration`
        """

        warnings = []
        if 'sqs_name' not in configuration:
            raise InvalidMonitorConfiguration('sqs_name is required for s3 monitor')
        if not isinstance(configuration['sqs_name'], basestring):
            raise InvalidMonitorConfiguration('sqs_name must be a string')
        if not configuration['sqs_name']:
            raise InvalidMonitorConfiguration('sqs_name must be a non-empty string')

        # If credentials exist, validate them.
        credentials = AWSClient.instantiate_credentials_from_config(configuration)

        region_name = configuration.get('region_name')

        # Check whether the bucket can actually be accessed
        with SQSClient(credentials, region_name) as client:
            try:
                client.get_queue_by_name(configuration['sqs_name'])
            except ClientError:
                warnings.append(ValidationWarning('sqs_access',
                                                  'Unable to access SQS. Check the name, region and credentials.'))

        return warnings
예제 #3
0
파일: s3_monitor.py 프로젝트: sau29/scale
    def load_configuration(self, configuration):
        """See :meth:`ingest.strike.monitors.monitor.Monitor.load_configuration`
        """

        self._sqs_name = configuration['sqs_name']
        self._region_name = configuration.get('region_name')
        # TODO Change credentials to use an encrypted store key reference
        self._credentials = AWSClient.instantiate_credentials_from_config(configuration)
예제 #4
0
    def load_configuration(self, configuration):
        """See :meth:`ingest.strike.monitors.monitor.Monitor.load_configuration`
        """

        self._sqs_name = configuration['sqs_name']
        self._region_name = configuration.get('region_name')
        # TODO Change credentials to use an encrypted store key reference
        self._credentials = AWSClient.instantiate_credentials_from_config(configuration)
예제 #5
0
 def test_instantiate_credentials_from_config_empty_secret_key(self):
     """Tests instantiating AWS Credentials from a configuration with an empty secret key."""
     config = {
         'credentials': {
             'access_key_id': 'ACCESSKEY',
             'secret_access_key': ' '
         }
     }
     self.assertIsNone(
         AWSClient.instantiate_credentials_from_config(config))
예제 #6
0
 def test_instantiate_credentials_from_config(self):
     """Tests instantiating AWS Credentials from a valid configuration."""
     config = {
         'credentials': {
             'access_key_id': 'ACCESSKEY',
             'secret_access_key': 'SECRETKEY'
         }
     }
     credential = AWSClient.instantiate_credentials_from_config(config)
     self.assertEqual(credential.access_key_id, 'ACCESSKEY')
     self.assertEqual(credential.secret_access_key, 'SECRETKEY')
예제 #7
0
파일: s3_broker.py 프로젝트: droessne/scale
    def load_configuration(self, config):
        """See :meth:`storage.brokers.broker.Broker.load_configuration`"""

        self._bucket_name = config['bucket_name']
        self._region_name = config.get('region_name')

        # TODO Change credentials to use an encrypted store key reference
        self._credentials = AWSClient.instantiate_credentials_from_config(config)

        if 'host_path' in config:
            volume = BrokerVolume(None, config['host_path'])
            volume.host = True
            self._volume = volume
예제 #8
0
    def load_configuration(self, config):
        """See :meth:`storage.brokers.broker.Broker.load_configuration`"""

        self._bucket_name = config['bucket_name']
        self._region_name = config.get('region_name')

        # TODO Change credentials to use an encrypted store key reference
        self._credentials = AWSClient.instantiate_credentials_from_config(config)

        # Ensure empty or white-space filled host_paths do not cause mounts to be applied
        if 'host_path' in config and len(config['host_path'].strip()):
            volume = BrokerVolume(None, config['host_path'])
            volume.host = True
            self._volume = volume
예제 #9
0
    def load_configuration(self, config):
        """See :meth:`storage.brokers.broker.Broker.load_configuration`"""

        self._bucket_name = config['bucket_name']
        self._region_name = config.get('region_name')

        # TODO Change credentials to use an encrypted store key reference
        self._credentials = AWSClient.instantiate_credentials_from_config(config)

        # Ensure empty or white-space filled host_paths do not cause mounts to be applied
        if 'host_path' in config and len(config['host_path'].strip()):
            volume = BrokerVolume(None, config['host_path'])
            volume.host = True
            self._volume = volume
예제 #10
0
파일: s3_broker.py 프로젝트: wong-j/scale
    def load_configuration(self, config):
        """See :meth:`storage.brokers.broker.Broker.load_configuration`"""

        self._bucket_name = config['bucket_name']
        self._region_name = config.get('region_name')

        # TODO Change credentials to use an encrypted store key reference
        self._credentials = AWSClient.instantiate_credentials_from_config(
            config)

        if 'host_path' in config:
            volume = BrokerVolume(None, config['host_path'])
            volume.host = True
            self._volume = volume
예제 #11
0
    def validate_configuration(self, config):
        """See :meth:`storage.brokers.broker.Broker.validate_configuration`"""

        warnings = []
        if 'bucket_name' not in config or not config['bucket_name']:
            raise InvalidBrokerConfiguration('INVALID_BROKER', 'S3 broker requires "bucket_name" to be populated')
        region_name = config.get('region_name')

        credentials = AWSClient.instantiate_credentials_from_config(config)

        # Check whether the bucket can actually be accessed
        with S3Client(credentials, region_name) as client:
            try:
                client.get_bucket(config['bucket_name'])
            except (ClientError, NoCredentialsError):
                warnings.append(ValidationWarning('bucket_access',
                                                  'Unable to access bucket. Check the bucket name and credentials.'))

        return warnings
예제 #12
0
파일: s3_broker.py 프로젝트: droessne/scale
    def validate_configuration(self, config):
        """See :meth:`storage.brokers.broker.Broker.validate_configuration`"""

        warnings = []
        if 'bucket_name' not in config or not config['bucket_name']:
            raise InvalidBrokerConfiguration('S3 broker requires "bucket_name" to be populated')
        region_name = config.get('region_name')

        credentials = AWSClient.instantiate_credentials_from_config(config)

        # Check whether the bucket can actually be accessed
        with S3Client(credentials, region_name) as client:
            try:
                client.get_bucket(config['bucket_name'])
            except ClientError:
                warnings.append(ValidationWarning('bucket_access',
                                                  'Unable to access bucket. Check the bucket name and credentials.'))

        return warnings
예제 #13
0
 def test_instantiate_credentials_from_config_missing_secret_key(self):
     """Tests instantiating AWS Credentials from a configuration missing secret key."""
     config = {'credentials': {'access_key_id': 'ACCESSKEY'}}
     with self.assertRaises(InvalidAWSCredentials):
         AWSClient.instantiate_credentials_from_config(config)
예제 #14
0
파일: test_aws.py 프로젝트: ngageoint/scale
 def test_instantiate_credentials_from_config_missing_access_key(self):
     """Tests instantiating AWS Credentials from a configuration missing access key."""
     config = { 'credentials': { 'secret_access_key': 'SECRETKEY' }}
     with self.assertRaises(InvalidAWSCredentials):
         AWSClient.instantiate_credentials_from_config(config)
예제 #15
0
파일: test_aws.py 프로젝트: ngageoint/scale
 def test_instantiate_credentials_from_config_empty_secret_key(self):
     """Tests instantiating AWS Credentials from a configuration with an empty secret key."""
     config = { 'credentials': { 'access_key_id': 'ACCESSKEY', 'secret_access_key': ' ' }}
     self.assertIsNone(AWSClient.instantiate_credentials_from_config(config))
예제 #16
0
파일: test_aws.py 프로젝트: ngageoint/scale
 def test_instantiate_credentials_from_config_missing_secret_key(self):
     """Tests instantiating AWS Credentials from a configuration missing secret key."""
     config = { 'credentials': { 'access_key_id': 'ACCESSKEY' }}
     with self.assertRaises(InvalidAWSCredentials):
         AWSClient.instantiate_credentials_from_config(config)
예제 #17
0
 def test_instantiate_credentials_from_config_missing_access_key(self):
     """Tests instantiating AWS Credentials from a configuration missing access key."""
     config = {'credentials': {'secret_access_key': 'SECRETKEY'}}
     with self.assertRaises(InvalidAWSCredentials):
         AWSClient.instantiate_credentials_from_config(config)
예제 #18
0
파일: test_aws.py 프로젝트: ngageoint/scale
 def test_instantiate_credentials_from_config(self):
     """Tests instantiating AWS Credentials from a valid configuration."""
     config = { 'credentials': { 'access_key_id': 'ACCESSKEY', 'secret_access_key': 'SECRETKEY'}}
     credential = AWSClient.instantiate_credentials_from_config(config)
     self.assertEqual(credential.access_key_id, 'ACCESSKEY')
     self.assertEqual(credential.secret_access_key, 'SECRETKEY')