Skip to content

Commit faece91

Browse files
Steve Martinellilin-hua-cheng
authored andcommitted
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
1 parent 4733fd0 commit faece91

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

openstackclient/api/object_store_v1.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ def container_create(
4444
"""
4545

4646
response = self.create(container, method='PUT')
47-
url_parts = urlparse(self.endpoint)
4847
data = {
49-
'account': url_parts.path.split('/')[-1],
48+
'account': self._find_account_id(),
5049
'container': container,
5150
'x-trans-id': response.headers.get('x-trans-id', None),
5251
}
@@ -154,12 +153,13 @@ def container_show(
154153

155154
response = self._request('HEAD', container)
156155
data = {
157-
'account': response.headers.get('x-container-meta-owner', None),
156+
'account': self._find_account_id(),
158157
'container': container,
159158
'object_count': response.headers.get(
160159
'x-container-object-count',
161160
None,
162161
),
162+
'meta-owner': response.headers.get('x-container-meta-owner', None),
163163
'bytes_used': response.headers.get('x-container-bytes-used', None),
164164
'read_acl': response.headers.get('x-container-read', None),
165165
'write_acl': response.headers.get('x-container-write', None),
@@ -194,9 +194,8 @@ def object_create(
194194
method='PUT',
195195
data=f,
196196
)
197-
url_parts = urlparse(self.endpoint)
198197
data = {
199-
'account': url_parts.path.split('/')[-1],
198+
'account': self._find_account_id(),
200199
'container': container,
201200
'object': object,
202201
'x-trans-id': response.headers.get('X-Trans-Id', None),
@@ -352,10 +351,11 @@ def object_show(
352351

353352
response = self._request('HEAD', "%s/%s" % (container, object))
354353
data = {
355-
'account': response.headers.get('x-container-meta-owner', None),
354+
'account': self._find_account_id(),
356355
'container': container,
357356
'object': object,
358357
'content-type': response.headers.get('content-type', None),
358+
'meta-owner': response.headers.get('x-container-meta-owner', None),
359359
}
360360
if 'content-length' in response.headers:
361361
data['content-length'] = response.headers.get(

openstackclient/tests/api/test_object_store_v1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def test_container_show(self):
157157
'container': 'qaz',
158158
'object_count': '1',
159159
'bytes_used': '577',
160+
'meta-owner': FAKE_ACCOUNT,
160161
'read_acl': None,
161162
'write_acl': None,
162163
'sync_to': None,
@@ -322,6 +323,7 @@ def test_object_show(self):
322323
'content-type': 'text/alpha',
323324
'content-length': '577',
324325
'last-modified': '20130101',
326+
'meta-owner': FAKE_ACCOUNT,
325327
'etag': 'qaz',
326328
'wife': 'Wilma',
327329
'x-tra-header': 'yabba-dabba-do',

openstackclient/tests/object/v1/test_container_all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ def test_object_show_container(self):
316316
'account',
317317
'bytes_used',
318318
'container',
319+
'meta-owner',
319320
'object_count',
320321
'read_acl',
321322
'sync_key',
@@ -327,6 +328,7 @@ def test_object_show_container(self):
327328
object_fakes.ACCOUNT_ID,
328329
'123',
329330
'ernie',
331+
object_fakes.ACCOUNT_ID,
330332
'42',
331333
'qaz',
332334
'rfv',

openstackclient/tests/object/v1/test_object_all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def test_object_show(self):
160160
'content-type',
161161
'etag',
162162
'last-modified',
163+
'meta-owner',
163164
'object',
164165
'x-object-manifest',
165166
)
@@ -171,6 +172,7 @@ def test_object_show(self):
171172
'text/plain',
172173
'4c4e39a763d58392724bccf76a58783a',
173174
'yesterday',
175+
object_fakes.ACCOUNT_ID,
174176
object_fakes.object_name_1,
175177
'manifest',
176178
)

0 commit comments

Comments
 (0)