|
|
@@ -40,7 +40,12 @@ class UrlConnection():
|
|
|
"""
|
|
|
Share the unmarshalling from XML to boto Python objects from the requests calls.
|
|
|
"""
|
|
|
- def _get_all_buckets(self, signed_url):
|
|
|
+
|
|
|
+ def get_all_buckets(self, headers=None):
|
|
|
+ LOG.debug('get_all_buckets: %s' % headers)
|
|
|
+ kwargs = {'action': 'GET'}
|
|
|
+
|
|
|
+ signed_url = self.get_url_request(**kwargs)
|
|
|
LOG.debug(signed_url)
|
|
|
|
|
|
response = requests.get(signed_url)
|
|
|
@@ -56,28 +61,17 @@ class UrlConnection():
|
|
|
return rs
|
|
|
|
|
|
|
|
|
+
|
|
|
class RazUrlConnection(UrlConnection):
|
|
|
|
|
|
def __init__(self):
|
|
|
self.raz = S3RazClient()
|
|
|
|
|
|
- def get_all_buckets(self, headers=None):
|
|
|
- url = self._generate_url()
|
|
|
- return self._get_all_buckets(url)
|
|
|
-
|
|
|
- def get_bucket(self, bucket_name, validate=True, headers=None):
|
|
|
- pass
|
|
|
-
|
|
|
- def get_key(self, key_name, headers=None, version_id=None, response_headers=None, validate=True):
|
|
|
- pass
|
|
|
-
|
|
|
- def get_all_keys(self, headers=None, **params):
|
|
|
- pass
|
|
|
-
|
|
|
- def _generate_url(self, bucket_name=None, object_name=None, expiration=3600):
|
|
|
+ def get_url_request(self, bucket_name=None, object_name=None, expiration=3600):
|
|
|
self.raz.get_url(bucket_name, object_name)
|
|
|
|
|
|
|
|
|
+
|
|
|
class UrlKey(Key):
|
|
|
|
|
|
def open_read(self, headers=None, query_args='', override_num_retries=None, response_headers=None):
|
|
|
@@ -88,7 +82,7 @@ class UrlKey(Key):
|
|
|
|
|
|
return
|
|
|
|
|
|
- def _generate_url(self, action='GET', **kwargs):
|
|
|
+ def get_url_request(self, action='GET', **kwargs):
|
|
|
LOG.debug(kwargs)
|
|
|
tmp_url = None
|
|
|
|
|
|
@@ -177,7 +171,7 @@ class UrlBucket(Bucket):
|
|
|
return rs
|
|
|
|
|
|
|
|
|
- def _generate_url(self, action='GET', **kwargs):
|
|
|
+ def get_url_request(self, action='GET', **kwargs):
|
|
|
LOG.debug(kwargs)
|
|
|
tmp_url = None
|
|
|
|
|
|
@@ -202,20 +196,26 @@ class BotoUrlConnection(UrlConnection):
|
|
|
self.connection.set_bucket_class(UrlBucket) # Use our bucket class to keep overriding any direct call to S3 made from list buckets
|
|
|
|
|
|
|
|
|
- def get_all_buckets(self, headers=None):
|
|
|
- LOG.debug('get_all_buckets: %s' % headers)
|
|
|
- kwargs = {'action': 'GET'}
|
|
|
+ def get_url_request(self, action='GET', **kwargs):
|
|
|
+ LOG.debug(kwargs)
|
|
|
+ tmp_url = None
|
|
|
|
|
|
- signed_url = self._generate_url(**kwargs)
|
|
|
+ try:
|
|
|
+ # http://boto.cloudhackers.com/en/latest/ref/s3.html#boto.s3.connection.S3Connection.generate_url
|
|
|
+ tmp_url = self.connection.generate_url(self.expiration, action, **kwargs)
|
|
|
+ except BotoClientError as e:
|
|
|
+ LOG.error(e)
|
|
|
+ if tmp_url is None:
|
|
|
+ raise S3FileSystemException("Resource does not exist or permission missing : '%s'" % kwargs)
|
|
|
|
|
|
- return self._get_all_buckets(signed_url)
|
|
|
+ return tmp_url
|
|
|
|
|
|
|
|
|
def get_bucket(self, bucket_name, validate=True, headers=None):
|
|
|
LOG.debug('get_bucket: %s' % bucket_name)
|
|
|
kwargs = {'action': 'GET', 'bucket': bucket_name}
|
|
|
|
|
|
- signed_url = self._generate_url(**kwargs)
|
|
|
+ signed_url = self.get_url_request(**kwargs)
|
|
|
|
|
|
response = requests.get(signed_url)
|
|
|
|
|
|
@@ -226,18 +226,3 @@ class BotoUrlConnection(UrlConnection):
|
|
|
LOG.debug(rs)
|
|
|
|
|
|
return rs
|
|
|
-
|
|
|
-
|
|
|
- def _generate_url(self, action='GET', **kwargs):
|
|
|
- LOG.debug(kwargs)
|
|
|
- tmp_url = None
|
|
|
-
|
|
|
- try:
|
|
|
- # http://boto.cloudhackers.com/en/latest/ref/s3.html#boto.s3.connection.S3Connection.generate_url
|
|
|
- tmp_url = self.connection.generate_url(self.expiration, action, **kwargs)
|
|
|
- except BotoClientError as e:
|
|
|
- LOG.error(e)
|
|
|
- if tmp_url is None:
|
|
|
- raise S3FileSystemException("Resource does not exist or permission missing : '%s'" % kwargs)
|
|
|
-
|
|
|
- return tmp_url
|