Merge "zun: remove the handling of not acceptable error"

This commit is contained in:
Zuul 2018-09-10 23:47:09 +00:00 committed by Gerrit Code Review
commit 917a5d5a20
2 changed files with 3 additions and 24 deletions

View File

@ -49,16 +49,9 @@ class ZunClientPlugin(client_plugin.ClientPlugin):
return client
def update_container(self, container_id, **prop_diff):
try:
if prop_diff:
self.client(version=self.V1_18).containers.update(
container_id, **prop_diff)
except zc_exc.NotAcceptable:
if 'name' in prop_diff:
name = prop_diff.pop('name')
self.client().containers.rename(container_id, name=name)
if prop_diff:
self.client().containers.update(container_id, **prop_diff)
if prop_diff:
self.client(version=self.V1_18).containers.update(
container_id, **prop_diff)
def network_detach(self, container_id, port_id):
with self.ignore_not_found:

View File

@ -12,8 +12,6 @@
import mock
from zunclient import exceptions as zc_exc
from heat.tests import common
from heat.tests import utils
@ -42,15 +40,3 @@ class ZunClientPluginTest(common.HeatTestCase):
self.plugin.update_container(self.resource_id, **prop_diff)
self.client.containers.update.assert_called_once_with(
self.resource_id, cpu=10, memory=10, name='fake-container')
def test_container_update_not_acceptable(self):
self.client.containers.update.side_effect = [
zc_exc.NotAcceptable(), None]
prop_diff = {'cpu': 10, 'memory': 10, 'name': 'fake-container'}
self.plugin.update_container(self.resource_id, **prop_diff)
self.client.containers.update.assert_has_calls([
mock.call(self.resource_id, cpu=10, memory=10,
name='fake-container'),
mock.call(self.resource_id, cpu=10, memory=10)])
self.client.containers.rename.assert_called_once_with(
self.resource_id, name='fake-container')