Example #1
0
 def test_locations(self):
     assert_true(validate_bucket_location(''))
     assert_true(validate_bucket_location('eu-central-1'))
     assert_true(validate_bucket_location('us-west-1'))
     assert_true(validate_bucket_location('us-west-2'))
     assert_true(validate_bucket_location('ap-northeast-1'))
     assert_true(validate_bucket_location('ap-northeast-2'))
     assert_true(validate_bucket_location('ap-southeast-1'))
     assert_true(validate_bucket_location('ap-southeast-2'))
     assert_true(validate_bucket_location('sa-east-1'))
     assert_true(validate_bucket_location('eu-west-1'))
Example #2
0
 def test_locations(self):
     assert_true(validate_bucket_location(''))
     assert_true(validate_bucket_location('eu-central-1'))
     assert_true(validate_bucket_location('us-west-1'))
     assert_true(validate_bucket_location('us-west-2'))
     assert_true(validate_bucket_location('ap-northeast-1'))
     assert_true(validate_bucket_location('ap-northeast-2'))
     assert_true(validate_bucket_location('ap-southeast-1'))
     assert_true(validate_bucket_location('ap-southeast-2'))
     assert_true(validate_bucket_location('sa-east-1'))
     assert_true(validate_bucket_location('eu-west-1'))
Example #3
0
 def test_locations(self):
     assert_true(validate_bucket_location(""))
     assert_true(validate_bucket_location("eu-central-1"))
     assert_true(validate_bucket_location("us-west-1"))
     assert_true(validate_bucket_location("us-west-2"))
     assert_true(validate_bucket_location("ap-northeast-1"))
     assert_true(validate_bucket_location("ap-northeast-2"))
     assert_true(validate_bucket_location("ap-southeast-1"))
     assert_true(validate_bucket_location("ap-southeast-2"))
     assert_true(validate_bucket_location("sa-east-1"))
     assert_true(validate_bucket_location("eu-west-1"))
Example #4
0
def create_bucket(auth, node_addon, **kwargs):
    bucket_name = request.json.get('bucket_name', '')
    bucket_location = request.json.get('bucket_location', '')

    if not utils.validate_bucket_name(bucket_name):
        return {
            'message': 'That bucket name is not valid.',
            'title': 'Invalid bucket name',
        }, httplib.BAD_REQUEST

    # Get location and verify it is valid
    if not utils.validate_bucket_location(bucket_location):
        return {
            'message': 'That bucket location is not valid.',
            'title': 'Invalid bucket location',
        }, httplib.BAD_REQUEST

    try:
        utils.create_bucket(node_addon, bucket_name, bucket_location)
    except exception.S3ResponseError as e:
        return {
            'message': e.message,
            'title': 'Problem connecting to S3',
        }, httplib.BAD_REQUEST
    except exception.S3CreateError as e:
        return {
            'message': e.message,
            'title': "Problem creating bucket '{0}'".format(bucket_name),
        }, httplib.BAD_REQUEST
    except exception.BotoClientError as e:  # Base class catchall
        return {
            'message': e.message,
            'title': 'Error connecting to S3',
        }, httplib.BAD_REQUEST

    return {
        'buckets': utils.get_bucket_names(node_addon)
    }
Example #5
0
def create_bucket(auth, node_addon, **kwargs):
    bucket_name = request.json.get('bucket_name', '')
    bucket_location = request.json.get('bucket_location', '')

    if not utils.validate_bucket_name(bucket_name):
        return {
            'message': 'That bucket name is not valid.',
            'title': 'Invalid bucket name',
        }, httplib.NOT_ACCEPTABLE

    # Get location and verify it is valid
    if not utils.validate_bucket_location(bucket_location):
        return {
            'message': 'That bucket location is not valid.',
            'title': 'Invalid bucket location',
        }, httplib.NOT_ACCEPTABLE

    try:
        utils.create_bucket(node_addon.user_settings, bucket_name,
                            bucket_location)
    except exception.S3ResponseError as e:
        return {
            'message': e.message,
            'title': 'Problem connecting to S3',
        }, httplib.NOT_ACCEPTABLE
    except exception.S3CreateError as e:
        return {
            'message': e.message,
            'title': "Problem creating bucket '{0}'".format(bucket_name),
        }, httplib.NOT_ACCEPTABLE
    except exception.BotoClientError as e:  # Base class catchall
        return {
            'message': e.message,
            'title': 'Error connecting to S3',
        }, httplib.NOT_ACCEPTABLE

    return {'buckets': utils.get_bucket_names(node_addon.user_settings)}
Example #6
0
 def test_bad_locations(self):
     assert_false(validate_bucket_location('Venus'))
     assert_false(validate_bucket_location('AlphaCentari'))
     assert_false(validate_bucket_location('CostaRica'))
Example #7
0
 def test_locations(self):
     assert_true(validate_bucket_location(''))
     assert_true(validate_bucket_location('EU'))
     assert_true(validate_bucket_location('us-west-1'))
Example #8
0
 def test_bad_locations(self):
     assert_false(validate_bucket_location('Venus'))
     assert_false(validate_bucket_location('AlphaCentari'))
     assert_false(validate_bucket_location('CostaRica'))
Example #9
0
 def test_locations(self):
     assert_true(validate_bucket_location(''))
     assert_true(validate_bucket_location('EU'))
     assert_true(validate_bucket_location('us-west-1'))
Example #10
0
 def test_bad_locations(self):
     assert_false(validate_bucket_location("Venus"))
     assert_false(validate_bucket_location("AlphaCentari"))
     assert_false(validate_bucket_location("CostaRica"))