Fix bug in object storage container creation setting metadata

New object storage containers were not correctly setting valid metadata
on creation. This was because the data wasn't being marked as dirty
when a NEW container resource object was being created, so it never
got sent with the initial creation request to the server.

Change-Id: I12cd626e2475b384511b2993c2c7b593184e5138
This commit is contained in:
Adrian Turjak 2019-12-19 15:36:54 +13:00 committed by Monty Taylor
parent 25d9aa7de8
commit 16502c0ec3
2 changed files with 4 additions and 8 deletions

View File

@ -113,7 +113,7 @@ class Container(_base.BaseResource):
name = kwargs.pop('id', None)
if name:
kwargs.setdefault('name', name)
return Container(_synchronized=True, **kwargs)
return cls(_synchronized=False, **kwargs)
def create(self, session, prepend_key=True, base_path=None):
"""Create a remote resource based on this instance.
@ -131,7 +131,7 @@ class Container(_base.BaseResource):
request = self._prepare_request(
requires_id=True, prepend_key=prepend_key, base_path=base_path)
response = session.put(
request.url, json=request.body, headers=request.headers)
request.url, headers=request.headers)
self._translate_response(response, has_body=False)
return self

View File

@ -193,13 +193,9 @@ class TestContainer(base.TestCase):
def _test_no_headers(self, sot, sot_call, sess_method):
headers = {}
data = {}
self.register_uris([
dict(method=sess_method, uri=self.container_endpoint,
json=self.body,
validate=dict(
headers=headers,
json=data))
validate=dict(headers=headers))
])
sot_call(self.cloud.object_store)
@ -211,7 +207,7 @@ class TestContainer(base.TestCase):
def test_commit_no_headers(self):
sot = container.Container.new(name=self.container)
self._test_no_headers(sot, sot.commit, 'POST')
self.assert_no_calls()
self.assert_calls()
def test_set_temp_url_key(self):
sot = container.Container.new(name=self.container)