cleanup account ids from container commands

use a common function to determine account ID instead of different
ways - depending on the response and command

Change-Id: I95adc5dc7d5a82a2cffc570d1ded24d1fc754a11
This commit is contained in:
Steve Martinelli 2015-09-10 16:10:55 -05:00 committed by Lin Hua Cheng
parent 4733fd0d3c
commit faece91756
4 changed files with 12 additions and 6 deletions

View File

@ -44,9 +44,8 @@ class APIv1(api.BaseAPI):
"""
response = self.create(container, method='PUT')
url_parts = urlparse(self.endpoint)
data = {
'account': url_parts.path.split('/')[-1],
'account': self._find_account_id(),
'container': container,
'x-trans-id': response.headers.get('x-trans-id', None),
}
@ -154,12 +153,13 @@ class APIv1(api.BaseAPI):
response = self._request('HEAD', container)
data = {
'account': response.headers.get('x-container-meta-owner', None),
'account': self._find_account_id(),
'container': container,
'object_count': response.headers.get(
'x-container-object-count',
None,
),
'meta-owner': response.headers.get('x-container-meta-owner', None),
'bytes_used': response.headers.get('x-container-bytes-used', None),
'read_acl': response.headers.get('x-container-read', None),
'write_acl': response.headers.get('x-container-write', None),
@ -194,9 +194,8 @@ class APIv1(api.BaseAPI):
method='PUT',
data=f,
)
url_parts = urlparse(self.endpoint)
data = {
'account': url_parts.path.split('/')[-1],
'account': self._find_account_id(),
'container': container,
'object': object,
'x-trans-id': response.headers.get('X-Trans-Id', None),
@ -352,10 +351,11 @@ class APIv1(api.BaseAPI):
response = self._request('HEAD', "%s/%s" % (container, object))
data = {
'account': response.headers.get('x-container-meta-owner', None),
'account': self._find_account_id(),
'container': container,
'object': object,
'content-type': response.headers.get('content-type', None),
'meta-owner': response.headers.get('x-container-meta-owner', None),
}
if 'content-length' in response.headers:
data['content-length'] = response.headers.get(

View File

@ -157,6 +157,7 @@ class TestContainer(TestObjectAPIv1):
'container': 'qaz',
'object_count': '1',
'bytes_used': '577',
'meta-owner': FAKE_ACCOUNT,
'read_acl': None,
'write_acl': None,
'sync_to': None,
@ -322,6 +323,7 @@ class TestObject(TestObjectAPIv1):
'content-type': 'text/alpha',
'content-length': '577',
'last-modified': '20130101',
'meta-owner': FAKE_ACCOUNT,
'etag': 'qaz',
'wife': 'Wilma',
'x-tra-header': 'yabba-dabba-do',

View File

@ -316,6 +316,7 @@ class TestContainerShow(TestContainerAll):
'account',
'bytes_used',
'container',
'meta-owner',
'object_count',
'read_acl',
'sync_key',
@ -327,6 +328,7 @@ class TestContainerShow(TestContainerAll):
object_fakes.ACCOUNT_ID,
'123',
'ernie',
object_fakes.ACCOUNT_ID,
'42',
'qaz',
'rfv',

View File

@ -160,6 +160,7 @@ class TestObjectShow(TestObjectAll):
'content-type',
'etag',
'last-modified',
'meta-owner',
'object',
'x-object-manifest',
)
@ -171,6 +172,7 @@ class TestObjectShow(TestObjectAll):
'text/plain',
'4c4e39a763d58392724bccf76a58783a',
'yesterday',
object_fakes.ACCOUNT_ID,
object_fakes.object_name_1,
'manifest',
)